View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:39 pm



Reply to topic  [ 5 posts ] 
 Trying to create a charged shot sniper rifle 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Mon Aug 08, 2011 4:17 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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.


Mon Aug 08, 2011 5:09 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.



Mon Aug 08, 2011 5:13 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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.


Mon Aug 08, 2011 10:36 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Tue Aug 09, 2011 11:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.061s | 14 Queries | GZIP : Off ]