View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:29 pm



Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
 Getting the height of the terrain 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Getting the height of the terrain
It's wierd. It doesn't give me any errors, but it doesn't work either.

Here I'll post the complete code:

Code:
function Update(self)
   if self:GetAltitude(0,7) <= 5 then
      self.PinStrength = 9999;
   end
   self.Age = 0;
   self.ToSettle = false;   
   local curdist = 25;
   for actor in MovableMan.Actors do
      local avgx = actor.Pos.X - self.Pos.X;
      local avgy = actor.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist then;
         self:GibThis();
      end
   end

end


It simply won't pin.


Sun Mar 06, 2011 6:20 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Getting the height of the terrain
The second argument in MovableObject:GetAltitude is the accuracy. You have it set to 7, which means that it only checks every 7 pixels whether there's any terrain. I'm not entirely positive how it rounds the numbers, but I would assume that it's always returning 7 unless the object is underground, in which case it would return 0. Set the accuracy to something less than 5 if you want to check if it's lower than 5.


Sun Mar 06, 2011 6:46 am
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Getting the height of the terrain
That worked.

Thanks a lot! Now my landmines won't turn into terrain. But I had to pin them 7 pixels above ground.

EDIT: 7? nah, just 4. Looks more natural.
And it also works great for bunker building phase =D


Sun Mar 06, 2011 6:55 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 18 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.329s | 13 Queries | GZIP : Off ]