| JK and MotS Editing >> Cog, AI, and Templates >> fast travelling projectiles (Moderator: Admins) | Previous Topic | Next Topic |
| Page 1 of 1 |
|
startup: MaxDist=100; //10 JKU's out LeastDist=MaxDist; StepDist=0.1; Vec=VectorSet(0, StepDist, 0); MaxThings=MaxDist/StepDist; //1000 things in this case HeapNew(MaxThings); Count=0; CantFire=0; ExpPos=VectorSet(0, 0, 0); ExpSec=-1; BeenRemoved=0; return; fire: BeenRemoved=0; if(CantFire) return; CantFire=1; Stuff=FireProjectile(Player, A_Proj.....); //A_Proj would be setup like a normal weapon //set to explode on things and/or level surfaces HeapSet(Count, Stuff); for(x=0; x<MaxThings; x=x+1) { Count=Count+1; Stuff=FireProjectile(Stuff, A_Proj, -1, -1, Vec,.....); CaptureThing(Stuff); SetThingVel(Stuff, VectorNorm(GetThingLVec(Stuff))); //1 JKU a second HeapSet(Count, Stuff); } RemovingThings=0; SetTimer(0.5); //Clear the board, create explosion return; removed: if(RemovingThings) return; BeenRemoved=1; //The closest one to the player to have //been removed is where the explosion should //be created... right? =S CurrentDist=VectorDist(GetThingPos(GetSenderRef()), GetThingPos(Player)); if(CurrentDist < LeastDist) { LeastDist=CurrentDist; LeastThing=GetSenderRef(); ClearThingFlags(GetSenderRef(), 0x2); //Don't destroy me plzkthx! } return; timer: RemovingThings=1; for(x=0; x<Count; x=x+1) { if(GetThingType(HeapGet(x)) > 0) { if(HeapGet(x) != LeastThing) DestroyThing(HeapGet(x)); } } if(!BeenRemoved) { //Didn't collide with a darn thing } else { //Create explosion //SendTrigger/MessageEx, pass LeastThing through //Set CantFire to 0 AFTER explosion has been created } return; |
| Page 1 of 1 | |
| JK and MotS Editing >> Cog, AI, and Templates >> fast travelling projectiles (Moderator: Admins) | Previous Topic | Next Topic |