Data Realms Fan Forums http://45.55.195.193/ |
|
Replacing HDFirearm with an MOSRotating upon firing (solved) http://45.55.195.193/viewtopic.php?f=73&t=31301 |
Page 1 of 1 |
Author: | No_0ne [ Thu Jun 21, 2012 7:32 pm ] |
Post subject: | 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. |
Author: | Lizardheim [ Thu Jun 21, 2012 7:54 pm ] |
Post subject: | 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. |
Author: | No_0ne [ Thu Jun 21, 2012 8:45 pm ] |
Post subject: | 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. |
Author: | Lizardheim [ Thu Jun 21, 2012 8:54 pm ] |
Post subject: | Re: Replacing HDFirearm with an MOSRotating upon firing |
Ah, gotcha. |
Author: | No_0ne [ Thu Jun 21, 2012 10:02 pm ] |
Post subject: | Re: Replacing HDFirearm with an MOSRotating upon firing |
Author: | No_0ne [ Sun Jul 01, 2012 8:38 am ] |
Post subject: | 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 |
Author: | Lizardheim [ Sun Jul 01, 2012 10:47 am ] |
Post subject: | Re: Replacing HDFirearm with an MOSRotating upon firing (solved) |
Think you can mess around with charheight to make it not pick up anything. |
Author: | Gotcha! [ Sun Jul 01, 2012 11:47 am ] |
Post subject: | 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. |
Author: | No_0ne [ Sun Jul 01, 2012 11:14 pm ] |
Post subject: | 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. |
Author: | Coops [ Sun Jul 01, 2012 11:19 pm ] |
Post subject: | 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) |
Author: | No_0ne [ Sun Jul 01, 2012 11:26 pm ] |
Post subject: | Re: Replacing HDFirearm with an MOSRotating upon firing (solved) |
Does that keep the player from picking up stuff? |
Author: | Coops [ Sun Jul 01, 2012 11:58 pm ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |