Data Realms Fan Forums
http://forums.datarealms.com/

Trying to create a charged shot sniper rifle
http://forums.datarealms.com/viewtopic.php?f=73&t=25030
Page 1 of 1

Author:  Asklar [ Mon Aug 08, 2011 4:17 am ]
Post subject:  Trying to create a charged shot sniper rifle

But it is failing. Epicly.

Everytime I think of shooting this it crashes. Plain old crash, with no messages and stuff. And the lua console is not giving me any kind of errors, so, help?

Code:
function Create(self)
   self.ChargeTimer = Timer()
        self.Shot = nil
end

function Update(self)
   
   if self:IsActivated() then
      if self.ChargeTimer:IsPastSimMS(1) and not self.ChargeTimer:IsPastSimMS(2499) then
         self.Shot = 1
            if self.Shot == 1 and not self.IsActivated() then
               self.LowDamage = CreateMOPixel("Particle .22 Carbine")
               self.LowDamage.Pos = self.MuzzlePos
               self.LowDamage:SetWhichMOToNotHit(MovableMan:GetMOFromID(self.RootID),-1)   
               self.LowDamage.Vel = Vector(100,0):RadRotate(self.RotAngle)
               MovableMan:AddParticle(self.LowDamage)
            end
      elseif self.ChargeTimer:IsPastSimMS(2500) and not self.ChargeTimer:IsPastSimMS(4999) then
         self.Shot = 2
            if self.Shot == 2 and not self.IsActivated() then
               for i = 1, 3 do
                  self.NormalDamage = CreateMOPixel("Particle Carbine")
                  self.NormalDamage.Pos = self.MuzzlePos
                  self.NormalDamage:SetWhichMOToNotHit(MovableMan:GetMOFromID(self.RootID),-1)
                  self.NormalDamage.Vel = Vector(110,0):RadRotate(self.RotAngle)
                  MovableMan:AddParticle(self.NormalDamage)
               end
            end
      elseif self.ChargeTimer:IsPastSimMS(5000) then
         self.Shot = 3
            if self.Shot == 3 and not self.IsActivated() then
               self.ExplosiveDamage = CreateAEmitter("Particle HE Carbine")
               self.ExplosiveDamage.Pos = self.MuzzlePos
               self.ExplosiveDamage:SetWhichMOToNotHit(MovableMan:GetMOFromID(self.RootID),-1)
               self.ExplosiveDamage.Vel = Vector(150,0):RadRotate(self.RotAngle)
               MovableMan:AddParticle(self.ExplosiveDamage)
            end
      end
   else
      self.ChargeTimer:Reset()
   end
end


I know there are a lot of charged-shot-type of script, but I never got any of them so I'm trying to create a more "simple" version.

Author:  CaveCricket48 [ Mon Aug 08, 2011 5:09 am ]
Post subject:  Re: Trying to create a charged shot sniper rifle

What does your ini code look like?

Also, that thing is never gonna fire. You're checking to see if the gun is not firing inside where it checks if the gun is firing.

Author:  Asklar [ Mon Aug 08, 2011 5:13 am ]
Post subject:  Re: Trying to create a charged shot sniper rifle

What the hell was that last sentence? That was the most complex thing I've ever read. In english. Nevermind, I'm an idiot.

And that thing was supposed to check if the mouse button is released (or something like that).

Well, my ini looks pretty fine, like most ini stuff I've coded.

I'm posting the entire ini script.


Author:  CaveCricket48 [ Mon Aug 08, 2011 10:36 pm ]
Post subject:  Re: Trying to create a charged shot sniper rifle

You don't have a round defined for your magazine. That's what's causing the crash.

Just have your gun fire a null round or something.

Author:  Asklar [ Tue Aug 09, 2011 11:31 pm ]
Post subject:  Re: Trying to create a charged shot sniper rifle

Nevermind, I figured it out. Now I just only need to add the aesthetics part to the code.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/