Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSM Editor Config for CBA Statemachine #1263

Merged
merged 4 commits into from
Dec 21, 2019

Conversation

Freddo3000
Copy link
Contributor

@Freddo3000 Freddo3000 commented Dec 10, 2019

When merged this pull request will:

  • Add a FSM Editor config file that allows it to create and edit CBA Statemachine configs
Included instructions
/* ----------------------------------------------------------------------------
CBA Statemachine Config for use with FSM Editor

Description:
    This is a config that allows you to create and edit CBA Statemachines using
    the Arma Tools FSM editor, for increased readability and expandability.

    It isn't by any means perfect, but it should be useable
    
Usage:
    1. Select this config using FsmAttributes > Compile Config
    2. Change FSM attributes under FsmAttributes > Attributes from Compile Config
        2.1 'list' parameter is parsed as list = QUOTE(x);
        2.2 'skipNull' parameter is parsed as skipNull = x;
    3. States
        3.1 'initCode' is parsed as is, and may contain onState = "", 
            onStateEntered = "" and/or onStateLeaving = ""
    4. Transitions
        4.1 'targetState' does not need to be entered, and simply follows the
            transition link
        4.2 'condition' is parsed as condition = QUOTE(x)
        4.3 'action' is parsed as is, and may contain onTransition = "" 
            and/or events[] = {}
			
Dependencies:
	In order to properly function, script_macros_common need to be included
Author:
    Freddo 2019-12-10
---------------------------------------------------------------------------- */

Example FSM:
fsm_editor

Same FSM but as text:
https://gist.github.com/Freddo3000/244d94c0056f2b4afb0f52fec73a57a2

Once ran through pboProject:
https://gist.github.com/Freddo3000/eab4a2afd7a4ffcbc688bcf37ce7e91d

While it could be prettier, it does its job well enough.

@PabstMirror PabstMirror added this to the 3.13.1 milestone Dec 10, 2019
@commy2
Copy link
Contributor

commy2 commented Dec 14, 2019

For the end user, why is the CBA_FSMEditor.cfg file inside the addons\cba_statemachine.pbo file?
That means they have to extract the PBO first to get it.

Should this file instead be on the wiki? If it is included into the release, should it not instead be inside optionals or some new folder?

@Freddo3000
Copy link
Contributor Author

The reason I placed it here was due to the statemachine Example.sqf and Example.hpp being present here. I'm fine with placing it anywhere though.

@commy2
Copy link
Contributor

commy2 commented Dec 14, 2019

@BaerMitUmlaut ? ^

@PiZZAD0X
Copy link

Great job, I wasn't aware this was possible with the BI FSM editor! I intend to use this config structure to build some more complex AI systems in a mod using the great state machine system set up by @BaerMitUmlaut. The two examples of the standard SM are shown on the wiki and various biforums posts so I think the config should be available via a wiki link in the hope of encouraging more regular usage of the CBA SM.

@PiZZAD0X
Copy link

I have tweaked this config with the intention of publishing configs directly from the FSMEditor. Saving in the .bifsm format preserves the FSM data for use in the editor, while saving the statemachine in the .fsm aka compiled format produces a CBA SM config.

With this tweaked config: https://gist.github.com/PiZZAD0X/3b4ec1ae33cdbc76b3dc2626a5559772

A .bifsm of https://gist.github.com/PiZZAD0X/0d656d5a22453ec6c36b5340d4a184bb
produces: https://gist.github.com/PiZZAD0X/0cc91850e2f3df40571f1ecc0d562d87 when compiled.

@commy2 commy2 modified the milestones: 3.13.1, 3.14 Dec 20, 2019
@commy2
Copy link
Contributor

commy2 commented Dec 21, 2019

Question:

    class CombatStance {
        onState = QUOTE(
            DEBUG_TAG('Combat stance');
            // Don't overide explicitly set stance
            private _hasStance = _this getVariable [QQGVAR(hasStance), false];
            if (!_hasStance && toLower (unitPos _this) != 'auto') exitWith {
                DEBUG_TAG('Skip stance');
            };

Does this work? There are newlines inside the macro (QUOTE()) argument. This should fail.

@PiZZAD0X
Copy link

Yes it does, but it works just fine throwing in the necessary \ Parser works fine with the \

Isn't best practice to throw these to a QFUNC instead of commands inside a quote inside config?

@commy2
Copy link
Contributor

commy2 commented Dec 21, 2019

Yeah, excessive script in config is bad, regardless of this.

@commy2
Copy link
Contributor

commy2 commented Dec 21, 2019

I added a barebone doc page for the statemachine that includes this:
https://github.com/CBATeam/CBA_A3/wiki/Statemachine

@commy2 commy2 merged commit 0c27a7d into CBATeam:master Dec 21, 2019
@Freddo3000 Freddo3000 deleted the statemachine_fsm-editor-cfg branch February 9, 2020 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants