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



Reply to topic  [ 3 posts ] 
 Need help with damage script 
Author Message
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Need help with damage script
So, the problem is that the attached script (shamelessy modified Medic Drone script) doesn't seem to work with AEmitters, and i don't know why. It's supposed to subtract health from any actor nearby at the shown rate (0.05 health every 100 milliseconds), and it works when it's put on an actor, but nothing happens when it's on an AEmitter. It'd be greatly appreciated if someone could fix it for me. (Note: I'm totally clueless regarding Lua, so please, bear with me)


Attachments:
Gas.rar [639 Bytes]
Downloaded 186 times
Thu May 28, 2009 1:25 pm
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Need help with damage script
I believe you have two problems.
1. Your timer isn't internal to the object. I helped Gotcha! with his killzone, and before I made the timer internal (put self. in front of all instances of the timer name) only the first killzone would work.
2. The code checks to see if the actor being looked at is on the same team as the object with the script attached. AEmitters don't have teams, so I don't know what it would do when it tried that comparison.

Try using this script instead.
Code:
function Create(self)
    --Keep track of how long it should be before healing people.
    self.healTimer = Timer();
    --Interval between healings, in milliseconds.
    self.healInterval = 100;
end

function Update(self)
    --Heal every interval.
    if self.healTimer:IsPastSimMS(self.healInterval) then
   --Cycle through all actors.
   for actor in MovableMan.Actors do
       --If the actor is on the right team, has less than 100 health and is not the healer, continue with code.
       if actor.ID ~= self.ID then
      --Trigonometry to find how far the actor is.
      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 < 40 then
          --If the actor is fairly close, heal them!
          actor.Health = actor.Health - 0.05;
      end
       end
   end
   --Reset the healing timer.
   self.healTimer:Reset();
    end
end


I just put in the above things into your script.


Thu May 28, 2009 2:19 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Need help with damage script
Ahh, thanks, it works like a charm now. :grin:


Thu May 28, 2009 2:59 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

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.038s | 16 Queries | GZIP : Off ]