GRIN_Wolfsong Posted November 13, 2006 Share Posted November 13, 2006 (edited) Ok. This got a little rushed due to a question asked about it. But here are the essentials on how to create a demolition objective or just setup a the possibility for the player to use a c4 charge. Demolition Objective How does the c4 props work? Let's take a look at this with an example. Let's say the first objective is to blow up an ADA. Then it can look something like the following. NEEDED (for this example): 1 c4 prop (world.xml) 1 ADA vehicle (world.xml) 1 trigger (mission.xml) 3 events (mission.xml) MAP EDITOR (WORLD.XML) First we'll place our ADA unit. Let's just name it "aa1". Then we need a c4 prop. In the map editor there are 8 different c4 props. There is NO difference between these! What you have to notice is the last part of the name as it is critical for the scripting. For example if you use c4_aa1, "aa1" is the important part. C4 PROPS: - c4_aa1 - c4_aa2 - c4_aa3 - c4_blow_antenna - c4_blow_powerstation - c4_bunker01 - c4_bunker02 - c4_gasstation We'll place a c4_aa1 in close proximity to the ADA, and we'll also name it "c4_aa1" so it's easy to remember which prop we used and in this case which unit it's ment to destroy. After doing that in the map editor it's time for some scripting in the mission.xml file. MISSION.XML First, you'll need to enable the c4 prop so that the player can use it. I suggest doing this in the event that activates the objective. Activate c4 prop event <event name="objective1_start"> <element type="Objective" id="objective1" headline_id="w01_obj1_head" txt_id="w01_obj3_txt" state="add" mode="1" start_time="1.0"/> <element type="Objective" id="objective1_wp" waypoint_id="w01_obj3_wp" state="add" waypoint="12515 -7169 217" mode="1" start_time="2.0"/> - Starts objective like seen in SP Scripting 2. <element type="EnableUnit" name_id="c4_aa1" start_time="3.0"/> Enables the c4 prop, which makes it visible and also activates the function that allows the player to press x to activate it. - name_id => use the same name you gave the c4 prop in the map editor. </event> Next, we must have an event for when the c4 is activated by the player. This is a required event implemented with the c4 prop. You don't need to include any elements in it if you don't want, but the NAME is critical of you'll get an error when trying to start the mission. We'll keep it empty to make it simple. On player activation event <event name="aa1_trigger"> </event> Notice the event name! "aa1" is the last part of the prop name you have placed, then just add "_trigger" after that. GRiN uses events to adjust the music when the c4 is active, which looks like this: <event name="aa1_trigger"> <element type="SetMusicMood" tempo="200" mood="200" start_time="0.0"/> <element type="SetMusicMood" tempo="-1000" mood="-1000" start_time="20.0"/> </event> Ok, that is all that is needed for the c4 to work. As it works on game physics it will destroy anything inside it's detonation radius automatically. But for it to work for us as an objective we'll need a trigger to detect that the ADA is destroyed and another event to be run after that and complete the objective. ADA Trigger <user name="destroy_aa1" type="once"> <trigger type="Vehicle"> <vehicle id="aa1"/> </trigger> <event name="destroy_aa1"/> </user> See SP Scripting 3 for more details on the trigger. ADA destoryed event <event name="destroy_aa1"> <element type="DisableUnit" name_id="c4_aa1"/> - Disable the c4 unit so the player can't see it anymore. <element type="Objective" id="objective1" state="remove" start_time="2.0"/> <element type="Objective" id="objective1_wp" state="remove" mode="1" start_time="3.0"/> - Sets objective as complete and removes waypoint. SP Scripting 2. </event> And the clean XML code with only overview comments: <!--TRIGGERS--> <!--ADA Trigger--> <user name="destroy_aa1" type="once"> <trigger type="Vehicle"> <vehicle id="aa1"/> </trigger> <event name="destroy_aa1"/> </user> <!--EVENTS--> <!--Activate c4 prop event--> <event name="objective1_start"> <element type="Objective" id="objective1" headline_id="w01_obj1_head" txt_id="w01_obj3_txt" state="add" mode="1" start_time="1.0"/> <element type="Objective" id="objective1_wp" waypoint_id="w01_obj3_wp" state="add" waypoint="12515 -7169 217" mode="1" start_time="2.0"/> <element type="EnableUnit" name_id="c4_aa1" start_time="3.0"/> </event> <!--On player activation event--> <event name="aa1_trigger"> </event> <!--ADA destoryed event--> <event name="destroy_aa1"> <element type="DisableUnit" name_id="c4_aa1"/> <element type="Objective" id="objective1" state="remove" start_time="2.0"/> <element type="Objective" id="objective1_wp" state="remove" mode="1" start_time="3.0"/> </event> Recap So what are the essentials for a c4 prop to work, without the objective parts? Checklist - Place c4 prop and remember it's name - Enable c4 prop in mission event - Create activation event called "*propname*_trigger" I may update this and clean it up some... Edited November 13, 2006 by Wolfsong Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.