ForbodingAngel

Untitled

Feb 24th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. function gadget:GameFrame(frame)
  2. if frame % 12 < .1 then
  3. for unitId, timeLeft in pairs(saleTime) do
  4. if timeLeft < frame then
  5. local unitDefId = spGetUnitDefID(unitId)
  6. local teamId = spGetUnitTeam(unitId)
  7. local ux, uy, uz = Spring.GetUnitPosition(unitId)
  8. spDestroyUnit(unitId, false, true)
  9. --Spring.Echo(resCount, type(resCount))
  10. if resCount and resCount ~= "" then
  11. for i = 1,resCount do
  12. resources[teamId][i] = min(resources[teamId][i] + (unitCost[unitDefId][i] or 0) * refundFactor, capacity[teamId][i])
  13. end
  14. else
  15. local currentMetal = Spring.GetTeamResources(teamId,"metal")
  16. local currentEnergy = Spring.GetTeamResources(teamId,"energy")
  17. local unitMetal = (UnitDefs[unitDefId].metalCost or 0) * refundFactor
  18. local unitEnergy = (UnitDefs[unitDefId].energyCost or 0) * refundFactor
  19.  
  20. --Spring.Echo(currentMetal, unitMetal)
  21. Spring.SetTeamResource(teamId, "m", currentMetal + unitMetal)
  22. Spring.SetTeamResource(teamId, "e", currentEnergy + unitEnergy)
  23. Spring.PlaySoundFile('sounds/chaching.wav', 5, ux, uy, uz)
  24. end
  25. end
  26. end
  27. end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment