Multiple targets, same name
Moderator: Moderators
Multiple targets, same name
[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.
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.
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
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
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
hope this helps, prob not cos it's all foreign 2 me :-/
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
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
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
hope this helps, prob not cos it's all foreign 2 me :-/
-
Desert Eagle
- Captain
- Posts: 237
- Joined: Mon Jan 13, 2003 1:05 am
- Location: Mapping Bunker
- Contact:
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
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
Desert-Eagle
....The Eagle Has Landed...
....The Eagle Has Landed...
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
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
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
hope this helps, prob not cos it's all foreign 2 me :-/
