I'm a newbie using LUA to make missions in Operation Flashpoint: Dragon Rising's mission editor. I've been trying to get the script down for about a week, I've googled, edited, and scoured the help index of the editor till it feels like my eyes are bleeding and it's all led to this. I'm having an issue with this "if...then" statement not doing anything. First, here's the whole thing:
function onMissionStart()
OFP:showLetterBoxOsd(false);
OFP:allowPlayerMovement(true);
OFP:allowPlayerFire(true);
OFP:setObjectiveState("Wave1","IN_PROGRESS");
OFP:setObjectiveState("Wave2","IN_PROGRESS");
OFP:activateEntitySet("enemy1");
end --This all seems to work fine, nothing to see here.
--OFP:isAlive(name of unit or entity set)
function isAlive() --After naming this function, a pesky "'<name>' expected near 'if'" error dissapeared so thats nice.
if OFP:isAlive("enemy1") == (false) --This "if..Then" statement should spawn "enemy2" when "enemy1" dies.
then
OFP:activateEntitySet("enemy2");
end
if OFP:isAlive("enemy2") == (false)
then
OFP:setObjectiveState("Wave2","COMPLETED")
OFP:missionCompleted()
end
end
Now here's what's giving me trouble:
function isAlive()
if OFP:isAlive("enemy1") == (false)
then
OFP:activateEntitySet("enemy2");
end
This is supposed to spawn enemy2
when enemy1
dies, but in game it might as well not exist, it doesn't work.
This names my function, the next line was throwing '<name>'
expected near if
until I did.
function isAlive()
This should track whether enemy1
is still alive, and if it returns a false it should spawn enemy2
.
if OFP:isAlive("enemy1") == (false)
then
OFP:activateEntitySet("enemy2");
end
function onMissionStart ist most likely a function the game calls when the mission starts. I could not find any official reference manual but the game seems to have some event based scripting system.
The remaining code you provided probably only executed when the file is loaded and therefor without any effect during the game.
Edit due to comment:
function onMissionStart()
OFP:showLetterBoxOsd(false);
OFP:allowPlayerMovement(true);
OFP:allowPlayerFire(true);
OFP:setObjectiveState("Wave1","IN_PROGRESS");
OFP:setObjectiveState("Wave2","IN_PROGRESS");
OFP:activateEntitySet("enemy1");
end --This all seems to work fine, nothing to see here.
The above code defines the function onMissionStart(). It most likely implements a function that is called by the game, when the mission starts.
You added the following code if I'm not mistaken:
--OFP:isAlive(name of unit or entity set)
function isAlive() --After naming this function, a pesky "'<name>' expected near 'if'" error dissapeared so thats nice.
if OFP:isAlive("enemy1") == (false) --This "if..Then" statement should spawn "enemy2" when "enemy1" dies.
then
OFP:activateEntitySet("enemy2");
end
if OFP:isAlive("enemy2") == (false)
then
OFP:setObjectiveState("Wave2","COMPLETED")
OFP:missionCompleted()
end
end
This also defines a function. isAlive. But who calls that function and when?
I found a list of events in DROPP. I presume that's the mission editor thing you're talking about. On certain events it will run certain functions. Like onAllplayersDead() would be called if all players are dead.
Explaining this all would be beyond the scope of this community. Just read through all of http://www.suderman.com/OFPDR/DROPP/reference.html and all files in http://www.suderman.com/OFPDR/DROPP/download.html
EventScripts = {
onAllPlayersDead = 0,
onArriveAtWaypoint = 0,
onCmdCompleted = 0,
onDeath = 0,
onDespawnEntitySet = 0,
onDespawnEntity = 0,
onDismount = 0,
onEnter = 0,
onEnterRVPoint = 0,
onFirepowerKill = 0,
onHit = 0,
onIdentified = 0,
onIncap = 0,
onLand = 0,
onLeave = 0,
onMissionStart = 0,
onMobilityKill = 0,
onMount = 0,
onMultiplayerMissionLoaded = 0,
onNoAmmo = 0,
onNoAmmoAll = 0,
onObjectDamage = 0,
onObjectDamage = 0,
onObjectiveCompleted = 0,
onObjectiveFailed = 0,
onObjectiveVisible = 0,
onOffboardSupp = 0,
onPinned = 0,
onPlaceableKill = 0,
onPlayEnter = 0,
onPlayDone = 0,
onPlayFailed = 0,
onPlayInvalid = 0,
onPvPMissionEnd = 0,
onRespawn = 0,
onSpawnedReady = 0,
onSpeechEnd = 0,
onSuppressed = 0,
onSuspected = 0,
onUnsuppressed = 0,
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.