Page 1 of 2
Multiple targets, same name
Posted: Thu Jun 19, 2003 6:38 pm
by Alcoholic
[self.mood=curious]ok i was really curious as to do this...[/mood]
lets say you want someone to shoot something, but there are three somethings all with the same name and in the same area. if someone wants to shoot a something, he is gonna see all 3 at once no matter what way he enters the area. my question is, how do you make him choose one and attack? i never worked with mp maps before, but i believed that if you had a tank fire at $player, it would go nuts, cuz there are like 30 players! any help would be appreciated.
Posted: Thu Jun 19, 2003 11:09 pm
by nuggets
create a random integer and then target it
shoot_clay_pot:
level.pot_number = randomint (3) //will return either 0, 1 or 2
switch (level.pot_number)
{
case 0:
$player shoot at $pot_0
etc...
}
or create them in an array
$player shoot at $pot[level.pot_number]
there's possibly an easier way cos, u'd also need stuff like
level.pot2 = 1 //when it's destroyed and therefore need to find a new target
Posted: Fri Jun 20, 2003 9:09 am
by jv_map
$player shoot at $pot[level.pot_number]
should be
$player shoot at $pot[(level.pot_number + 1)]

Posted: Fri Jun 20, 2003 3:12 pm
by bdbodger
If you are going to use a randomint and one targetname for 3 targets you could do this
$player shootat $pot[(randomint($pot.size)+1)]
Posted: Fri Jun 20, 2003 6:25 pm
by nuggets
not if they're labelled pot 0, 1 and 2
and is it's using case 0, adding 1 will skip that case...
Posted: Sat Jun 21, 2003 1:51 pm
by bdbodger
targetname arrays start at 1 not 0 where for example randomint(4) will give you 0 1 2 3 which is 4 numbers the +1 is nessesary with random numbers and targetname arrays .
Posted: Sat Jun 21, 2003 6:47 pm
by nuggets
lol, i've never noticed that before, i only create arrays when they have about 8 objects in there, so i guess the 0th one will never work
but you could do a much more complicated thing than JV suggested by -1 from the array
i know, i know, it's a stupid idea, i just don't like being wrong

Posted: Sat Jun 21, 2003 6:50 pm
by Alcoholic
hmmm.. let me put it another way..
lets say you have a tank in multiplayer that shoots at any player it see's. how do you script the tank so it doesnt go nuts?
Posted: Sat Jun 21, 2003 7:17 pm
by nuggets
tanks have already been done, parts and JV sorted that one
a search will get you the details

Posted: Sun Jun 22, 2003 2:45 am
by Desert Eagle
I used this to target allied players, with a tiger tank. Did not work in TOW map though, worked okay in roundbased and objective. It would target axis players, but not shoot. Maybe it will help:
I created a tiger tank and give it a targetname of tiger1 and ran this thread $tiger1 thread target
//*** find an allied player near by to shoot at!
Target:
println ("looking for target")
//look for first player in range and shoot at them!
for (self.i = 1; self.i <= 32; self.i++)
{
if ($player[self.i])
{
if ($player[self.i].dmteam == allies)
{
if (vector_length (self.origin - $player[self.i].origin) > 200)
{
if (vector_length (self.origin - $player[self.i].origin) < 3000)
{
if (self cansee $player[self.i])
{
println ("targeting player #" + self.i)
self.gun setAimTarget $player[self.i]
self.gun waittill ontarget
self.gun anim fire
goto breakloop
}
else
{
println "can't see him!"
}
}
}
}
}
}
println "no target found"
breakloop:
wait 2
goto Target
end
Posted: Sun Jun 22, 2003 3:01 am
by Alcoholic
thanks thats just what i needed to find out.
Posted: Sun Jun 22, 2003 4:00 am
by Alcoholic
does goto target mean to loop the thread or something?
Posted: Sun Jun 22, 2003 9:12 am
by mohaa_rox
it's like a loop to go back to the same thread.
Posted: Sun Jun 22, 2003 9:53 am
by nuggets
lmao, i can see why rox has so many posts too
about the goto command, it's pretty much the same is thread, except it won't continue to run the thread after the goto, it's goes somewhere else
so you could use it to determine which thread will be selected
if (this_happens)
{goto it_did}
else
{it didn't}
but bear in mind that you'll get an over flow if you don't have pauses in there as
Desert Eagle used wait 2 before it reloops the thread
Posted: Sun Jun 22, 2003 10:03 am
by mohaa_rox
nuggets wrote:lmao, i can see why rox has so many posts too

cause i spam and repeat what ppl say
