Joined: Mon Oct 22, 2012 4:09 am Posts: 22 Location: Columbus, Ohio
[Help] Two-Legged Turrets
I'm presently working on a relatively unusual actor and I've run into a snag. I'm working off of an AHuman base for bipedal legs and proper jetpack balance. The issue is that I want it set up with turret-like weapons that it can't drop, but can be shot off of it. I had a look at this topic and, while Bad Boy's code helped me whip up a neat little side-function that prevents it from picking up new weapons, I can't quite get the HDFirearm to go back into its inventory when dropped.
So far, the code I've modified is looking like this:
Code:
function Update(self)
if self.EquippedItem ~= nil then -- The code below isn't working correctly. I think it's just not spotting the WEAPON_DROP event? if self.EquippedItem.PresetName == "Spoiler Gun FG" then if self:GetController():IsState(Controller.WEAPON_DROP) then self:AddInventoryItem(CreateHDFirearm("Spoiler Gun FG", "Spoiler.rte")); end -- The code below is working correctly. elseif self.EquippedItem.PresetName ~= "Spoiler Gun FG" and self.EquippedItem.PresetName ~= "Spoiler Gun BG" then if self.Health < 100 then self.Health = math.min(self.Health + self.EquippedItem.Mass * .5, 100) self.HealSound = CreateAEmitter("Spoiler Heal Sound Dummy") self.HealSound.Pos = self.Pos self.HealSound.PinStrength = 1000 MovableMan:AddParticle(self.HealSound); local Cross = CreateMOSParticle("Particle Heal Effect", "Base.rte") if Cross then Cross.Pos = self.AboveHUDPos + Vector(0, 4) -- Set the particle's position to just over the actor's head MovableMan:AddParticle(Cross) end end self.EquippedItem.ToDelete = true end end end
Additionally, the actor has a lot of difficulty aiming the weapon. It usually aims very high, and won't engage with the background weapon (if it's the only weapon available) at all. I'm not sure if this is an inherent problem with background weapons, or if it might be because I'm using fake arms to mount the weapons onto.
if not self:HasObject("object name") then self:AddInventoryItem(CreateHDFirearm("Gun name", "Gunrte.rte")) end
This'll make it so if the actor doesn't have the object it'll add one. This won't work for multiples of a weapon for that reason (it could with a bit more code) but otherwise it'll probably do what you want. I'm not sure why the other one isn't working or if it ever did, it's been a while since I posted that haha
Tue Feb 25, 2014 1:10 am
Insano-Man
Joined: Mon Oct 22, 2012 4:09 am Posts: 22 Location: Columbus, Ohio
Re: [Help] Two-Legged Turrets
That got the weapon re-affixing itself, now I just need to figure out how to ensure it won't come back after being destroyed. I think I just might be able to jigger something up with some sharpness fiddling. Thanks!
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