User:Celtic Minstrel/UnitBehaviourProposal

From The Battle for Wesnoth Wiki

This is an idea for generalizing the "unit formulas" concept.

[unit]
    [ai]
        [behavior]
            id=some_id
            engine=fai
            # Same as the old syntax for unit formulas
            formula="move(me.loc, dest_loc)" # Or loop_formula
            priority=3
            [vars]
                dest_loc="loc(12,20)"
            [/vars]
        [/behavior]
        # ai_special could translate to something like this:
        [behavior]
            id=some_id2
            engine=cpp
            mode=guardian
        [/behavior]
        # And you could do similar things in Lua, too:
        [behavior]
            id=some_id3
            engine=lua
            priority=5 # Or, evaluation=<< ... >> for variable priorities
            code=<<
                local me, cfg, data = ...
                ai.move(me.loc, cfg.dest_x, dest_cfg.y)
            >>
            [args]
                dest_x,dest_y=12,20
            [/args]
        [/behavior]
    [/ai]
[/unit]
This page was last edited on 29 March 2016, at 13:48.