How to discover the player type
-
I ran into a situation where i needed to setup a units weapon differently for AI than a Human player. Simply put, the AI isnt capable of changing a weapons modes so I'm presetting a mode that will be of the most use to it.
Example:
OnCreate = function(self,builder,layer) AWalkingLandUnit.OnCreate(self) -- Creating Globals self.Artillery = self:GetWeaponByLabel('Artillery') self.Cannon = self:GetWeaponByLabel('Cannon') self.WpnMode = nil -- Set the weapon based on the player type if self.Brain.BrainType == 'Human' then if myDebug then WARN(' Human player, Cannon enabled') end self.Cannon:SetEnabled(true) self.Artillery:SetEnabled(false) self.WpnMode = 'Cannon' else if myDebug then WARN(' AI player, Artillery enabled') end self.MyCannon:SetEnabled(false) self.Artillery:SetEnabled(true) self.WpnMode = 'Artillery' end end,