Author |
Message |
No_0ne
Joined: Wed Feb 14, 2007 5:37 am Posts: 350
|
Replacing HDFirearm with an MOSRotating upon firing (solved)
I need a script for a panzerfaust-like weapon I'm making. It needs to do these two things
1. Delete the firearm after it fires 2. Within that same frame, create an MOSRotating that will take on the firearm's position, angle and hflipped properties
So a script that will make it look like the weapon is discarded the moment it was fired.
Last edited by No_0ne on Thu Jun 21, 2012 11:03 pm, edited 1 time in total.
|
Thu Jun 21, 2012 7:32 pm |
|
|
Lizardheim
DRL Developer
Joined: Fri May 15, 2009 10:29 am Posts: 4107 Location: Russia
|
Re: Replacing HDFirearm with an MOSRotating upon firing
Can't you just make the emitter fired send some particles backwards that gibs it and make the mosr a gib?
Same effect, no Lua required.
|
Thu Jun 21, 2012 7:54 pm |
|
|
No_0ne
Joined: Wed Feb 14, 2007 5:37 am Posts: 350
|
Re: Replacing HDFirearm with an MOSRotating upon firing
I could but I'd rather avoid doing that, as I'd like the gun to also gib like normal. My preference for lua for this really just comes down to aesthetics.
|
Thu Jun 21, 2012 8:45 pm |
|
|
Lizardheim
DRL Developer
Joined: Fri May 15, 2009 10:29 am Posts: 4107 Location: Russia
|
Re: Replacing HDFirearm with an MOSRotating upon firing
Ah, gotcha.
|
Thu Jun 21, 2012 8:54 pm |
|
|
No_0ne
Joined: Wed Feb 14, 2007 5:37 am Posts: 350
|
Re: Replacing HDFirearm with an MOSRotating upon firing
Okay, lock this thread. I managed to do it on my own.
|
Thu Jun 21, 2012 10:02 pm |
|
|
No_0ne
Joined: Wed Feb 14, 2007 5:37 am Posts: 350
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
I'm going to be reusing this thread for another request, one that's quite a ways out of my scope for lua coding. So, I made this big bastard here: As you can see he has his own gun. I want to make it so the gun cannot be dropped (voluntarily or involuntarily). (maybe check for if the gun is dropped, then replant it in the owner's inventory) I also want the mech to not pickup any other weapons, or force it to drop or gib the weapon immediately on pickup. That way the mech can only use the gun that was made for it and no other gun. I tried doing it on my own but failed miserably, so any help would be appreciated. Additional information 1. When the mech dies, I plan on making it so that it and everything attached to it gibs. 2. The gun itself is set to not be hit by MOs
|
Sun Jul 01, 2012 8:38 am |
|
|
Lizardheim
DRL Developer
Joined: Fri May 15, 2009 10:29 am Posts: 4107 Location: Russia
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
Think you can mess around with charheight to make it not pick up anything.
|
Sun Jul 01, 2012 10:47 am |
|
|
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
And have its health disappear? Not really an option in my opinion. Bad Boy gave me this bit of code: Code: if not self:HasObject("Gun Name Here") then self:AddInventoryItem(CreateHDFirearm("Gun Name Here" , "ModName.rte")); end Using a modification of this would at least solve the 'always have this gun' bit.
|
Sun Jul 01, 2012 11:47 am |
|
|
No_0ne
Joined: Wed Feb 14, 2007 5:37 am Posts: 350
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
i did it Code: function Create(self) self.myGun = CreateHDFirearm("OniTech Reaper")
--purge inventory
for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i);
if mo.RootID == self.ID and mo:IsHeldDevice() then
mo = ToHeldDevice(mo); if mo.PresetName ~= "OniTech Reaper" then mo:ToDelete(true); end end end
self:AddInventoryItem(self.myGun); self:EquipFirearm(true); end
function Update(self)
if self.InventorySize == 1 then --something was just picked up
--find gun for i=1,MovableMan:GetMOIDCount()-1 do local mo = MovableMan:GetMOFromID(i);
if mo.RootID == self.ID and mo:IsHeldDevice() then
mo = ToHeldDevice(mo); if mo.PresetName ~= "OniTech Reaper" then --this gun isnt our gun, break it mo:GibThis(); self:EquipFirearm(true); break; end end end else if self.myGun.RootID ~= self.ID and (not self.myGun:IsAttached()) then --special weapon was dropped, put it back in inventory local magCount = self.myGun.Magazine.RoundCount; self.myGun.ToDelete = true;
local newGun = CreateHDFirearm("OniTech Reaper") newGun.Magazine.RoundCount = magCount;
self:AddInventoryItem(newGun); self.myGun = newGun; end end end could probably be optimized, but at least it works.
|
Sun Jul 01, 2012 11:14 pm |
|
|
Coops
Joined: Wed Feb 17, 2010 12:07 am Posts: 1545 Location: That small peaceful place called Hell.
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
You could just have gone the easy way and get the actor's controller and use Code: self:GetController():SetState(Controller.WEAPON_PICKUP, false) self:GetController():SetState(Controller.WEAPON_DROP, false)
|
Sun Jul 01, 2012 11:19 pm |
|
|
No_0ne
Joined: Wed Feb 14, 2007 5:37 am Posts: 350
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
Does that keep the player from picking up stuff?
|
Sun Jul 01, 2012 11:26 pm |
|
|
Coops
Joined: Wed Feb 17, 2010 12:07 am Posts: 1545 Location: That small peaceful place called Hell.
|
Re: Replacing HDFirearm with an MOSRotating upon firing (solved)
Its what I used for my SAW Mech.
Actually I remember the drop command still worked though, so keep the replacing your inventory code part.
|
Sun Jul 01, 2012 11:58 pm |
|
|
|