Posted: Sat May 01, 2004 2:16 pm
I just made this script based on some of the code you's have been talking about. The instructions are at the top of the script. The difference with this script is the player fires the Flak88 by standing near it and targeting something with any weapon in your hand and pressing the key you have setup for 'use'.
Regards,
Kirby.
[/code]
Regards,
Kirby.
Code: Select all
/*
//===================================================================================
*********** Player Controlled Flak88 Turret ****************
By: Combat Kirby
================
Setup:
=====
In the map editor put a Flak88 base and Flak88 Turret in your map.
Give the Flak Turret the targetname flak88.
Optional:
You can also build a collision mask for the flak88 then target
the flak88 to the collision mask. (Instructions for making a
collision mask DO NOT accompany this script but a collision
mask is NOT NEEDED to use this script).
*** NOTE ***
If you are modding a 'Stock Map' the Flak88 Base and Turret can be spawned
in from your main map script. Just make sure to give the Flak88 Turret the
targetname of flak88 when spawning it in. Also, DO NOT spawn the Turret
as a 'script_model' or else the animations will NOT work.
Copy and paste the local.master lines into your main map script under 'level wattill prespawn'
You may need to add your maps beginning file name to the end of the aliascache lines
between the quotation marks if your map file name doesn't start with DM or OBJ to be
able to use the sound alias.
local.master = spawn scriptmaster
local.master aliascache firetouch1 sound/mechanics/Player_Fire1.wav soundparms 1.0 0.3 0.6 0.6 320 2200 item loaded maps "dm obj"
local.master aliascache firetouch2 sound/mechanics/Player_Fire2.wav soundparms 1.0 0.3 0.6 0.6 320 2200 item loaded maps "dm obj"
local.master aliascache firetouch3 sound/mechanics/Player_Fire3.wav soundparms 1.0 0.3 0.6 0.6 320 2200 item loaded maps "dm obj"
local.master aliascache explode_tank1 sound/weapons/explo/Explo_MetalMed1.wav soundparms 1.0 0.2 0.8 0.2 1500 9000 weapon loaded maps "dm obj"
local.master aliascache explode_tank2 sound/weapons/explo/Explo_MetalMed2.wav soundparms 0.9 0.2 0.8 0.2 1500 9000 weapon loaded maps "dm obj"
local.master aliascache explode_tank3 sound/weapons/explo/Explo_MetalMed3.wav soundparms 0.9 0.2 0.8 0.2 1500 9000 weapon loaded maps "dm obj"
local.master aliascache explode_tank4 sound/weapons/explo/Explo_MetalMed4.wav soundparms 0.9 0.2 0.8 0.2 1500 9000 weapon loaded maps "dm obj"
Save this file to your main/global folder and give it the file name: Player_Flak.scr
In your main map script under 'level waittill spawn' place this line:
exec global/Player_Flak.scr
Setting the Flak's Health:
=========================
You can set the Flak88 health level by using the 'level.flak_health' variable like this:
level.flak_health = 200
This must be used in your main map script before loading this script.
Example:
level.flak_health = 200
exec global/Player_Flak.scr
This example will give all Flak88 Turret's 200 health level. If you do not
use this level variable, the Flak health is 500 by default.
How to Fire the Flak:
====================
Stand near the Flak88 and aim with any weapon you are holding
and press the key you have assigned for 'use'.
The flak88 can be destroyed by rockets and grenades by knocking down it's
health level.
If you get too near the Flak88 after it has been destroyed the player will
start losing health by burning himself.
** NOTE **
You can have more than 1 Player Flak88 in your map.
You must targetname all Flak88 Turrets: flak88.
*/
//================================================================================
main:
if(!flak88) end
cache models/animate/fx_explosion_tank.tik
cache models/fx/scriptbazookaexplosion.tik
cache models/animate/fx_mortar_dirt.tik
cache models/animate/fx_mortar_higgins.tik
cache models/statweapons/flak88_d.tik
for(local.i = 1 ; local.i <= $flak88.size ; local.i ++)
$flak88[local.i] thread setup
end
//=====================================================================================
setup:
self dmprojectile "projectiles/tigercannonshell.tik"
//self.target = "flak_clip"
if(self.target)
self setCollisionEntity self.target
if(level.flak_health != NIL)
self.health = level.flak_health
else
self.health = 500
self takedamage
self removeondeath 0
self turnspeed 45
self immune bullet
self immune fast_bullet
self immune shotgun
self immune bash
self immune explosion
local.flaktrigger = spawn trigger_use targetname (self + "_player_flak_trigger")
local.flaktrigger.origin = self.origin
local.flaktrigger message ""
local.flaktrigger setsize ( -300 -300 0 ) ( 300 300 60 )
local.flaktrigger setthread player_fire_flak
local.flaktrigger.flakgun = self
thread kill_flak
end
//================================================================================
player_fire_flak:
//self = trigger_use called from 'setthread'
local.player = parm.other
if(!isAlive local.player) end
if(!isAlive self.flakgun) end
if(!local.player isTouching self) end
self nottriggerable
local.fwd_vec = angles_toforward local.player.viewangles
local.view = local.player gettagposition "Bip01 Head"
local.range = 5000
local.vector = trace(local.view + local.fwd_vec * 64) (local.view + local.fwd_vec * local.range ) 0
local.target = spawn script_origin origin (local.vector - ( 0 0 32 ))
self.flakgun setAimTarget local.target
local.player iprint "Flak Targeting...!"
wait 2
if(!isAlive self.flakgun) end
self.flakgun anim fire
thread spawn_fx "fx/scriptbazookaexplosion.tik" local.target.origin 2
thread spawn_fx "animate/fx_mortar_higgins.tik" local.target.origin 2
thread spawn_fx "animate/fx_mortar_dirt.tik" local.target.origin 2
wait 2
self.flakgun anim idle
self.flakgun clearAimTarget
local.target remove
self triggerable
end
//====================================================================================
kill_flak:
//self = flak88
self waittill death
self setAimTarget NULL
thread spawn_fx "animate/fx_explosion_tank.tik" self.origin 2
thread spawn_fx "animate/fx_mortar_dirt.tik" self.origin 2
self playsound explode_flak
local.damaged = waitthread spawn_damaged "statweapons/flak88_d.tik"
self hide
thread animate_impact local.damaged
radiusdamage local.damaged.origin 200 200
wait 1
thread global/message_print.scr::message "Flak 88 Cannon Destroyed!" NIL 5
if(self.target)
{
local.collision = waitthread spawn_collision self.target.brushmodel self.origin self.angles
thread fire_burn local.collision
}
else
{
local.damaged solid
thread fire_burn local.damaged
}
end
//=================================================================================
fire_burn local.object:
while(1)
{
for(local.i = 1 ; local.i <= $player.size ; local.i ++)
{
if ((isAlive $player[local.i]) && ($player[local.i].dmteam != "spectator") && ($player[local.i] isTouching local.object))
{
$player[local.i] hurt .2
$player[local.i] playsound firetouch
wait .5
$player[local.i] stopsound
}
}
waitframe
}
end
//====================================================================
animate_impact local.mdl:
//make the model lurch up, down and sideways when hit
local.mdl time .75
local.mdl rotatex -10
local.mdl rotatey 10
local.mdl rotatez -10
local.mdl move
wait 1
local.mdl rotatex 10
local.mdl rotatey -10
local.mdl rotatez 10
local.mdl move
end
//====================================================================================
spawn_fx local.fx local.origin local.removetime:
local.effects = spawn local.fx
local.effects.origin = local.origin
local.effects anim start
if(local.removetime)
{ wait (local.removetime)
local.effects remove
end
}
else
{
end local.effects
}
end
//===========================================================================
spawn_damaged local.mdl:
local.dmg = spawn script_model model local.mdl
local.dmg.origin = self.origin
local.dmg.angles = self.angles
local.dmg notsolid
end local.dmg
//========================================================================
spawn_collision local.brushmodel local.origin local.angles:
local.collision = spawn script_object model local.brushmodel
local.collision.origin = local.origin
local.collision.angles = local.angles
end local.collision
//==================================================================