
If you want to familiarize yourself with or you don't know how to load the editor, read my first post "Mission Editor Introduction" which gives a brief overview of the editor.
Tutorial Goals
- Create a single 4 man squad
- Create waypoints to objective
- Create an enemy squad as the primary mission objective
- End mission when objective is complete or when we fail
Every mission has a few things in common; you have a player and an enemy that is the objective. In this first tutorial, we will be the most minimalistic. We will create the friendly units which will consist of you and your squad. No mission is any fun without an enemy, so we will be creating an enemy squad. Our objective will be to eliminate the enemy squad. If we die, the mission will end in failure. If we eliminate the entire enemy squad, the mission will finish. Sound simple, well it is for the most part. Putting objects on the map is pretty simple. The scripting will be a little challenging, especially if you don't have any programming experience. But, this first tutorial should be easy if you follow along carefully, so let's get started.
Start by launching the Mission Editor.
- Zoom in on the island of Skirinka on the uppermost tip until you can see the area around the lighthouse.
- In the Create panel on the right hand side, select USMC, and then from Fireteams, select USMC Assault Team and place your new fireteam near that last bend leading to the lighthouse. Then press the Escape key "Esc". This will reset your cursor back to a neutral state, otherwise when you clicked again on the map you would continue to place more fireteams. There are time when you want to do that, but not right now. Let's keep this mission really simple.
- Zoom into your new fireteam until you can see the little white shield on the fireteam leader and select that unit.
- Now select Modify from from the panels on the right at the bottom and scroll down to Character. Change control mode from AI to Player. You could save your mission at this point and if you want to see what you have so far, you could run the mission. This would obviously be a pretty boring map at this point. Let's create an enemy to shoot.
- In the Create panel on the right hand side, select PLA, and select Fireteams, and then PLA Assault Team.
Now zoom into the lighthouse, and place your fireteam between the buildings and before you deselect them select the Rotate button from the toolbar. Click in the center of the fireteam and drag to the left until they are facing the road. To get your cursor out of rotate mode, you can't just press the Escape key, you have to select a different mode from the toolbar, so go back and select the Move button. You can move and rotate the soldiers however you like. Standing in a straight line is kind of boring, but do whatever you like. If you select the fireteam Echelon shield you select the whole unit or you select the individual soldiers by selecting the AI circles.
- If you were to play that mission you now have some enemies, but after you kill them, you are left to wander around with nothing much to do. To keep things really simple, we are going to make our objective to get to the lighthouse and this will complete the mission. This should be pretty easy, to accomplish both in game and in the editor.
- In the Create panel on the right, select System > Mission > Triggers (triggerzone). Place the triggerzone on the lighthouse.
In the Create panel, select System > Mission > Mission objective and place it on the lighthouse too. While the objective is still selected, in the Modify panel, we are going to change some settings to make this objective show up in our objective list. First, in the Entity section, change the name to mainObjective. Then in the Transform section, change the Altitude to 20 meters. Now in the next section Objective change the Type from Disabled to Primary Objective. Change the Objective Text (in the UI) to
"Get to lighthouse for extraction" and the Objective Text (in the game) to "Get to Lighthouse" and that should do it.- In the Create panel once again, select System > Mission > Level script and place it anywhere on the map. Now you should have a new tab on top of the map that says level.lua. Select that tab and past the following code into the editor under "-- Write your LUA script here." I will explain what the different parts of the script do at the end of the article.
function onMissionStart()
OFP:showLetterBoxOsd(false);
OFP:allowPlayerMovement(true);
OFP:allowPlayerFire(true);
end
function onEnter_triggerzone(zoneName, unitName)
OFP:setObjectiveState("mainObjective", "COMPLETED");
OFP:missionCompleted();
end
function onDeath_iu06usfldr(victim, killer)
OFP:missionFailedKIA()
end - Now save and play your mission.
Operation Flashpoint Dragon Rising has a scripting language built into it called Lua. You can find more information about Lua at lua.org.
The first function is an event handler that get run when the mission starts. The functions we are using are prefixed with on. This means, when a certain event happens, run the actions within that function.
Thanxxx. .David. ..... ur tut iz awsum. ......
ReplyDeletei made ma first mission. .....coz of ur help. ..... thanx. ....
bt i need help in spawning an ememy heli when player enter a trigger zone. ..can u help me with this. ......
I know this thread is ancient, but I just started editing in Dragon Rising and I'm having trouble. None of my scripts seem to be running, ever.
ReplyDeleteAs a test case, I wrote this one,
function onMissionStart()
local onMissionStart = OFP:spawnEntitySetAtLocation(Wave1)
Wave1.onDeath = Pointer:new("win_mission")
end
function win_mission()
OFP:missionCompleted()
end
It's supposed to spawn the Wave1 entity group on mission start, then end the mission when they die. When I run it the units spawn but nothing happens when they die, it seems they're spawning just because I placed them on the map instead of because my script says so.
Having the units spawn when I tell them to is important because I want to make a multi wave defense mode.
Is there something I'm missing here?
Try
ReplyDeletefunction onDeath_Wave1(victim, killer)
OFP:missionCompleted()