PDA

View Full Version : [TUTORIAL] How to make a basic firefight map



L0d3x
October 30th, 2009, 09:44 PM
How to make a Firefight map
By L0d3x

This tutorial will teach you how to make a basic firefight map, similar to the one seen in my b40_firefight.
After having read this, you should be able to understand the scripts that I released for said map.
Said scripts can be found here: http://forum.halomaps.org/index.cfm?page=topic&topicID=29501&start=lastpage
The map can be found here:
http://forum.halomaps.org/index.cfm?page=topic&topicID=29469

Things that are used in this tutorial, but aren't covered specifically in this tutorial:
- custom animations, compiled as a .JMW, will be used to animate dropships to come in and leave the map
- basic sapien knowledge
- knowledge of how to get a script working/compiled in Sapien (creating a .hsc file).

We're going to assume that the animations are compiled into the following folder:
"levels\my_firefight\my_firefight_phantom", and the animation itself is called "top_anims".
"top_anims" itself contains 4 independent animations:
-top1_in: this animation was made to bring the dropship to a position above the battlefield.
-top1_drop: this animation was made to bring down the dropship to a position low enough to deploy troops.
-top1_wait: this animation was made to keep the phantom roughly in place, as the troops are deployed.
-top1_out: this animation was made to get the phantom out of the battlefield.


This tutorial will use a fictional scenario with following assets defined in Sapien:
- a phantom dropship named top1
- an ai encounter named dropship_actors, containing a squad named droppers, a squad named b, and a squad named c
- droppers squad should be set up to use firing positions A
- squad b should be set up to use firing positions B
- squad c, of course, will be set up to use firing positions C
- These squads will be used to let the ai follow the player around.
- Define the amount of ai you want the dropship to drop off in the squad named "droppers".
- Place starting points anywhere where the player won't be able to see them.
- Make sure that "automatic migration" is checked for squad b and squad c.
- place firing positions A wherever you want the droppers to attack initially.
- place firing positions B in the first "zone" where you want the ai to follow the player. When the player comes near this "zone", the droppers actors
will basically maneuver to zone B. The same applies for firing positions C, they just define another "zone" for the ai to follow the player, if he
crosses this zone.

Also make sure your map is set up as single player, and that you have a starting position for the player.
Make sure all "game modes" things for the starting position are set to "none".

Now that the stuff in Sapien is set up, it's time for the scripting. Don't be afraid, it's not that hard.

We're going to set up the scripts so that we have the dropship come in again everytime the actors inside the dropship die at the hands of the player.

First we shall define a static script that will take care of all the animations of the dropship.
A static script, when called, will execute everything within it. We can reference a static script as much as we want further in the .hsc file!

;;;This static script is responsible for executing the custom animations of the dropship, and unloading any ai in the dropship. Nothing more.
(script static void dropship1CustomAnims
(custom_animation top1 levels\my_firefight\my_firefight_phantom\top_anims top1_in 1)
(sleep (unit_get_custom_animation_time top1))
(custom_animation top1 levels\my_firefight\my_firefight_phantom\top_anims top1_drop 1)
(sleep (unit_get_custom_animation_time top1))
(custom_animation top1 levels\my_firefight\my_firefight_phantom\top_anims top1_wait 1)
(vehicle_unload top1 "passenger")
(sleep (unit_get_custom_animation_time top1))
(custom_animation top1 levels\my_firefight\my_firefight_phantom\top_anims top1_out 1)
(sleep (unit_get_custom_animation_time top1))
(object_destroy top1)
)

This script is pretty straight-forward. When called it will execute all the animations we made for the dropship.
Take special notice to the "vehicle_unload" command.

One would reference this static script by typing: "(dropship1CustomAnims)".


With a static script defined to play our animations, we now need a script that will control when the dropship animations should be played.
We'll use a continuous script to achieve this goal. Remember that we want the dropship to come in whenever the ai from the previous dropship has died.



(global boolean startDropshipTop1 false);This boolean will tell us when the custom animations for top1 can be played.
(global boolean roundComplete false); This boolean represents if a round has been completed or not

;;;This script is responsible for controlling wether or not the custom animations of the dropship should be called upon.
(script continuous dropship1Starter
(sleep_until startDropshipTop1)
(dropshipTop1CustomAnims)
(sleep_until (= startDropshipTop1 false));LINK ME
)

;;;This static script defines exactly what should happen within one round of firefight excitement.
(script static void top1_round
(object_create_anew top1)
;;create the ai and load them in the dropship
(ai_place dropships/droppers)
(vehicle_load_magic top1 "passenger" (ai_actors dropships/droppers))
;;set startDropshipTop1 to true, this will allow the custom animations to be played, see the continuous script above
(set startDropshipTop1 true)
;;let the ai follow the players
(ai_follow_target_players dropships)
;;script execution will be paused until all the ai from the dropship are dead
(sleep_until (<= (ai_living_count dropships) 0))
;;once all the ai are dead, the round is complete
(set roundComplete true);LINK ME AS WELL
;;we now let the above continuous script finish, and thus restart execution of the continuous content, see LINK ME above
(set startDropshipTop1 false)
)

;;;This script is responsible for controlling the (infinite) execution of rounds
(script continuous roundController
;;The new round has not yet been completed
(set roundComplete false)
;;Execute what should happen this round
(top1_round)
;;Pause this script's execution until the round is complete
(sleep_until roundComplete);LINK ME AS WELL
;;Now a new round can take place once again :-D
)

Notice the comments I placed. You should see the connection between The lines that have "LINK ME" and "LINK ME AS WELL" as a comment.
This should further explain how the above scripts work together.

Alright, now you should be able to create a basic firefight map with a dropship!


You can, of course, further enhance the script and scenario to allow for a more exciting setup. Be creative!

TeeKup
October 31st, 2009, 01:04 AM
Excellent!!! I'm eager to see more firefight maps.

You know, Lost Cove has the potential to be a VERY good firefight.

.Wolf™
October 31st, 2009, 07:16 AM
Someone needs to model a map based on firefight =)

English Mobster
November 1st, 2009, 04:42 AM
Added to the Ultimate HCE Tutorial Index (http://www.modacity.net/forums/showthread.php?t=18957); good job, L0d3x!