Hey Liebe ArmAworld Comunity,
da ich mich viele Jahre in der ArmA Comunity rumgetrieben habe und auch verschiedenste arten von Missions Bau gesehen haben und relativ oft sehr große Probleme darinne gesehen habe wollte ich hier mal kurz zeigen/erklären wie man es vielleicht machen kann ohne das man 1. die übersicht verliert und 2. Performance zu sparen.
Wie bin ich überhaubt darauf gekommen das so zu machen.
Also angefangen hat es als ich verstanden hatte was man mit Spawn und Waituntils im grundlegenden Storry missions bau alles beweltigen kann(das heißst man hat eine art Story board in dem von oben nach unten die gesamte geschichte seht und man damit etwas mehr übersicht hat darüber was wann wo Passiert). Jedoch ist mir schon nach einiger zeit aufgefallen das dieses ein sehr Unschönes und unperformantes Stück missions bau ist das einen sehr starken Script Lag erzeugt. Und ich habe viel ausprobiert und geschaut wie man das regeln kann und habe lange keine Idee gehabt, Doch zu irgendeiner Späten Nacht stunde in einem Teamspeak erinnerte ich mich daran das ein bekannter ArmA Spieler von mir meinte das man doch Missionen eigendlich mit Eventhandlern Viel Performanter zubauen sein muss. Jedoch als dieses damals mir vorgeschlagen wurde wusste ich noch nicht wie ich das umsetzten. Aber dafür ist mir vor einpaar wochen die Idee dazu gekommen.
Ich habe 2 kleine Scripts dafür geschrieben 1x eins das ein Event hinzuführt und 1x ein Script ein Script das ein Event Triggert.
addMissionEventHandler:
- [COLOR=#FF8040][COLOR=#006400][I]/*
- * Name: addMissionEvent
- *
- * Author: joko // Jonas
- *
- * Discription: Add a Event for the Mission Flow
- *
- * Parameter:
- * 0: EventName as STRING
- * 1: Code or Function as STRING
- * 2: Parameter for Code as Array (Optinal)
- * 3: Is 0: Called or 1:Spawned (Optinal default: 0)
- * 4: Times Called(how often can this EventCallen(Optinal default: -1))
- * 5: Protected (Optinal default true)
- * 6: Override (Optinal default: false)
- *
- * Return:
- * Boolean - Event is set or not
- *
- */[/I][/COLOR]
- [COLOR=#191970][B]private[/B][/COLOR] [COLOR=#7A7A7A]"_isOK"[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]params[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_eventName"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"_eventFunction"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_eventParameter"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_eventCall"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#FF0000]0[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_times"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#FF0000]-1[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_protected"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#000000]true[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_overrideEvent"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#000000]false[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_isOK[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]false[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_return[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]nil[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]![/B][/COLOR][COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#191970][B]isNil[/B][/COLOR] [COLOR=#1874CD]_eventName[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#1874CD]_overrideEvent[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#1874CD]_isProtected[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#191970][B]missionNamespace[/B][/COLOR] [COLOR=#191970][B]getVariable[/B][/COLOR] [COLOR=#1874CD]_eventName[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]select[/B][/COLOR] [COLOR=#FF0000]4[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#1874CD]_isProtected[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR][COLOR=#1874CD]_isOK[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]false[/COLOR][COLOR=#8B3E2F][B]}[/B][/COLOR] [COLOR=#191970][B]else[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR][COLOR=#1874CD]_isOK[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]true[/COLOR][COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR] [COLOR=#191970][B]else[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#1874CD]_isOK[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]true[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#1874CD]_isOK[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#1874CD]_eventVariable[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#1874CD]_eventFunction[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#1874CD]_eventParameter[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#1874CD]_eventCall[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#1874CD]_times[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#1874CD]_protected[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]missionNamespace[/B][/COLOR] [COLOR=#191970][B]setVariable[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#1874CD]_eventName[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#1874CD]_eventVariable[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]publicVariable[/B][/COLOR] [COLOR=#1874CD]_eventName[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_return[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]true[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR] [COLOR=#191970][B]else[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]![/B][/COLOR][COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#191970][B]isNil[/B][/COLOR] [COLOR=#7A7A7A]"JK_Debug"[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#1874CD]_error[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#191970][B]format[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"Error Event:%1 can not set because Event is Protected"[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]diag_log[/B][/COLOR] [COLOR=#1874CD]_error[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#191970][B]hint[/B][/COLOR] [COLOR=#1874CD]_error[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_return[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]false[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_return[/COLOR]
- [/COLOR]
triggerMissionEventhandler:
- [COLOR=#FF8040][COLOR=#006400][I]/*
- * Name: triggerMissionEvent
- *
- * Author: joko // Jonas
- *
- * Discription: Trigger a Event that is defined in the Mission
- *
- * Parameter:
- * N:
- * 0: EventName as STRING
- * 1: Target as Object or Boolean or Array
- *
- */[/I][/COLOR]
- [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#191970][B]private[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_eventCode"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"_eventVariable"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"_target"[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#006400][I]// get Event Content[/I][/COLOR]
- [COLOR=#1874CD]_eventVariable[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#191970][B]missionNamespace[/B][/COLOR] [COLOR=#191970][B]getVariable[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#000000]_x[/COLOR] [COLOR=#191970][B]select[/B][/COLOR] [COLOR=#FF0000]0[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#8B3E2F][B]{[/B][/COLOR] [COLOR=#191970][B]hint[/B][/COLOR] [COLOR=#7A7A7A]"Error Event Not Found"[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR] [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#FF0000]0[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#000000]_target[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#000000]_x[/COLOR] [COLOR=#191970][B]select[/B][/COLOR] [COLOR=#FF0000]1[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_eventVariable[/COLOR] [COLOR=#191970][B]params[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"_eventFunction"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"_eventParameter"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"_eventCall"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"_times"[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_eventCode[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR][COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#006400][I]// Check if Count for Execute[/I][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]![/B][/COLOR][COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#1874CD]_times[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR][COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#FF0000]0[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]exitWith[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR][COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#1874CD]_times[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#1874CD]_times[/COLOR] [COLOR=#8B3E2F][B]-[/B][/COLOR] [COLOR=#FF0000]1[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#006400][I]//Debug[/I][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#8B3E2F][B]![/B][/COLOR][COLOR=#191970][B]isNil[/B][/COLOR] [COLOR=#7A7A7A]"JK_Debug"[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#191970][B]hint[/B][/COLOR] [COLOR=#191970][B]format[/B][/COLOR][COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#7A7A7A]"Event %1 Start Now"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#000000]_x[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#006400][I]//Convert Function name to Code[/I][/COLOR]
- [COLOR=#1874CD]_eventCode[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#191970][B]typeName[/B][/COLOR] [COLOR=#1874CD]_eventFunction[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR][COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#7A7A7A]"STRING"[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#191970][B]missionNamespace[/B][/COLOR] [COLOR=#191970][B]getVariable[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#1874CD]_eventFunction[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#8B3E2F][B]{[/B][/COLOR][COLOR=#191970][B]hint[/B][/COLOR] [COLOR=#7A7A7A]"Error Function Not Found"[/COLOR][COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR] [COLOR=#191970][B]else[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#1874CD]_eventFunction[/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#006400][I]// Call Code with BIS_fnc_MP @todo(Update to remoteExec)[/I][/COLOR]
- [COLOR=#191970][B]if[/B][/COLOR] [COLOR=#8B3E2F][B]([/B][/COLOR][COLOR=#1874CD]_eventCall[/COLOR] [COLOR=#8B3E2F][B]=[/B][/COLOR][COLOR=#8B3E2F][B]=[/B][/COLOR] [COLOR=#FF0000]0[/COLOR][COLOR=#8B3E2F][B])[/B][/COLOR] [COLOR=#191970][B]then[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#1874CD]_eventParameter[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#1874CD]_eventCode[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"BIS_fnc_call"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#000000]_target[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#000000]false[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#000000]true[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR] [COLOR=#191970][B]call[/B][/COLOR] BIS_fnc_MP[COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR] [COLOR=#191970][B]else[/B][/COLOR] [COLOR=#8B3E2F][B]{[/B][/COLOR]
- [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#1874CD]_eventParameter[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#1874CD]_eventCode[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#7A7A7A]"BIS_fnc_spawn"[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#000000]_target[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#000000]false[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR] [COLOR=#000000]true[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR] [COLOR=#191970][B]call[/B][/COLOR] BIS_fnc_MP[COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- missioNameSpace [COLOR=#191970][B]setVariable[/B][/COLOR] [COLOR=#8B3E2F][B][[/B][/COLOR][COLOR=#000000]_x[/COLOR] [COLOR=#191970][B]select[/B][/COLOR] [COLOR=#FF0000]0[/COLOR][COLOR=#8B3E2F][B],[/B][/COLOR][COLOR=#1874CD]_eventVariable[/COLOR][COLOR=#8B3E2F][B]][/B][/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [COLOR=#8B3E2F][B]}[/B][/COLOR] [COLOR=#191970][B]forEach[/B][/COLOR] [COLOR=#000000]_this[/COLOR][COLOR=#8B3E2F][B];[/B][/COLOR]
- [/COLOR]
wenn ihr eure mission Testen wollt dann fügt einfach ein JK_Debug = true; in die Init und dann bekommt ihr Dialog und hint ausgaben. um die zu deaktivieren löscht/Kommentiert dies dann aus
Das Script ist sicherlich noch nicht fehler frei da ich es nur mal "geschreiben" habe und noch nicht testen konnte
PastBin:http://pastebin.com/WN5rvR8P