Game crashes when executing an script from decorate

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:

Game crashes when executing an script from decorate

#1

Post by Lord_of_D: » Wed Dec 07, 2016 7:56 pm

An icon is supposed to be shown on the hud displaying if the player has an item or not(This is so it can be shown too on chasecam mode), however when the player pickups an item that gives a random item which is supposed to be displayed on the hud the game freezes for a momment and then crashes, can somebody help me out?

Code: Select all

Actor RandomItem : Ammo 10000
{
	Radius 64
	Height 64
	Inventory.PickupMessage "You got a Random Item!"
	Inventory.PickupSound "ITEMBOX1"
	Inventory.Amount 1
	Inventory.MaxAmount 1
	+MOVEWITHSECTOR
	States
	{
	Spawn:
		ITEM ABCDEFGHIJKLMNOP 4 Bright
		Loop
	Pickup:
		TNT1 A 0
		Stop
	}
}


Actor Player : DoomPlayer
{
	...
	
	States
	{
	...
	Stay:
		...
		TNT1 A 0 A_JumpifInventory("RandomItem",1,"GiveItem")
		...
	GiveItem:
		TNT1 A 0 A_JumpifInventory("CheckItem",1,"Stay")
		TNT1 A 0 A_GiveInventory("CheckItem",1)
		TNT1 A 0 ACS_ExecuteAlways(602,0)
		Goto Stay

Code: Select all

#library "HUDICONS"
#include "zcommon.acs"

Script 600 Enter
{
		SetFont("ITMEMPTY");
		HudMessage(s:"A"; HUDMSG_Plain, PlayerNumber(), 0 , 0.5, 0.1, 0);
}

Script 601 (Void)
{
		SetFont("ITMEMPTY");
		HudMessage(s:"A"; HUDMSG_Plain, PlayerNumber(), 0 , 0.5, 0.1, 0);
}

Script 602 (void)
{
	int Check = Random(1,2);
	if(Check == 1){
		GiveInventory("GreenSkullAmmo",1);
		SetFont("ITMGSKUL");
		HudMessage(s:"A"; HUDMSG_Plain, PlayerNumber(), 0 , 0.5, 0.1, 0);
	}
	if(Check == 2){
		GiveInventory("RedSkullAmmo",1);
		SetFont("ITMRSKUL");
		HudMessage(s:"A"; HUDMSG_Plain, PlayerNumber(), 0 , 0.5, 0.1, 0);
	}

}

User avatar
Ænima
Addicted to Zandronum
Posts: 3582
Joined: Tue Jun 05, 2012 6:12 pm

Re: Game crashes when executing an script from decorate

#2

Post by Ænima » Wed Dec 07, 2016 8:13 pm

The ACS looks fine.

Is there a zero-tic infinite loop in the "Stay:" state? I can't tell because you didn't post the full code.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

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

Re: Game crashes when executing an script from decorate

#3

Post by Lord_of_D: » Wed Dec 07, 2016 8:59 pm

Ænima wrote:The ACS looks fine.

Is there a zero-tic infinite loop in the "Stay:" state? I can't tell because you didn't post the full code.
there isnt, theres a single state of "1", everything else are multiple states that play a sound or jump to another state, but the jump to GiveItem is almost at the beginning of the state, maybe thats what causing this crash:

Code: Select all

Stay:
		DSLY A 0 Healthing(100)
		TNT1 A 0 A_JumpifInventory("RandomItem",1,"GiveItem")
		TNT1 A 0 A_TakeInventory("BikeSpeed", 1)
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeft")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRight")
		TNT1 A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		TNT1 A 0 A_JumpIfInventory("Turbo", 1, "Accelerate")
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		DSLY A 1 SetPlayerProperty(1,1,4)
		TNT1 A 0 A_JumpIfInventory("TurnLeft", 1, "TurnLeft")
		TNT1 A 0 A_JumpIfInventory("TurnRight", 1, "TurnRight")
		TNT1 A 0 A_JumpIfInventory("BackPedal", 1, "BackPedal")
		TNT1 A 0 A_TakeInventory("MaxLeft", 1)
		TNT1 A 0 A_TakeInventory("MaxRight", 1)
		TNT1 A 0 A_JumpIfInventory("Accelerate", 1, "Accelerate")
		TNT1 A 0 A_PlaySound("KARTEFF1", 2, 1, 1)
		TNT1 A 0 A_TakeInventory("MaxLeft", 1)
		TNT1 A 0 A_TakeInventory("MaxRight", 1)
		Loop
edit: nope, it still crashes

User avatar
Combinebobnt
Retired Staff / Community Team Member
Posts: 1906
Joined: Mon Jun 04, 2012 3:37 am
Location: Earth
Contact:

Re: Game crashes when executing an script from decorate

#4

Post by Combinebobnt » Wed Dec 07, 2016 9:51 pm

What is the state of "CheckItem" before all of this? If it is already 1 such as when I guess you pick up 2 items, the two states will just loop back and forth forever. Make sure it gets taken/reset properly or whatever.

nice karts

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

Re: Game crashes when executing an script from decorate

#5

Post by Lord_of_D: » Wed Dec 07, 2016 10:12 pm

Combinebobnt wrote:What is the state of "CheckItem" before all of this? If it is already 1 such as when I guess you pick up 2 items, the two states will just loop back and forth forever. Make sure it gets taken/reset properly or whatever.
the "CheckItem" is just an inventory item that that im using to prevent that, and the max amount a player can have is 1, so the "2 items" problem wont happen, also i have in mind to discard the "CheckItem" once the weapon is used.

Code: Select all

Actor CheckItem : Inventory
{
	Inventory.MaxAmount 1
}

User avatar
Combinebobnt
Retired Staff / Community Team Member
Posts: 1906
Joined: Mon Jun 04, 2012 3:37 am
Location: Earth
Contact:

Re: Game crashes when executing an script from decorate

#6

Post by Combinebobnt » Wed Dec 07, 2016 11:06 pm

You misunderstood "2 items"; I mean that the first time you pick up the item, checkitem has a value of 1. The next time you pick it up, both a_jumps will trigger and there is an infinite loop (from what I can tell). Yes you definitely want to take it away or write the code different or whatever

Post Reply