View unanswered posts | View active topics It is currently Mon Jan 13, 2025 7:06 pm



Reply to topic  [ 5 posts ] 
 Grenade catching <Solved> 
Author Message
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1972
Location: The Netherlands
Reply with quote
Post 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


Last edited by Gotcha! on Wed Mar 10, 2010 10:37 pm, edited 1 time in total.



Wed Mar 10, 2010 8:15 pm
Profile
User avatar

Joined: Wed Sep 09, 2009 3:16 am
Posts: 3032
Location: Somewhere in the universe
Reply with quote
Post Re: Grenade catching
I believe its been made already, by PhntmAgn.


Wed Mar 10, 2010 8:37 pm
Profile
User avatar

Joined: Mon Feb 02, 2009 9:18 pm
Posts: 618
Location: Ancient Hispania
Reply with quote
Post Re: Grenade catching
dragonxp wrote:
I believe its been made already, by PhntmAgn.

by mail2345


Wed Mar 10, 2010 8:42 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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.


Wed Mar 10, 2010 10:16 pm
Profile
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1972
Location: The Netherlands
Reply with quote
Post Re: Grenade catching
Once again you save the day, CC48! You have my gratitude. :grin:
It works like a charm indeed.


Wed Mar 10, 2010 10:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.039s | 15 Queries | GZIP : Off ]