GetWeaponArray
Moderator: GZDoom Developers
GetWeaponArray
Or some similar function. Basically a way to get the class names of all the weapon actors loaded in the game. Could be good for compatibility of mods and such, I know I'd find it useful...
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: GetWeaponArray
There is a console command to get that info:
Code: Select all
dumpclasses (for all available classes)
dumpclasses weapon (for weapon classes)
Re: GetWeaponArray
The only problem is that ConsoleCommand was denied from ZDoom like three times already... so... Any alternatives?
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: GetWeaponArray
I don't understand. What do you mean by "denied"?
- Project Shadowcat
- Posts: 9369
- Joined: Thu Jul 14, 2005 8:33 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: Blacksburg, SC USA
- Contact:
Re: GetWeaponArray
ConsoleCommand is a Skulltag exclusive command.Blue Shadow wrote:I don't understand. What do you mean by "denied"?
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: GetWeaponArray
I checked the ConsoleCammand page on the wiki, now I get it. But regardless, all you have to do is drop the console and type the command (dumpclasses weapon) and you get the list of weapons. It's not a rocket science. 
Re: GetWeaponArray
...Uhhh, I need to be able to use those strings in a SCRIPT, you know, for a MOD. I don't just want to know for the sake of knowing...
Re: GetWeaponArray
Caps not required. Words were meaningful on their own. Severe underestimation is not welcome.
I would be surprised if this feature were added. All weapon classes must be registered at load-time, in an array accessible by an ACS-function. The most convenient data to store in the array might be the NAME (zdoom-specific string with unique integer ID) as an integer. The ACS-function returns the name, and print/strparam with a feature that has been submitted for consideration (http://forum.zdoom.org/viewtopic.php?f=34&t=30806) could be used to extract a string for ACS. For the string to have any utility it must be processed through the STRPARAM-function.
So -
New ACS function: int GameWeaponCount(): returns the number of weapon classes registered
New ACS function: int GameWeaponName(int index): returns the INT that can be evaluated to a weapon's classname
Submitted ACS extension: print/strparam(g:name_int): print name-int as string
Give random weapon:
GiveIventory( STRPARAM(g: GameWeaponName( random(0, GameWeaponCount()-1) ) ), 1);
Other concerns about the suggestion:
Why not extend it to all inventory objects? (Possibly accessing them through separate functions according to category)
You could have categories on base-classes: WeaponPickup (all inherited from weaon), HealthPickup (all inherited from health), AmmoPickup (all...), Pickup (any other pickup)
How to avoid giving things that should not be given?
The sigil in strife, and weapons used for non-military purposes, such as triggering or executing a cutscene / event. How not to hand them out? (More relevant notion of item that must not be given: A single class serving only as parent to 5 or 10 other classes, designed never to come into play itself).
Anything that would not be given by GIVE ALL (CCMD) should be filtered out of these arrays, as it is implied that randomly acquiring this is not good for gameplay.
Additionally, inventory might require an extra property or declaration element, to exclude it from the array.
If we choose only to support actors defined in decorate at this point, it is probably quite doable, and I have sometimes wanted something like this, as I tire easily of writing tables of weapon-names and finding them absent in other mods. However, when combining mods, you might in gameplay end up with only weapons from one of the mods, if they both replace the same spawning objects; but actor definitions from both mods will exist, meaning this feature will draw on definitions that do probably not suit the rest of the feature-set.
I would be surprised if this feature were added. All weapon classes must be registered at load-time, in an array accessible by an ACS-function. The most convenient data to store in the array might be the NAME (zdoom-specific string with unique integer ID) as an integer. The ACS-function returns the name, and print/strparam with a feature that has been submitted for consideration (http://forum.zdoom.org/viewtopic.php?f=34&t=30806) could be used to extract a string for ACS. For the string to have any utility it must be processed through the STRPARAM-function.
So -
New ACS function: int GameWeaponCount(): returns the number of weapon classes registered
New ACS function: int GameWeaponName(int index): returns the INT that can be evaluated to a weapon's classname
Submitted ACS extension: print/strparam(g:name_int): print name-int as string
Give random weapon:
GiveIventory( STRPARAM(g: GameWeaponName( random(0, GameWeaponCount()-1) ) ), 1);
Other concerns about the suggestion:
Why not extend it to all inventory objects? (Possibly accessing them through separate functions according to category)
You could have categories on base-classes: WeaponPickup (all inherited from weaon), HealthPickup (all inherited from health), AmmoPickup (all...), Pickup (any other pickup)
How to avoid giving things that should not be given?
The sigil in strife, and weapons used for non-military purposes, such as triggering or executing a cutscene / event. How not to hand them out? (More relevant notion of item that must not be given: A single class serving only as parent to 5 or 10 other classes, designed never to come into play itself).
Anything that would not be given by GIVE ALL (CCMD) should be filtered out of these arrays, as it is implied that randomly acquiring this is not good for gameplay.
Additionally, inventory might require an extra property or declaration element, to exclude it from the array.
If we choose only to support actors defined in decorate at this point, it is probably quite doable, and I have sometimes wanted something like this, as I tire easily of writing tables of weapon-names and finding them absent in other mods. However, when combining mods, you might in gameplay end up with only weapons from one of the mods, if they both replace the same spawning objects; but actor definitions from both mods will exist, meaning this feature will draw on definitions that do probably not suit the rest of the feature-set.
Re: GetWeaponArray
There is already a class called [wiki=Classes:HealthPickup]HealthPickup[/wiki], and it's not the same as [wiki=Classes:Health]Health[/wiki].
-
Blzut3
-

- Posts: 3219
- Joined: Wed Nov 24, 2004 12:59 pm
- Operating System Version (Optional): Kubuntu
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Contact:
Re: GetWeaponArray
Really this is an over complication of things. I think all that P1ayer27 needs is for a function which returns true/false if the actor exists: bool FindActor(str classname);FDARI wrote:Stuff
Re: GetWeaponArray
Gez: I didn't mean for the ACS-functions to name the base classes, but to be tied to specific base classes; however, I was also not aware of the HealthPickup-class. If the feature is at all relevant, that might be too.
Blzut3: The original request is for an array of all weapon classes. You could conceptually determine this by testing all strings for a subset that represents available weapons. However, this would require infinity * something operations to return an already known quantity. Even "stuff" is better than that.
Basic needs outlined: A finite list of existing weapon classes, and a way to access it from ACS.
Suggested implementation: One function to find upper bound. Lower bound 0. One function to retrieve an entry within these bounds, returning null-name for out-of-bounds requests.
Also: The concerns that give CHEATNOTWEAPON a reason to live, also apply to most plausible uses of this array. (Generic weapon-table lookup.) I suggest that such arrays should be limited at least to types provided by "give all".
Blzut3: The original request is for an array of all weapon classes. You could conceptually determine this by testing all strings for a subset that represents available weapons. However, this would require infinity * something operations to return an already known quantity. Even "stuff" is better than that.
Basic needs outlined: A finite list of existing weapon classes, and a way to access it from ACS.
Suggested implementation: One function to find upper bound. Lower bound 0. One function to retrieve an entry within these bounds, returning null-name for out-of-bounds requests.
Also: The concerns that give CHEATNOTWEAPON a reason to live, also apply to most plausible uses of this array. (Generic weapon-table lookup.) I suggest that such arrays should be limited at least to types provided by "give all".
Re: GetWeaponArray
Just saying it might be confusing if HealthPickup means something in DECORATE and something else in ACS.
Actually I'd use actor names rather than keywords. More extensible this way. You want to populate an array with weapon names? Then use "Weapon" as the parameter. You want to populate it with FighterWeapon names? Use "FighterWeapon". Ammo? Use "Ammo". And so on.
Actually I'd use actor names rather than keywords. More extensible this way. You want to populate an array with weapon names? Then use "Weapon" as the parameter. You want to populate it with FighterWeapon names? Use "FighterWeapon". Ammo? Use "Ammo". And so on.
Re: GetWeaponArray
You may be onto something, but I don't fully understand it.
It looks a bit like:
int CountSubclasses(str parent_class): returning number of subclasses in a quasi-array (possbly only including classes given by GIVE ALL)
int GetSubclassName(str parent_class, int subclass): returning unique name-representing integer from the corresponding quasi-arraySuggested code for spawning a random weapon. It requires a way for ACS to make strings of zdoom-class-names (g: in print/strparam), which is part of another feature suggestion (code submitted).
It looks a bit like:
int CountSubclasses(str parent_class): returning number of subclasses in a quasi-array (possbly only including classes given by GIVE ALL)
int GetSubclassName(str parent_class, int subclass): returning unique name-representing integer from the corresponding quasi-array
Code: Select all
int arr_len = CountSubclasses("Weapon") ;
int class_name = GetSubclassName("Weapon", random(0, arr_len - 1) );
Spawn( STRPARAM(g:class_name), ... );