FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login
    The current pre-release of the client ("pioneer" in the version) is only compatible to itself. So you can only play with other testers. Please be aware!

    How to discover the player type

    Scheduled Pinned Locked Moved Modding & Tools
    1 Posts 1 Posters 211 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      Resin_Smoker
      last edited by

      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,  
      

      Kykhu Oss https://youtu.be/JUgyGTgeZb8
      Unit Thrower https://youtu.be/iV8YBXVxxeI
      Beam Tentacle https://youtu.be/le5SNwHvC4c
      Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
      Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

      1 Reply Last reply Reply Quote 0
      • First post
        Last post