De-targeting players
Moderator: Moderators
De-targeting players
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.
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.
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.
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.
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.
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.
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..
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..
