Page 2 of 3

Posted: Sat May 01, 2004 2:16 pm
by Combat Kirby
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: 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
//==================================================================
[/code]

Posted: Sat May 01, 2004 6:47 pm
by HotShizzle
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....

Posted: Sat May 01, 2004 10:07 pm
by HotShizzle
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...

Posted: Sat May 01, 2004 10:51 pm
by Phil
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

//commanddelay 0.2 drunk 0.12 0.12

cache blastmark.spr
cache models/fx/bazookaexplosion.tik
}
client
{
originemitter bazookatrail
(
model vsssource.spr
velocity 150
friction 0.85
randvel crandom 10 crandom 10 crandom 10
accel 0 0 20
spawnrate 110
color .4 .4 .4
spritegridlighting
alpha 0.4
fadein 0.1
fadedelay 1.0
scalemin 0.8
scalemax 1.0
scalerate 0.5
life 2.0 2.5
)
}
}

animations
{
idle projectile_bazooka.skc
}


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"

// turret settings
idleCheckOffset "-240 0 0"
viewOffset " -100 -10 115"

//pickupsound flak88_reload
//noammosound flak88_reload

// Primary fire type info
projectile models/projectiles/flak88shell.tik
firetype projectile
ammotype "heavy"
//semiauto
//clipsize 1
meansofdeath rocket
bulletcount 1
usenoammo 1
ammorequired 0
firedelay 5.0
bulletrange 8000
bulletdamage 200
bulletspread -35 -35
tracerfrequency 3
turnspeed 38
pitchcaps "-55 10 0"

// DM Attributes
dmprojectile models/projectiles/flak88shell.tik
dmusenoammo 1
dmammorequired 0
dmfiredelay 5.0
//dmbulletcount 1
dmbulletrange 8000
dmbulletdamage 400
dmbulletspread 15 15 75 75
dmcrosshair 0

SoundSet "tank_"
}
client
{
cache muzsprite.spr
cache models/fx/muzflash.tik
cache models/ammo/rifleshell.tik
cache model vsssource.spr
cache model smoke_ring.spr
}
}


animations
{
idle 88turret.skc
wheel_left 88turret_wheel_left.skc
wheel_right 88turret_wheel_right.skc
fire 88turret_fire.skc
{

server
{
first shoot
}

client
{
entry stopaliaschannel king_snd_fire
first sound king_snd_fire weapon 1.0 -1 0.95 0.1

first tagspawn tag_barrel
(
model vsssource.spr
count 6
alpha 0.30
color 1.00 1.00 1.00
life 0.70
scalerate 15.00
cone 20.00 20.00
velocity 700.00
accel -2000.00 0.00 0.00
friction 4.00
fade
circle
randomroll
)

// muzzle flash
first tagdlight tag_barrel 0.25 0.2 0.05 110 0.11
first tagspawn tag_barrel
(
spawnrate 1.00
model muzsprite.spr
alpha 0.50
color 1.00 1.00 1.00
varycolor
scale 1.70
life 0.05
scalerate 1.00
velocity 4.00
friction 3.00
fade
alignstretch 1.00
)

first tagspawn tag_barrel
(
spawnrate 1.00
model muzsprite.spr
alpha 0.50
color 1.00 1.00 1.00
scale 1.60
life 0.05
scalerate 0.70
velocity 17.00
offsetalongaxis 9 0 0
fade
alignstretch 0.40
)

first tagspawn tag_barrel
(
spawnrate 1.00
model muzsprite.spr
alpha 0.50
color 1.00 1.00 1.00
scale 1.60
life 0.05
velocity 18.00
fade
)

first tagspawn tag_barrel
(
spawnrate 1.00
model models/fx/muzflash.tik
color 1.00 1.00 1.00
scale 1.09
life 0.01
velocity 2009.00
accel 0.00 20.00 30.00
friction 2.00
offsetalongaxis range -10 4 0 0
fade
alignstretch 0.02
)

first tagspawn tag_barrel
(
spawnrate 1.00
model models/fx/snipesmoke.tik
color 1.00 1.00 1.00
scale 3.00
life 1.00
velocity 220.00
friction 10.00
angles 0 0 random 270
avelocity 0 0 10
align
)

}

}
}

/*QUAKED turretweapon_german_88mmflakturret (0.5 .25 0.25) (-32 -32 0) (32 32 128)
Big gun - Boom boom.
*/


Save this as flak88turret.tik & put it in statweapons folder.

Turn the models folder into a zip folder by using Winzip.
Then rename the new zipped folder to flak88.pk3 & then add it to your Main foler.

All flak88's should be useable.

Posted: Sun May 02, 2004 12:00 pm
by Bjarne BZR
Wow Phil, that was cool... tried it on Hunt :) But the fire speed was way out of control, it fired as fast as computationally possible...

Posted: Sun May 02, 2004 1:05 pm
by bdbodger
Well I give up then because if worked good in my test map . Good luck .

Posted: Mon May 03, 2004 1:31 am
by HotShizzle
*sigh* jv can u help me on this one?? or if some1 got the answer please post it!

Posted: Mon May 03, 2004 6:56 am
by Bjarne BZR
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!". :?

Posted: Mon May 03, 2004 8:37 am
by bdbodger
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 .

Posted: Mon May 03, 2004 7:17 pm
by HotShizzle
:evil: :evil: ^^ Bjarne thats wat i meant by *sigh* since you said that it goes too fast!

Posted: Mon May 03, 2004 9:41 pm
by Bjarne BZR
HotShizzle wrote: :evil: :evil: ^^ Bjarne thats wat i meant by *sigh* since you said that it goes too fast!
Well, try to be more scpecific in the future then.

The thing is that this fast fire speed is a bit strange... as both firedelay and dmfiredelay is set to 5...

Does the 5 second delay work for you Phil? And if so: what is it that we missed?

Posted: Tue May 04, 2004 6:13 pm
by M&M
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

Posted: Wed May 05, 2004 2:28 am
by bdbodger
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 .

Posted: Wed May 05, 2004 7:21 pm
by HotShizzle
OK i will try everything...but if anyone gets more solutions please post it...jv can u post a solution?

Posted: Sat Jun 05, 2004 8:40 pm
by Phil
you want the,

accurate crossair
longer fire-delay
different projectile model.


What model? must be from the game.

I'll have a play about with it, see what i come up with when i've got 10 mins spare. :roll: