Page 1 of 1

enemy death problems

Posted: Mon Jun 07, 2004 9:42 pm
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....................

Posted: Mon Jun 07, 2004 10:20 pm
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...

#set

Posted: Mon Jun 07, 2004 11:55 pm
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.

Posted: Tue Jun 08, 2004 2:45 am
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