CheckWeapon works from 'puke' but not from Pain state

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: CheckWeapon works from 'puke' but not from Pain state

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

by Graf Zahl » Tue Sep 11, 2018 12:13 am

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.

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

by Arctangent » Mon Sep 10, 2018 9:37 pm

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.

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

by SPZ1 » Mon Sep 10, 2018 7:16 pm

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? :?

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

by Graf Zahl » Mon Sep 10, 2018 11:31 am

All this hackery wouldn't be necessary if you used the proper features (i.e. ZScript.)

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

by SPZ1 » Mon Sep 10, 2018 10:44 am

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 !!

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

by SPZ1 » Mon Sep 10, 2018 8:03 am

Is there any way to check from the player ?

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

by Blue Shadow » Sun Sep 09, 2018 8:35 pm

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.

CheckWeapon works from 'puke' but not from Pain state

by SPZ1 » Sun Sep 09, 2018 6:03 pm

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

Top