Author Topic: Fully Automatic Weapons  (Read 5243 times)

gila kid

  • Visitor
  • *
  • Posts: 4
    • View Profile
    • http://www.freewebs.com/public_coolness.htm
Fully Automatic Weapons
« on: 2005-03-22, 08:57:25 AM »
How do I script automatic weapons?
Could I use the old Sub Player_OnControllerMove(OldA, NewA)
can I use the oncontrollermove oldactions and newactions and button1 in a combinatoin to make a weapon fire fully automatic?? I use ctrl to shoot.
Thank You
Gila Kid
(Halo 2 Xbox Gamertag)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Fully Automatic Weapons
« Reply #1 on: 2005-03-22, 11:00:00 AM »
You can have it be fully automatic, however you will need to put in some sort of delay so that bullets aren't coming from the gun ~30 times a second. Unless that's what you want.

It would be something like

Code: [Select]
Dim delay, isShooting

Sub Player_OnControllerMove(OldActions, NewActions)
   if (Not OldActions) And NewActions And ACTION_BUTTON1 then
      isShooting = true
   elseif OldActions And (Not NewActions) And ACTION_BUTTON1 then
      isShooting = false
   end if

   'Shooting code does not go here
End Sub

Sub Player_OnAfterMoveSprites()
   delay = delay + 1
   if delay >= 10 then    '10 makes it approximately 3 times a second (30 frames per second, divided by 10 frames = 3)
      if isShooting then
         'Put code here to shoot bullet
      end if
      delay = 0
   end if
   'Rest of the function that already exists goes here
End Sub
Edward Dassmesser

gila

  • Guest
Fully Automatic Weapons
« Reply #2 on: 2005-03-22, 02:16:07 PM »
Thank You! Why didn't I think of that?? Its so simple. Geese. I must be slow today.
I guess the OldActions and  (Not NewActions) is like saying "If the player is NOT doing something new and holding button1, then dont shoot anything. Can you explain that part a little more? Am I right?
The delay must slow it down just by calculation? I thought that It would be ran so fast that a small calc like that will not make a difference in game speed.

Thank You

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Scripting wizard
« Reply #3 on: 2005-03-22, 08:01:40 PM »
The scripting wizard has this built in!

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Fully Automatic Weapons
« Reply #4 on: 2005-03-23, 12:25:41 AM »
I thought it was in the scripting wizard, but since I don't have it where I am, I just came up with my own interpretation of how to do it.

As for slowing it down, no, it doesn't actually slow the game down, but it only shoots once every ten frames instead of once every frame with the way this works (because "delay" is increased once every frame, and if it's equal to ten, then shoot).

--Edit--

Oh, and to explain the OldActions And (Not NewActions) And ActionButton1, that's basically saying if they just stopped pressing the fire button.  (ActionButton1 was part of OldActions, and Not part of NewActions)
Edward Dassmesser

Gila

  • Guest
Fully Automatic Weapons
« Reply #5 on: 2005-03-23, 08:44:17 AM »
I realize it has it built in. I would like to learn the source code though. I found it rather easy to write my own shooting script. Its quite simplier in size to. (Of course it only has left right direction).