Data Realms Fan Forums
http://45.55.195.193/

Grenade catching <Solved>
http://45.55.195.193/viewtopic.php?f=73&t=18078
Page 1 of 1

Author:  Gotcha! [ Wed Mar 10, 2010 8:15 pm ]
Post subject:  Grenade catching <Solved>

Helloes,

I am using a lua script that someone made (dunno who made it to be honest), which replenishes a thrown grenade.
However, these grenades, when thrown, get 'caught' by enemy actors, dropships and sometimes even the thrower himself! It's like the grenades 'snap' to the actor and explode, instead of just bouncing off their heads.

I've tried changing the lua script with my lack of lua know-how, thus only resulting in errors. All I basically need is having the grenade respawn in the inventory after throwing, but not have it stick to actors.

Would anyone mind having a look at it? :)

Attachment:
Thermal Grenade.txt

Author:  dragonxp [ Wed Mar 10, 2010 8:37 pm ]
Post subject:  Re: Grenade catching

I believe its been made already, by PhntmAgn.

Author:  NaXx [ Wed Mar 10, 2010 8:42 pm ]
Post subject:  Re: Grenade catching

dragonxp wrote:
I believe its been made already, by PhntmAgn.

by mail2345

Author:  CaveCricket48 [ Wed Mar 10, 2010 10:16 pm ]
Post subject:  Re: Grenade catching

Here ya go.

Code:
function Create(self)
   self.spawnedbomb = false;

   self.autoswitch = true; -- This makes the actor switch to the newly added grenade after it's added to its inventory. true for yes and false for no.

end

function Update(self)

   if self.spawnedbomb == false and self:IsActivated() == true then
   self.spawnedbomb = true;
   self.grabobject = SceneMan:CastMORay(self.Pos,Vector(-self.Vel.X,-self.Vel.Y):SetMagnitude(50),self.ID,0,true,0);
    if self.grabobject ~= 255 then
   self.target2 = MovableMan:GetMOFromID(self.grabobject);
   self.target = MovableMan:GetMOFromID(self.target2.RootID);
     if MovableMan:IsActor(self.target) then
   ToActor(self.target):AddInventoryItem(CreateTDExplosive(self.PresetName));

      if self.autoswitch == true and self.target.ClassName == "AHuman" then
   ToActor(self.target):GetController():SetState(Controller.WEAPON_CHANGE_PREV,true);
      end

     end
    end
   end

end


Also, when you attach the script to your grenade, you don't have to change a single thing and it'll work.

Author:  Gotcha! [ Wed Mar 10, 2010 10:37 pm ]
Post subject:  Re: Grenade catching

Once again you save the day, CC48! You have my gratitude. :grin:
It works like a charm indeed.

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