Jump to content

PSTEE - Modded inventory problems (and solutions).


szef

Recommended Posts

Quoting from discord:

"Me and my buddy have been working on a little Planescape:Torment EE UI mod and we have an issue with Inventory Background. Replacing the existing mosaic with ours is simple enough, but it seems like there is a permanent black background in the back. We wanted our inventory box to 'float' over the game screen (as we have seen possible on a pre-EE mod screenshot).

iM4vo3C.png

 

Does anyone know how to get rid of that black background or is it just not a part of the 'world' setup anymore and whatever we're trying to do, actually cannot be done?

This is NOT the indented graphic but illustrates the issue: though clearly both the graphics have some functional transparency, the solid black background prevails":

 

20221028123556_1.thumb.jpg.e960fdaa1b41a58801d95704e1bede34.jpg

Edited by szef
Link to comment

While we couldn't figure out how to remove background to show the world, we decided to make use of the space we're left with. Currently, we're working with a piece of stats page but it has a weird issue.

While we did get it to display easily, it only ever displays if it has been displayed in the character sheet first. If we swap to another character's inventory, the stat block remains the same, and we end up with e.g. Morte's summany on the Nameless One's inventory page. Does anyone know a way to refresh that other than display a new character sheet first?

 

20221031091403_1.jpg

Link to comment
Spoiler

There are strings in dialog.tlk, like e.g. #59856 ~Current State~, or #4233 ~Armor Class Modifiers~.

In-game, the character stats are displayed up-to-date under this strings.

Is there any way to find out where this is coming from?

(The .dlg files do not have the above strings. Maybe they have a tokens or something? If so, how i can see them?)

Edit:

print_r - gives something like this, in this example of stats info:

 [characterInformationString] => table: 06831870 {
INFO: LUA:                                     [1] => table: 08D6CA68 {
INFO: LUA:                                              [1] => 39596
INFO: LUA:                                              [2] => bestenemy
INFO: LUA:                                            }
INFO: LUA:                                     [2] => table: 08D6CA68 {
INFO: LUA:                                              [1] => 41278
INFO: LUA:                                              [2] => timespent
INFO: LUA:                                            }
INFO: LUA:                                     [3] => table: 08D6CA68 {
INFO: LUA:                                              [1] => 41279
INFO: LUA:                                              [2] => favspell
INFO: LUA:                                            }
INFO: LUA:                                     [4] => table: 08D6CA68 {
INFO: LUA:                                              [1] => 41280
INFO: LUA:                                              [2] => favweapon
INFO: LUA:                                            }
INFO: LUA:                                   }

Table? Is there a way to do something like:

text lua "Infinity_FetchString(insert this table, string or whatever)  ?

 

New idea - new problem, this time with disappearing "new" journal, after enter the bestiary :D. 

UPDATE: This issue was solved.

Edited by szef
Link to comment

Yeah, I didn't think that was possible for someone at our level. The more that I'm currently on linux, so dealing with some exe, would be difficult... If I'm not mistaken. As for the native pst files (for linux) also do not know how to sensibly approach with anything useful. I tried debugger (gdb, objdump), unfortunately, it really does not give me much hehe.

Too bad :(.

Edit:

@aqrit I'm curious how you discovered that this function/offset - 0x00220F4F is responsible for the root inventory background/menu?

In general, do you think that the example idea of inventory (grid/backround) on the left and the game-world on the right is possible to obtain in EE version?

Edited by szef
Link to comment

> I tried debugger (gdb, objdump)

I'm not familiar with any linux tools for this. Assuming EE is even written in C++...

gdb could probably get the job done, but you'll probably want something specialized for this type of work.

  • For debuggers/disassemblers, I assume most people use Ghidra or IDA Pro on linux.  The freeware version of IDA Pro  doesn't include a debugger or decompiler though. Maybe radare2 (or cutter) could be good?
  • For memory scanners: top google results are "GameConqueror" or "PINCE".

 

> I'm curious how you discovered that this function/offset - 0x00220F4F is responsible for the root inventory background/menu?

I don't recall, that was ~10 years ago. However, hooking the DirectDraw API and watching the callstack would've made it clear which function was drawing to which screens.

There are many ways to find this function,  that is the "game" of reverse engineering. e.g. the inventory menu has a hot-key of "i" so one could hook the keyboard handler then trace to the code that launches the inventory.  Or one could hook the open file API then trace the lifetimes of the CHU or background image files. A memory scanner combined with hardware breakpoints is a  giant shortcut to a lot of different strategies...

 

> In general, do you think that the example idea of inventory (grid/background) on the left and the game-world on the right is possible to obtain in EE version?

All things are possible, given enough time...

I don't own the EE version and I haven't followed any news about any of the enhancements... but they probably changed the code a lot around this area.

Edited by aqrit
Link to comment

 

Ending... Ghidra could probably handle it ;) (but the debugger crashed with java version incompatibility error, hmm).
However, I discovered some corresponding functions, while gdb gave some list (hmm):

Spoiler

 

Non-debugging symbols:
0x00000000008cd9d0  CScreenInventory::EngineDestroyed()
0x00000000008cd9e0  CScreenInventory::EngineGameUninit()
0x00000000008cd9f0  CScreenInventory::EngineInitialized()
0x00000000008cda00  CScreenInventory::OnLButtonDblClk(CPoint)
0x00000000008cda10  CScreenInventory::OnLButtonDown(CPoint)
0x00000000008cda30  CScreenInventory::OnLButtonUp(CPoint)
0x00000000008cda50  CScreenInventory::OnMouseMove(CPoint)
0x00000000008cda60  CScreenInventory::OnRButtonDown(CPoint)
0x00000000008cda70  CScreenInventory::OnRButtonUp(CPoint)
0x00000000008cda80  CScreenInventory::UpdatePersonalItemStatus(int)
0x00000000008cda90  CScreenInventory::OnRestButtonClick()
0x00000000008cdbb0  CScreenInventory::TimerSynchronousUpdate()
0x00000000008cdc50  CScreenInventory::OnKeyDown(int)
0x00000000008cdee0  CScreenInventory::EngineGameInit()
0x00000000008cdf70  CScreenInventory::EngineDeactivated()
0x00000000008ce010  CScreenInventory::~CScreenInventory()
0x00000000008ce010  CScreenInventory::~CScreenInventory()
0x00000000008ce0f0  CScreenInventory::~CScreenInventory()
0x00000000008ce3e0  CScreenInventory::UpdateContainerStatus(int, short)
0x00000000008ce450  CScreenInventory::CScreenInventory()
0x00000000008ce450  CScreenInventory::CScreenInventory()
0x00000000008ce5c0  CScreenInventory::ResetGroundPile()
0x00000000008ce610  CScreenInventory::SetErrorString(unsigned int, unsigned int)
0x00000000008ce6f0  CScreenInventory::SetErrorString2(unsigned int, char*, unsigned int)
0x00000000008ce820  CScreenInventory::SetItemCompareString(CString, unsigned int)
0x00000000008ce850  CScreenInventory::GetCurrentGroundPage()
0x00000000008ce880  CScreenInventory::FetchGroundPile(short, int)
0x00000000008cea10  CScreenInventory::GetMaxGroundPage()
0x00000000008cea70  CScreenInventory::OnGroundPage(int)
0x00000000008cebc0  CScreenInventory::FlushGroundPiles()
0x00000000008cf0d0  CScreenInventory::UpdateLua()
0x00000000008cf140  CScreenInventory::GetAbilitiesList(int)
0x00000000008cf350  CScreenInventory::ApplyItemOnSprite(int, int, Item_ability_st const*, CAIObjectType&, CItem*)
0x00000000008cf730  CScreenInventory::PlaySwapSound(CItem*, CItem*)
0x00000000008d0170  CScreenInventory::CheckMultiPlayerViewable()
0x00000000008d02b0  CScreenInventory::OnPortraitLClick(unsigned int)
0x00000000008d0380  CScreenInventory::EngineActivated()
0x00000000008d04d0  CScreenInventory::DelayLearnSpellCheck(CResRef const&)
0x00000000008d04f0  CScreenInventory::DelayStatChange()
0x00000000008d0520  CScreenInventory::CancelLearnSpellCheck()
0x00000000008d0550  CScreenInventory::UnPauseGame()
0x00000000008d05a0  CScreenInventory::IsCharacterInRange(int)
0x00000000008d0750  CScreenInventory::IsCharacterDead(int)
0x00000000008d07a0  CScreenInventory::GetInventorySlotHighlight(int)
0x00000000008d07c0  CScreenInventory::GetGroundSlotHighlight(int)
0x00000000008d07e0  CScreenInventory::RenderEncumbrance(CPoint, CRect)
0x00000000008d1110  CScreenInventory::ClearPortraitHighlighting()
0x00000000008d1190  CScreenInventory::GetButtonString(int)
0x00000000008d15d0  CScreenInventory::SwapWithPortrait(int, int)
0x00000000008d18a0  CScreenInventory::FindFreePersonalSlotOfType(EquipmentSlotTypes)
0x00000000008d1970  CScreenInventory::IsEquipSlotValid(unsigned int)
0x00000000008d20b0  CScreenInventory::IsSlotValid(unsigned int)
0x00000000008d2220  CScreenInventory::MapButtonIdToInventoryId(int, int)
0x00000000008d2360  CScreenInventory::FindFreePersonalSlot(unsigned int, unsigned int)
0x00000000008d2480  CScreenInventory::GetPersonalSlotHighlight(int)
0x00000000008d2540  CScreenInventory::GetWeaponSlotHighlight(int)
0x00000000008d2840  CScreenInventory::GetSlotHighlight(int)
0x00000000008d2a20  CScreenInventory::CheckSlotMergable(unsigned int)
0x00000000008d2b60  CScreenInventory::GetSlotIdForTempItem()
0x00000000008d3140  CScreenInventory::SwapWithSlot(int, int, unsigned short, int)
0x00000000008d5710  CScreenInventory::SelectItemAbility(int, int, int)
0x00000000008d6330  CScreenInventory::IsAbilitiesButtonActive(int)
0x00000000008d6560  CScreenInventory::GetUseButtonText(int, int)
0x00000000008d6700  CScreenInventory::DrinkPotion(int)
0x00000000008d7a60  CScreenInventory::CheckItemIdentify(int)
0x00000000008d7bb0  CScreenInventory::GetScrollIdentifyEnabled(int)
0x00000000008d7c70  CScreenInventory::GetSpellIdentifyEnabled(int)
0x00000000008d7e30  CScreenInventory::IdentifyWithSpell(int)
0x00000000008d8050  CScreenInventory::IdentifyWithScroll(int)
0x00000000008d8230  CScreenInventory::CopyNote(int)
0x00000000008da810  CScreenInventory::CancelEngine()
0x00000000008dabb0  CScreenInventory::MapButtonIdToItemInfo(int, CItem*&, unsigned int&, CResRef&, CResRef&, unsigned short&)
0x00000000008daf50  CScreenInventory::IsSpriteOrderable()
0x00000000008dafb0  CScreenInventory::IsUseButtonActive(int, int)
0x00000000008db440  CScreenInventory::GetUseButtonMode(int)
0x00000000008db630  CScreenInventory::TimerAsynchronousUpdate()
0x00000000008db910  CScreenInventory::CopySpell(int)
0x00000000008dbed0  CScreenInventory::OnUseButtonClick(int, int)
0x00000000008dc220  CScreenInventory::CheckMouseMove()
0x00000000008dc230  CScreenInventory::CheckSystemKeyCtrl()
0x00000000008dc240  CScreenInventory::SetSystemKeyCtrl(unsigned char)
0x00000000008dc250  CScreenInventory::CheckMouseLButton()
0x00000000008dc260  CScreenInventory::CheckMouseRButton()
0x00000000008dc270  CScreenInventory::GetNumVirtualKeys()
0x00000000008dc280  CScreenInventory::GetVirtualKeys()
0x00000000008dc290  CScreenInventory::GetVirtualKeysFlags()

 

945221088_Przechwycenieobrazuekranu_2023-01-26_17-39-44.jpg.bd02081e77d3b69e33fd8e869f22e7d4.jpg

Edited by szef
Link to comment

For profiencies (from previous post) in inventory, it looks like that's enough: 

text lua "characters[id].proficiencies.pstDetails"

As for:

Spoiler

But how to 'rewrite' the code to display (in inventory) statistics like: bestenemy, favspell, favweapon etc.? 

There are such functions:
 

--Label stringref, var for value, percent flag
characterInformationString = { 
	{39596, "bestenemy"},
	{41278, "timespent"},
	{41279, "favspell"},
	{41280, "favweapon"},
}
characterInformationDisplayCategories = { 
	{41308, "partygamexp", 1},
	{41307, "partygamekills", 1},
	{825,	"gamexpvalue"},
	{41281, "gamekills"},
}
function formatCharacterInformationStr()
	local str = ""
	local tab = characters[currentID].Stats
	for k,v in pairs(characterInformationString) do
		str = str .. "^N" .. Infinity_FetchString(v[1]) .. "^-" .. "\n" .. tab[v[2]].current .. "\n\n"
	end
	return str
end
function getCharacterInformationValue(row)
	local str = characters[currentID].Stats[characterInformationDisplayCategories[rowNumber][2]].current
	if(characterInformationDisplayCategories[rowNumber][3] == 1) then
		str = str .. "%"
	end
	return str
end

 

- onOpen
    "
        characterInformationDisplayStr = formatCharacterInformationStr()
    "

Does anyone have any ideas? ;)


Solution (thanks to @Bubb)

"characters[id].Stats.bestenemy.current"
"Infinity_FetchString(41308)"
"characters[id].Stats.partygamexp.current ..'%'"

 

Edited by szef
Link to comment
Spoiler

After some time, I wanted to try to recreate something similar to a combined inventory like in dragonspear++ ui etc.

Unfortunately I don't know how to: turn off the highlighting of the entire grid section when moving items? Not a single slot, but all 20 slots highlighted... This purple frame (turn off or proper refreshing). 

 

 

 

Thanks to @Bubb indispensable help, the black layer problem has been solved.

 

Edited by szef
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...