Data Realms Fan Forums
http://45.55.195.193/

Healing Script (still need help)
http://45.55.195.193/viewtopic.php?f=1&t=16587
Page 1 of 1

Author:  Jadestone [ Sun Sep 20, 2009 12:38 pm ]
Post subject:  Healing Script (still need help)

Please can some one make this lua script for me:

Heal the actor by pressing B
By Pressing B you toggle it on and off
The Actor gains 2 Health Per Second While Healing
Ment for a Actor or Craft or Somthing (nothing in specific)
I want it to only heal it self.

I only need this for my mod and im just kinda learning lua...

Author:  vagyr [ Sun Sep 20, 2009 12:47 pm ]
Post subject:  Re: Healing Script (simple but i need it please help)

here you go this should work.
press the pie menu button to activate the script(this way you can use it even if you are on team 2)
Code:
function Create(self)
    --Keep track of how long it should be before healing people.
    healTimer = Timer();
    --Interval between healings, in milliseconds.
    healInterval = 100;
    --Heal counter.
    self.healnum = 0;
end

function Update(self)
    --Heal every interval.
    if healTimer:IsPastSimMS(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.Team == self.Team and actor.Health < 100 and actor.ID == self.IDactor:GetController():IsState(Controller.PIE_MENU_ACTIVE)    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 < 100 then
          --If the actor is fairly close, heal them!
          actor.Health = actor.Health + 2;
          --Every 8 health healed, put a little icon above the actor's head to show that it is indeed healing.
          if self.healnum == 8 then
             --Create the particle.
             local part = CreateMOSParticle("Particle Heal Effect");
             --Set the particle's position to just over the actor's head.
             part.Pos = actor.AboveHUDPos + Vector(0,4);
         --Add the particle to the world.
             MovableMan:AddParticle(part);
          end
      end
       end
   end
   --Reset the healing timer.
   healTimer:Reset();
   --Increment the heal counter.
   self.healnum = self.healnum + 1;
   --Reset it if it's gone too far.
   if self.healnum > 8 then
       self.healnum = 0;
   end
    end
end

it is just a small edit on the heal bot but it should not bring any problem

Author:  Jadestone [ Sun Sep 20, 2009 12:54 pm ]
Post subject:  Re: Healing Script (simple but i need it please help)

Wow that was fast lol...

Author:  Jadestone [ Sun Sep 20, 2009 12:59 pm ]
Post subject:  Re: Healing Script (simple but i need it please help)

i tried it it dident work :( try making it a key

if you dident get it i wanted it to only heal it self.

Author:  piipu [ Sun Sep 20, 2009 6:47 pm ]
Post subject:  Re: Healing Script (still need help)

Code:
function Create(self)
  self.healing = false
  self.healtime = Timer()
end

function Update(self)
  if self:IsPlayerControlled() and UInputMan:KeyPressed(2) then
    self.healing = not self.healing
  end
  if self.healing and self.healtime:IsPastSimMS(500) and self.Health <= 100 then
    self.healtime:Reset()
    self.Health = self.Health + 1
  end
end

Author:  vagyr [ Sun Sep 20, 2009 8:54 pm ]
Post subject:  Re: Healing Script (still need help)

huh...
i was ridicusly wrong.
sorry

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/