Changeset 3344
- Timestamp:
- 12/01/08 19:29:39 (5 weeks ago)
- Location:
- trunk/mods/ca/LuaRules/Gadgets
- Files:
-
- 2 modified
-
planetwars.lua (modified) (3 diffs)
-
unit_morph.lua (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mods/ca/LuaRules/Gadgets/planetwars.lua
r3342 r3344 43 43 if (unitDef.isBuilding == true or unitDef.maxAcc == 0) then -- structure 44 44 uid = CreateUnit("armpwdeploy", tryx, tryy, tryz, 'N', teamnum - 1) -- todo determine side name 45 GG.morphHandler.AddExtraUnitMorph(uid, {into = m.unitname, time = 10, metal=0, energy=0,})45 GG.morphHandler.AddExtraUnitMorph(uid, {into = m.unitname, time = 20, metal=0, energy=0,}, m.owner) 46 46 else -- normal unit 47 47 uid = CreateUnit(m.unitname, tryx, tryy, tryz, 'N', teamnum - 1) … … 78 78 local err, success 79 79 local modOptions = Spring.GetModOptions() 80 80 81 81 if (modOptions) and modOptions.planetwars and modOptions.planetwars ~= '' then 82 82 optionsRaw = modOptions.planetwars … … 96 96 if err then Spring.Echo('Planet Wars error: ' .. err) end 97 97 --options did not load, remove 98 98 99 return false 99 100 end -
trunk/mods/ca/LuaRules/Gadgets/unit_morph.lua
r3336 r3344 107 107 local morphDefs = {} --// make it global in Initialize() 108 108 local extraUnitMorphDefs = {} -- stores mainly planetwars morphs 109 local pwUnitOwners = {} -- stores owners of planetwars units 109 110 local hostName = nil -- planetwars hostname 110 111 local morphUnits = {} --// make it global in Initialize() … … 300 301 301 302 302 local function AddExtraUnitMorph(unitID, morphDef ) -- adds extra unit morph (planetwars morphing)303 local function AddExtraUnitMorph(unitID, morphDef, owner) -- adds extra unit morph (planetwars morphing) 303 304 local unitDefID = Spring.GetUnitDefID(unitID) 304 305 local ud = UnitDefs[unitDefID] 305 306 local teamID = Spring.GetUnitTeam(unitID) 307 pwUnitOwners[unitID] = owner 306 308 morphDef = BuildMorphDef(ud, morphDef) 307 309 extraUnitMorphDefs[unitID] = morphDef … … 394 396 395 397 local newUnit = Spring.CreateUnit(defName, px, py, pz, 0, unitTeam) 398 399 Spring.SetUnitPosition(newUnit, px, py, pz) 396 400 397 401 if (extraUnitMorphDefs[unitID] ~= nil and hostName ~= nil) then -- send planetwars deployment message 398 local data = unitTeam..","..defName..","..math.floor(px)..","..math.floor(pz)..",".."S" -- todo determine and apply smart orientation of the structure402 local data = (pwUnitOwners[unitID] or unitTeam)..","..defName..","..math.floor(px)..","..math.floor(pz)..",".."S" -- todo determine and apply smart orientation of the structure 399 403 Spring.SendCommands("w "..hostName.." pwdeploy:"..data) 400 404 extraUnitMorphDefs[unitID] = nil 401 end 402 403 Spring.SetUnitPosition(newUnit, px, py, pz)404 405 local h = Spring.GetUnitHeading(unitID)406 Spring.SetUnitRotation(newUnit, 0, -h * math.pi / 32768, 0) 405 pwUnitOwners[unitID] = nil 406 else -- set rotation only if unit is not planetwars 407 local h = Spring.GetUnitHeading(unitID) 408 Spring.SetUnitRotation(newUnit, 0, -h * math.pi / 32768, 0) 409 end 410 407 411 408 412 --//copy experience