PDA

View Full Version : Quick Scripting Question


Giant Graffiti
03-19-2009, 05:15 PM
Is there a way to kill all the enemies in an area? I've found a script to kill the nearest enemy, but that's not really what I'm looking for.

Star Admiral
03-19-2009, 05:52 PM
Assuming this is for TSL, you can try this:

void main() {
object oTarget = GetFirstObjectInArea( OBJECT_INVALID, OBJECT_TYPE_CREATURE );
while( GetIsObjectValid( oTarget ) ) {
if( GetIsEnemy( oTarget ) ) {
AssignCommand( oTarget, ClearAllActions() );
SetCommandable( FALSE, oTarget );
ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectDeath( FALSE, TRUE, TRUE ), oTarget, 0.00 );
}
oTarget = GetNextObjectInArea( OBJECT_INVALID, OBJECT_TYPE_CREATURE );
}
}

- Star Admiral