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

use CBA state machine #9

Merged
merged 1 commit into from
Mar 2, 2019
Merged

use CBA state machine #9

merged 1 commit into from
Mar 2, 2019

Conversation

Fusselwurm
Copy link
Member

@Fusselwurm Fusselwurm commented Feb 21, 2019

what this is

use CBA state machine for (nearly) everything

rationale

where we're coming from

to date, civilian behavior is a bunch of chained cba_fnc_waituntilandexecute, prone to bugs, and nearly impossible to extend.

all civilian thoughts i could find, with possible transitions (correct me where i'm very wrong)

screenshot_20190222_091824

enter CBA state machine

  • CBA state machine is really neat as it prevents mucho confusion about what happens when:
    • you define states : at every point in time it's very clear what a given unit does
    • you define transitions : ensure only one transition at a time, and only defined transitions
    • it also takes care not to put too much stress on the server

implementation

  • one state machine for emotions (from relaxation to panic).
    • shots fired close by -> boom panic
    • after some time, relax again
  • one state machine for activities
    • unit's personal goals (visit different town, tending to field, taking a walk)
      • currently only "patrol" (on foot) and "voyage" (in vehicle)
    • forced behavior
      • surrender when pointed at with weapon
      • fleeing (and hiding) in panic after emotional panic
  • state machines in /functions/state . all states and transitions for one machine currently in one file, may need to get split up

implemented states and transitions

screenshot_20190227_191607

  • red: panic event transition
  • blue: un-panic event transition

At this point, I'm only interested in reproducing existing behavior, esp. concerning the flight/hide/relax mechanism.

More behaviors may be added easily, with "rally" being the magic starting point where a group of civilians get together, and the leader decides what to do.

TODO

@Fusselwurm
Copy link
Member Author

Fusselwurm commented Feb 22, 2019

tbh, I have a hard time believing that creating a gazillion transitions (even if they are event transitions) is more efficient than direct calls, but… we'll see.

@Fusselwurm
Copy link
Member Author

@McDiod @nomisum noch kein detailliertes review nötig, aber feedback zum ansatz wird schon gern genommen

@McDiod
Copy link
Collaborator

McDiod commented Feb 24, 2019

feedback zum ansatz

Kann nur besser werden 👍

@Fusselwurm
Copy link
Member Author

seems to work in MP now. ready for testing.

@Fusselwurm
Copy link
Member Author

Fusselwurm commented Feb 28, 2019

note to self: CBA state machine is missing some features that would be useful, namely:

  • nesting
  • time tracking / delays

=> todo: raise the issue with cba devs

edit: CBATeam/CBA_A3#1082

	* create state machines for emotions, activities and cleanup
	  (despawning)
	* create state graphs as documentation

	CHANGES
	* you cannot point your car as a weapon – so civs will
	  not surrender to cars
	* also you cannot point your weapon from your car,
	  as far as civs are concerned
	* civs dont disembark when shot at in their vehicles
	* player civilians will see 'getDown' and 'sendAway'
	  commands as hints
	* some variability in civ behavior concerning panic cooldown
	  and chance to surrender
	* require ACE3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants