View difference between Paste ID: JeFKgT48 and
SHOW: | | - or go back to the newest paste.
1-
1+
--AIBrain.lua hook - remove non-allied gold amounts from sync, except for observers
2
3
local prevClass = AIBrain
4
5
AIBrain = Class(prevClass) {
6
7
    InternalGiveResources = function(self, type, amount)
8
        prevClass.InternalGiveResources(self, type, amount)
9
        if Sync.ArmyGold and Sync.ArmyGold[self:GetArmyIndex()] > 0
10
        and GetFocusArmy() ~= -1 and not IsAlly(GetFocusArmy(), self:GetArmyIndex()) then
11
            Sync.ArmyGold[self:GetArmyIndex()] = 0
12
13
        end
14
    end,
15
16
    TakeResource = function(self, type, amount)
17
        prevClass.TakeResource(self, type, amount)
18
        if Sync.ArmyGold and Sync.ArmyGold[self:GetArmyIndex()] > 0
19
        and GetFocusArmy() ~= -1 and not IsAlly(GetFocusArmy(), self:GetArmyIndex()) then
20
            Sync.ArmyGold[self:GetArmyIndex()] = 0
21
        end
22
    end,
23
24
}