View unanswered posts | View active topics It is currently Wed Jul 17, 2019 3:50 am



Reply to topic  [ 6 posts ] 
 force reload 
Author Message
User avatar

Joined: Tue Jan 12, 2010 8:25 pm
Posts: 400
Location: mukilteo, wa
Reply with quote
Post force reload
how would i force a gun to reload?
I'm editing the duel fire mode template to be triggered by a key, not the pie menu & to force the gun to reload when it switches between modes.
Also i plan to make it play a sound (probably to device switch noise from base files) to let you know you changed modes.
I know how to set it to be triggered by a key, the reloading part has me stumped.

-thanks


Sat Sep 10, 2011 11:06 am
Profile
Online
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11408
Location: Here
Reply with quote
Post Re: force reload
Code:
HDFirearm:Reload();


Sat Sep 10, 2011 3:41 pm
Profile
User avatar

Joined: Tue Jan 12, 2010 8:25 pm
Posts: 400
Location: mukilteo, wa
Reply with quote
Post Re: force reload
thank you

I seem to have missed something when making it switch by pressing F
I'm not sure what i did wrong. also I'm thinking that adding AEmitter to play a sound at switch would be redundant due to the reload sound would already play.
... Just ignore the AEmitter I'm going to edit it out.

Mode1 code
Code:
-- this edit is a work in progress

function Create(self)

   self.switchToWeapon = "Spiderbot Grenade Launcher Alt-Fire"; -- PresetName of gun to switch to
   self.switchToClass = "HDFirearm";

end

function Update(self)

   local actor = MovableMan:GetMOFromID(self.RootID);
   if MovableMan:IsActor(actor) then
      local actor = ToAHuman(actor);
      if UInputMan:KeyHeld(6) then                                -- press f to switch modes
         HDFirearm:Reload();                                 -- force reload as soon as weapon switches
--         ?????? = CreateAEmitter("SwitchSound", "X-9.rte");  -- play sound... might not need this due to it reloading
         if self.switchToClass == "HDFirearm" then
            local switchGun = actor:AddInventoryItem(CreateHDFirearm(self.switchToWeapon));
         elseif self.switchToClass == "TDExplosive" then
            local switchGun = actor:AddInventoryItem(CreateTDExplosive(self.switchToWeapon));
         elseif self.switchToClass == "HeldDevice" then
            local switchGun = actor:AddInventoryItem(CreateHeldDevice(self.switchToWeapon));
         end
         actor:GetController():SetState(Controller.WEAPON_DROP,true);
         self.ToDelete = true;
      end
   end

end


Last edited by salt_1219 on Sat Sep 10, 2011 9:14 pm, edited 1 time in total.



Sat Sep 10, 2011 8:26 pm
Profile
Online
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11408
Location: Here
Reply with quote
Post Re: force reload
Could you put some code tags around that? Kinda hard to read.

Edit: When I said "HDFirearm:Reload()," you're supposed to replace 'HDFirearm' with the pointer to an HDFirearm.


Sat Sep 10, 2011 8:57 pm
Profile
User avatar

Joined: Tue Jan 12, 2010 8:25 pm
Posts: 400
Location: mukilteo, wa
Reply with quote
Post Re: force reload
Ok thanks, sorry im typing on my cell.
I will add code blocks & add the pointer.

Okay stupid question here, the pointer in this case would be the guns name?

self.wepname = "Grenade Launcher";
or
gun.PresetName == "Grenade Launche"; -- no, that would be for a if statement, and would mean equal to.
("Grenade Launcher"):Reload();

I really need to look at more scripts, I clearly have trouble even doing a simple edit.


Sat Sep 10, 2011 9:12 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: force reload
Well, if the script is attached to the weapon, then the weapon is "self" pointer. And if you want to reload the weapon then you do self:Reload().


Sun Sep 11, 2011 6:10 am
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.017s | 13 Queries | GZIP : Off ]