|
-
Apprentice
[G2]Change const to var?
Hello. It's possible(with using Ikarus/Lego or just basic Daedalus) to change during game a original string from Text.d and Constants.d? Example, during dialoge with Xardas, we set "Name_Currency" = "something", and after save/loading game that new string exist on game?
-
Gothic does not have "const".
A "const" is basically a "var" that is re-initialized every time the game is restarted.
You can always re-assign a "const" and the new value will be instantly reflected.
A "const" is not stored in the savegame.
-
Apprentice
So, if i want change 3 const string from Text and Constants, how i should try it? Because i don't think this is easy like "Name_Currency is original set as Gold", so i can during dialoge add "Name_Currency = other text".
Geändert von dorumia (30.08.2021 um 18:40 Uhr)
-
Apprentice
-
Zitat von dorumia
So, if i want change 3 const string from Text and Constants, how i should try it? Because i don't think this is easy like "Name_Currency is original set as Gold", so i can during dialoge add "Name_Currency = other text".
Some things are hard-coded into the engine, and only looked up once (e.g. TRADE_CURRENCY or smth like that, that one thing that says gold), other things can be set in initGlobal to apply on load or in specific dialog options etc.
Zitat von dorumia
Or it's impossible?
What do you try to accomplish?
No one can really help you with the information you gave us until now.
-
Apprentice
Zitat von Kirides
Some things are hard-coded into the engine, and only looked up once (e.g. TRADE_CURRENCY or smth like that, that one thing that says gold), other things can be set in initGlobal to apply on load or in specific dialog options etc.
What do you try to accomplish?
No one can really help you with the information you gave us until now.
What i try accomplish? I try get two different trade currency during game. For example - basic currency from my script are Magic Ore. And what i want? I want change them during game(not on start, but ex. in moment, when we meet specific NPC) to original Gold.
-
Zitat von dorumia
What i try accomplish? I try get two different trade currency during game. For example - basic currency from my script are Magic Ore. And what i want? I want change them during game(not on start, but ex. in moment, when we meet specific NPC) to original Gold.
You can try the following code (Gothic 2 only)
It requires Ikarus to work
Code:
func void UpdateCurrency() {
// Set these two values and then call UpdateCurrency
// TRADE_CURRENCY_INSTANCE = "ITMI_PAN";
// NAME_Currency = "Pfanne(n): ";
// TRADE_VALUE_MULTIPLIER = 60.0;
const int idx = 0; idx = MEM_FindParserSymbol(TRADE_CURRENCY_INSTANCE);
const int GetCurrencyInstance_CurrencyInstance_G2 = 9137116; // 008b6bdc
const int GetCurrencyInstanceName_CurrencyInstanceName_G2 = 11210948; // 00ab10c4
const int GetCategorySelfPlayerPrefix_CategoryPrefix_G2 = 11210556; // 00ab0f3c
const int GetValueMultiplier_ValueMultiplier_G2 = 11211032; // 00ab1118
// Set the trade value multiplier.
MEM_WriteInt(GetValueMultiplier_ValueMultiplier_G2, castToIntf(TRADE_VALUE_MULTIPLIER));
// Sets the used item for trade
MEM_WriteInt(GetCurrencyInstance_CurrencyInstance_G2, idx);
MEM_WriteString(GetCurrencyInstanceName_CurrencyInstanceName_G2, TRADE_CURRENCY_INSTANCE);
// Sets the prefix that is used for display in the players inventory
MEM_WriteString(GetCategorySelfPlayerPrefix_CategoryPrefix_G2, NAME_Currency);
};
Geändert von Kirides (01.09.2021 um 08:37 Uhr)
-
Apprentice
Zitat von Kirides
You can try the following code (Gothic 2, as you didn't mention which gothic version you're using...)
It requires Ikarus to work
Code:
func void UpdateCurrency() {
// Set these two values and then call UpdateCurrency
// TRADE_CURRENCY_INSTANCE = "ITMI_PAN";
// NAME_Currency = "Pfanne(n): ";
// TRADE_VALUE_MULTIPLIER = 60.0;
const int idx = 0; idx = MEM_FindParserSymbol(TRADE_CURRENCY_INSTANCE);
const int GetCurrencyInstance_CurrencyInstance_G2 = 9137116; // 008b6bdc
const int GetCurrencyInstanceName_CurrencyInstanceName_G2 = 11210948; // 00ab10c4
const int GetCategorySelfPlayerPrefix_CategoryPrefix_G2 = 11210556; // 00ab0f3c
const int GetValueMultiplier_ValueMultiplier_G2 = 11211032; // 00ab1118
// Set the trade value multiplier.
MEM_WriteInt(GetValueMultiplier_ValueMultiplier_G2, castToIntf(TRADE_VALUE_MULTIPLIER));
// Sets the used item for trade
MEM_WriteInt(GetCurrencyInstance_CurrencyInstance_G2, idx);
MEM_WriteString(GetCurrencyInstanceName_CurrencyInstanceName_G2, TRADE_CURRENCY_INSTANCE);
// Sets the prefix that is used for display in the players inventory
MEM_WriteString(GetCategorySelfPlayerPrefix_CategoryPrefix_G2, NAME_Currency);
};
Yeah sorry, im stupid. Of course i mean G2. This code work perfect(i create another Update_Currency to check if i can back to early value), but i have question to future research. How i can get that address?
Code:
const int GetCurrencyInstance_CurrencyInstance_G2 = 9137116; // 008b6bdc
Because i can give any name to const, but how i can find needed address and other stuff? Anyway, big thanks for that. Really.
Geändert von dorumia (31.08.2021 um 22:58 Uhr)
-
Zitat von dorumia
Yeah sorry, im stupid. Of course i mean G2. This code work perfect(i create another Update_Currency to check if i can back to early value), but i have question to future research. How i can get that address?
Code:
const int GetCurrencyInstance_CurrencyInstance_G2 = 9137116; // 008b6bdc
Because i can give any name to const, but how i can find needed address and other stuff? Anyway, big thanks for that. Really.
This is a bit difficult.
I used a decompiler (Ghidra) and looked up references to "TRADE_CURRENCY_INSTANCE", found GetCurrencyInstance, looked around to find some static variable (denoted by "DAT_0000000" where the "0" is some hexadecimal value. Now i had to do some guess work to find out where the string value started, because i didn't know what part of the string is being accessed.
Once i found that out, i looked up NAME_Currency (as that was another string, so i kinda knew what to expect) and the others, which were int and float values respectively - a lot easier to find out, as they're just a single 4 byte value.
To find all of this, i looked up every function that contained something with "currency" in hope to find everything.
Luckily, the refactor for Gothic 2 made all of this configurable through script values. I tried to lookup something simmilar for G1, but found nothing. The only ITMINUGGET reference i found, was for cheat codes ^^
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
|
|