function Create(self) self.basemass = 15 self.roundmass = 0.4 self.ejectoffset = -16 self.ejectspeed = -12 self.magcount = self.Magazine.RoundCount end function Update(self) --determine the root object. if self.RootID ~= 255 then self.y = MovableMan:GetMOFromID(self.RootID) if self.y then if self.y:IsActor() then self.z = ToActor(MovableMan:GetMOFromID(self.RootID)) if self.Magazine then if self:IsReloading() then self.justfired = 0 else if self.magcount ~= self.Magazine.RoundCount and self.Magazine.IsFull == false then self.justfired = 1 self.Sharpness = self.Sharpness - 1 self.c = CreateMOSRotating("Grande Casing","Shadow Echelon.rte") if self.HFlipped == true then -- Left self.c.Vel = self.z.Vel + Vector(self.ejectspeed,0):RadRotate(self.RotAngle + math.pi) self.c.Pos = self.Pos + Vector(self.ejectoffset,0):RadRotate(self.RotAngle + math.pi) self.z.AngularVel = self.z.AngularVel - (2000 / self.z.Mass) self.c.RotAngle = self.RotAngle + math.pi else -- Right self.c.Vel = self.z.Vel + Vector(self.ejectspeed,0):RadRotate(self.RotAngle) self.c.Pos = self.Pos + Vector(self.ejectoffset,0):RadRotate(self.RotAngle) self.z.AngularVel = self.z.AngularVel + (2000 / self.z.Mass) self.c.RotAngle = self.RotAngle end self.c.AngularVel = 0 self.c:SetWhichMOToNotHit(self.z, -1) self.z:SetWhichMOToNotHit(self.c, -1) MovableMan:AddParticle(self.c) else self.justfired = 0 if self.Sharpness < self.Magazine.RoundCount then self.Magazine.RoundCount = self.Sharpness print("not enough ammo for a full mag") end end self.magcount = self.Magazine.RoundCount end else self.justfired = 0 end end end --stuff to always do, regardless of if someone's holding it --displays the ammo self.b = CreateHeldDevice("Null Device","Shadow Echelon.rte") if self.Sharpness > 0 then self.b.PresetName = self.Sharpness.." Rds" else self.b.PresetName = "Empty!" end self.b.Vel = self.y.Vel self.b.Pos.X = self.y.Pos.X if self.y:IsDevice() then self.b.Pos.Y = self.y.Pos.Y + 36 else self.b.Pos.Y = self.y.Pos.Y - 2 end self.b:SetWhichMOToNotHit(self.y, -1) MovableMan:AddParticle(self.b) end --reweight accordingly to ammo remains self.Mass = self.basemass + self.roundmass * self.Sharpness end