Author Topic: Inventory  (Read 538 times)

0 Members and 1 Guest are viewing this topic.

bitterman

  • Full Member
  • ***
  • Posts: 249
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Inventory
« on: February 12, 2017, 12:06:11 PM »
Is there a manual about how to work with inventory?

Some info placed here but seems like it's for TDM only and based on addition C++ code.

http://wiki.thedarkmod.com/index.php?title=Inventory

In D3 I can place some model on the map, set key "inv_name" and triggered some action with it.

But how organized info about items in inventory and how to works with it via scripts (for vanilla D3)?

Thanks.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #1 on: February 12, 2017, 02:21:56 PM »
Edit:  Realized just now that you made the Debug HUD thread so you already know most of this stuff!  *facepalm  Oh well it doesn't hurt to have this here for others.

Yes in here and here, the quake 4 one has some commands that don't work on idtech 4 based on Doom 3, is really a trial and error but i can say that "stoptransitions " only work on Quake 4.

btw I'm more or less stuck on that as well, it seams Doom 3 inventory is hardcoded, for example i tried to use the battery definition that comes with doom 3, to have a functional battery in game but it seams id never made the c++ code necessary to support batteries, by the def existence, they tested that, perhaps for the flashlight but then removed the code and went with a weapon based flashlight, using that def i only get a error on the console.

After have said that i think it IS possible to do a script based inventory, this is what i think one should do:

Make gui for the inventory, make a ingame model to attach that gui to (with a model def or on the editor), using the key/val par:

Code: [Select]
key - gui
val - guis/gui_name.gui

To change values on the gui, using a script or a trigger, you need to go trough the model where that gui is defined:

the cmd for that is:

1- in the GUI inside a WindowDef you first need to make a special key/val  for example:

Code: [Select]
windowDef TextItemName
{
rect 10,5,50,10
visible 1
text "gui::foo" // gui::valueName, valuename can be anything is just a pointer/placeholder for the value - afaik valueName must be unique between parm's but i could be wrong
textalign 0       // or texalign "gui::valueName"
textscale 0.15
font "fonts/micro"
}

update 1 - gui::valueName can be used in logic operations, for example:
Code: [Select]
if ("gui::player_armor"  <= 0) {
set "Lines1::visible" "0" ;
set "Lines1_1::visible" "1" ;
}

2 - Then use in a script -> $gameObject.setGuiParm("foo","bar"); // foo initial parm value -> bar new parm value


To change values on the GUI directly you use:

Code: [Select]
// onEvent runs every frame, carefull
onEvent
{
set "TextItemName::text" "foo" ;
}


OnNamedEvent  // this seams to be called from the c++ code, didn't found a way, for now, to use this from script or even run this directly from the GUI cmd's like onAction.


Use the normal GUI cmd's for example.


Code: [Select]
windowDef inventory_slot
{
rect 0,0,77,66
visible 1
background "guis/assets/pda/inventory/inventory_slot"
matcolor 1,1,1,1
float "numbON" 1
//notime 1

onMouseEnter
{
                                               // highlights the button
                                               transition "numb::matcolor" "1 1 1 1" "0.6 0.7 0.7 1" "1000";
}

onMouseExit
{
                                               // un-highlights the button
transition "numb::matcolor" "0.6 0.7 0.7 1" "1 1 1 1" "1000";
}

onAction
{
//set "cmd" "play guisounds_menuclickup" ; // this is not working but seams to be supported by the Doom 3 GUI system!

localSound guisounds_menuclickup; // this works

if ( "inventory_slot::numbON" == 1 )
{
set "numb::visible" "0";
set "inventory_slot::numbON" "0";
set "TextItemName::text" "foo"
}
if ( "inventory_slot::numbON" == 0 )
{
set "numb::visible" "1";
set "inventory_slot::numbON" "1";
set "TextItemName::text" "bar"
}
}
« Last Edit: February 12, 2017, 02:57:09 PM by argoon »

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #2 on: February 12, 2017, 06:06:53 PM »
I also realized that you are not talking of the GUI per se but how to handle player inventory items?

If so, personally i don't know much about it, i do know that you can use editor special entity def's, like target_give, func_itemremove, i now that you can also define new items, on the items.def, but afaik they need to be based around existent ones, because also afaik item properties are hardcoded on the c++ code, that is why the Battery item that i talked above, even tho defined in the items.def file, doesn't work.

btw aren't items also Entities, so anything that applies to entities should also apply to items?

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 849
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Inventory
« Reply #3 on: February 13, 2017, 08:38:21 AM »
The only experience with inventory items in stock D3 I've had is they're used like a key: the player needs item X to access thing Y, a script checks to see if player has X.  If he does, Y is accessed, if not, the player is told you need X.
I'm not familiar with TDM's inventory system but I know stock D3 doesn't have a system like Quake 2 or 3, where you can pick things up & later use them.
Well, it kind of does: the weapon system is like that, so if you added more weapons via script/C you could select & use them, or you could replace current weapons with something not for offensive purposes (like something to drop a mine, activate a shield, give health, etc).

motorsep

  • Hero Member
  • *****
  • Posts: 959
  • Karma: +74/-127
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Inventory
« Reply #4 on: February 13, 2017, 10:52:35 AM »
In RoE you can store power cell and use it later.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #5 on: February 13, 2017, 05:43:29 PM »
... stock D3 doesn't have a system like Quake 2 or 3, where you can pick things up & later use them...

Isn't the parm "inv_carry" in items for that?

This is what it says: if set to 1, is carried as opposed to instant use

 

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 849
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Inventory
« Reply #6 on: February 13, 2017, 10:28:12 PM »
I believe that's how the power cell motorsep is referring to works in ROE.  I still think the power cell is used via scripts though, I haven't played ROE in a while.
Instant use would be health, a key would be carried.

bitterman

  • Full Member
  • ***
  • Posts: 249
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #7 on: February 15, 2017, 10:42:09 AM »
Thanks for info.

The base concept (as I think now):

P.S. Also I see other interesting things (e.g. inv_text, inv_id) but looks like this is unrealized features.
« Last Edit: February 15, 2017, 10:48:19 AM by bitterman »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 849
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Inventory
« Reply #8 on: February 15, 2017, 12:54:35 PM »
good chance it's used in RoE, Q4 or Prey.  stock D3 seemed to have stuff for all three scattered about but never used/finished in the original game dll.

bitterman

  • Full Member
  • ***
  • Posts: 249
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #9 on: February 21, 2017, 11:09:49 AM »
So we have array of items. Each of item is accessible from gui script via "gui::inv_name_n" (from "inv_name_0" to "inv_name_19", but not tested yet).

Current number of items is placed in "inv_count" (and can be read via "gui::inv_count").
« Last Edit: February 22, 2017, 09:44:35 AM by bitterman »

bitterman

  • Full Member
  • ***
  • Posts: 249
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #10 on: February 25, 2017, 08:55:58 AM »
Now I try to work with items from map and scripts.

First pretender is func_itemremove. I just placed this func on the map and set key "remove". But seems like it doesn't works. I can put item in inv_name_0 then touch func but there is no reaction. I still see item in PDA. What's wrong?

Perhaps I must refresh windowDef witch contain inv_name_0 in PDA, but how?

In Code I see:
Code: [Select]
#ifdef _D3XP
EVENT GiveInventoryItem/RemoveInventoryItem

How to know is current exe was compiled with this key?

*************** upd

Ok I set trigger and targeteg it with func_itemremove. Trigger is working but item is still shown in PDA.
« Last Edit: February 25, 2017, 11:52:07 AM by bitterman »

bitterman

  • Full Member
  • ***
  • Posts: 249
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #11 on: February 28, 2017, 10:18:19 AM »
func_itemremove works with 'inv_name' key, not 'name'.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #12 on: March 26, 2017, 09:27:44 AM »
Bitterman thank you for your experiments and posting detail images of your findings they will certainly help.

Today working on a complex "swingdoor" i reached a spot where i need to work with inventory items, for keys and required inventory items, from my limited studies, to be able to detect those item's from the player character you need to assign some reference to them on the player def file, and use $player1.getKey(keyname), the problem is how do you assign a item to the player at run time using this method?
Perhaps setKey will do? It doesn't change the behavior of the entity at run time because spawn arguments only run at spawn time, but at lest you can change the value and use that change with getkey again, in this way you spawn with no key for a door "key = null" at run time change the value using setkey to "key = inv_name",  retrieve that new value with getkey and use that to open or close the door. 
This ability afaik is already built on the func_door entity from Doom 3 but i don't know if it works automatically i have yet to test this on it.

So this is what i gathered till now i'm still to find or think of a way to detect them directly from the player inventory from script, something like the c++ function FindInventoryItem you showed above, saying this i realized many functions we need exist but aren't exposed to the script, fortunately many can be replicated on the script side.

I know is possible to expose them to script relatively easy but that requires you to compile the source code, and at lest for me my tries coding on the c++ side ended in disaster till now, is much more complex, i hit barriers and frustration much faster and crash the engine very easily, just by changing or adding some small stuff, i don't blame the (fhdoom) engine of course but my lack of knowledge on c++ coding, my lack of knowledge how the code is structured and how the engine parts are really interconnected, compared to that scripting is so much easier at lest to a person like me with limited coding experience.

bitterman

  • Full Member
  • ***
  • Posts: 249
  • Karma: +8/-5
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #13 on: March 26, 2017, 10:57:16 AM »
Try to use trigger with key/val 'requires' 'key_name' and 'remove' '1' (or something like).
It works only if required item present in inventory and then remove it from inventory.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: Inventory
« Reply #14 on: March 26, 2017, 12:54:22 PM »
Thanks i will try that but my swingDoor is not based on the normal func_door but on a func_mover (with some complex scripting in the mix) because only those have the rotation functions ability built in, don't know if it has the required c++ code for that to work, from my source code readings i do know that both func_door and func_mover inherent from mover_binary but func_door has plenty more code on it.