ACS Question - Can I get a property from a weapon?

Discuss all aspects of editing for ZDoom.
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

ACS Question - Can I get a property from a weapon?

Postby obscuritan » Sat Dec 17, 2016 4:46 am

I'm trying to use a bit of ACS to check the ammo type of an item. Ideally I would like a function like this:
Code: Select allExpand view
function str GetWeaponAmmoType(str weaponType)
{
// Check that the weapon exists, and complain about it if it doesn't.
// Return the Weapon.AmmoType property from the weapon specified in the argument
}


The idea is that GetWeaponAmmoType("Chaingun") would return "Bullets" or whatever the correct string is.

I've looked around the wiki and can't find anything that might help with this. Sorry if I have asked in the wrong place - I am very new to Doom modding.
obscuritan
 
Joined: 17 Dec 2016

Re: ACS Question - Can I get a property from a weapon?

Postby TechnoDoomed1 » Sat Dec 17, 2016 9:29 am

There's no such functionality that I'm aware of. You could store a mapping weapon --> ammo in an array, and then create a function that uses it to satisfy your needs.

Code: Select allExpand view
#define WEAPON_PISTOL 0
#define WEAPON_SHOTGUN 1
#define WEAPON_SUPERSHOTGUN 2
#define WEAPON_CHAINGUN 3
#define WEAPON_ROCKETLAUNCHER 4
#define WEAPON_PLASMARIFLE 5
#define WEAPON_BFG9000 6

#define WEAPON_MIN_VALUE 0
#define WEAPON_MAX_VALUE 6

str Ammo = {"Clip", "Shell", "Shell", "Clip", "RocketAmmo", "Cell", "Cell"};

function str GetWeaponAmmoType (int weapon) {
    if (weapon < WEAPON_MIN_VALUE || weapon > WEAPON_MAX_VALUE) {
        print(s:"This weapon code does not exist.");
    }
    else{
        return Ammo[weapon];
    }
}

Not perfect, since you have to refer to each weapon by its define'd constant number (and not its name), but otherwise follows your criteria.
TechnoDoomed1
 
Joined: 29 Jul 2016
Location: Spain

Re: ACS Question - Can I get a property from a weapon?

Postby obscuritan » Sat Dec 17, 2016 7:29 pm

Thanks for the reply - The code I'm working on has a list of weapons already, so I guess I'll just manually add the ammo types as you said.
obscuritan
 
Joined: 17 Dec 2016


Return to Editing (Archive)

Who is online

Users browsing this forum: honeypony and 2 guests