Author Topic: Chaining attacks  (Read 3141 times)

defaultplayer

  • Visitor
  • *
  • Posts: 6
    • View Profile
Chaining attacks
« on: 2006-07-15, 02:28:48 PM »
Not sure if this should be in scripting or not.  I'm looking for a sample game that allows a player to do the 'ol 3 hit combo.  I'm currently working on a small project with some other folks, and we thought it would be cool if the player had normal, power, and combo attacks.  The combo would be activated by pressing the attack button 3 times within a time limit.  It's pretty much just like the old school brawler games.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Chaining attacks
« Reply #1 on: 2006-07-15, 06:28:13 PM »
This could be done either with or without script, but I would just recommend script simply because inventory is not really meant to be used as a regular variable.  Either way, you would have to simply set a variable that would decrease each frame (either with a special function that subtracts one from inventory or just subtract one during OnAfterMoveSprites, or whenever you choose) that get's set to, for example, 60 under the following conditions:  It is currently equal to 0 and the player has pressed attack.  Then, if they player presses attack again, keep track of that (with a boolean variable or a different inventory item).  Then, if they press attack and the first variable is greater than 0 and the second variable is also greater than 0 (i.e. true) execute the combo and reset both of the counters.  When subtracting from the first inventory, check to see if it's 0.  If it is, set the second (the boolean) to 0 as well.
Edward Dassmesser

defaultplayer

  • Visitor
  • *
  • Posts: 6
    • View Profile
Re: Chaining attacks
« Reply #2 on: 2006-07-16, 08:56:00 AM »
Let me make sure I'm understanding this.  For a jab, jab, uppercut the pseudocode would be something like this:

timer=60  ;with timer decreasing every frame or onMove or whatever
attackIndex=0  ;keeps track of how many times attack has been pressed

If Player attacks AND attackIndex==0
    Use attack 1
    attackIndex++
    start timer
Else If Player attacks AND attackIndex==1
     Use attack 1
     attackIndex++
Else If Player attacks AND attackIndex==2 AND timer>0
     Use attack 2
     attackIndex=0
     timer=0

Sorry about the sloppy code.  I haven't programmed in a while, and I'm still learning VBscript.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Chaining attacks
« Reply #3 on: 2006-07-16, 02:16:02 PM »
That would work well, yes.
Edward Dassmesser