Forged Alliance Forever Forged Alliance Forever Forums 2016-04-13T11:01:05+02:00 /feed.php?f=41&t=12249 2016-04-13T11:01:05+02:00 2016-04-13T11:01:05+02:00 /viewtopic.php?t=12249&p=125089#p125089 <![CDATA[Re: About Script instanciating...]]> I think this gives me a better Idea of how I want to proceed. I will actually probably have one main script loop that will do its stuff on all AI controlled armies, or have one start whenever an AI OnCreateArmyBrain() is called, depending on which I find more simple and visually clearer. Basically I wont go as far as to use the magic you are speaking about lol. It will be more a state machine than some complex system with out of the box scripts, getting info fed to it by the aiBrains and determining if it should take an action (in short). Luckily most functions I need are already in the game's lua files, such as stuff for monnitoring eco drain/production, issuing build orders and etc.

Thank you again, I had a very hard time grasping what was going on with the aiBrain :)

Statistics: Posted by Redmoth — 13 Apr 2016, 11:01


]]>
2016-04-13T08:34:42+02:00 2016-04-13T08:34:42+02:00 /viewtopic.php?t=12249&p=125088#p125088 <![CDATA[Re: About Script instanciating...]]>

Code:
Funcs = {
    SomeCoolFunc = function(self)
        print "This is a cool function I will inject on the brain
    end,
}

-- assume you have 'brain' as reference to the brain you want to change
for k, f in Funcs do
    brain[k] = f
end


That will dynamically add / overwrite the functions to the brain.

(paths for Forged Alliance, have no idea if SupCom2 has brain at same place)

Statistics: Posted by Crotalus — 13 Apr 2016, 08:34


]]>
2016-04-13T05:00:18+02:00 2016-04-13T05:00:18+02:00 /viewtopic.php?t=12249&p=125078#p125078 <![CDATA[About Script instanciating...]]>

I am new to Lua, but able to write a few scripts. One thing I dont understand, is how SupCom instances things.
For example: SupCom 2 has an aiBrain.lua class.

When you start a game, each player (humans and ais) each get their own instance of an aiBrain class, Which lets you control each player's aiBrain individually without affecting others. You can call GetBrain() on a player, and that will return the player's aiBrain instance.

What I dont get is: how is this class instanced for the player? How is it that a new aiBrain is created when you start a game?
Does local var = import('lua/sim/aiBrain.lua') make a new instance of aiBrain.lua?

I am trying to write a custom AI class instance that will coexist with the normal aiBrain.lua instance.

so when the aiBrain class is instanced, it calls its own OnCreate() function, which in turn instances a 'My custom ai.lua'.

Another blatant example is instances of a unit class on every unit in the game. unless I am mistaken.

Any answers? Any answer, from simple to complicated, I will apreciate :)

Statistics: Posted by Redmoth — 13 Apr 2016, 05:00


]]>