Page 1 of 2
De-targeting players
Posted: Tue Jul 29, 2003 6:39 pm
by Bilko
I followed the tutorial on the manstein site for the flak88 autofire. Works great. However, I think theres a problem with targeting. I adapted and built upon it...
My MG is based on a trigger_multiple to aim and fire at the player and when I enter the trigger zone it does so, kills me and all seems fine. However, when I respawn the MG is still following me even outside the trigger zone, then, whoever enters the trigger zone it still fires at me.
Similarly, I have 4 flak88 on the same principle (trigger_multiple). They seem to work fine until there is more than one player in the game and when there is they, they do not work at all.
Also, with the MG in the game, the flak88s dont seem to work at all.
I can post my script if you want but its quite long.
Any ideas? I think it needs to be able to destinguish between different players, but I could be wrong.
I'm new to scripting so this could be totally wrong and any and all help is greatly appreciated. Thanks.
Bilko.
Posted: Tue Jul 29, 2003 7:34 pm
by jv_map
Well, I'm afraid no one will be able to help you unless you post at least some parts of the script...
Posted: Tue Jul 29, 2003 7:49 pm
by Bilko
Sorry, here it is. I have 4 flak88. I think you can guess their names etc:
alert_guns: //called by the setthread on the trigger_multiple
goto Fire_88mm_weapon1
goto Fire_88mm_weapon2
goto Fire_88mm_weapon3
goto Fire_88mm_weapon4
end
Fire_88mm_weapon1:
// Initalise
local.gun_name = $88mm_weapon1
local.target = $player
//Set target
local.gun_name setaimtarget local.target
local.gun_name waittill ontarget
//Set Accuracy
local.range = 48 + randomint(64)
local.offset = 48 + randomint(64)
//Gun Fire
local.gun_name anim fire
wait 0.2
local.gun_name anim start
// Shell Flight
wait(0.2 + ((randomint(6)) * .1))
local.a = local.target.origin
if((randomint(100)) < 50)
local.a[0] = local.a[0] + local.range
else
local.a[0] = local.a[0] - local.range
if((randomint(100)) < 50)
local.a[1] = local.a[1] + local.offset
else
local.a[1] = local.a[1] - local.offset // Redefines the target to make it look realistical
local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"
local.Exp3 = spawn "animate/fx_mortar_higgins.tik" // Play the explosions
exec global/earthquake.scr .23 4 0 0 // The screen shakes each impact
local.Exp1.origin = local.a
local.Exp1 anim start
local.Exp2.origin = local.a
local.Exp2 anim start
local.Exp3.origin = local.a
local.Exp3 anim start
wait(1) // Disables the animation
local.Exp1 remove
local.Exp2 remove
local.Exp3 remove // Removes the animations
local.gun_name setaimtarget $FlakBaseAim
//----------------------------------------------
Fire_88mm_weapon2:
// Initalise
local.gun_name = $88mm_weapon2
local.target = $player
//Set target
local.gun_name setaimtarget local.target
local.gun_name waittill ontarget
//Set Accuracy
local.range = 48 + randomint(64)
local.offset = 48 + randomint(64)
//Gun Fire
local.gun_name anim fire
wait 0.2
local.gun_name anim start
// Shell Flight
wait(0.2 + ((randomint(6)) * .1))
local.a = local.target.origin
if((randomint(100)) < 50)
local.a[0] = local.a[0] + local.range
else
local.a[0] = local.a[0] - local.range
if((randomint(100)) < 50)
local.a[1] = local.a[1] + local.offset
else
local.a[1] = local.a[1] - local.offset // Redefines the target to make it look realistical
local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"
local.Exp3 = spawn "animate/fx_mortar_higgins.tik" // Play the explosions
exec global/earthquake.scr .23 4 0 0 // The screen shakes each impact
local.Exp1.origin = local.a
local.Exp1 anim start
local.Exp2.origin = local.a
local.Exp2 anim start
local.Exp3.origin = local.a
local.Exp3 anim start
wait(1) // Disables the animation
local.Exp1 remove
local.Exp2 remove
local.Exp3 remove // Removes the animations
local.gun_name setaimtarget $FlakBaseAim
//----------------------------------------
Fire_88mm_weapon3:
// Initalise
local.gun_name = $88mm_weapon3
local.target = $player
//Set target
local.gun_name setaimtarget local.target
local.gun_name waittill ontarget
//Set Accuracy
local.range = 48 + randomint(64)
local.offset = 48 + randomint(64)
//Gun Fire
local.gun_name anim fire
wait 0.2
local.gun_name anim start
// Shell Flight
wait(0.2 + ((randomint(6)) * .1))
local.a = local.target.origin
if((randomint(100)) < 50)
local.a[0] = local.a[0] + local.range
else
local.a[0] = local.a[0] - local.range
if((randomint(100)) < 50)
local.a[1] = local.a[1] + local.offset
else
local.a[1] = local.a[1] - local.offset // Redefines the target to make it look realistical
local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"
local.Exp3 = spawn "animate/fx_mortar_higgins.tik" // Play the explosions
exec global/earthquake.scr .23 4 0 0 // The screen shakes each impact
local.Exp1.origin = local.a
local.Exp1 anim start
local.Exp2.origin = local.a
local.Exp2 anim start
local.Exp3.origin = local.a
local.Exp3 anim start
wait(1) // Disables the animation
local.Exp1 remove
local.Exp2 remove
local.Exp3 remove // Removes the animations
local.gun_name setaimtarget $FlakBaseAim
//----------------------------------------
Fire_88mm_weapon4:
// Initalise
local.gun_name = $88mm_weapon4
local.target = $player
//Set target
local.gun_name setaimtarget local.target
local.gun_name waittill ontarget
//Set Accuracy
local.range = 96 + randomint(64)
local.offset = 96 + randomint(64)
//Gun Fire
local.gun_name anim fire
wait 0.2
local.gun_name anim start
// Shell Flight
wait(0.4 + ((randomint(6)) * .1))
local.a = local.target.origin
if((randomint(100)) < 50)
local.a[0] = local.a[0] + local.range
else
local.a[0] = local.a[0] - local.range
if((randomint(100)) < 50)
local.a[1] = local.a[1] + local.offset
else
local.a[1] = local.a[1] - local.offset // Redefines the target to make it look realistical
local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"
local.Exp3 = spawn "animate/fx_mortar_higgins.tik" // Play the explosions
exec global/earthquake.scr .23 4 0 0 // The screen shakes each impact
local.Exp1.origin = local.a
local.Exp1 anim start
local.Exp2.origin = local.a
local.Exp2 anim start
local.Exp3.origin = local.a
local.Exp3 anim start
wait(1) // Disables the animation
local.Exp1 remove
local.Exp2 remove
local.Exp3 remove // Removes the animations
local.gun_name setaimtarget $FlakBaseAim
end // This brings the 88 gun back to its starting position (needs a script_origin inside the map)
//-------------------------------------------------
This fires 'em one after another (not sure why) but last time I tested, when theres more than one person they do nothing. I think it's 'cos they can't distinguish between different players and so do nothing, not sure though.
Bilko.
Posted: Tue Jul 29, 2003 7:59 pm
by jv_map
This is why it doesn't work with more than one player:
local.target = $player
// $player is a listener if there's one player
// $player is an array if there are more players
//Set target
local.gun_name setaimtarget local.target
// gun can aim at any listener with an origin (simpleentity)
// gun can't aim at an array -> 'cannot cast array to listener' error
One flak can't possibly aim at more than one player simultaneously.
Posted: Tue Jul 29, 2003 8:03 pm
by Bilko
OK, I understand that, thats kinda what I was thinking, but can I overcome it?
Bilko.
Posted: Tue Jul 29, 2003 8:42 pm
by Alcoholic
if you want it to target a random player, do this:
level.players = $player.size //how many players are there?
local.diedamit = (randomint (level.players) + 1) //random ints start with 0, and theres no $player # 0, so add 1 to whatever you get.
$gun1 setaimtarget local.diedamit
$gun1 waittill ontarget
$gun1 startfiring
//blah blah blah
it would have to be more complex, for example, this thing here will track people through walls and just shoot.. i made a tank script that works great, you can ambush it and all, but im too lazy to fix it..
Posted: Wed Jul 30, 2003 8:14 am
by Bilko
OK, thanks, but really I need it when someone enters the trigger_multiple. Could that bit of script be adapted?
Bilko.
Posted: Wed Jul 30, 2003 10:21 am
by jv_map
You can use if(local.player isTouching $mytrigger), but you'd also have to check if the player isn't spectating

Posted: Wed Jul 30, 2003 10:55 am
by Bilko
How would I use that? Sorry, I'm new to all of this
Bilko.
Posted: Wed Jul 30, 2003 12:15 pm
by nuggets
if ((local.player isTouching $mytrigger) && !(local.player.dmteam == "spectator"))
Posted: Wed Jul 30, 2003 1:28 pm
by Bilko
Sorry, I meant how would I use that in my script?
Bilko.
Posted: Wed Jul 30, 2003 3:21 pm
by bdbodger
couldn't you use something like this since you are useing a setthread
local.guntarget=parm.other
while(local.guntarget istouching self)
{
$gun1 setaimtarget local.guntarget
.....
.....
}
$gun1 setaimtarget null // ?
Posted: Wed Jul 30, 2003 5:13 pm
by Bilko
sounds feasible, ill give it a try.
Bilko.
Posted: Wed Jul 30, 2003 6:14 pm
by Bilko
Thanks a lot everybody, especially bdbodger, it works superbly!
If you're interested I'll post the script to you.
Thanks guys!
Bilko.
Posted: Thu Jul 31, 2003 12:13 am
by nuggets
may sound like a really stupid question but give it some thought before answering...
if someone will only trigger this when they're in the trigger... why use iftouching? they'll always be touching the trigger