Ok. This got a little rushed due to a question I got about it. But here are the essentials on how to create a demolition objective or just setup a 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.
[color="RoyalBlue"]C4 PROPS:
- c4_aa1
- c4_aa2
- c4_aa3
- c4_blow_antenna
- c4_blow_powerstation
- c4_bunker01
- c4_bunker02
- c4_gasstation[/color]
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
[color="RoyalBlue"]
[/color]
- Starts objective like seen in SP Scripting 2.
[color="RoyalBlue"][/color]
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.
[color="RoyalBlue"][/color]
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
[color="RoyalBlue"]
[/color]
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:
[color="RoyalBlue"]
[/color]
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
[color="RoyalBlue"]
[/color]
See SP Scripting 3 for more details on the trigger.
ADA destoryed event
[color="RoyalBlue"]
[/color]
- Disable the c4 unit so the player can't see it anymore.
[color="RoyalBlue"]
[/color]
- Sets objective as complete and removes waypoint. SP Scripting 2.
[color="RoyalBlue"][/color]
And the clean XML code with only overview comments:
[color="RoyalBlue"]
[/color]
[color="RoyalBlue"]
[/color]
[color="RoyalBlue"]
[/color]
[color="RoyalBlue"]
[/color]
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"