Author Topic: Inventory  (Read 199 times)

0 Members and 1 Guest are viewing this topic.

bitterman

  • Full Member
  • ***
  • Posts: 193
  • 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

  • Full Member
  • ***
  • Posts: 202
  • Karma: +14/-76
  • 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

  • Full Member
  • ***
  • Posts: 202
  • Karma: +14/-76
  • 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: 774
  • Karma: +30/-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: 910
  • Karma: +72/-126
  • 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

  • Full Member
  • ***
  • Posts: 202
  • Karma: +14/-76
  • 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: 774
  • Karma: +30/-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: 193
  • 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: 774
  • Karma: +30/-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: 193
  • 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: 193
  • 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: 193
  • 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'.