52 lines
2.3 KiB
Plaintext
52 lines
2.3 KiB
Plaintext
|
void ApplyDamage(object oSource, int nTrapType){
|
||
|
int i = 0;
|
||
|
object oCreature = GetNearestObject(OBJECT_TYPE_CREATURE, oSource, i);
|
||
|
//Check for anyone standing in the wrong place
|
||
|
while(GetIsObjectValid(oCreature) && GetDistanceBetween(oSource, oCreature) <= 1.5f) {
|
||
|
//apply damage based on <span class="highlight">trap</span> type
|
||
|
if(nTrapType == 0){
|
||
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(d10(10)+100,DAMAGE_TYPE_PIERCING), oCreature);
|
||
|
}else{
|
||
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(d10(10)+100,DAMAGE_TYPE_FIRE), oCreature);
|
||
|
}
|
||
|
i++;
|
||
|
oCreature = GetNearestObject(OBJECT_TYPE_CREATURE, oSource, i);
|
||
|
}
|
||
|
}
|
||
|
void main()
|
||
|
{
|
||
|
if(GetLocalInt(OBJECT_SELF, "nNumEntered")==0)
|
||
|
return; //no one is in this area
|
||
|
int s=0;
|
||
|
int f=0;
|
||
|
float fDelay;
|
||
|
object oWP = GetFirstObjectInArea(OBJECT_SELF);
|
||
|
while(GetIsObjectValid(oWP)){
|
||
|
if(GetTag(oWP)=="WP_SPIKE"){//check spike traps
|
||
|
//two seconds delay between each spike
|
||
|
fDelay = IntToFloat(s)*2.f;
|
||
|
//Delay the visual effect and damage
|
||
|
DelayCommand(fDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_SPIKE_TRAP), GetLocation(oWP)));
|
||
|
DelayCommand(fDelay,ApplyDamage(oWP,0));
|
||
|
//set local int for trigger
|
||
|
DelayCommand(fDelay,SetLocalInt(oWP,"nTrapArmed",1));
|
||
|
DelayCommand(fDelay+2.0f,SetLocalInt(oWP,"nTrapArmed",0));
|
||
|
s++;
|
||
|
}else if(GetTag(oWP)=="WP_FIRE"){//check fire traps
|
||
|
//These fire off in pairs, offset timing from spikes (spreads out the calls to ApplyDamage())
|
||
|
//one second delay between each pair of flames
|
||
|
//remove the /2 if you want them to fire singly
|
||
|
fDelay = IntToFloat(f/2)+0.5f;
|
||
|
DelayCommand(fDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), GetLocation(oWP)));
|
||
|
DelayCommand(fDelay,ApplyDamage(oWP,1));
|
||
|
//set local int for trigger
|
||
|
DelayCommand(fDelay,SetLocalInt(oWP,"nTrapArmed",1));
|
||
|
DelayCommand(fDelay+1.0f,SetLocalInt(oWP,"nTrapArmed",0));
|
||
|
f++;
|
||
|
}
|
||
|
oWP = GetNextObjectInArea(OBJECT_SELF);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|