www.tombraiderforums.com

Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Software Development

Reply
 
Thread Tools
Old 11-01-15, 20:19   #1131
Nickotte
Historian
 
Nickotte's Avatar
 
Join Date: May 2010
Location: Italy
Posts: 256
Default

Absolutely! I'm going to make a TR4/5 style inventory and a custom one as well, will work on them as soon as this one is functioning well enough.

Updated with italian translation!

EDIT: I have a problem solving the save/load bugs, more specifically with the items in the inventory. The problem is, the way the inventory originally works is by containing items that are independent from the actual items Lara has in any given moment, e.g. the option/saving/loading/etc. selectors, or the compass or the statistics watch in TR2; this way, the inventory will never be completely empty and this would make many things waaay easier in the inventory management. I have no idea how the current item loading system works, so I can't just tell the engine to automatically add said items and keep them as isolated special items instead of saving them/reloading with the other items. Can anybody elucidate me on the matter?
Also, is there a way to check what is the current game?

Last edited by Nickotte; 12-01-15 at 02:28.
Nickotte is offline   Reply With Quote
Old 13-01-15, 23:05   #1132
Nickotte
Historian
 
Nickotte's Avatar
 
Join Date: May 2010
Location: Italy
Posts: 256
Default

Mmmm, I partially fixed the save/load problem, but now the level switching broke and I really can't figure out why.

So close to working!
Anybody can help? I'll work on something else in the meantime.
Nickotte is offline   Reply With Quote
Old 14-01-15, 00:40   #1133
Richard_trle
Historian
 
Richard_trle's Avatar
 
Join Date: Aug 2003
Location: Brazil
Posts: 431
Default

Quote:
Originally Posted by Nickotte View Post
Mmmm, I partially fixed the save/load problem, but now the level switching broke and I really can't figure out why.

So close to working!
Anybody can help? I'll work on something else in the meantime.
what exactly do you need help with?:
Richard_trle is offline   Reply With Quote
Old 14-01-15, 01:04   #1134
Lwmte
Explorer
 
Lwmte's Avatar
 
Join Date: Aug 2010
Posts: 963
Default

Oh, sorry for long delay, I was a bit busy with other things these two days (working, some real life deeds... also, saw movie "Leviathan", by the way - pure genius work by my favorite russian director)...

So you have problem saving items in inventory? Or getting them to load into it in the first place? Look, all inventory adding/removing business is done via script functions. Each time you load engine or start new level (without load command), a small script is executed to add certain items to inventory. It should be done on per-game basis, as different TR versions had different start-up inventories, but currently it's placeholder script for ALL game versions and levels.

Just open this file: scripts/inventory/items.lua. This script is basically used to populate each game version's item database by using createBaseItem function. Currently, the syntax is:

createBaseItem(item ID, inventory model ID, world model ID, item type, base count, item name)

As TR1-3 and TR4-5 had different menu items (TR1-3 had passport, glasses, CD player and gamepad/keys, while TR4-5 only had load/save items), there is different set of items being populated for different versions. That is, case switches for TR1-3 have these four items, and case switches for TR4-5 only have load/save items. To load passport/player/glasses into TR4-5 versions, you have to invent some kind of workaround; I hope some day we'll be able to load external model files to support nonexistent items, but currently all I can offer you is to make some kind of placeholder, like this, for TR4:
Code:
    createBaseItem(ITEM_PASSPORT, 376, 376, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_PASSPORT);
    createBaseItem(ITEM_VIDEO, 376, 376, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_VIDEO);
    createBaseItem(ITEM_AUDIO, 376, 376, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_AUDIO);
    createBaseItem(ITEM_CONTROLS, 376, 376, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_CONTROLS);
And this for TR5:
Code:
    createBaseItem(ITEM_PASSPORT, 357, 357, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_PASSPORT);
    createBaseItem(ITEM_VIDEO, 357, 357, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_VIDEO);
    createBaseItem(ITEM_AUDIO, 357, 357, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_AUDIO);
    createBaseItem(ITEM_CONTROLS, 357, 357, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_CONTROLS);
These code pieces will add placeholder menu items to menu ring, but all they will look like LOAD items (diskettes), because TR4-5 just doesn't contain proper models.

That's first part you have to do. Then, let's return to what I said earlier - in the same script file there is a small code piece which is placeholder inventory filler, which acts the same way for ALL levels being loaded; that is, no matter which level or game you'll launch, you'll get compass, pistols, three small medipacks and one large medipack. This code piece is right at the end of this script file - it's preceded by "test TR_ITEMS" commentary:

Code:
addItem(player, ITEM_COMPASS, 1);
addItem(player, ITEM_PISTOL, 1);
addItem(player, ITEM_SMALL_MEDIPACK, 3);
addItem(player, ITEM_LARGE_MEDIPACK, 1);
BUT! You can successfully use this script file to force engine to load other specific items for any level every time. Just add this code after aforementioned lines:

Code:
addItem(player, ITEM_PASSPORT, 1);
addItem(player, ITEM_VIDEO, 1);
addItem(player, ITEM_AUDIO, 1);
addItem(player, ITEM_CONTROLS, 1);
Then, engine will load these four "global" items for all levels. Note that items will be saved when user saves the game, and re-loaded on game loading, so you won't lose them in load/save cases. That's the proper way to manage things.
Quote:
Also, is there a way to check what is the current game?
Sure, you can use engine_world.version variable to check game version, for ex. if(engine_world.version == TR_II) condition will check if level file is TR2 version.

If you need to know not the level file version (as TR2/TR2Gold and TR3/TR3Gold file formats are identical), but specific game version... Well... That could be a bit tricky. All game version stuff is managed inside the script, i. e. engine itself only knows about file formats, games are set strictly within Lua scripts. So most likely you'll need to move corresponding management to Lua script; it depends on purpose where you'll use game version variable.

However, I just checked, and there is "setGame" script command, while there is NO "getGame" script command... By the way, for some reason TeslaRus introduced secondary game index, so right now "setgamef" is used instead of "setgame", while "setgame" uses different indexes... I don't know why he did that! Anyway, if you'll need specific script function to check GAME version, not ENGINE version, then say me, and I'll set it up for you.

By the way, I'm afraid we'll eventually need to check up game version inside source code itself, as TR2Gold used re-arranged entity set-ups, which messes up gameplay when TR2 executable is used with TR2Gold (while file format remained the same)... I guess we'll introduce special flag to set specific engine behaviour for such cases.

Quote:
I partially fixed the save/load problem, but now the level switching broke and I really can't figure out why.
Possible it happens because you're trying to add non-existent base items to inventory - I see in your commit that you're strictly add passport, controls and audio items into items.lua file, while not registering base items, as I described above. In your case, engine can simply crash while switching to TR4-5 levels, because base items are undefined. Or you have some other problems?

Last edited by Lwmte; 14-01-15 at 01:09.
Lwmte is offline   Reply With Quote
Old 14-01-15, 01:27   #1135
Nickotte
Historian
 
Nickotte's Avatar
 
Join Date: May 2010
Location: Italy
Posts: 256
Default

Thanks a lot! I eventually tracked down the item adding scripts and the game version tracking
I just temporarily read engine_world.version inside the inventory functions to change stuff according to the game.

Quote:
Originally Posted by Richard_trle View Post
what exactly do you need help with?:
Quote:
Originally Posted by Lwmte View Post
Possible it happens because you're trying to add non-existent base items to inventory - I see in your commit that you're strictly add passport, controls and audio items into items.lua file, while not registering base items, as I described above. In your case, engine can simply crash while switching to TR4-5 levels, because base items are undefined. Or you have some other problems?
I temporarily told the engine to omit non-esistent items, so that's not the problem; switching to other engines isn't the problem either, as even reloading the same level again does this.
Basically, it starts up fine and can save and load without a problem inside the same level; the problem is, when reloading or switching level one time, it soft crashes on "ntdll!TpWaitForAlpcCompletion()" (or so sais C::B) and on AddEffectSlotArray() in file alAuxEffectSlot.c (line 432). Upon reloading/switching level a second time, it finally crashes on SkeletalModel_Clear() in file mesh.cpp (line 217).

Since I didn't touch either of those, my only thought was to have been doing wrong with pointers (those pesky little things are simply the worst )

Oh, and another thing: the line createBaseItem(ITEM_COMPASS, 121, 121, ITEM_TYPE_SYSTEM, 1, ITEM_NAME_COMPASS); in items.lua seems to be doing nothing at all. Is the compass item hard-coded?

EDIT: Scratch the last problem, it was a couple of undefined items IDs that Lua changed to 0

THRILLAH

Last edited by Nickotte; 14-01-15 at 16:20.
Nickotte is offline   Reply With Quote
Old 14-01-15, 19:13   #1136
Ado Croft
Historian
 
Join Date: Apr 2013
Posts: 265
Default

Wau, it works fine for me. Only thing i have to note is that when I place some key to the current hole, then some quest items will disappear in inventory
But it is not a big problem

Last edited by Ado Croft; 14-01-15 at 19:15.
Ado Croft is offline   Reply With Quote
Old 14-01-15, 20:54   #1137
Nickotte
Historian
 
Nickotte's Avatar
 
Join Date: May 2010
Location: Italy
Posts: 256
Default

Mmmm... This doesn't sounds good at all. I tried reloading some previous commit - even prior to my fork - and it keeps doing it. I think I might have my heap corrupted somehow....


By the way, it's only doing it while debugging for me. If I run from the executable, it loads other levels just fine. So check this if you're trying to reproduce!

Last edited by Nickotte; 14-01-15 at 21:14.
Nickotte is offline   Reply With Quote
Old 15-01-15, 07:45   #1138
Ado Croft
Historian
 
Join Date: Apr 2013
Posts: 265
Default

Well, i decided to record a video about these bugs. Here it is:

https://www.youtube.com/watch?v=L36W...ature=youtu.be

"By the way, it's only doing it while debugging for me. If I run from the executable, it loads other levels just fine. So check this if you're trying to reproduce!"

well, it is more complicated then i thought. As you can see on this video I tried to load level 11(Tibetan Foothills) from TR2. When i change some game from console and then i load the current level it doesn't work at all. But when I change 12 level to 18-17,15,13-6,3 level in config file and then I load it, it works fine but when I change for example 6 level to 5 level and load it, it doesn't work at all. Really weird bug

Last edited by Ado Croft; 15-01-15 at 08:21.
Ado Croft is offline   Reply With Quote
Old 15-01-15, 18:31   #1139
Nickotte
Historian
 
Nickotte's Avatar
 
Join Date: May 2010
Location: Italy
Posts: 256
Default

I'm starting to think it always did it and I just didn't notice it... have you by any chance been able to figure if it always did it for you?

Anyway, I fixed the disappearing items!
Nickotte is offline   Reply With Quote
Old 15-01-15, 21:42   #1140
Ado Croft
Historian
 
Join Date: Apr 2013
Posts: 265
Default

Well, i'm not sure what u exactly mean but i have noticed when i set game for example: game 1 level 2 and load the current position in Tibetan Foothills in TR2 then it works... I guess some levels from various games will successfully load the current position and some levels not.

Anyway, thanks for fixing rendering bug. Now it works almost great but there is a bug i haven't noticed before. I'm gonna try to explain it in Barkhang Monastery level: i.e. when i pick up three pieces of prayer wheel and then i place one of them to the puzzle hole then it will disappear other prayer wheels in inventory

Last edited by Ado Croft; 15-01-15 at 22:06.
Ado Croft is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 19:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.