Page 1 of 1

COOKIES!!!!

Posted: 12 Mar 2008, 17:54
by kiki
Whoever can figure out how to correctly find the range of a nanotower with lua gets a cookie. I am using BA to test, and UnitDefs[unitID].buildDistance and UnitDefs[unitID].buildDistance + Spring.GetUnitDefDimensions(unitID).radius both do not give full range, but only about half. Also, if you succeed you will get my pretty lua widget.

Re: COOKIES!!!!

Posted: 12 Mar 2008, 19:02
by TheFatController
buildDistance is correct I'm not sure what you're doing, try this function to test:

Code: Select all

function widget:UnitFinished(unitID, unitDefID, unitTeam)

  local x,_,z = Spring.GetUnitPosition(unitID)
      
  for angle=0,360,40 do
    local xp = (x + (math.sin(math.rad(angle)) * UnitDefs[unitDefID].buildDistance))
    local zp = (z + (math.cos(math.rad(angle)) * UnitDefs[unitDefID].buildDistance))
    Spring.MarkerAddPoint(xp,0,zp)
  end

end
Edit: OH you're using UnitDefs[unitID] instead of UnitDefs[unitDefID] that would be why - it's reading another unit :p i'll leave my code in for its leet point spamming and geometry skills

Re: COOKIES!!!!

Posted: 12 Mar 2008, 19:50
by CarRepairer
TheFatController does not need anymore cookies. I'll take them instead.

Re: COOKIES!!!!

Posted: 13 Mar 2008, 02:22
by kiki
Oh! no wonder! I was thinking that that may be a possibility as i was in the car. Cookies for you!!! That also explains why with a different build order the value was different.

Re: COOKIES!!!!

Posted: 23 Mar 2008, 01:08
by AF
The cookie king throwns upon sales of counterfeit cookies

Re: COOKIES!!!!

Posted: 23 Mar 2008, 18:24
by kiki
sale? Counterfeit? AF?