Creating a triggerable multiplayer Flak88 :: Bjarne Grönnevik
We like to blow things up don't we? Yes we do. And what do we like
to use? Indeed, the biggest gun we can get our hands on. So lets
put our hands on a Flak88.
-------------------------------------------------------------------------------
Create a Flak88
-------------------------------------------------------------------------------
First: create a Flak88 base ( with nothing selected, right click
on the map grid and select turretweapon -> german -> 88mmflakbase
).
Second: create a Flak88 ( with nothing selected, right click on
the map grid and select turretweapon -> German -> 88mmflakturret
).
Give the turret this key-value pair ( with the object selected,
press 'n' and enter the key-value pairs at the bottom of the dialog
) :
Key
Value
Explanation
targetname
flak88
A name used by other entities to target this entity.
Place the turret on top of the base. We want this to look good.
Done.
Give it a trigger
Create a trigger_use ( with nothing selected, right click on the
map grid and select trigger->use ).
Give it this key-value pair ( with the object selected, press 'n'
and enter the key-value pairs at the bottom of the dialog
) :
Key
Value
Explanation
setthread
fire_flak88
This tells the trigger to call the method "fire_flak88"
in the map script file.
Reposition the trigger so that it sits at a good place... back
of the Flak88 perhaps? Done.
-------------------------------------------------------------------------------
Fire the gun
-------------------------------------------------------------------------------
OK, now the scripting begins! Remember the setthread
above? Well lets write that 'fire_flak88' method in the script:
// ARCHITECTURE: Bjarne Grönnevik
// SCRIPTING: Bjarne Grönnevik
fire_flak88:
// Just a test target. Set it to what you
// would like to destroy.
local.target = ( 100.0 0.0 0.0 )
// Start the main gun fire animation.
$flak88 anim fire_scripted
// Wait to give time to the shell to get to the target.
wait 1
// Set the animation back to idle ( else the fire
// animation will not work the next fire )
$flak88 anim idle
// Spawn the explosion animations.
waitthread blow_a_place_up
end
-------------------------------------------------------------------------------
Blow up the spot where it hits
-------------------------------------------------------------------------------
You saw the
waitthread blow_a_place_up
...above, right? Well, we need to actually blow it up, not just
threaten to do it. So lets write the method that blows it up:
// ARCHITECTURE: Bjarne Grönnevik
// SCRIPTING: Bjarne Grönnevik
blow_a_place_up:
// Just a test target. Set it to what you
// would like to destroy.
local.target = ( 100.0 0.0 0.0 )
// Spawn the explosion animations.
local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"
local.Exp3 = spawn "animate/fx_mortar_higgins.tik"
// Shake the ground hard.
exec global/earthquake.scr .23 4 0 0
// Get the animations going.
local.Exp1.origin = local.target
local.Exp1 anim start
local.Exp2.origin = local.target
local.Exp2 anim start
local.Exp3.origin = local.target
local.Exp3 anim start
wait 1
// Remove the animations.
local.Exp1 remove
local.Exp2 remove
local.Exp3 remove
end
OK! What we have now is a Flak88 that we can fire by pressing a
trigger.
-------------------------------------------------------------------------------
Think about extending this
-------------------------------------------------------------------------------
There are some things missing... the Flak88 is a bit boring, isn't
it?
Fire sound
The fire sound of the animation will not work in multiplayer games
because of the fact that the ubersound.scr does not have an alias
named flak_snd_fire that is configured
for multiplayer games. Solve this by using jv_map's new ubersound
workaround at .MAP
to be able to hear it in multiplayer as well.
Aiming the Flak88
This example uses a static location to fire at. There is no need
for this. You can fire the Flak88 at any target. You can also realign
the Flak88 to point at the target... something like this:
$flak88 setaimtarget local.target
Or maybe a system of switches that lets you control the angle and
elevation of the Flak88 to create a guess-fire-calibrate-fire-calibrate-fire-BOOM!
scenario.
Reloading the Flak88
As it is now, you can fire the Flak88 as fast as you can trigger
it... not very realistic. So maybe add a delay before it can be
fired again? Maybe it only has a limited amount of shells available?
Maybe remove a shell-model from a nearby ammunitions crate each
time a reload is started?
Fully automatic Flak88
Maybe the trigger is only used to start a complex behavior where
the Flak88 ( or maybe a series of Flak88:s ) start to randomly carpet
bomb an area ( The omaha beach perhaps )?
Player controlled Flak88
Maybe you can glue the player to the Flak88 and make it act in
the same way as an MG42 machine gun?
You don't have to use a Flak88. You can use any weapon. You can
build your own weapons if you like. But the Flak88 is the only gun
( that I know of ) that contains the firing animations from scratch.
But there is no reason why you can't spawn a muzzle flash, the same
way you spawn the other FX in these examples.
Flying Flak88
Maybe we should stop here...
-------------------------------------------------------------------------------
Can I do this only by scripting?
-------------------------------------------------------------------------------
Yes you can. And if you like to mess with existing maps, like the
ones shipped with MOH:AA or ones that others made that you don't
have the *.map file for: you can still add a usable Flak88. The
scripting parts above is exactly the same. But setting up a Flak88
turret and a trigger is done like this:
// ARCHITECTURE: Bjarne Grönnevik
// SCRIPTING: Bjarne Grönnevik
spawn_a_flak88:
// Spawn a script model and give it a targetname
local.flak = spawn script_model "targetname" "flak88"
// Set the model to be drawn/used
local.flak model "statweapons/flak88turret.tik"
// Set where it should be
local.flak.origin = ( -100.0 .0 0.0 )
// Set where it should point at
local.flak.angles = ( 0.0 0.0 0.0 )
// Set how big it should be
local.flak.scale = 1.0
// Create the trigger and give it a targetname
local.trigger = spawn trigger_use "setthread" "fire_flak88"
// Set where it should be
local.trigger.origin = ( 0.0 100.0 0.0 )
// Set the size of it
local.trigger setsize ( -50 -50 -50 ) ( 50 50 50 )
end
And to initiate the spawning of the Flak88, write this in the main
method ( after level waittill prespawn )
That's all you need to know for now... I bet your evil brain is
already thinking about how to combine this simple stuff with other
simple stuff into a really complex thing that will blow up players
in a completely new way. Remember, make it fun... fun is better
than cool and complex. Ask any player.
Thanx to Nemesis,
for teaching me how to make a Flak88 fire at all...