GetWeaponArray

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: Developers

GetWeaponArray

Postby P1ayer27 » Mon Sep 26, 2011 9:24 pm

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...
P1ayer27
 
Joined: 14 Aug 2009

Re: GetWeaponArray

Postby Blue Shadow » Mon Sep 26, 2011 9:44 pm

There is a console command to get that info:

Code: Select allExpand view
dumpclasses             (for all available classes)
dumpclasses weapon      (for weapon classes)
User avatar
Blue Shadow
 
Joined: 14 Nov 2010

Re: GetWeaponArray

Postby P1ayer27 » Mon Sep 26, 2011 10:15 pm

The only problem is that ConsoleCommand was denied from ZDoom like three times already... so... Any alternatives?
P1ayer27
 
Joined: 14 Aug 2009

Re: GetWeaponArray

Postby Blue Shadow » Mon Sep 26, 2011 11:21 pm

I don't understand. What do you mean by "denied"?
User avatar
Blue Shadow
 
Joined: 14 Nov 2010

Re: GetWeaponArray

Postby Project Dark Fox » Tue Sep 27, 2011 12:29 am

Blue Shadow wrote:I don't understand. What do you mean by "denied"?

ConsoleCommand is a Skulltag exclusive command.
User avatar
Project Dark Fox
Nightmare Fuel Station Attendant
 
Joined: 14 Jul 2005
Location: The Gutter

Re: GetWeaponArray

Postby Blue Shadow » Tue Sep 27, 2011 1:14 am

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. :P
User avatar
Blue Shadow
 
Joined: 14 Nov 2010

Re: GetWeaponArray

Postby P1ayer27 » Tue Sep 27, 2011 1:17 am

...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...
P1ayer27
 
Joined: 14 Aug 2009

Re: GetWeaponArray

Postby FDARI » Tue Sep 27, 2011 3:10 am

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 (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.
User avatar
FDARI
Bronies eunt domus
 
Joined: 03 Nov 2009

Re: GetWeaponArray

Postby Gez » Tue Sep 27, 2011 3:58 am

There is already a class called HealthPickup, and it's not the same as Health.
Gez
 
Joined: 06 Jul 2007

Re: GetWeaponArray

Postby Blzut3 » Tue Sep 27, 2011 10:01 am

FDARI wrote:Stuff

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);
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: GetWeaponArray

Postby FDARI » Tue Sep 27, 2011 10:49 am

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".
User avatar
FDARI
Bronies eunt domus
 
Joined: 03 Nov 2009

Re: GetWeaponArray

Postby Gez » Tue Sep 27, 2011 3:15 pm

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.
Gez
 
Joined: 06 Jul 2007

Re: GetWeaponArray

Postby FDARI » Tue Sep 27, 2011 3:29 pm

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-array
Code: Select allExpand view
int arr_len = CountSubclasses("Weapon") ;
int class_name = GetSubclassName("Weapon", random(0, arr_len - 1) );

Spawn( STRPARAM(g:class_name), ... );
Suggested 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).
User avatar
FDARI
Bronies eunt domus
 
Joined: 03 Nov 2009


Return to Feature Suggestions

Who is online

Users browsing this forum: Bing [Bot] and 0 guests