I would like a script that causes one tile (most likely a tile that blends with a wall) to fire a projectile (say, an arrow projectile, preferably) when the player steps on a second tile (a floor switch)
Switch triggered projectile shooters [Request]
#1
Posted 19 May 2016 - 10:26 AM
#2
Posted 29 May 2016 - 07:23 AM
ffc script TrapTriggerShooter{ void run(int enem, int combo_ID, int sfx, int fire_dir){ int q; npc n; int t; while (true){ if ( !t ){ for ( q = 0; q < 176; q++) { if ( Collision(q) && ComboD[q] == combo_ID ) { ComboD[q]++; if ( sfx ) Game->PlaySound(sfx); n = Screen->CreateNPC(enem); n->X = this->X; n->Y = this->Y; n->Misc[10] = 2147; t = 1; } } } if ( t ){ for ( q = 0; q <= Screen->NumNPCs(); q++){ n = Screen->LoadNPC(q); if ( n->Misc[10] == 2147 && n->Dir != fire_dir ) n->Dir = fire_dir; } } Waitframe(); } } } //Check for collision between Link and a combo at location 'cmb'. bool Collision(int cmb){ int c[4]; c[0] = Link->X+Link->HitXOffset+Link->DrawXOffset; c[1] = Link->Y+Link->HitYOffset+Link->DrawYOffset; c[2] = c[0]+(Link->HitWidth); c[3] = c[1]+(Link->HitHeight); if ( !RectCollision( ComboX(cmb), ComboY(cmb), (ComboX(cmb)+16), (ComboY(cmb)+16), c[0], c[1], c[2], c[3]) ) return false; else if ( !(Distance(CenterLinkX(), CenterLinkY(), (ComboX(cmb)+8), (ComboY(cmb)+8)) < 8) ) return false; return true; }
This requires the updated Collision functions from my std.zh update packs that allow collision checks on combos and other object pairs. It creates an npc that you should configure to fire shots as desired.
D0: The enemy that you want to spawn. It will spawn where you place the ffc, and it should both be invisible, and ignore all attacks.
D1: The combo ID to use as a trigger. The script advances it when triggered similar to step next, so set up your combo table accordingly.
D2: The sound to play when triggering the trap. 0 for none.
D3: The direction the enemy should fire. Use the numeric values from std-constants.zh.
Edited by ZoriaRPG, 29 May 2016 - 08:13 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users