[QUOTE=Beholder;14630]
Same principal, only the math was just a bit backwards.
dx = playerx+1.5-B[/B];
dy = playery+2-B[/B];
ang = getangle(dx,dy); //No need for a 90’ offset
[/QUOTE]
I always get the delta stuff backwards. As for the offset… oops! Graal seems so weird with handling angles, I tend to always have to offset it by pi/2. Could just be my math, though
[QUOTE=Shiny;14632]I always get the delta stuff backwards. As for the offset… oops! Graal seems so weird with handling angles, I tend to always have to offset it by pi/2. Could just be my math, though :)[/QUOTE]
I’ll admit I’ve had to do it too at times, graal logic can be weird sometimes O_o
[QUOTE=NeMoD;14631]perfect but how do I make it damage the player?[/QUOTE]
Generally I would have a weapon NPC that handles all projectile triggers.
So first you’d have the tile itself:
[php]if (created) {
dx = playerx+1.5-(x+1.5); // delta x (distance between two points)
dy = playery+2-(y+2); // delta y
ang = getangle(dx,dy); // get the angle from the delta
setshootparams tile,1; // first parameter sends that it’s a tile
// second sends potential damage to player
shoot x,y,z,ang,0,0,tilespin,; // SHOOT
}[/php]
Then you’d do something like this in maybe a weapon called -projectiles…
[php]if (actionprojectile) {
if (strequals(#p(0),tile)) { // If projectile is a tile
hurt strtofloat(#p(1)); // do potential damage
} else if (strequals(#p(0),arrow)) { // If projectile is an arrow
hurt strtofloat(#p(1)); // do potential damage
// do other stuff maybe?
}
}[/php]
This is just elaborated to give you an idea of how a weapon can handle all projectiles(because if you put this stuff in say, a bow script, it won’t work if the other player doesn’t have the bow also!). Admittedly, I always had problems with projectiles and handling their interaction, so this may not work.
Can’t you slash those tiles in Zelda to stop them? I was bored so I remade it so you can hit them and break them :3
EDIT:
I noticed each tile in Zelda goes off consecutively after one another.
Here, this automatically sets the timer that way, 1 second after another. You can change this via the “Settings” area.
if (playerenters) {
///////////
// SETTINGS
// Initial delay upon entering room (Seconds)
this.idelay = 1;
// Delay before shoot after last panel (Seconds)
this.edelay = 1;
// Speed of tile
this.speed = 0.75;
// Power of tile (Hurt power)
this.hpower = 1;
///////////
this.delay = this.idelay;
save[3] = 141;
for (i=0;i<npcscount;i++) {
if (npcs[i].save[3] == 141) {
this.delay += this.edelay;
}
}
dontblock;
drawunderplayer;
timeout = this.delay;
this.px = x;
this.py = y;
}
if (timeout) {
if (this.dead == 1) {
putleaps 2,this.px+0.5,this.py+0.5;
this.px = -1;
this.py = -1;
hideimg 300;
return;
}
hidelocal;
timeout = 0.05;
shoot();
move();
draw();
checkslash();
checkdmg();
end();
}
function shoot() {
if (this.bc < 0) {
return;
}
putleaps 2,x+0.5,y+0.5;
this.bc = -1;
this.dx = (playerx+1.5)-(x+0.5);
this.dy = (playery+2)-(y+0.5);
this.len = (this.dx*this.dx+this.dy*this.dy)^0.5;
this.addx = (this.dx/this.len)*this.speed;
this.addy = (this.dy/this.len)*this.speed;
this.px = x;
this.py = y;
}
function move() {
if (this.px in |0,64| && this.py in |0,64|) {
this.px += this.addx;
this.py += this.addy;
}
}
function draw() {
if (this.px in |0,64| && this.py in |0,64|) {
showani 300,this.px,this.py,tilespin,;
}
}
function checkdmg() {
if (this.px in |0,64| && this.py in |0,64|) {
if (abs((playerx+1.5)-(this.px+0.5))<2 && abs((playery+2)-(this.py+0.5))<2) {
hurt this.hpower*2;
this.dead = 1;
}
}
}
function checkslash() {
if (this.px in |0,64| && this.py in |0,64|) {
if (abs((playerx+(vecx(playerdir)*2)+1.5)-(this.px+0.5))<2 && abs((playery+(vecy(playerdir)*2)+2)-(this.py+0.5))<2) {
if (strequals(#m,sword)) {
this.dead = 1;
}
}
}
}
function end() {
if (onwall(this.px,this.py)) {
this.dead = 1;
}
if (onwall(this.px+1,this.py)) {
this.dead = 1;
}
if (onwall(this.px,this.py+1)) {
this.dead = 1;
}
if (onwall(this.px+1,this.py+1)) {
this.dead = 1;
}
if (this.px < 0 || this.px > 64) {
if (this.py < 0 || this.py > 64) {
this.dead = 1;
}
}
}
The first one you put in the editor is the first one that goes off.
What I was thinking was providing the tile array for the tile, then running a loop in the level that checks for them to register all tile NPCs, creating an array from it and then treating them accordingly. Maybe I’ll script it tonight.
those onwalls at the bottom are a bit redundant o_o
for(this.i=0;this.i<4;this.i++) if (onwall(this.px+this.i%2,this.py+int(this.i/2))) this.dead=1;
Then theres the save[3], save can only hold 0~220
[/QUOTE]
Yeah, I’m aware about the “redundant onwalls”. Just didn’t feel like writing the loop out o.o
The save, didn’t know about that limit o.o Thanks.
I thought about that, however, I realized there would be no way to define which one goes off first, etc easily for the LAT.
Also, it would be far easier to place the tiles below that will be shown when the attacking tile lifts up (The tiles “under” the enemy tile). Just simply drag your NPC out and slap it on top of the tiles.
[QUOTE=Downsider;14678]
Yeah, I’m aware about the “redundant onwalls”. Just didn’t feel like writing the loop out o.o
The save, didn’t know about that limit o.o Thanks.
I thought about that, however, I realized there would be no way to define which one goes off first, etc easily for the LAT.
Also, it would be far easier to place the tiles below that will be shown when the attacking tile lifts up (The tiles “under” the enemy tile). Just simply drag your NPC out and slap it on top of the tiles.
Ease of use FTW.
[/QUOTE]
that’s how I have it setup right now :D, it’s scary how much it looks like the real thing :eek: