Trying to make the player roll, but it doesnt works

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Lord_of_D:
Posts a lot
Posts: 691
Joined: Sun Aug 26, 2012 5:31 am
Location: Mexico
Contact:

Trying to make the player roll, but it doesnt works

#1

Post by Lord_of_D: » Wed May 18, 2016 8:00 pm

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

FascistCat
 
Posts: 98
Joined: Mon Jul 20, 2015 12:51 pm

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

#2

Post by FascistCat » Wed May 18, 2016 8:48 pm

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)

User avatar
Sean
IRC Operator
Posts: 982
Joined: Thu Jan 16, 2014 9:09 pm
Location: United Kingdom
Clan: Zandronum
Clan Tag: [Za]
Contact:

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

#3

Post by Sean » Wed May 18, 2016 9:20 pm

You have a PLA1 B -1 frame in your Spawn state. IIRC -1 means the state lasts forever.
<capodecima> i dont say any more word without my loyer jenova

User avatar
Lord_of_D:
Posts a lot
Posts: 691
Joined: Sun Aug 26, 2012 5:31 am
Location: Mexico
Contact:

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

#4

Post by Lord_of_D: » Wed May 18, 2016 10:20 pm

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);
	}
}

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

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

#5

Post by SwordGrunt » Fri May 20, 2016 10:12 pm

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)

Post Reply