-
Mein Codebeispiel war minimal, es ist also nicht unbedingt deine Schuld, dass du es falsch verwendet hast
Code:
var string s; s = "A";
var int ptr; ptr = _@s(s);
var string s2; s2 = MEM_ReadString(ptr);
Print(s2);
Dieses Beispiel sollte "A" ausgeben.
-
Ich meine einen Fehler in den String-Funktionen entdeckt zu haben. Folgende Situation:
Ich möchte prüfen, ob ein String in einem anderen enthalten ist. STR_IndexOf(string, string) bietet sich an. Da mir die Groß- und Kleinschreibung egal ist wende ich auf jeden Parameter STR_Upper an.
Code:
var int k;
k = STR_IndexOf(STR_Upper("wog"), STR_Upper("o"));
Der erwartete Rückgabewert: 1
Der erfolgte Rückgabewert: 0
Es wird immer 0 zurückgegeben, auch, wenn man "g" statt "o" nimmt.
Folgendes jedoch funktioniert:
Code:
var string s; s = "wog";
s = STR_Upper(s);
var int k; k = STR_IndexOf(s, STR_Upper("o"));
Es scheint also etwas mit dem unmittelbarem, zweimaligem Aufruf von STR_Upper etwas zu tun zu haben.
Ist nicht weiter schlimm, dass das passiert, man kann es ja bequem anders machen, ist mir halt nur aufgestoßen und ich dachte es interessiert vielleicht jemanden
-
Das ist ein bekanntes Problem, das nicht von Ikarus sondern von Gothic selber stammt. Als Rückgabewerte werden nur Referenzen (Adressen) gepusht, keine konkreten Werte. Diese Referenzen werden dann beim zweiten Aufruf überschrieben. Einfaches Beispiel
Code:
Print(ConcatStrings(IntToString(1), IntToString(2)));
gibt "22" aus und nicht, wie zu erwarten wäre, "12".
Bei Integern hast du eigentlich das selbe Problem:
Code:
func int foo(var int x) {
return x;
};
...
Print(IntToString(foo(1)+foo(15))); // Ausgabe: "30" und nicht "16
Allerdings kann das verhindert werden, in dem man die Rückgabewerte noch in der Funktion dereferenziert:
Code:
func int foo(var int x) {
return +x;
};
Mit dieser Definition hätte man das Problem nicht.
Leider kann man Strings nicht so einfach dereferenzieren, deswegen zeigen String-Funktionen dieses Verhalten meistens (Ein Workaround ist denkbar, aber ist in Ikarus nur in einigen Funktionen zu finden (MEM_PushString() glaube ich).
-
Okay, wieder was gelernt.
Danke!
-
focus color for the mobs beling locked
hi, I hava review all posts regarding ikarus forsearching answer how to change focus color of chests being locked and I could not find solution. As it see I tried a few combinations.
here is script for Gothic !, but it seems to not working properly.
Code:
func void FocusColor() {
var oCNpc her;
her = Hlp_GetNpc (hero);
//var oCMobLockable Zamek;
//Zamek = MEM_PtrToInst (her.focus_vob);
var int col;
const int zCView_SetFontColor_offset = 7339392; //6FFD80 thiscall(zCColor)
if (Hlp_Is_oCNpc(her.focus_vob)){ //jeśli patrzysz na skrzynię
//var oCMobContainer Chest;
var oCMobLockable Chest;
Chest = MEM_PtrToInst(her.focus_vob);
if (Chest.bitfield & oCMobLockable_bitfield_locked)
//(Chest._oCMobLockable_bitfield == true) //if chest is locked
{
col = RGBAToZColor(0,0,255,255); // blue color will appear
}
else
{
col = RGBAToZColor(255,255,255,255);//neutral if this is no chest
};
var int ptr;ptr = MEM_Alloc(4);
MEM_WriteInt(ptr, col);
CALL_IntParam(ptr);
CALL__thiscall(MEM_ReadInt(screen_offset), zCView_SetFontColor_offset);
MEM_Free(ptr);
};
};
-
Ich hab bisher immer VirtualKeys und die dazugehörigen WinAPI funktion genutzt für die Tastenabfrage und würde das gerne auf die Gothic Funktion umstellen.
Bietet Gothic eine Funktion an, um die DIK_Keys in den dazugehörigen char, bzw string umzuwandeln?
-
chest or door being locked or no
Hi, again me. I review your example (beispiel) skript for gothic1 and I still do not work on my ikarius.
It seems the print the same text "Folgendes Vob geöffnet: " on each kind of mob (bed, chest, cl;audron. etc.) what is wrong?
HTML-Code:
func void OpenFocussedChestOrDoor() { var oCNpc her;
her = Hlp_GetNpc (hero);
//Gar kein Fokusvob?
if (!her.focus_vob) {
Print ("Kein Fokus!");
return;
};
//Fokusvob kein verschließbares Vob?
if (!Hlp_Is_oCMobLockable(her.focus_vob)) {
Print ("Keine Truhe oder Tür im Fokus!");
return;
};
var oCMobLockable Lockable;
Lockable = MEM_PtrToInst (her.focus_vob);
if (Lockable.bitfield & oCMobLockable_bitfield_locked)
{
Lockable.bitfield = Lockable.bitfield & ~
oCMobLockable_bitfield_locked;
Print (ConcatStrings (
"Folgendes Vob geöffnet: ",
Lockable._zCObject_objectName));
} else {
Print (ConcatStrings (
Lockable._zCObject_objectName,
" war gar nicht abgeschlossen!"));
};
};
-
Zitat von mainclain
Ich hab bisher immer VirtualKeys und die dazugehörigen WinAPI funktion genutzt für die Tastenabfrage und würde das gerne auf die Gothic Funktion umstellen.
Bietet Gothic eine Funktion an, um die DIK_Keys in den dazugehörigen char, bzw string umzuwandeln?
Soweit ich weiß, nicht. Ich habe das mal gelöst, indem ich die einzelnen Keys abgefragt habe (frisst bei mehr als 50 Buchstaben ENORM Perfomance), was natürlich nicht besonders elegant ist
-
Zitat von mainclain
Ich hab bisher immer VirtualKeys und die dazugehörigen WinAPI funktion genutzt für die Tastenabfrage und würde das gerne auf die Gothic Funktion umstellen.
Bietet Gothic eine Funktion an, um die DIK_Keys in den dazugehörigen char, bzw string umzuwandeln?
Mir ist keine bekannt.
Willst du auf Tastaturlayouts Rücksicht nehmen? Wenn nicht, sollte man sich das doch fix selber basteln können.
-
Zitat von Lehona
Mir ist keine bekannt.
Willst du auf Tastaturlayouts Rücksicht nehmen? Wenn nicht, sollte man sich das doch fix selber basteln können.
Genau das wollte ich^^
Zitat von Rantragon
Soweit ich weiß, nicht. Ich habe das mal gelöst, indem ich die einzelnen Keys abgefragt habe (frisst bei mehr als 50 Buchstaben ENORM Perfomance), was natürlich nicht besonders elegant ist [Bild: fressehalten.gif]
Das war nicht das Problem, das Problem war, aus den key den jeweiligen String zu generieren (z.b. aus DIK_SEMIKOLON ein ö oder welcher umlaut das darstellt usw.) und das ganze natürlich noch im Bezug auf das in Windows definierte Tastaturlayout.
-
Es gibt
Code:
.text:004D2130 unsigned char __cdecl GetCharFromDIK(int, int, int)
Wobei der erste Parameter der DIK-Code ist und du die letzten beiden einfach bei 0 lassen kannst, glaube ich (wird zumindest bei den meisten Calls, die ich mir angesehen habe, gemacht - keine Ahnung, welche Auswirkungen die genau haben).
-
hm vll noch shift und altgr oder sowas.
Ich teste es bei zeiten mal aus.
-
ikarus on Gothic 1
again me,
if anyone of advandced modders is willing to help our polish community with autopen chest/door please join to discussion. We can not sorted this matter till today.
http://themodders.org/index.php?topi...39013#lastPost
-
Zitat von pawbuj
Could you further explain the problem, the most modders here dont speak(myself included) polish and just guessing the problem from the code given is difficult.
These days, most of my projects can be found on github.
-
Zitat von Pawbuj
hi, I hava review all posts regarding ikarus forsearching answer how to change focus color of chests being locked and I could not find solution.
Take that.
func void ChestColorChanger()
{ var oCNpc her;
var int ptr;
var oCMobContainer chest;
var int col;
chest = MEM_PtrToInst (her.focus_vob);
her = Hlp_GetNpc (hero);
const int zCView__SetFontColor = 8034576; // Address in g1: 7339392 and in g2: 8034576
if !Hlp_Is_oCMobContainer(her.focus_vob)
{ col = RGBA(255,255,255,255); //White return; }
else
{ if (chest._oCMobLockable_bitfield & oCMobLockable_bitfield_locked) { col = RGBA(197,10,10,255); //Red }
else
{ col = RGBA(255,255,255,255); //White }; };
ptr = MEM_Alloc(4);
MEM_WriteInt(ptr, col);
CALL_IntParam(ptr);
CALL__thiscall(MEM_ReadInt(screen_offset), zCView__SetFontColor);
MEM_Free(ptr); };
Similarly with doors.
Geändert von hatrez123 (17.05.2014 um 18:39 Uhr)
-
hook engine on g1
hi, anyone knows how to use hookengine on gothic 1?
anyone tested?
-
Zitat von pawbuj
hi, anyone knows how to use hookengine on gothic 1?
anyone tested?
There's a version for Gothic 1 floating around (on TheModders.org even), but I think it was modified and certainly isn't completely up to date.
LeGo will most likely never support Gothic 1 (unless someone is willing port it), so I won't bother porting it. If you feel like doing it yourself, you're most welcome.
-
I have this version of Hook Engine, but there is no much document with guide how to use it.
another isssue:
is possiible (of course with Ikarus paket, not a standard scripts) to control other NPC's body (like by using spell "control" ) by their ID?
-
Do you know that you can control other NPCs in Marvin-Mode if you focus them and press "o"? It's very easy to achieve the same with scripts. However, I'm sure you can easily introduce bugs if you aren't careful, so it really depends on what exactly you want to do.
You don't really need much documentation to use HookEngine. The address is an address within the code-segment of the Gothic.exe, the oldInstr parameter is the smallest length of instructions bigger than 4 (so 5 at least) at the given address and func is the function you want to have called when said address is executed. Most (if not all) available register (EAX, EDX, ...) will be applied if you change them within your called function.
It's really more about the general concepts that you have to understand than about this one script. If you don't know how to find the address you want and have nobody do it for you, no amount of documentation will help you.
-
The best way is change the visual of main hero. I can suppose, that hero instance(mean PC_Hero) is hardcoding in engine and changing npc to control him by scripts (like press 'o') will cause of bugs.
I've one problem:
func void init_global()
{ Game_InitGerman();
Lego_Init(Lego_HookEngine);
var string GothicRestarted;
if (!Hlp_StrCmp(GothicRestarted, "YES"))
{ HookEngine(oCGame__UpdateStatus, 5, "ChestColorChanger");
HookEngine(oCGame__UpdateStatus, 5, "DoorColorChanger");
GothicRestarted = "YES"; }; };
I'm hooking two funcs but it's cause of game crash at the start(without any errors).
But with hooked one func works great.
func void init_global()
{ Game_InitGerman();
Lego_Init(Lego_HookEngine);
var string GothicRestarted;
if (!Hlp_StrCmp(GothicRestarted, "YES"))
{ HookEngine(oCGame__UpdateStatus, 8, "ChestColorChanger");
//HookEngine(oCGame__UpdateStatus, 5, "DoorColorChanger");
GothicRestarted = "YES"; }; };
These funcs are changing color of focused chest(when is locked/unlocked/empty) and focused doors(when are locked/unlocked). I don't know oldInstr value. If oldInstr value is lower than 8 it's cause of game crash.
Geändert von hatrez123 (24.05.2014 um 10:55 Uhr)
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
|