Forged Alliance Forever Forged Alliance Forever Forums 2016-04-14T22:03:55+02:00 /feed.php?f=41&t=12253 2016-04-14T22:03:55+02:00 2016-04-14T22:03:55+02:00 /viewtopic.php?t=12253&p=125246#p125246 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]> Thank you for all the help you are offering me, It helps enourmously!

Statistics: Posted by Redmoth — 14 Apr 2016, 22:03


]]>
2016-04-14T07:48:38+02:00 2016-04-14T07:48:38+02:00 /viewtopic.php?t=12253&p=125155#p125155 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]>
So you could make your own class:
Code:
Cortex = Class ({
    __init = function(self, args)
        self.strategy = args.strategy
    end,
   
    DoSomething = function(self)
    end,
})


and put it on an individual brain here:
https://github.com/FAForever/fa/blob/re ... in.lua#L91
Code:

OnCreateAI = function(self, planName)
    ...
    self.cortex = Cortex({strategy='Rush'})
    ...
end

Statistics: Posted by Crotalus — 14 Apr 2016, 07:48


]]>
2016-04-14T01:03:28+02:00 2016-04-14T01:03:28+02:00 /viewtopic.php?t=12253&p=125139#p125139 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]>
Say I have 4 ais that benefit from the script. Say my script has a 'strategy' variable. With the unit or entity technique I know i can have access to the 'strategy' of that particulars player from itself without having, say, a main loop that does

Code:
Exampleloop = function(self)

    CurPlayer = 0
    NbPlayer = 4
    For CurPlayer < NbPlayer do

       army = GetArmyIndex(CurPlayer)
       army:DoSomeFunction()
   

    end

   --OR
   
   Players = GetAllPlayersInGame
   For i, p in players do
   
   brain = GetaiBrain(player)
   brain:DoSomething()
   end


end,



Edit: this has to do with my question of yesterday. Since I dont understand how a class is instanciated in supcom (like the aiBrain being one instance Per player) So I do not know how to instanciate my CleverAI class the same way as an aiBrain. I would need a function like CreateaiBrain() but CreateCleverAI()

Edit2: I DO know however that If I CreateUnitHPR(), this will make an Instance of that unit. I can sadly not find any logical function that does CreateInstanceOfClass or CreateInstanceOfScript etc

Statistics: Posted by Redmoth — 14 Apr 2016, 01:03


]]>
2016-04-14T00:55:07+02:00 2016-04-14T00:55:07+02:00 /viewtopic.php?t=12253&p=125138#p125138 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]>
You could immediately ForkThread from there and then have a separate code-path to do whatever you want.

Code:
ForkThread(import('/link/to/some/module.lua').InitCleverAI, brain)

Statistics: Posted by Crotalus — 14 Apr 2016, 00:55


]]>
2016-04-14T00:31:24+02:00 2016-04-14T00:31:24+02:00 /viewtopic.php?t=12253&p=125136#p125136 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]>
Edit: I know there are multiple ways, but looking for just about the simplest to comprehend since Im not inherently confortable with supcom's stuff

Statistics: Posted by Redmoth — 14 Apr 2016, 00:31


]]>
2016-04-14T00:29:07+02:00 2016-04-14T00:29:07+02:00 /viewtopic.php?t=12253&p=125135#p125135 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]>
Code:
SomeUnit = Class(Unit) {
    OnCreate = function(self) {
      --[[local spec = {
            Owner = unit
        }
   
        local entity = Entity(spec)
        self:ForkThread(self.DoSomethingWithEntity)
        ]]--
        self:ForkThread(self.DoSomethingWithUnit)
    end)
}

Statistics: Posted by Redmoth — 14 Apr 2016, 00:29


]]>
2016-04-14T00:26:00+02:00 2016-04-14T00:26:00+02:00 /viewtopic.php?t=12253&p=125134#p125134 <![CDATA[Re: Creating empty entity(not unit or projectile,etc) and sp]]>
Code:
SomeUnit = Class(Unit) {
    OnCreate = function(self) {
        local spec = {
            Owner = unit
        }
   
        self.entity = Entity(spec)
        self:ForkThread(self.DoSomethingWithEntity)
    end),
}

Statistics: Posted by Crotalus — 14 Apr 2016, 00:26


]]>
2016-04-14T00:17:30+02:00 2016-04-14T00:17:30+02:00 /viewtopic.php?t=12253&p=125133#p125133 <![CDATA[Creating empty entity(not unit or projectile,etc) and spawn?]]>
I know how to copy a unit's file and have it as a new unit in the game.

Is this possible with an entity? My plan is to have a script running on a unit I will spawn.
However i would much prefer it not actually being a 'unit'(ie no blueprint, no model, no display, no blip on radar etc, only the entity in the gameworld running the script I will write in it)

Thank you :)

Statistics: Posted by Redmoth — 14 Apr 2016, 00:17


]]>