[Not a bug] CheckWeapon works from 'puke' but not from Pain state

Bugs that have been investigated and resolved somehow.

Moderator: Developers

CheckWeapon works from 'puke' but not from Pain state

Postby SPZ1 » Sun Sep 09, 2018 7: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 allExpand view
#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!");
   }
}
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

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

Postby Blue Shadow » Sun Sep 09, 2018 9: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.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010

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

Postby SPZ1 » Mon Sep 10, 2018 9:03 am

Is there any way to check from the player ?
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

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

Postby SPZ1 » Mon Sep 10, 2018 11: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 !!
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

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

Postby Graf Zahl » Mon Sep 10, 2018 12:31 pm

All this hackery wouldn't be necessary if you used the proper features (i.e. ZScript.)
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby SPZ1 » Mon Sep 10, 2018 8: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? :?
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

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

Postby Arctangent » Mon Sep 10, 2018 10: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.
User avatar
Arctangent
squawky
 
Joined: 06 Nov 2014
Discord: SquawkyAtan#2371

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

Postby Graf Zahl » Tue Sep 11, 2018 1: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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 1 guest