View unanswered posts | View active topics It is currently Thu Jan 09, 2025 10:09 pm



Reply to topic  [ 6 posts ] 
 Healing Script (still need help) 
Author Message

Joined: Wed Sep 02, 2009 10:57 am
Posts: 30
Reply with quote
Post 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...


Last edited by Jadestone on Sun Sep 20, 2009 1:06 pm, edited 3 times in total.



Sun Sep 20, 2009 12:38 pm
Profile
User avatar

Joined: Sun Jan 11, 2009 10:54 am
Posts: 365
Reply with quote
Post 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


Sun Sep 20, 2009 12:47 pm
Profile

Joined: Wed Sep 02, 2009 10:57 am
Posts: 30
Reply with quote
Post Re: Healing Script (simple but i need it please help)
Wow that was fast lol...


Sun Sep 20, 2009 12:54 pm
Profile

Joined: Wed Sep 02, 2009 10:57 am
Posts: 30
Reply with quote
Post 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.


Sun Sep 20, 2009 12:59 pm
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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


Sun Sep 20, 2009 6:47 pm
Profile
User avatar

Joined: Sun Jan 11, 2009 10:54 am
Posts: 365
Reply with quote
Post Re: Healing Script (still need help)
huh...
i was ridicusly wrong.
sorry


Sun Sep 20, 2009 8:54 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.141s | 15 Queries | GZIP : Off ]