Changeset 3324
- Timestamp:
- 11/29/08 21:21:36 (5 weeks ago)
- Location:
- trunk/mods/ca/LuaRules/Gadgets
- Files:
-
- 2 modified
-
planetwars.lua (modified) (1 diff)
-
unit_start_boost.lua (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mods/ca/LuaRules/Gadgets/planetwars.lua
r3296 r3324 40 40 tryy = GetGroundHeight(tryx, tryz) 41 41 if TestBuildOrder(unitDefID, tryx, tryy, tryz, 'N') or spawnTries > 20 then 42 42 local uid = nil 43 43 if (unitDef.isBuilding == true or unitDef.maxAcc == 0) then -- structure 44 localuid = CreateUnit("armpwdeploy", tryx, tryy, tryz, 'N', teamnum - 1) -- todo determine side name44 uid = CreateUnit("armpwdeploy", tryx, tryy, tryz, 'N', teamnum - 1) -- todo determine side name 45 45 GG.morphHandler.AddExtraUnitMorph(uid, {into = m.unitname, time = 10, metal=0, energy=0,}) 46 46 else -- normal unit 47 local uid = CreateUnit(m.unitname, tryx, tryy, tryz, 'N', teamnum - 1) 47 uid = CreateUnit(m.unitname, tryx, tryy, tryz, 'N', teamnum - 1) 48 end 49 50 if (m.unitname == 'armcom' or m.unitname == 'corcom') then 51 GG.boostHandler.AddBoost(uid) 48 52 end 49 53 -
trunk/mods/ca/LuaRules/Gadgets/unit_start_boost.lua
r3321 r3324 47 47 48 48 local boost = {} 49 local startMetal= {}50 49 local boostMax = {} 50 local teamMetal = {} 51 51 52 52 -------------------------------------------------------------------------------- 53 53 -------------------------------------------------------------------------------- 54 55 local function AddBoost(unitID, newBoost, newBoostMax) 56 local tm = teamMetal[Spring.GetUnitTeam(unitID)] 57 boost[unitID] = newBoost or tm 58 boostMax[unitID] = newBoostMax or tm 59 SendToUnsynced("UpdateBoost", unitID, boost[unitID], boostMax[unitID]) 60 end 61 62 63 function gadget:Initialize() 64 -- self linking 65 GG['boostHandler'] = {} 66 GG['boostHandler'].AddBoost = AddBoost 67 end 68 54 69 55 70 function gadget:UnitDestroyed(unitID) … … 80 95 boost[builderID] = boost[builderID] - BOOST_RATE 81 96 Spring.SetUnitHealth(unitID, { health = progress*maxHealth, build = progress }) 82 SendToUnsynced("UpdateBoost", builderID, boost[builderID], startMetal[builderID])97 SendToUnsynced("UpdateBoost", builderID, boost[builderID], boostMax[builderID]) 83 98 return false 84 99 else … … 99 114 if (teamID ~= gaiaID and (not teamLuaAI or teamLuaAI == "")) then 100 115 local metal = Spring.GetTeamResources(teamID, 'metal') 101 116 teamMetal[teamID] = metal 102 117 --Spring.SendMessage("Initializing team "..teamID.." with "..metal) 103 118 … … 111 126 local defID = Spring.GetUnitDefID(unitID) 112 127 if (defID ~= nil and UnitDefs[defID] ~= nil and UnitDefs[defID].isCommander and UnitDefs[defID].name ~= "chickenbroodqueen") then 113 boost[unitID] = metal 114 startMetal[unitID] = metal 115 --Spring.SendMessage("for unit " ..unitID) 116 SendToUnsynced("UpdateBoost", unitID, metal, metal) 128 AddBoost(unitID) 117 129 break 118 130 end