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'.
/*
//===================================================================================
*********** 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
//==================================================================
ok i see i have multiple responses...but to get an answer from everyone and to try out their solutions to see which is best....the answer to Bjarne's question is that i want to attach the player to the Flak88 and aim by using the wiewport....also bdbodger i see you have gotten the method for the flak...but i tried it and it doesnt work at all....
OK listen up everyone please come up with a solution....the targetname of my flak88 turret is flak88...remember i want it to be like when u go up to flak you press use and then u are in the view like you have it with the mg42 and then you press fire and it will fire...also give the code to the ubersound workaround...
Make a folder called models, then make another folder inside it called Projectiles
Copy this to notepad:
TIKI
setup
{
scale 1.0 // Needs to be unnaturally large so it is visible
lod_scale 30
path models/ammo/bazooka_shell
skelmodel projectile_bazooka.skd
surface bazookashell shader bazookashell
}
init
{
server
{
classname Projectile
anim idle
setsize "-4 -4 -4" "4 4 4"
speed 1500 // full realistic speed is 2800 (175ft/sec)
addownervelocity 0
hitdamage 200
life 20.0
health 50
takedamage
meansofdeath rocket
explosionmodel models/fx/bazookaexplosion.tik
explodeontouch
smashthroughglass 64
//knockback 300
dlight 0.4 0.2 0.1 256 // red green blue radius
gravity 0.2
//avelocity random 90 random 90 60
Save this as flak88shell.tik & put in the Projectiles folder.
Make another folder in the Models folder & call it statweapons.
Open notepad again & copy this:
TIKI
setup
{
scale 0.62 // Set default scale to 16/30.5 since world
// is in 16 units per foot and model is in cm's
//scale 1.55 // Seems to work better than 0.52
path models/statweapons/88mmflak
skelmodel 88turret.skd
surface all shader flak88
}
init
{
server
{
classname TurretGun
weapontype cannon
name "88mm A.T. Gun"
HotShizzle wrote:*sigh* jv can u help me on this one?? or if some1 got the answer please post it!
What is it more you need? Did you not see Phil's answer? Is that not exactly what you wanted?
You said "i want it to be like when u go up to flak you press use and then u are in the view like you have it with the mg42 and then you press fire and it will fire...also give the code to the ubersound workaround..."
That is exactly what Phils code will do... so if it still does not work, tell us so instead of *sigh*.
Were trying to help you here, but we need your help in doing so, not just repeating posts saying "Help, tell me the solution!".
Phil's code shows promise but needs to be adjusted . I found it a bit hard at first to mount the gun and I don't know what this will look like in a multiplayer game . As Bjarne BZR said it fires too fast and is not very accurate .
i remember there was a topic exactly like it a few months ago !!!
try doing a search (i think it was in the mapping forum ,but not sure it still might be here)
also, it seems on my mohaa there is a similar script to phils cause i can activate the flak there by pressing e (action button) ,and instead of deploying the bomb (or removing it) i get myself on the flak and start firing !!! i have to look closely at the red " bomb place " to deploy/undeploy the bomb
also ,this flak fires very quickly and i usually must have a rocket launcher selected cause the flak seems to use those rounds !!!!!
the old topic i was referring to at the beggining of this post also had a similar problem but i dont know if it was solved since i stopped following it
I have not tried it but I think that combat kirby has the best answer . In phil's script it will look really strange to other players in a multi player game . Maybe try everything and make up you own mind and maybe get a friend to join a game with you and see what it look like in game .