title.
I'm using the scripted traps script in the database and as long as Link is moving whatsoever, he is not harmed by the traps I set. When stationary however, he takes damage very rapidly and from a distance of like, half a tile more than it should.
Here's the code just in case I modified something without realizing.
Spoiler
//import "std.zh" const int LINK_HURT = 19;// SFX for Link getting hurt // Set Vx and Vy to positive numbers for most traps to avoid unintended behavior. // If placed at greatest X, will start going left, otherwise going right. If placed at bottom of screen will start going up, otherwise down. //D0 - One for horizontal. // Two for vertical movement. Either one or two can be used for diagonal movement, // Three is a horizontal stationary trap. Set initial Vx and Vy to zero. // Four is a vertical stationary trap. Set initial Vx and Vy to zero. // Five is a circular trap. Set Vx to positive for clockwise movement and negative for counterclockwise. // Place circular trap at location that will serve as the center of the circle, then set radius. // Circular traps will bounce off solid objects and can get stuck if not placed correctly. //D1 - Least X position //D2 - Greatest X position //D3 - Least Y position //D4 - Greatest Y position //D5 - How much damage you take. Defaults to one-quarter heart. //D6 - Radius of circle. Used in creating traps with circular movement. ffc script ScriptTraps{ void run(int direction, int leftX, int rightX, int bottomY, int topY, int damage, float radius){ bool MovingLeft = false; bool MovingRight = false; bool MovingUp = false; float angle; bool MovingDown = false; float SpeedX = this->Vx; float SpeedY = this->Vy; int height = this->TileHeight; int width = this->TileWidth; int OrigX = this->X; int OrigY = this->Y; int EndX = this->X + (16 * width); int EndY = this->Y + (16 * height); while(true){ if (damage <=4) damage = 4; if (LinkCollision(this) && !Link->Action == LA_GOTHURTLAND){ Link->HP -= damage; Link->Action = LA_GOTHURTLAND; Game->PlaySound(LINK_HURT); } if (direction == 1){ for (int i = 0; i < height; i++){ if (Screen->isSolid(this->X - 1, this->Y + (16 * i) + 8)){ this->Vx = SpeedX; MovingRight = true; } else if (Screen->isSolid(this->X + 17, this->Y + (16 * i) + 8)){ this->Vx = -1 * SpeedX; MovingLeft =true; } } for (int i = 0; i < width; i++){ if (Screen->isSolid(this->X + (16 * i) + 8, this->Y - 1)){ this->Vy = SpeedY; } else if (Screen->isSolid(this->X + (16 * i) + 8, this->Y + 17)){ this->Vy = -1 * SpeedY; } } if (this->Y >= topY)this->Vy = -1 * SpeedY; if (this->Y <= bottomY) this->Vy = SpeedY; if(this->X <= rightX && !MovingLeft){ this->Vx = SpeedX; MovingRight = true; } else if (this->X >= leftX && !MovingRight){ this->Vx = -1 * SpeedX; MovingLeft = true; } else if (this->X >= rightX) MovingRight = false; else if (this->X <= leftX)MovingLeft = false; } else if (direction == 2){ for (int i = 0; i < height; i++){ if (Screen->isSolid(this->X - 1, this->Y + (16 * i) + 8)){ this->Vx = SpeedX; } else if (Screen->isSolid(this->X + 17, this->Y + (16 * i) + 8)){ this->Vx = -1 * SpeedX; } } for (int i = 0; i < width; i++){ if (Screen->isSolid(this->X + (16 * i) + 8, this->Y - 1)){ this->Vy = SpeedY; MovingUp = true; } else if (Screen->isSolid(this->X + (16 * i) + 8, this->Y + 17)){ this->Vy = -1 * SpeedY; MovingDown = true; } } if (this->X >= rightX)this->Vx = -1 * SpeedX; if (this->X <= leftX) this->Vx = SpeedX; if(this->Y <= topY && !MovingDown){ this->Vy = SpeedY; MovingUp = true; } else if (this->Y >= bottomY && !MovingUp){ this->Vy = -1 * SpeedY; MovingDown = true; } else if (this->Y >= topY)MovingUp = false; else if (this->Y <= bottomY)MovingDown = false; } else if (direction == 3){ this->Vx = SpeedX; if (Link->Y + 16 >= OrigY && Link->Y <= EndY){ for(int i = 0; i<height; i++){ if (Screen->isSolid(this->X - 1, this->Y + (16 * i) + 8)){ SpeedX = 1; MovingRight = true; } else if (Screen->isSolid(this->X + 17, this->Y + (16 * i) + 8)){ SpeedX = -1; MovingLeft =true; } } if(this->X <= rightX && !MovingLeft){ SpeedX = 1; MovingRight = true; } else if (this->X >= leftX && !MovingRight){ SpeedX = -1; MovingLeft = true; } else if (this->X >= rightX) MovingRight = false; else if (this->X <= leftX)MovingLeft = false; } else{ MovingLeft = false; MovingRight = false; if(this->X <= OrigX && OrigX > leftX)SpeedX = 1; else if (this->X >= OrigX && OrigX < rightX)SpeedX = -1; else if ((this->X >= OrigX && OrigX>= rightX) || this->X <= OrigX && OrigX<= leftX)SpeedX = 0; } } else if (direction == 4){ this->Vy = SpeedY; if (Link->X + 16 >= OrigX && Link->X <= EndX){ for (int i = 0; i < width; i++){ if (Screen->isSolid(this->X + (16 * i) + 8, this->Y - 1)){ SpeedY = 1; MovingUp = true; } else if (Screen->isSolid(this->X + (16 * i) + 8, this->Y + 17)){ SpeedY = -1; MovingDown = true; } } if(this->Y <= topY && !MovingDown){ SpeedY = 1; MovingUp = true; } else if (this->Y >= bottomY && !MovingUp){ SpeedY = -1; MovingDown = true; } else if (this->Y >= topY)MovingUp = false; else if (this->Y <= bottomY)MovingDown = false; } else{ MovingDown = false; MovingUp = false; if(this->Y <= OrigY && OrigY > bottomY)SpeedY = 1; else if (this->Y >= OrigY && OrigY < topY)SpeedY = -1; else if ((this->Y >= OrigY && OrigY>= topY) || this->Y <= OrigY && OrigY<= bottomY)SpeedY = 0; } } else if (direction == 5){ for(angle = 0; true; angle = (angle + SpeedX) % 360){ this->X = OrigX + radius * Cos(angle); this->Y = OrigY + radius * Sin(angle); for(int i = 0; i < height; i++){ if (Screen->isSolid(this->X - 1, this->Y + (16 * i) + 8) || Screen->isSolid(this->X + 17, this->Y + (16 * i) + 8)) SpeedX *=-1; } for (int i = 0; i < width; i++){ if (Screen->isSolid(this->X + (16 * i) + 8, this->Y - 1) || Screen->isSolid(this->X + (16 * i) + 8, this->Y + 17)) SpeedX *=-1; } if (damage <=4) damage = 4; if (LinkCollision(this) && !Link->Action == LA_GOTHURTLAND){ Link->HP -= damage; Link->Action = LA_GOTHURTLAND; Game->PlaySound(LINK_HURT); } Waitframe(); } } Waitframe(); } } }