Spawned Weapons, Scripting and Destruction

Post your scripting questions / solutions here

Moderator: Moderators

Wolf-Man
Private
Posts: 5
Joined: Sun May 18, 2003 10:46 am

Spawned Weapons, Scripting and Destruction

Post 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.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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
Image
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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
Image
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post 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.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

No wonder, you were trying to turn the flak into a drivable (sp) tank ;)
Image
Wolf-Man
Private
Posts: 5
Joined: Sun May 18, 2003 10:46 am

Post 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:
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Under the bridge, is that coord (0 0 0) perhaps?
Image
Wolf-Man
Private
Posts: 5
Joined: Sun May 18, 2003 10:46 am

Post by Wolf-Man »

Yep! Sounds about right.

Tell me, oh script God, wtf do I do now?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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 :?
Image
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post 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.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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
Sgt.Pepper
Sergeant
Posts: 69
Joined: Tue Feb 25, 2003 5:41 pm
Location: Canada

Post 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
TheShiznaeSpe
Major
Posts: 304
Joined: Wed Feb 05, 2003 11:45 pm
Location: US
Contact:

Post 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?
Post Reply