enemy death problems

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
longshanks
Lance Corporal
Posts: 18
Joined: Thu Dec 19, 2002 8:51 pm

enemy death problems

Post by longshanks »

well what the problem i am having is i am trying to count the enemys that are spawned through a trigger when they are all dead it prints something on screen HERE IS THE CODE I HAVE BEEN USING



exec global/ai.scr
exec global/loadout.scr maps/test_ai.scr


main:
level waittill prespawn
level waittill spawn

$player item weapons/mp40.tik

fadein 2 0 0 0 1
wait 2
level.script = "maps/test_ai.scr"
thread global/ai.scr::spawnset#1
thread EnemSet1

end
//-----------------------------------
EnemSet1:

// Spawn AI set1


$enemyspawnertrigger waittill trigger
thread global/ai.scr::spawnset#1

level.bad_guys_left = 0

$spawnset#1 thread BadGuyCheck

end


//----------------------------------------------------------------------------
BadGuyCheck:

// Counts the bad guys that are spawned in and when they are all dead,
// updates the objective as complete.
//----------------------------------------------------------------------------
level.bad_guys_left++
self waittill death
level.bad_guys_left--


if ( level.bad_guys_left==0 )
{

iprintln_noloc "The soldiers have been killed. Mission complete!"
}

//end
i am using 4 soldiers

i have given soldier1 a #set 1
$targetname= enemyspawner
#group 1
///////////////////////////////////////
soldier2
#set 1
group 2
$targetname = enemyspawner
///////////////////////////////////
soldier 3 #set 1
#group 3
$targetname = enemyspawner
////////////////////////////////////
soldier 4
#set 1
#group 4
$targetname = enemyspawner
/////////////////////////
the trigger
#set 1
using trigger multiple
$targetname = enemyspawnertrigger

the trigger works fine and they all spawn correctly

i have tried using bits of the code from ai tutorial from spearhead sdk
but it cant get it to work properly
any sugestions PLEASE ...............
LONGSHANKS....................
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

i'm supposing you did

$enemyspawner thread badguycheck1

maybe that would work better than $spawnset#1, i've never heard of that.
try making your if like this...

if (bla == bla)
instead of
if(bla==bla)
dunno if it makes a difference or not but try it...
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

#set

Post by tltrude »

The ai.scr script is looking for just numbers, not "#set".

thread global/ai.scr::spawn 1

But that line will be done by the trigger if it has the same set numuber as the spawners. Below is what the ai script says about it.

=================================

You can create a trigger_multiple with targetname "enemyspawnertrigger" to set off the spawning. Give it the same #set value as whichever spawners you want it to set off. Or you can do "thread global/ai.scr::spawn #" where # is the #set value you want to set off.

You can also do "thread global/ai.scr::spawngroup # #" where the first # is the #set value you want to set off and the second # is the #group value you want to set off.
Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Also the global/ai.scr has this
if (level.totalbaddies == NIL)
level.totalbaddies = 1
else
level.totalbaddies++

local.ent = waitthread global/spawner.scr::spawner_activate level.enemyspawner[local.i]

if (level.enemyspawner[local.i].enemyname != -1)
local.ent.targetname = level.enemyspawner[local.i].enemyname
If you give your spawners a enemyname then when they spawn the enemyname will become thier targetname also level.totalbaddies is equal to the number of enemyspawners spawned and I think goes down when they die .
deathcheck:

self waittill death
level.totalbaddies--
end
Image
Post Reply