View unanswered posts | View active topics It is currently Thu Jan 09, 2025 3:07 pm



Reply to topic  [ 6 posts ] 
 Homing gatling trouble 
Author Message

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post Homing gatling trouble
gatling code:
Code:
AddEffect = MOPixel
   PresetName = Bullet Gatling Gun
   Mass = 0.062
   ScriptPath = Alfmod.rte/Devices/Weapons/Machineguns/Gattling.Lua
   LifeTime = 780
   Sharpness = 42
   HitsMOs = 1
   GetsHitByMOs = 0
   Color = Color
      R = 210
      G = 198
      B = 178
   Atom = Atom
      Material = Material
         CopyOf = Bullet Metal
      TrailColor = Color
         R = 210
         G = 198
         B = 178
      TrailLength = 40


AddEffect = MOPixel
   CopyOf = Bullet Gatling Gun
   PresetName = Tracer Gatling Gun
   Mass = 0.068
   Sharpness = 42
   Color = Color
      R = 255
      G = 226
      B = 0
   Atom = Atom
      Material = Material
         CopyOf = Bullet Metal
      TrailColor = Color
         R = 255
         G = 226
         B = 0
      TrailLength = 50


AddAmmo = Round
   PresetName = Round Gatling Gun
   ParticleCount = 1
   Particle = MOPixel
      CopyOf = Bullet Gatling Gun
   Shell = MOSParticle
      CopyOf = Casing
   FireVelocity = 120
   ShellVelocity = 13
   Separation = 0


AddAmmo = Round
   PresetName = Tracer Gatling Gun
   ParticleCount = 1
   Particle = MOPixel
      CopyOf = Tracer Gatling Gun
   Shell = MOSParticle
      CopyOf = Casing
   FireVelocity = 121
   ShellVelocity = 13
   Separation = 0


AddAmmo = Magazine
   PresetName = Magazine Gatling Gun
   Mass = 10
   HitsMOs = 0
   GetsHitByMOs = 0
   SpriteFile = ContentFile
      FilePath = Alfmod.rte/Devices/Sprites/MagazineGatlingunA.bmp
   FrameCount = 1
   SpriteOffset = Vector
      X = -3
      Y = -7
   EntryWound = AEmitter
      CopyOf = Dent Metal
   ExitWound = AEmitter
      CopyOf = Dent Metal
   AtomGroup = AtomGroup
      AutoGenerate = 1
      Material = Material
         CopyOf = Military Stuff
      Resolution = 2
      Depth = 0
   DeepGroup = AtomGroup
      AutoGenerate = 1
      Material = Material
         CopyOf = Military Stuff
      Resolution = 3
      Depth = 1
   DeepCheck = 0
   JointStrength = 200
   JointStiffness = 1
   JointOffset = Vector
      X = 0
      Y = 0
   ParentOffset = Vector
      X = -12
      Y = 0
   DrawAfterParent = 0
   RoundCount = 100
   RTTRatio = 6
   RegularRound = Round
      CopyOf = Round Gatling Gun
   TracerRound = Round
      CopyOf = Tracer Gatling Gun
   AddGib = Gib
      GibParticle = MOPixel
         CopyOf = Spark Yellow 1
      Count = 5
      Spread = 2.25
      MaxVelocity = 20
      MinVelocity = 8
   AddGib = Gib
      GibParticle = MOSParticle
         CopyOf = Gib Metal Rust Micro A
      Count = 4
      Spread = 2.25
      MaxVelocity = 15
      MinVelocity = 5
   GibWoundLimit = 2


AddDevice = HDFirearm
   PresetName = Gatling Gun
   Description = Alfmod's feared heavy weapon that features a large magazine and amazing firepower.  Reloading is not an issue because there is enough ammo to kill everyone even remotely close.
   AddToGroup = Weapons
   Mass = 54
   HitsMOs = 0
   GetsHitByMOs = 1
   SpriteFile = ContentFile
      FilePath = Alfmod.rte/Devices/Sprites/GatlingunA.bmp

   FrameCount = 3
   SpriteOffset = Vector
      X = -17
      Y = -5
   SpriteAnimMode = 4
   SpriteAnimDuration = 500
   EntryWound = AEmitter
      CopyOf = Dent Metal
   ExitWound = AEmitter
      CopyOf = Dent Metal
   GoldValue = 210
   AtomGroup = AtomGroup
      AutoGenerate = 1
      Material = Material
         CopyOf = Military Stuff
      Resolution = 4
      Depth = 0
   DeepGroup = AtomGroup
      AutoGenerate = 1
      Material = Material
         CopyOf = Military Stuff
      Resolution = 4
      Depth = 10
   DeepCheck = 0
   JointStrength = 75
   JointStiffness = 0.5
   JointOffset = Vector
      X = -7
      Y = 3
   DrawAfterParent = 0
   StanceOffset = Vector
      X = 3
      Y = 8
   SharpStanceOffset = Vector
      X = 2
      Y = 6
   SupportOffset = Vector
      X = -2
      Y = -3
   SharpLength = 100
   Magazine = Magazine
      CopyOf = Magazine Gatling Gun
   Flash = Attachable
      CopyOf = Muzzle Flash Shotgun
   FireSound = Sound
      AddSample = ContentFile
         FilePath = Base.rte/Sounds/Taka.wav
   EmptySound = Sound
      AddSample = ContentFile
         FilePath = Base.rte/Devices/EmptyClick3.wav
   ReloadStartSound = Sound
      AddSample = ContentFile
         FilePath = Base.rte/Devices/ReloadStart.wav
   ReloadEndSound = Sound
      AddSample = ContentFile
         FilePath = Base.rte/Devices/ReloadEnd.wav
   RateOfFire = 1300


//////// Spin up & Spin down variables

   ActivationDelay = 1000
   DeactivationDelay = 1000

//////// Spinning Sound

   ActiveSound = Sound
      AddSample = ContentFile
         FilePath = Alfmod.rte/Devices/Weapons/SpinSound.wav     // Maybe you can control the pitch relative to the firing speed?
      LoopSetting = -1

   ReloadTime = 4000
   FullAuto = 1
   FireIgnoresThis = 1
   ShakeRange = 9
   SharpShakeRange = 5
   NoSupportFactor = 4
   ParticleSpreadRange = 0.8
   ShellSpreadRange = 8
   ShellAngVelRange = 2
   MuzzleOffset = Vector
      X = 17
      Y = -1
   EjectionOffset = Vector
      X = -10
      Y = -3
   AddGib = Gib
      GibParticle = MOPixel
         CopyOf = Spark Yellow 1
      Count = 8
      Spread = 2.25
      MaxVelocity = 20
      MinVelocity = 8
   AddGib = Gib
      GibParticle = MOPixel
         CopyOf = Spark Yellow 2
      Count = 10
      Spread = 2.25
      MaxVelocity = 20
      MinVelocity = 8
   AddGib = Gib
      GibParticle = MOPixel
         CopyOf = Drop Oil
      Count = 8
      Spread = 2.25
      MaxVelocity = 10
      MinVelocity = 1
   AddGib = Gib
      GibParticle = MOSParticle
         CopyOf = Gib Metal Rust Micro A
      Count = 18
      Spread = 2.25
      MaxVelocity = 15
      MinVelocity = 5
   AddGib = Gib
      GibParticle = MOSParticle
         CopyOf = Gib Metal Grey Micro A
      Count = 16
      Spread = 2.25
      MaxVelocity = 15
      MinVelocity = 5
   AddGib = Gib
      GibParticle = MOSRotating
         CopyOf = Gib Device Small J
      Count = 1
   AddGib = Gib
      GibParticle = MOSRotating
         CopyOf = Gib Device Small H
      Count = 1
   AddGib = Gib
      GibParticle = MOSRotating
         CopyOf = Coalition Weapons Gib I
      Count = 1
      Offset = Vector
         X = -2
         Y = -1
   AddGib = Gib
      GibParticle = MOSRotating
         CopyOf = Coalition Weapons Gib J
      Count = 1
      Offset = Vector
         X = -3
         Y = -1
   AddGib = Gib
      GibParticle = MOSRotating
         CopyOf = Coalition Weapons Gib G
      Count = 1
      Offset = Vector
         X = 5
         Y = 0
   GibWoundLimit = 5


Bullet code:
Code:
function Create(self)
--The timer that will measure out the missile's events.
    self.LTimer = Timer();

--The missile's target, currently set to nothing.

    self.target = nil;

--Find out who shot the weapon by finding the closest actor within 50 pixels.
    local curdist = 50;
    for actor in MovableMan.Actors do
   local avgx = actor.Pos.X - self.Pos.X;
   local avgy = actor.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.parent = actor;
   end
    end

--If the missile has no firer, make it go after anyone.  Otherwise, set its team to that of the firer.
    if MovableMan:IsActor(self.parent) then
   self.Team = self.parent.Team;
    else
   self.Team = -1;
    end
end

function Update(self)
    if self.LTimer:IsPastSimMS(5) then
   --Get a target.  Go for the closest actor within 500 pixels.
   if MovableMan:IsActor(self.target) == false then
       local curdist = 500;
       for actor in MovableMan.Actors do
      local avgx = actor.Pos.X - self.Pos.X;
      local avgy = actor.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist and actor.Team ~= self.Team then
          curdist = dist;
          self.target = actor;
      end
       end
   end

   --If the target still exists...
   if MovableMan:IsActor(self.target) then
       --The direction from the center of the missile to the target.
       local targetdir = math.atan2(-(self.target.Pos.Y-self.Pos.Y),(self.target.Pos.X-self.Pos.X));


       if targetdir ~= self.Vel.AbsDegAngle then
      self.Vel.DegRotate(targetdir - self.Vel.AbsDegAngle);
       end



   end
    end
end


Why does it not work?


Sun May 17, 2009 1:02 am
Profile
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Homing gatling trouble
Protip: do not post huge amounts of code, upload the .ini instead.
Will take a at the code now...


Sun May 17, 2009 1:05 am
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Homing gatling trouble
You're trying to rotate MOPixels, and then expecting them to travel toward your enemy. It's not going to work. Use the .lua from this thread (minimissile2.rar) instead. It does not require your projectile to be an AEmitter.


Sun May 17, 2009 1:21 am
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Homing gatling trouble
Read the .lua, it doesn't rotate the particle, it rotates its Vel vector.
Change targetdir = stuff line to
Code:
local targetdir = math.atan2(-(self.target.Pos.Y-self.Pos.Y),(self.target.Pos.X-self.Pos.X))*180/math.pi;

That converts targetdir from radians to degrees.


Sun May 17, 2009 10:52 am
Profile

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post Re: Homing gatling trouble
Not working, here is file:
Attachment:
Alfmod.zip [1.72 MiB]
Downloaded 160 times


Sun May 17, 2009 12:55 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Homing gatling trouble
alfie275 wrote:
Code:
self.Vel.DegRotate(targetdir - self.Vel.AbsDegAngle);

Ah, didn't see that, thought it was the facing. Hm, that's interesting, might prove useful...


Sun May 17, 2009 2:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: Google [Bot]


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.047s | 15 Queries | GZIP : Off ]