CheckWeapon works from 'puke' but not from Pain state

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
SPZ1
Posts: 244
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois
Contact:

CheckWeapon works from 'puke' but not from Pain state

Post by SPZ1 »

Pretty much what happens here is that when you hit the artifact with the "ExorSword" it is supposed to say "TRUE!" but it doesn't! It is strange though that if you "Puke 2" in the console it works correctly. I cannot figure out this behavior! :bang:

Apparently, I have hit the board attachment limit so here is a link to the demo file:

https://1drv.ms/u/s!Ap4KZFMds2L1hCsrgX0_Ikh52mdj

EDIT: Sorry guys forgot to include the ACS code:

Code: Select all

#include "include/zcommon.acs"

script 1 ENTER {
	ClearInventory();
	GiveInventory("MageSword", 1);
	GiveInventory("ExorSword", 1);
	
}

script 2 (void) {
	if (CheckWeapon("ExorSword")){
		PrintBold(s:"TRUE!");
	} else {
		PrintBold(s:"FALSE!");
	}
}
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: CheckWeapon works from 'puke' but not from Pain state

Post by Blue Shadow »

When the script is run from the Pain state of this "artifact" actor, it itself is the activator of the script, and so, the check for the weapon is performed on it, not the player. When you run the script from the console via the puke command, the player is the activator, so the check is performed on the player.
User avatar
SPZ1
Posts: 244
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois
Contact:

Re: CheckWeapon works from 'puke' but not from Pain state

Post by SPZ1 »

Is there any way to check from the player ?
User avatar
SPZ1
Posts: 244
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois
Contact:

Re: CheckWeapon works from 'puke' but not from Pain state

Post by SPZ1 »

Well everybody,
I have found a way around this issue so that a weapon can be checked seemingly from a ACTOR's pain state!

1. You are going to need a custom player class so you can define a custom state (I used PrintWeapon: )
2. You are going to need to have an ACS library or script defined for the map you are currently in
3. When the ACTOR you are striking goes into the pain state, it activates a script
4. The script changes the player class's current state (use SetActorState) into PrintWeapon:
5. PrintWeapon uses another script (from within the player class) and can sucessfully check the player's weapon !!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CheckWeapon works from 'puke' but not from Pain state

Post by Graf Zahl »

All this hackery wouldn't be necessary if you used the proper features (i.e. ZScript.)
User avatar
SPZ1
Posts: 244
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois
Contact:

Re: CheckWeapon works from 'puke' but not from Pain state

Post by SPZ1 »

I looked at the ZScript action functions page in the wiki but I only see functions to check the inventory and not the currently active weapon. Could you shed some light on your mysterious statement? :?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: CheckWeapon works from 'puke' but not from Pain state

Post by Arctangent »

You don't need an action function for that at all. You can access a player's weapon through the ReadyWeapon variable in their PlayerInfo, which itself is accessible through the player variable of any actor they control ( usually just their current PlayerPawn, though ).

With ZScript, you should get used to digging through the source files either via GitHub or by extracting them from gzdoom.pk3 - there is no telling how much will get added to the wiki even if someone spectacularly committed decides to add as much as they can to it, because there's some stuff that is vitally important to look up or understand to do some things but is otherwise completely irrelevant for 99% of users. If you feel like something should be on there, though, feel free to toss it up yourself; the entire point of a wiki is to allow community members to update and expand it whenever they want, after all.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CheckWeapon works from 'puke' but not from Pain state

Post by Graf Zahl »

Arctangent wrote: With ZScript, you should get used to digging through the source files either via GitHub or by extracting them from gzdoom.pk3
It should be noted here that this applies to all forms of programming: Documentation can only be a part of it, to really understand things you'll have to dig through example code to see how it all has to be used.

As an example, just have a look at Apple's API docxs. To call them minimalist would be some major understatement, it's virtually impossible to deduce their use just from the docs. Without the multitudes of examples and tutorials floating around on the internet it'd be a hopeless undertaking to develop for the platform.
Post Reply

Return to “Closed Bugs [GZDoom]”