I'm trying to write a script that shows jumping sprites when the player presses the jump button. I'm pretty sure it was working fine originally but then I changed some other stuff in the player decorate file and later on noticed it wasn't working properly. The sprites are supposed to show as soon as the jump button is pressed, while the player is going up into the air. I then use a_jumpif(momz < 0, "falling") to show the jump sprite when falling back down or dropping from a ledge.
It seems that my script just doesn't work at all so Doomguy jumps into the air looking stiff but falls back down showing the correct falling sprites.
Here is the jump script:
Code: Select all
#include "zcommon.acs"
#define JUMP_ITEM "isJumping"
#define PLAYER_TID 1000
script 1 ENTER
{
Thing_ChangeTID(0, PLAYER_TID); // Assign TID if needed
while (true)
{
// Check if player is pressing jump
if (GetPlayerInput(-1, INPUT_BUTTONS) & BT_JUMP)
{
if (!CheckInventory(JUMP_ITEM))
{
GiveInventory(JUMP_ITEM, 1);
}
}
else
{
if (CheckInventory(JUMP_ITEM))
{
TakeInventory(JUMP_ITEM, 1);
}
}
Delay(1); // Run every tic
}
}
And here is the player decorate code:
Code: Select all
actor Doomguy : PlayerPawn replaces Doomplayer
{
Health 100
Radius 16
Height 56
Player.AttackZOffset 8
Player.JumpZ 8
Player.ViewHeight 41
Player.ForwardMove 1.1
Player.SideMove 1.1
Player.ColorRange 112, 127
Player.SoundClass "player"
Player.DisplayName "Marine"
Player.CrouchSprite "PLYC"
Player.StartItem "SmoothPistol"
Player.StartItem "Fist"
Player.StartItem "Clip", 50
States
{
Spawn:
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY A 1
Goto StandStill
StandStill:
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY A 1
Loop
See:
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY A 4
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY B 4
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY C 4
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY D 4
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
Loop
Jumping:
PJMP A 4
TNT1 A 0 A_JumpIf(momz > 0, "Falling")
Goto StandStill
Falling:
PJMP A 4
Goto StandStill
Missile:
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY E 12
Goto Spawn
MoveShoot:
POSS ABCD 4
Goto See
Melee:
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY F 6 BRIGHT
Goto Missile
Pain:
TNT1 A 0 A_JumpIf(momz < 0, "Falling")
TNT1 A 0 A_JumpIfInventory("isJumping", 1, "Jumping")
PLAY G 4
PLAY G 4 A_Pain
Goto Spawn
Death:
PLAY H 10 A_PlayerSkinCheck("AltSkinDeath")
PLAY I 10 A_PlayerScream
PLAY J 10 A_NoBlocking
PLAY KLM 10
PLAY N -1
Stop
XDeath:
PLAY O 5 A_PlayerSkinCheck("AltSkinXDeath")
PLAY P 5 A_XScream
PLAY Q 5 A_NoBlocking
PLAY RSTUV 5
PLAY W -1
Stop
AltSkinDeath:
PLAY H 6
PLAY I 6 A_PlayerScream
PLAY JK 6
PLAY L 6 A_NoBlocking
PLAY MNO 6
PLAY P -1
Stop
AltSkinXDeath:
PLAY Q 5 A_PlayerScream
PLAY R 0 A_NoBlocking
PLAY R 5 A_SkullPop
PLAY STUVWX 5
PLAY Y -1
Stop
}
}
actor isJumping : Inventory
{
Inventory.MaxAmount 1
+INVENTORY.HUBPOWER
}