Page 1 of 2

Spawned Weapons, Scripting and Destruction

Posted: Sun May 18, 2003 10:48 am
by Wolf-Man
I've been working with the stock maps, and adding new features like wire, mortars etc.

I'm having trouble with the static weapons. I've placed some flak88's but when they're destroyed, they disappear instead of leaving a destroyed version behind.

Note I'm only doing this through the script, not mapping. I'd appreciate it if someone can clue me in? Keep it simple, because I'm not as good at scripting as I should be.

Thanks in advance.

Posted: Sun May 18, 2003 2:12 pm
by jv_map
global/vehicles_thinkers.scr wrote: self waittill death
self setaimtarget NULL
self show
self playsound explode_flak88
radiusdamage self.origin 200 200
self thread spawn_fx models/fx/fx_tank_explosion.tik
local.damaged = thread spawn_damaged models/statweapons/flak88_d.tik
self remove

Posted: Sun May 18, 2003 2:31 pm
by Sgt.Pepper
Ok, how would that be applied to the original flak script? Here's the flak script:

//Flak On Crossroads - Allied
local.flakcannon = spawn models/statweapons/P_flak88.tik
local.flakcannon.origin = ( -223.97 -2653.97 240.13 )
local.flakcannon.angle = 271
local.flakcannon.scale = 1
local.flakcannon yawCenter 450
local.flakcannon maxYawoffset 50
local.flakcannon bulletDamage 30

Would we add something like:

local.flakcannon exec global/vehicles_thinkers.scr

Posted: Sun May 18, 2003 2:47 pm
by jv_map
Na just copy the code into your own thread :?

//Flak On Crossroads - Allied
local.flakcannon = spawn models/statweapons/P_flak88.tik
local.flakcannon.origin = ( -223.97 -2653.97 240.13 )
local.flakcannon.angle = 271
local.flakcannon.scale = 1
local.flakcannon yawCenter 450
local.flakcannon maxYawoffset 50
local.flakcannon bulletDamage 30
local.flakcannon thread mypflakthread
(....)
end

mypflakthread:
self waittill death
self setaimtarget NULL
self playsound explode_flak88
radiusdamage self.origin 200 200
self thread global/vehicles_thinkers.scr::spawn_fx models/fx/fx_tank_explosion.tik
local.damaged = thread global/vehicles_thinkers.scr::spawn_damaged models/statweapons/flak88_d.tik
self remove
end

Posted: Sun May 18, 2003 3:18 pm
by Sgt.Pepper
That did it. Once more thanks for your help.

That command I posted earlier, the local.flakcannon exec blah.scr ended up crashing the game and eventually my comp.

Thanks again.

Posted: Sun May 18, 2003 3:20 pm
by jv_map
No wonder, you were trying to turn the flak into a drivable (sp) tank ;)

Posted: Mon May 19, 2003 2:06 am
by Wolf-Man
Ok we've done that, but it seems to leave behind a destroyed flak88 on the map.

Example, on the crossroads map, we've put a flak88 at each end, and when you destroy them, they work as they should. But under the bridge in the water is a destroyed cannon?

The script doesn't even have those coordinates... weird. :shock:

Posted: Mon May 19, 2003 9:52 am
by jv_map
Under the bridge, is that coord (0 0 0) perhaps?

Posted: Mon May 19, 2003 2:12 pm
by Wolf-Man
Yep! Sounds about right.

Tell me, oh script God, wtf do I do now?

Posted: Mon May 19, 2003 2:55 pm
by jv_map
I have one more question: is the destroyed gun there at the start or does it appear when you shoot a flak88?

On another note, make sure to add this line:
local.flakcannon immune bash

Otherwise the game will crash when someone bashes the gun :?

Posted: Mon May 19, 2003 3:13 pm
by Sgt.Pepper
The destoryed gun is there before the original ones are destoryed.

Yeah, and in two maps the destoryed gun appears as close as possible to ( 0 0 0 ).

Oh, and will add that immune bash line.

Posted: Mon May 19, 2003 3:23 pm
by jv_map
Hmm I must have missed something while copying :oops:

local.damaged = thread global/vehicles_thinkers.scr::spawn_damaged models/statweapons/flak88_d.tik

should be:

waitthread global/vehicles_thinkers.scr::spawn_damaged models/statweapons/flak88_d.tik self.angles self.origin

Posted: Mon May 19, 2003 6:34 pm
by bdbodger
Did I see that you where useing the p_flakk88.tik that is a spearhead gun isn't it ? In spearhead there is a global script for the destoyed models you use it like this
Steps in Radiant:

1. Make a turret weapon in Radiant
2. Give the weapon a $targetname
3. Give it a health
4. if you want it to block when it gets destroyed? have it target the collision geometry

Steps in your script:

1. In your main script you need to add right after level waittill spawn
The $targetname of the weapon followed by the following thread

Ei. Lets say we have called a player mountable turret $targetname gun1

The script would read

$gun1 thread global/stationaryweapons.scr::MountedStationaryWeapon statweapons/P_aagun_d.tik
the last part of that is the destroyed model you want to use . You can use this script for the flakk too just use p_flak88_d.tik

Posted: Mon May 19, 2003 7:31 pm
by Sgt.Pepper
Ok, with the changed line we're still have the destoryed gun appear. Let me copy it out to make sure that I've got it right. I put the dash in there to indicate that the next line should be a continuation of the previous line.

mypflakthread:
self waittill death
self setaimtarget NULL
self playsound explode_flak88
radiusdamage self.origin 200 200
self thread global/vehicles_thinkers.scr::spawn_fx models/fx/fx_tank_explosion.tik
waitthread global/vehicles_thinkers.scr::spawn_damaged models/statweapons/flak88_d.tik -self.angles self.origin
self remove
end

Posted: Mon May 19, 2003 8:04 pm
by TheShiznaeSpe
wouldn't it be just as easy to use the exploder script?

-spawn script_models
-give them local.whatever.targetname = $exploderfire, $explodertrigger, $exploder, and $explodersmashed
-then add exec global/exploder.scr

or would that not work?