Page 1 of 1

Trying to make the player roll, but it doesnt works

Posted: Wed May 18, 2016 8:00 pm
by Lord_of_D:
Im trying to make the player roll when he has a certain ammount of ammo(which regenerates automatically) and he presses a key button, however by some reason that i cant decipher it doesnt works, this is all the coding i have atm:

DECORATE

Code: Select all

States
  {
  Spawn:
	PLA1 B -1
	PLA1 B 0 A_JumpifInventory("RollLeftInv",1,"RollLeft")
	PLA1 B 0 A_JumpifInventory("RollRightInv",1,"RollRight")
	loop
  RollLeft:
	//TNT1 A 0 A_JumpIf("DodgeAmmo"<100, "CancelRoll")
	TNT1 A 0 A_ChangeFlag ("NOPAIN", 1)
	PRAL A 0 A_TakeInventory("RollLeftInv")
	PRAL A 0 A_TakeInventory("RollRightInv")
	PRAL A 0 ThrustThing(angle*256/360+64, 30, 0, 0)
	PRAL ABCDE 4
	TNT1 A 0 A_ChangeFlag ("NOPAIN", 0)
	PRAL A 0 A_TakeInventory("RollLeftInv")
	PRAL A 0 A_TakeInventory("RollRightInv")
	PRAL A 0 A_TakeInventory("DodgeAmmo",100)
	Goto Spawn
  RollRight:
	//TNT1 A 0 A_JumpIf("DodgeAmmo" < 100, "CancelRoll")
	TNT1 A 0 A_ChangeFlag ("NOPAIN", 1)
	PRAL A 0 A_TakeInventory("RollLeftInv")
	PRAL A 0 A_TakeInventory("RollRightInv")
	PRAL A 0 ThrustThing(angle*256/360+192, 30, 0, 0)
	PRAL EDBCA 4
	TNT1 A 0 A_ChangeFlag ("NOPAIN", 0)
	PRAL A 0 A_TakeInventory("RollLeftInv")
	PRAL A 0 A_TakeInventory("RollRightInv")
	PRAL A 0 A_TakeInventory("DodgeAmmo",100)
	Goto Spawn
  CancelRoll:
	TNT1 A 0 A_TakeInventory("RollLeftInv")
	TNT1 A 0 A_TakeInventory("RollRightInv")
	Goto Spawn
KEYCONF

Code: Select all

addmenukey "Roll Left" roleft
alias roleft "puke 500"
defaultbind Z roleft

addmenukey "Roll Right" roright
alias roright "puke 501"
defaultbind C roright
ACS

Code: Select all

#library "commands"
#include "zcommon.acs"

Script 500 (VOID) NET
{
	GiveInventory("RollLeftInv", 1);
}

Script 501 (VOID) NET
{
	GiveInventory("RollRightInv", 1);
}
any idea on how to solve this? im trying first to make it work before putting the ammo requirement

Re: Trying to make the player roll, but it doesnt works

Posted: Wed May 18, 2016 8:48 pm
by FascistCat
Until someone with better knowledge arrives, why don't you try inserting another state called 'CheckRoll' and go into it from the 'Spawn' state? That way you don't loop in the Spawn state. Or try inserting a 1 tic frame duration in the loop. Also this: http://zdoom.org/wiki/Actor_states (check Flow control and -1 duration frames)

Re: Trying to make the player roll, but it doesnt works

Posted: Wed May 18, 2016 9:20 pm
by Sean
You have a PLA1 B -1 frame in your Spawn state. IIRC -1 means the state lasts forever.

Re: Trying to make the player roll, but it doesnt works

Posted: Wed May 18, 2016 10:20 pm
by Lord_of_D:
ok, i made it work, that part of the -1 was the problem, so i changed both jumps from the state "Spawn" to "See" and now they work, however im trying to make the conditional, and it doesnt works:

Code: Select all

#library "commands"
#include "zcommon.acs"

Script 500 (VOID) NET
{
	If(CheckInventory("DodgeAmmo" >= 100))
	{
		GiveInventory("RollLeftInv", 1);
	}
}

Script 501 (VOID) NET
{
	If(CheckInventory("DodgeAmmo" >= 100))
	{
		GiveInventory("RollRightInv", 1);
	}
}

Re: Trying to make the player roll, but it doesnt works

Posted: Fri May 20, 2016 10:12 pm
by SwordGrunt
CheckInventory returns the amount of the specified inventory item

(CheckInventory("DodgeAmmo" >= 100)) doesn't work as you expected it to since you're using a comparison operator as if it was a math operator

Try changing it to (CheckInventory("DodgeAmmo") >= 100)