Advertisement
IronBanes

Untitled

Dec 21st, 2022
1,890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var current = state_machine.get_current_node()
  2.  
  3.     velocity.y += _gravity
  4.     if velocity.y > MAXFALLSPEED:
  5.         velocity.y = MAXFALLSPEED
  6.     elif velocity.y > 0:
  7.         state_machine.travel("fall 2")
  8.     else:
  9.         if sworddrawn && current == "idle":
  10.             state_machine.travel("idle-2")
  11.  
  12.     if Input.is_action_just_pressed("Light Attack"):
  13.         if (current == "idle-2" || current == "walk 2"):
  14.             state_machine.travel(attacks[randi()%2])
  15.             return
  16.         elif current == "idle":
  17.             state_machine.travel("punch")
  18.             return
  19.         elif current == "walk":
  20.             state_machine.travel("run-punch")
  21.             return
  22.  
  23.     if Input.is_action_just_pressed("Heavy Attack"):
  24.         if (current == "idle-2" || current == "walk 2"):
  25.             state_machine.travel("attack1")
  26.             return
  27.         elif current == "idle":
  28.             state_machine.travel("kick")
  29.             return
  30.  
  31.     if Input.is_action_just_pressed("Draw Sword Sheathe Sword"):
  32.  
  33.         if sworddrawn:
  34.             state_machine.travel("idle")
  35.             sworddrawn = false
  36.  
  37.         elif !sworddrawn:
  38.             state_machine.travel("idle-2")
  39.             sworddrawn = true
  40.  
  41.     if is_on_floor:
  42.         if Input.is_action_pressed("move_right"):
  43.  
  44.             if sworddrawn:
  45.                 state_machine.travel("walk 2")
  46.  
  47.             if not sworddrawn:
  48.                 state_machine.travel("walk")
  49.  
  50.             velocity.x = MAXSPEED
  51.             $Sprite.scale.x = 1
  52.  
  53.         elif Input.is_action_pressed("move_left"):
  54.  
  55.             if sworddrawn:
  56.                 state_machine.travel("walk 2")
  57.  
  58.             if not sworddrawn:
  59.                 state_machine.travel("walk")
  60.  
  61.             velocity.x = -MAXSPEED
  62.             $Sprite.scale.x = -1
  63.  
  64.         else:
  65.             velocity.x = 0
  66.             if sworddrawn:
  67.                 state_machine.travel("idle-2")
  68.             elif not sworddrawn:
  69.                 state_machine.travel("idle")
  70.  
  71.         if Input.is_action_just_pressed("jump"):
  72.             state_machine.travel("jump")
  73.             velocity.y = -JUMPFORCE
  74.  
  75.  
  76.     if Input.is_action_pressed("move_right"):
  77.         velocity.x = MAXSPEED
  78.         $Sprite.scale.x = 1
  79.  
  80.     elif Input.is_action_pressed("move_left"):
  81.         velocity.x = -MAXSPEED
  82.         $Sprite.scale.x = -1
  83.  
  84.     else:
  85.         velocity.x = 0
  86.  
  87.  
  88.     velocity = move_and_slide(velocity,vector2.UP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement