OpenXcom Forum

Modding => Released Mods => XPiratez => Topic started by: darkestaxe on August 24, 2018, 06:55:18 am

Title: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 24, 2018, 06:55:18 am
I was looking into the idea of adding gear slot functionality into CE and while I think I've found the right part of the OXCE code, but then things got strange...

Is Piratez using a custom version of OXCE to add inventory layouts to armor types? And why/how are we using fixed weapons as inventory slots? If someone did add proper support for custom inventory layouts into OXCE ... would that even help piratez?

I mean what the flying tits is this?
Code: [Select]
armors:
  - type: STR_PIR_CASTAWAY_ARMOR_UC
    spriteSheet: PIR_489.PCK
    spriteInv: MAN_489
    builtInWeapons: // WAAAAAAHt?!?
      - INV_NULL_4X3
      - INV_NULL_2X1_LS
           ...
      - INV_NULL_1X2_QD //This built in weapon is the Quickdraw slot for this armor?
items:
  - type: INV_NULL_1X2_QD
    invWidth: 1
    invHeight: 2
    fixedWeapon: true
    defaultInventorySlot: STR_QD_SLOT //But where is STR_QD_SLOT defined?
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Solarius Scorch on August 24, 2018, 09:25:01 am
Built-in weapons are the vanillest vanilla. The only thing OXCE+ adds is forcing the item into a specific inventory slot.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Meridian on August 24, 2018, 10:50:28 am
//But where is STR_QD_SLOT defined?

This is also vanilla:

Code: [Select]
invs:
  - id: STR_QD_SLOT
    x: 176
    y: 104
    slots:
      - [0, 0]
      - [0, 1]
    costs:
      STR_BACK_PACK: 14
      STR_BELT: 8
      STR_GROUND: 5
      STR_LEFT_HAND: 3
      STR_LEFT_LEG: 10
      STR_LEFT_SHOULDER: 10
      STR_RIGHT_HAND: 3
      STR_RIGHT_LEG: 10
      STR_RIGHT_SHOULDER: 10
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Yankes on August 24, 2018, 12:31:52 pm
This was done because there is only one possible layout for inventory. Add more would made code lot time more complex.
Forcing fixed weapons in some defined slot was small hack that allow reuse normal item behavior to limit inventory space per armor.

and remember xpiratez use OXCE+ not OXCE, there are diffrences and if you look on OXCE you will miss some logic that was add to OXCE+
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 25, 2018, 09:26:58 am
Oh, ok I get it now. The fixed weapons in the armors are being used to plug unused inventory slots, and OXC already allowed u to define extra slots, and Piratez just put that in a different .rul somewhere.

So now we just need to figure out how to add a property to an item that limits which inventory sections it can be placed in, add a hook right where the game checks to see if the item fits and there are enough time units, input an extra check for whether the given item can be placed in said inventory slot, else inform user STR_ITEM_CANT_GO_HERE.

Quote from: Inventory.cpp
Code: [Select]
void Inventory::mouseClick(Action *action, State *state)
{
  ...
// Check if this inventory section supports the item
if (!_selItem->getRules()->canBePlacedIntoInventorySection(slot->getId()))
{
_warning->showMessage(_game->getLanguage()->getString("STR_CANNOT_PLACE_ITEM_INTO_THIS_SECTION"));
}
Quote from: RuleItem.cpp
Code: [Select]
/**
 * Checks if the item can be placed into a given inventory section.
 * @param inventorySection Name of the inventory section (RuleInventory->id).
 * @return True if the item can be placed into a given inventory section.
 */
bool RuleItem::canBePlacedIntoInventorySection(const std::string &inventorySection) const
{
// backwards-compatibility
if (_supportedInventorySections.empty())
return true;

// always possible to put an item on the ground
if (inventorySection == "STR_GROUND")
return true;

// otherwise check allowed inventory sections
return std::find(_supportedInventorySections.begin(), _supportedInventorySections.end(), inventorySection) != _supportedInventorySections.end();
}
Code: [Select]
/**
 * Loads the item from a YAML file.
 * @param node YAML node.
 * @param mod Mod for the item.
 * @param listOrder The list weight for this item.
 */
void RuleItem::load(const YAML::Node &node, Mod *mod, int listOrder, const ModScript& parsers)
_supportedInventorySections = node["supportedInventorySections"].as< std::vector<std::string> >(_supportedInventorySections);

OMFG it was there all along?!?!?!?! WTF
Quote from: MeridianOXC committed on Oct 31, 2016
Items can now be limited to certain inventory slots only

hahaha 2 years ago? WOW! NVM guys meridian already gone and done fixed it already. Guess the next project is making a mod for Piratez that adds the new slots and associated item requirements.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 27, 2018, 11:27:11 am
So now we just need to figure out how to add a property to an item that limits which inventory sections it can be placed in, add a hook right where the game checks to see if the item fits and there are enough time units, input an extra check for whether the given item can be placed in said inventory slot, else inform user STR_ITEM_CANT_GO_HERE.

For what purpose, pissing the player off?
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 27, 2018, 08:43:33 pm
For what purpose, pissing the player off?

No, my whole idea is that bras and towels should have their own dedicated inventory location. I had thought that was the intended idea with those 'gear' items in the first place. I thought the whole idea was that scarf equips to the neck slot like it says, and we only stick it in backpacks because OXC doesn't support a 'neck' slot for only neck slot items.

If I were to make a mod that shifted the standard equipment slots around and added dedicated gear holder slots, then I'd need a way to make those slots a place only for those items. Otherwise I'd just be adding a place to stick a Canteen o Wisdom or booze on nude armor. Aside from breaking balance, there still wouldn't be any way to justify equipping a scarf or towel.

Due to size concerns on the equip screen I don't think there's room for a neck, back, bra, legs each so they might have to share 1 or 2 slots, but at least they wouldn't just fill up your backpack.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 27, 2018, 09:13:30 pm
Yeah, now I get you. I had that idea too - basically making an equippable paperdoll for outfits, like in RPG games, but it's impossible with what we have. Although, maybe with clever scripting, or new code? The community needs dedicated coders, step up and make your dreams come true :)
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: KZad Bhat on August 28, 2018, 09:41:51 am
There is someone who did a mod to add a whole bunch of inventory slots, but I haven't checked it out to see if he managed to do it all through ruleset and art resources, if he had to do patch to the executable. If just by ruleset, it may only need some new exec code to add a condition for certain gear requirements.
Edit: I did find it here:
https://openxcom.org/forum/index.php/topic,4848.0.html (https://openxcom.org/forum/index.php/topic,4848.0.html)
It is done just by ruleset, but I'm guessing nothing new here for you really, Dioxine. It would be nice to add some restriction to extra slots for special equipment. Especially since with such you could actually have the Ushanka and shawl even while nude without letting people use the extra gear slots to sneak extra weapons they can't carry.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 28, 2018, 01:48:03 pm
I posted the remaining code to restrict by slot over in the extended+ forum so we'll just have to wait and see, unless someone wants to add a list of allowed slots to the ruleset for every single equipable item in all of Piratez.

In the meantime it's quite easy to add, remove, or rearrange equipment slots in the ruleset, so I went ahead and toyed with a proof of concept.

It works, sort-of, as seen in the first image, but it's basically just a couple more spots to put anything you want for now.

The bigger issue now, I think, is that many gear items are simply to large to make small slots for them. For my demo I used type 1 slots (holds 1 item of any size) which take up a lot of space. Hypothetically if we did use my layout, someone would need to go through all the soldier images and shift each one about 8 pixels over. That wouldn't be too difficult, but whoever had to do it might very well break down and just start crying after a few hundred of them. I wouldn't blame them.

A better solution might be to shrink the graphics for the gear items themselves, especially since many of them aren't all that big anyway. Also, as you can see in my images, the text on top of gear slots is optional, though I still don't really like the idea of putting brown boxes all over the beautiful outfit art.

A more ambitious implementation would be to add a 'hidden' option to gear slots as well as a 'behind' option. Hide the squares (more accurately, don't draw them) and let players seem to put the gear items directly on the soldier, with the back-slot items rendering behind (before) the soldier image. Then scale/edit gear items graphics to match the soldier image. That way when you put a bra on a gal, it looks like she's just wearing the bra. (Changes to render order might be more then Meridian would allow.)

As an added bonus it would look absolutely hilarious for a male slave wearing a bra over his superman outfit! As for the height difference there'd have to be 2 versions of some of the slots with one blocked off by fixed weapons, though the fakes could be transparent for slots that are already invisible.

If there's interest in my more ambitious idea, I'm game for attempting to figure out the CE+ code to make it work. Assuming it's not already there...
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 28, 2018, 03:44:17 pm
I am not aware of any code that lets you limit what can be carried in an inventory slot.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 29, 2018, 05:22:12 am
I am not aware of any code that lets you limit what can be carried in an inventory slot.

supportedInventorySections: on an item. That's the code I was showing earlier. I made an example that works with current OXCE+ for the last couple years.

https://openxcom.org/forum/index.php/topic,6543.0.html (https://openxcom.org/forum/index.php/topic,6543.0.html) - Thread where I posted code changes to add a property to the actual slot that limits default items with no supportedInventorySections: also.

Code: [Select]
#We can use the supportedInventorySections: parameter to limit an item to certian inventory locations.
#This has no effect on the ground, which is always allowed, and no effect on other items.
items:
  - type: STR_NOOSE
    #With everything listed except QD, we block the rope from the QD slot.
    supportedInventorySections:
      - STR_RIGHT_HAND
      - STR_LEFT_HAND
      - STR_BELT
      - STR_BACK_PACK
      - STR_RIGHT_LEG
      - STR_LEFT_LEG
      - STR_RIGHT_SHOULDER
      - STR_LEFT_SHOULDER
  - type: STR_FIRST_AID_KIT
    #Same thing, but first aid kit can now only go in your left hand.
    supportedInventorySections:
      - STR_LEFT_HAND

Pic shows this example being tested, the medkit in the belt was already there, attempting to pick it up and put it back in the belt generated the same error.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: ohartenstein23 on August 29, 2018, 05:36:24 am
I am not aware of any code that lets you limit what can be carried in an inventory slot.

It's two years old, bladum requested it and Solarius seconded, Meridian implemented and then we all apparently forgot about it until this thread.  You seemed to be busy talking about how you reversed the inventory TU costs for backpacks in the same thread.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 29, 2018, 07:08:07 am
Lol. OK, good thing you reminded me of this. It is an interesting feature, however I don't see how this would allow fitting all the cool gear... Maybe if you used 1x1 slots? There is at least 10 gear slots atm.
Not even mentioning the scary amount of work it would take to set these parameters for every single item in the game.

So, darkestaxe? Do you think it is possible to rearrange slots in such a way that this works? 2 aux slots are nice but likely not enough... And it's not really acceptable how the paperdoll is squashed from our right.

Hmm, I think you could add a sequence of aux slots, each next about 16 px lower than the last to save space, each partially occluding the previous one. Would not look pretty, but could work...
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 30, 2018, 04:21:54 am
Lol. OK, good thing you reminded me of this. It is an interesting feature, however I don't see how this would allow fitting all the cool gear... Maybe if you used 1x1 slots? There is at least 10 gear slots atm.
Not even mentioning the scary amount of work it would take to set these parameters for every single item in the game.

The link is to a thread where I posted code so we wouldn't have to add those parameters for every single item. https://openxcom.org/forum/index.php/topic,6543.0.html (https://openxcom.org/forum/index.php/topic,6543.0.html)

So, darkestaxe? Do you think it is possible to rearrange slots in such a way that this works? 2 aux slots are nice but likely not enough... And it's not really acceptable how the paperdoll is squashed from our right.

If we're willing to put the slots over the doll, then yes. Some items might have to be shrunk a little but I think all the slots should be able to fit. Problem, there would be squares all over the doll!

Hmm, I think you could add a sequence of aux slots, each next about 16 px lower than the last to save space, each partially occluding the previous one. Would not look pretty, but could work...

But 10? IDK about 10. That would create a lot of cursor bugs.

We could use all 1x1 slots and make all the gear items 1x1. At least coat and towel would have to shrink or they would cover way too many squares around them. We would also have to cut the backpack max size down to 3x3 or limit to 5, maybe 6 slots.

Dioxine, what do you think of reworking some of the gear-slot items' art to be able to fit on something like the pics below? Because overlapping a little is one thing, but a raincoat centered on a box in that grid would cover-up an awful lot of stuff, and even more overlap on the ground.

Otherwise there's the idea I talked about in my last post up; about putting the slots on the doll and making code to hide (not draw) the squares. Dioxine would you want to have items go directly on the doll? Because some things like the bra already look kinda like you could just stick them right on the doll. Then the bootypedia could say "To equip a synthread bra on a Gal, put it onto her boobs so it covers up both of her nipples. :P"
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 30, 2018, 09:28:51 am
Interesting ideas. No, shrinking is not really an option at this point. These small 10 slots well... I can already see that it's going nowhere and your original idea with general-purpose slots was better. Putting slots all over the doll... Hmm there was that idea with paperdoll overlays/layers, maybe these ideas can be merged together?... TBH I have no idea how to implement this feature, but I am interested in further developements.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: legionof1 on August 30, 2018, 05:36:18 pm
I think the limited "general" purpose Aux slots are better from a balance perspective. Fewer higher influence choices, is better then many low influence choices. Just fitting the best item your tech allows for a slot is not engaging game-play. Picking only 2 aux items appropriate for your situation is.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 30, 2018, 11:31:34 pm
So I'm thinking just 2 isn't really enough, but BIS for every slot is too hard, and we don't even necessarily need that. Also, some utility items probably have other places they should be equipped, like backpack slot gear should go ... guess where. Can u guess? Hel charms should continue to fill ur inventory. If you could wear a shield without using inventory space, then it would be an outfit. Maybe 'don't panic' towel can just go anywhere it fits, including aux slots?

Alright here's what I got now:
(Note, for now you have to pretend that non-utility items won't go in places that they shouldn't. And this is just a demo, not complete.)
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: legionof1 on August 31, 2018, 01:42:28 am
12 space seems decent, with appropriate slotting restrictions.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Ridаn on August 31, 2018, 06:26:17 pm
Cant those slots just be made uninteractable with existing features?
Like assign 998TU worth to move to/from AUX (everywhere, including floor), with a custom text string for those 998TU?
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 31, 2018, 06:47:25 pm
Custom text string is impossible, but the 999 TU idea is sound, if we agree to the price of lowering utility value... At least it doesn't involve an insane amount of work to set allowable slots for every stinking item in the game Maybe just as a single util slot that is allowed for Nude outfits?

Also Legion, while I agree that having only 2 utility items would streamline the game, I also like the fact that you can custom-set your inventory to whatever you want... It is the core advantage of old xcom.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on August 31, 2018, 09:05:36 pm
999 TU idea could work, sort of, but remember I've already posted OXCE+ code changes that would add exactly what we need to do it properly. Slot restriction levels.

Code: [Select]
invs:
   -   type: STR_AUX
       restrictionLevel: 2

Restriction level 2 will make a slot accept only those items with allowedInventorySlots listing that slot. Thus we would only have to do allowedInventorySlots for utility items that belong in the AUX slot.

This is all assuming someone with visual studio and github is willing to try building with my code, and if it builds, pushes it to Meridians branch. The code changes to add gear slot restriction levels are really small and if we need it for Piratez gear slots, I doubt Meridian will say no.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on August 31, 2018, 11:19:26 pm
Yeah but I'm concerned with inventory cluttering... Also... A though, if you go Nudist, why should you be allowed to "cheat" by wearing clothes? If you want to fight while wearing clothes, um... wear clothes?
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: legionof1 on September 01, 2018, 02:25:58 am
Well need not be just 2, the point is to emphasize adapting to the situation not just lugging in a half dozen best in slot support items. Where the actual balance point is up to the you the modder.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on September 01, 2018, 07:31:25 am
Yeah but I'm concerned with inventory cluttering... Also... A though, if you go Nudist, why should you be allowed to "cheat" by wearing clothes? If you want to fight while wearing clothes, um... wear clothes?

Using the latest version, the size of the Aux slot can be managed per-outfit in the same way as the backpack is currently, with fake weapon blocks.

I myself don't really know how much of it should be blocked on different outfits since I'm still new to Piratez and haven't even made it to the mid-game. I'm still trying to figure out what I can safely shoot down with 20mm and a laser charger, and it's even worse on the battlescape. I keep equipping all these hundreds of different guns, and always still take out cattle-prods after every gun fails to take down anything. Except for that shotgun with the .6g cause it can butt-smack them, and the roto-gun which kills all the not dangerous stuff that I wanted to make slaves out of. Oh, right, moral grenades are starting to seem like they might be effective though, and I just got some dojos so I'll have to see if any of my gals can do anything with guns in a couple months. Plus something I'm reaserching about enterprise is supposed to make it so I can buy lasers.

BTW, I'm pretty sure medpacks don't really train bravery, but I have yet to patch 20 wounds with the same soldier in a battle so I can't be sure. What was I talking about? I'm gonna go test the medkit bravery thing.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Rince Wind on September 01, 2018, 12:43:15 pm
Even bandages train bravery.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: BBHood217 on September 01, 2018, 01:47:26 pm
A heal has to actually occur to get bravery training, you can't just waste a medikit on a fully healed gal.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on September 12, 2018, 05:29:04 pm
I made a mockup of what I consider to be a possibility without compromising the paperdoll space too much...
So how ugly does it look? :)

EDIT: another setup in the 2nd pic
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Solarius Scorch on September 12, 2018, 07:59:46 pm
The first one is obviously rather nasty due to the overlapping, but I still like it more than the second. The second one would be fine if it wasn't for the QD slot - it completely breaks my orientation about where the backpack is, where the belt is, and where the QD is. I would have to read it carefully every time, and that's just a big no.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on September 13, 2018, 05:54:21 pm
Well, how about this one, then:
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Solarius Scorch on September 13, 2018, 06:17:06 pm
Better, but how about moving the QD upwards by one box? Right now it's basically more leg space.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on September 13, 2018, 06:36:18 pm
I don't want it to invade the paperdoll space any more...
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Solarius Scorch on September 13, 2018, 07:14:52 pm
I don't want it to invade the paperdoll space any more...

I understand, but I still think it'd be better. Even acceptable.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: legionof1 on September 13, 2018, 07:57:39 pm
i like this last one.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: darkestaxe on September 14, 2018, 04:35:34 pm
The last one looks good to me if we're going with 1 gear item.

It would give us a place to pick one big utility item regardless of it's size, while still preferring smaller or easier to fit utility items in the rest of the inventory. This way a towel might actually get used, but won't necessarily be the only utility item anyone would choose.

Assuming meridian adds slot restrictions, I don't think current OXCE+ will be work with piratez. One issue I know of is that STR_UNAVAILABLE will be ignored unless we create a research project for it. Solution, make researching STR_UNAVAILABLE depend on STR_UNAVAILABLE, since STR_UNAVAILABLE will then be a valid research topic and will be enforced, even for itself. Otherwise we all get to build an Eye Of Horus at the beginning of the game.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: Dioxine on September 14, 2018, 05:45:10 pm
I think I can fit one more 1x1 gear space in this setup, for things like goggles or amulets. Well, ushankas won't see much use, it seems :)
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: The Think Tank on September 19, 2018, 04:20:56 am
I'll still use it if only for the Spirit of Motha Russia  :-*
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: legionof1 on September 19, 2018, 05:34:08 am
People are actually using the ushankas now? Unless your downing ships on the poles, your just not hitting cold that often in the early stages of the game where your lack of outfit tech actually makes cold mean something. Heat tends to last longer since heavy nonpower armor tends to have heat problems.
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: khade on September 21, 2018, 11:20:19 am
Is it possible to do a tab system, one tab showing weapons and equipment, and the second showing auxiliary items?
Title: Re: Custom inventories, gear slots and OXCE limitations
Post by: wolfreal on October 14, 2018, 02:29:09 am
People are actually using the ushankas now? Unless your downing ships on the poles, your just not hitting cold that often in the early stages of the game where your lack of outfit tech actually makes cold mean something. Heat tends to last longer since heavy nonpower armor tends to have heat problems.

I do. I used then in the early game, when reaching chainmail, for cold missions.