Download

PrimalItem Class

i see there is a “primalitem” which is kind of a container for all primalitems.
also there is primalitem_consumable_eatable, which is kind of a container for all eatable stuff…

isn’t there something like that for ammo/weapons/resources???

like primalitem_ammo for all ammo items
and not a specific item like primalitem_ammo_c4

(purpose: )
i would like to check what’s in my inventory. what class it belongs to and make shure it is not a resource.

Easy way is to create a reverse list (what not to include), you hit the reverse list first (CastToC4 did it work, skip, else CastToAmmoBase) as that list will most likely be smaller. Now note, AmmoBase I believe covers arrows as well

I’ve been working on something similar (look through items, does it use durability, is it damaged, repair if yes) I’ve had to skip things like water containers, and paint brushes (they use durability for water amount and paint remaining)

And you are correct PrimalItem is the base class, which everything can be referenced as thanks to parenting, you can take a PrimalItem reference and attempt to cast it to the type you want PrimalItemWeapon_Rifle or PrimalItemAmmo_Arrow

Now I’m not sure if there is a baseclass for resources, but what you can do is follow the parent paths

Search in the content browser for “wood” look at parent or open with reference viewer (Left side is parents, right is children) so travel the left path of the primalitems until you see the base class (you will probably see a bunch on the right because they all child from it)

but I know weapons, food, soups, ammo, armor all have a base class (and some of them have a base base class) just takes some investigating to find what you need.

hey, thank you very much!
i found some (ammo_base, armor is split into 5 classes: base pants/boots…[just why? saddles? omg…]), but need to investigate further.

but seriously, isn’t that (primal item groups) something important to have?
i could imagine all kinds of scenarios where this could make things easier…
how do the devs go about that? do they create those groups every time on the fly? this would be utterly inefficient.

They probably don’t make it up on the fly, it takes some design aspect, and foresight in creating groups, in this case they are programming with object oriented, with game object decoupling in mind.

I was a bit baffled to find C4 is a ammo type (as I thought you could pace it by hand) realized the c4 detonator is the weapon that consumes c4.
But most of the setup they did was to create a template for the items (base classes) that has the components and variables that would be shared among all of that type PrimalItem being the great-grand-parent why even things like a helmet will have an option for a weapon template. This is so things like inventories can hold them all more easily thanks to inheritance (parenting classes)

I bet if you look at base_pants it will have a parent of armor_base or something like that, and all armors will point to that.
But like I mentioned, it’s easier to get the list of “do not want” and compare against them rather than the list of “I want” if you are doing a vastly broad want. Some of my buffs and items have small want lists so I don’t mind going “It is this, or this, or this” because it’s only like 5 items.

ok, i see
what a pity it’s not following strict naming conventions…

so i’ll need to dig through it.
honestly i don’t really get the reference viewer.

e.g.: Wood

to the right i see:
PrimalItemResourceGeneric
BlueprintGraph
Engine, Icon and stuff

to the left it’s weird:
there are some PrimalItemStructers of some of my mods
and a “Collapsed nodes” containing 204 nodes
but when i open it, there’s nothing in there. (can click further in “forever”)

can’t try it atm, but i think PrimalItemResourceGeneric could work

PrimalItemResourceGeneric is most likely the base class of all resources. and that node that says collapsed 204 means the current settings (depth 1, 15 layers) is hiding those, if you turn the 15 to 205 it would show them all, saddly that will probably kill your machine/kit because I believe it might be using a recursive function to find all the connections. There is a bunch because alot of things in the game use wood (crafting) but you can always open an object(edit) and look in the upper right you can see a section or label of “parent class” that can also help you find the “base class”

So since you may have found the class you need “PrimalItemResourceGeneric” you can simply loop through the inventory, and try to cast to PrimalItemResourceGeneric if successful apply logic, if not, move on.

foreach, and foreachwithbreak are some nice loops to use.

thank you for your help.
i’ve got it to work and set it up like so:
c04cc7c8d5313d6743fef4723ea4b6eb0efc1e7a.jpeg
this checks wether there is some kind of armor/weapon/ammo/tool inside the inventory.

I see you have a array length check in the lowerright, I’m pretty sure a foreachloop will catch that, but if you really need to make sure the array has something (in the case of players will always have something, cannot remove the implant) you should have that check before you get to the array (Is array > than 0? If yes, Loop, if not break/do other logic)

Also I’m guessing somewhere in there you’re getting the item’s BaseCraftingMaterialRequirements and returning 1/2 of that (Is there a server config for return amount of something recycled? talking about demolishing structures) you might also have to multiply: BaseAmount * ((1+ItemRating) * ResourceRatingMultiplier)
I have ItemRating + 1 because I’m pretty sure items (crafted by player) start at rating 0.