View Full Version : addAction executing a FSM?
objects init field:
jump1 addaction ["HALO jump", "scripts\halo_jump.sqf"];
halo_jump.sqf
//halo_jump.sqf
//Allows the user to click the map and start a Halo jump.
halo = true;
hintSilent "Click on the map where you'd like to HALO.";
onMapSingleClick "player setPos _pos; [player, 3000] execFSM 'scripts\halo.fsm';halo = false;hint 'Close the map'";
waitUntil{!halo};
onMapSingleClick "";
It teleports me, -showScriptErrors without error, to the destination, no halo =( The FSM is good I hijacked it from a reputable source, then checked it vs. other sources. The only funky things I've noticed is that player's altitude is defined twice, both in halo_jump.sqf and in halo.fsm, but I've tried it both ways with/without it there, same problem. It has to be the way the FSM is being called, but I really can't find any resources out there, on how to correctly call a FSM through addAction + onMapSingleClick +fsm.
-I will note that the fsm is intended for use jumping out of a static, or starting off in HALO.
Any help would be appreciated.
.kju [PvPscene]
Jul 23 2011, 04:12
a) what is inside the halo.fsm
b) what is the location of it
this is what's in halo.fsm. This should allow for a perfectly working/ sexy altimeter.
start:
_alt = 3000;
BIS_AdvHints_Header = "";
BIS_AdvHints_Text = "";
BIS_AdvHints_Footer = "";
BIS_AdvHints_Duration = -1;
BIS_AdvHints_ShowCond = "true";
BIS_AdvHints_ShowCode = "";
BIS_AdvHints_HideCond = "";
BIS_AdvHints_HideCode = "";
BIS_AdvHints_Silent = false;
BIS_AdvHints_Seamless = false;
BIS_AdvHints_KeyPress = "";
BIS_AdvHints_CanSkip = true;
BIS_AdvHints_NoFooter = fal
Falling:
(position player select 2) > 1
halo:
player spawn bis_fnc_halo;
player setdir 0;
player setvelocity [0,120*0.8,0];
player allowdamage true;
Next:
-This is blank-
Altitude:
call BIS_AdvHints_setDefaults;
BIS_AdvHints_THeader = "ALTIMETER";
BIS_AdvHints_TInfo = "";
BIS_AdvHints_TImp = localize "STR_EP1_mission.fsmFSM_States_MFF0_0";
BIS_AdvHints_TAction = "";
BIS_AdvHints_TBinds = "";
BIS_AdvHints_HideCond = "false";
BIS_AdvHints_Seamless = true;
BIS_AdvHints_Text = call BIS_AdvHints_formatText;
BIS_AdvHints_Dynamic = [
{'MoveForward' call BIS_getKeyBind},
{'MoveBack' call BIS_getKeyBind},
{'TurnLeft' call BIS_getKeyBind},
{'TurnRight' call BIS_getKeyBind},
{round(position player select 2)},
{round((position player select 2) * 3.28)},
{'Action' call BIS_getKeyBind}
];
BIS_AdvHints_Spawn = [] spawn BIS_AdvHints_showHintSpawn;
opened:
vehicle player != player
parachute:
-this is blank-
landed:
vehicle player == player;
End Halo:
call BIS_AdvHints_setDefaults;
player setvariable ["bis_fnc_halo_terminate",true];
Continue:
(scriptDone BIS_AdvHints_Spawn)
End:
-This is Blank-
The FSM is located inside mission folder\scripts\halo.fsm
.kju [PvPscene]
Jul 23 2011, 13:16
thanks. not quite sure sure if this is the case, but its worth a try.
scripts can be also used to reference files outside pbos in arma\scripts\*
so try to rename your folder and see if that helps
other than that did you use diag_log inside the fsm to see if it gets in there and how far?
I changed file paths, with no change, I added in diag_log through each step of the FSM, the only time it reported was the one in start of the FSM. My start now looks like:
START:
diag_log "hello I'm working!";
_alt = 3000;
BIS_AdvHints_Header = "";
BIS_AdvHints_Text = "";
BIS_AdvHints_Footer = "";
BIS_AdvHints_Duration = -1;
BIS_AdvHints_ShowCond = "true";
BIS_AdvHints_ShowCode = "";
BIS_AdvHints_HideCond = "";
BIS_AdvHints_HideCode = "";
BIS_AdvHints_Silent = false;
BIS_AdvHints_Seamless = false;
BIS_AdvHints_KeyPress = "";
BIS_AdvHints_CanSkip = true;
BIS_AdvHints_NoFooter = false;
So I see "Hello I'm Working!" but none of the other's I put in. So it obviously isn't likeing something in my start node of the fsm. perhaps it's how _alt is defined twice? I changed it just now to see if making the height the sqf puts me to was higher than the height the fsm looks for.. but still, teleportation with no errors.
Here is my report: (Ignore the warning :-)
[100167,3596.17,0,"XEH: PreInit Started. v3.0.7"]
[100167,3596.19,0,"MISSINIT","Survival_Horror_Co-Op_V%2e01","namalsk",false,true,false]
[100167,3603.33,0,"XEH: PreInit Finished"]
[100167,3603.45,0,"XEH: VehicleCrewInit: 13"]
[100167,3602.41,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[100184,3603.87,0,"XEH: PostInit Started"]
[100184,3603.91,0,"CBA_VERSIONING",["#CBA_HASH#",["cba","ace"],[[[0,7,6,160],-1],[[1,11,0,494],-1]],[[0,0,0],0]]]
[100184,3604.26,0,"XEH: PostInit Finished; [true,false,false,true,false,true,true,true,true,false]"]
"hello I'm working!"
---------- Post added at 01:48 PM ---------- Previous post was at 01:42 PM ----------
ok I put in a few more diag_logs to try to pin point, it makes it out of START, and starts looping at falling
Falling:
diag_log "You should be falling1";
(position player select 2) > 1
Report now looks like:
"hello I'm working!"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
"You should be falling1"
That has to be the culprit because the very next code is the call to bis_fnc_halo which.. isn't happening obviously. But Im not sure what array falling is referring to, but that still doesn't explain some of the funky behavior... like, technically I should be >Teleported >_alt 3000 > fall to my death cuz bis_fnc_halo was never called so I don't know, my mind is tad boggled.
Thanks for your help** :)
.kju [PvPscene]
Jul 23 2011, 15:03
a) make a screenshot of the FSM or generate a EMF picture file
b) you can define priorities for conditions if you have multiple after a state
Any particular part of the FSM?
.kju [PvPscene]
Jul 23 2011, 15:54
well the part where it gets stuck?! :)
haha... I suppose that would be a logical choice... it'll be up in jus a sec, a full screen shot makes it hard to read.
---------- Post added at 04:03 PM ---------- Previous post was at 03:56 PM ----------
START:
http://i878.photobucket.com/albums/ab349/Splintz/start1_1.jpg
Falling:
http://i878.photobucket.com/albums/ab349/Splintz/falling1_1.jpg
It will loop "You should be falling1" in the log.
**See Page 2 For file upload.**
kylania
Jul 23 2011, 16:24
Just upload the whole thing, much easier to debug than fragmented screenshots of code...
-All conditions have a priority of 0 right now. Just noticed your post kylania, one moment on the file.
maga upload DL link (http://www.megaupload.com/?d=DP6QCN9G)
kylania
Jul 23 2011, 18:43
Ok, yeah seems you tried to rip halo.fsm out of the Evolution mission, but you left out some critical parts.
In the FSM you only had to really change a few lines and leave everything else alone. You also needed to initialize the adv hints system before calling the FSM.
TL/DR: Here's a demo mission (http://www.mediafire.com/?j4v5a05hgj96l9o) with these changes already made to try out.
So, change halo.sqf to read this:
[] call bis_fnc_hints;
//create an empty thread, to avoid 'BIS_AdvHints_Spawn' being nil at the beginning
if (isNil "BIS_AdvHints_Spawn") then {
BIS_AdvHints_Spawn = [] spawn {
waitUntil {false};
};
};
halo = true;
hintSilent "Click on the map where you'd like to HALO.";
onMapSingleClick "player setPos _pos; [3000] execFSM 'scripts\halo.fsm';halo = false;hint 'Close the map'";
waitUntil{!halo};
onMapSingleClick "";
In this complete version of the halo.fsm (http://www.armaholic.com/datas/users/halo_4754.7z) change the START InitCode to read like this by adding all the red text and leaving the white text alone:
//_marker = "HaloMarker";
//_rnd=Random(200);
//_h=9000;
//_pos = [getmarkerpos _marker select 0,getmarkerpos _marker select 1, _h+_rnd];
_h = _this select 0;
_pos = [getPosASL player select 0, getPosASL player select 1, _h];
player setpos _pos;
player setvariable ["bis_fnc_halo_now",true];
player setdir 0;
BIS_AdvHints_Header = "";
BIS_AdvHints_Text = "";
BIS_AdvHints_Footer = "";
BIS_AdvHints_Duration = -1;
BIS_AdvHints_ShowCond = "true";
BIS_AdvHints_ShowCode = "";
BIS_AdvHints_HideCond = "";
BIS_AdvHints_HideCode = "";
BIS_AdvHints_Silent = false;
BIS_AdvHints_Seamless = false;
BIS_AdvHints_KeyPress = "";
BIS_AdvHints_CanSkip = true;
BIS_AdvHints_NoFooter = false;
You'll also want to limit the action to only show up on the ground, or else you can halo jump while jumping.
this addAction ["HALO JUMP","scripts\halo_jump.sqf",[],1,false,true,"","getPos _target select 2 < 2"];
kylania and pvpscene,
Thank you very much for both of your time into this matter, it is very much appreciated. This is my first time working with a fsm, and it was driving me crazy, I couldn't bring myself to move on with development until I figured out why it wasn't working, and now that I look it over it makes a little more sense.
I'm not a great scripter, I know enough to make me dangerous is all, but I'm getting better. I have my first few basic scripts under my belt.
Thanks again for your time. I would not imagine that there will be any further issues here, so this thread could be considered closed.
-Skelt
kylania
Jul 23 2011, 19:34
Hey, you're jumping into FSM for scripting which is a lot more than most people do. I've pretty much skipped it so far myself since it's basically the same as just straight coding, but just complicated enough to confuse you even though you know what you're doing. :)
Just glad we got it figured out and you're able to jump out of perfectly good airplanes now. :)
Haha, I couldn't agree more, with both statements.
Thanks again.
Just before you go...
I have been doing a bit of HALO stuff myself recently and I have noticed that in a script heavy environment, both the ACE HALO and BIS HALO routines get very laggy. In that key presses aren't always recognised and the action menus tend to take a while to action.
Will running the HALO using FSM improve matters here, or is it just a case that FSM facilitates easier scripting of states and has to fight for the schedule space along with everything else?
I know it is not quite on-topic so I apologise for this.
From what I understand, FSM is the best route to take for time critical actions, which is part of the reason I decided to play with the halo.fsm. In any case, this post fully details what you need to make it work, and run some tests :)
Well, from some initial testing, this method works much better than running either the BIS HALO or ACE HALO in a script heavy environment. I can control and land a HALO jump even when the FPS is hitting the low-teens. Great stuff.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.