-
Only one param? Or if i understand more params is called like this:
Code:
func void pAI_PlayAni(var c_npc slf, var string ani)
{
passArgumentS(ani);
passArgumentN(slf);
Print(ConcatStrings(slf.name, " play ani: "));
Print(ani);
ContinueCall();
};
//Setup:
HookDaedalusFunc(AI_PlayAni, pAI_PlayAni);
-
Yeah, you can do any amount of parameters. I would probably call the PassArgumentX-functions right above ContinueCall() but I think it doesn't even matter.
Edit: That's an external, though, you can't hook those. Look at Print_FixPS() in Interface.d to learn how to "hook" externals (rather: how to replace externals).
-
LeGo initialization for Gothic 1
Here is a little hint on how to initialize LeGo (or also only Ikarus) for Gothic 1. This is not so apparent since Gothic 1 does not have an Init_Global function.
You simply create the Init_Global function yourself and have it called from all[1] Init_* functions.
[1] Not Init_Sub_* functions!
Here the Startup.d in unified diff:
Code:
--- a/_work/DATA/Scripts/content/Story/Startup.d
+++ b/_work/DATA/Scripts/content/Story/Startup.d
@@ -1,3 +1,13 @@
+/*
+ * This function was added to Gothic 1 for initialization. It is called on every new game, loading and level change.
+ */
+func void INIT_Global() {
+ // Initialize LeGo
+ LeGo_Init(LeGo_All);
+};
+
+
+
func VOID STARTUP_SUB_PSICAMP ()
{
//-----------OLD MINE-----------------------------------------
@@ -2266,6 +2276,8 @@
//-------- eigentliche Startup des Spiels --------
FUNC VOID INIT_WORLD ()
{
+ INIT_Global();
+
INIT_Sub_Newcamp ();
INIT_Sub_Oldcamp ();
INIT_Sub_Psicamp ();
@@ -2359,6 +2371,8 @@
FUNC VOID INIT_ORCGRAVEYARD ()
{
+ INIT_Global();
+
Wld_SetMobRoutine (00,00, "FIREPLACE", 1);
//-------- Attitüden initialisieren --------
@@ -2502,6 +2516,8 @@
FUNC VOID INIT_ORCTEMPEL ()
{
+ INIT_Global();
+
//-------- Objekt-TAs --------
Wld_SetMobRoutine (00,00, "FIREPLACE", 1);
@@ -2634,6 +2650,8 @@
FUNC VOID INIT_OLDMINE ()
{
+ INIT_Global();
+
Wld_SetMobRoutine (00,00, "FIREPLACE", 1);
//-------- Attitüden initialisieren --------
@@ -2714,5 +2732,7 @@
FUNC VOID INIT_FREEMINE ()
{
+ INIT_Global();
+
//-------------------Fackeln-----------------------------
Wld_SetMobRoutine (00,00, "FIREPLACE", 1);
-
Good idea! I added a link to this in the opening post.
-
I made some functions for LeGo, which I needed, so now i can send this function in LeGo topic:
New functions:
* int zpixelx(int x) - shorter version Print_ToVirtual(x, PS_X)
* int zpixely(int y) - shorter version Print_ToVirtual(y, PS_Y)
* void View_SetPos(int hndl, int new_x, int new_y) - Engine function zCView::SetPos( int, int)
* void View_SetTransparency(int hndl, int alpha) - Engine function for change View alpha
* zCViewText* View_CreateText(int hndl, int x, int y, string txt) - Engine function for create text in object (return zCViewText object)
* void View_SetFont(int hndl, string font) - Change font for View object
* void View_InsertItem(int hndl, int view) - Insert view object in hndl
* int anx(int hndl, int x) && int any(int hndl, int y) - return pixel positon by handle object (similary to Print_ToVirtual())
* int nax(int hndl, int x) && int nay(int hndl, int y) - convert virtual position to pixel for handle object (similary to Print_ToPixel())
* View_RePos(int hnd, int x1, int y1, int x2, int y2) - by this function you can now set position similary to View_Create(...)
Examples:
Code:
func void example()
{
var int pView1; pView1 = View_Create(1, 1, 1, 1);
var int pView2; pView2 = View_Create(1, 1, 1, 1);
View_RePos(pView1, 1024, 1024, 3000, 3000);
View_SetTexture(pView1, "White");
View_SetTransparency(pView1, 150);
View_Open(pView1);
//Second object - insert in first
View_SetPos(pView2, zpixelx(100), zpixely(100));
View_Resize(pView2, zpixelx(100), zpixely(100));
View_SetTexture(pView1, "Black");
View_SetFont(pView2, FONT_SCREEN);
View_CreateText(pView2, 1024, 1024, "My text!");
View_InsertItem(pView1, pView2);
};
Source:
Code:
const int zCView__SetPos = 8025520; //0x007A75B0 void __thiscall zCView::SetPos(int, int)
const int zCView__SetTransparency = 8020064; //0x007A6060 void __thiscall zCView::SetTransparency(int)
const int zCView__CreateText = 8037040; //0x007AA2B0 zCViewText * __thiscall zCView::CreateText(int, int, zSTRING)
const int zCView__SetFont = 8034592; //0x007A9920 void __thiscall zCView::SetFont(zSTRING)
const int zCView__InsertItem = 8043216; //0x007ABAD0 void __thiscall zCView::InsertItem(zCView*)
const int zCView__anx = 8019584; //0x007A5E80 int __thiscall zCView::anx(int)
const int zCView__any = 8019648; //0x007A5EC0 int __thiscall zCView::any(int)
const int zCView__nax = 8019456; //0x007A5E00 int __thiscall zCView::nax(int)
const int zCView__nay = 8019520; //0x007A5E40 int __thiscall zCView::nay(int)
//Need all addresses for Gothic 1 !!!
func int zpixelx(var int x)
{
return Print_ToVirtual(x, PS_X);
};
func int zpixely(var int y)
{
return Print_ToVirtual(y, PS_Y);
};
func void ViewPtr_SetPos(var int ptr, var int x, var int y)
{
CALL_IntParam(y);
CALL_IntParam(x);
CALL__thiscall(ptr, zCView__SetPos);
};
func void View_SetPos(var int hndl, var int x, var int y)
{
ViewPtr_SetPos(getPtr(hndl), x, y);
};
func void View_SetPosPxl(var int hndl, var int x, var int y)
{
View_SetPos(hndl, zpixelx(x), zpixely(y));
};
func void ViewPtr_SetTransparency(var int ptr, var int alpha)
{
if(alpha >= 255){
alpha = 255;
};
CALL_IntParam(alpha);
CALL__thiscall(ptr, zCView__SetTransparency);
};
func void View_SetTransparency(var int hndl, var int alpha)
{
ViewPtr_SetTransparency(getPtr(hndl), alpha);
};
func int ViewPtr_CreateText(var int ptr, var int x, var int y, var string txt)
{
CALL_zStringPtrParam(txt);
CALL_IntParam(y);
CALL_IntParam(x);
CALL__thiscall(ptr, zCView__CreateText);
return CALL_RetValAsPtr();
};
func int View_CreateText(var int hndl, var int x, var int y, var string txt)
{
return ViewPtr_CreateText(getPtr(hndl), x, y, txt);
};
func void ViewPtr_SetFont(var int ptr, var string font)
{
CALL_zStringPtrParam(STR_Upper(font));
CALL__thiscall(ptr, zCView__SetFont);
};
func void View_SetFont(var int hndl, var string font)
{
ViewPtr_SetFont(getPtr(hndl), font);
};
func void ViewPtr_InsertItem(var int ptr, var int vptr)
{
CALL_IntParam(true);
CALL_PtrParam(vptr);
CALL__thiscall(ptr, zCView__InsertItem);
};
func void View_InsertItem(var int hndl, var int vptr)
{
ViewPtr_InsertItem(getPtr(hndl), getPtr(vptr));
};
func int anx(var int hndl, var int x)
{
CALL_IntParam(x);
CALL__thiscall(getPtr(hndl), zCView__anx);
return CALL_RetValAsInt();
};
func int any(var int hndl, var int y)
{
CALL_IntParam(y);
CALL__thiscall(getPtr(hndl), zCView__any);
return CALL_RetValAsInt();
};
func int nax(var int hndl, var int x)
{
CALL_IntParam(x);
CALL__thiscall(getPtr(hndl), zCView__nax);
return CALL_RetValAsInt();
};
func int nay(var int hndl, var int y)
{
CALL_IntParam(y);
CALL__thiscall(getPtr(hndl), zCView__nay);
return CALL_RetValAsInt();
};
func void ViewPtr_RePos(var int ptr, var int x, var int y, var int x2, var int y2)
{
var zCView v; v = _^(ptr);
v.vposx = x;
v.vposy = y;
var int hlp[2];
hlp[0] = x2 - x + 1;
hlp[1] = y2 - y + 1;
if(hlp[0] <= 0){
hlp[0] = 1;
};
if(hlp[1] <= 0){
hlp[1] = 1;
};
v.vsizex = hlp[0];
v.vsizey = hlp[1];
};
func void View_RePos(var int h, var int x, var int y, var int x2, var int y2)
{
ViewPtr_RePos(getPtr(h), x, y, x2, y2);
};
So... good luck with this functions
-
Ich wollte Mud-Freaks "Freies Zielen" in unsere G2 Mod einbinden, musste aber hierfür unsere bisherige LeGo Version 2.4.0 auf die neue 2.5.0 aktualisieren. Beim parsen der Scripte gab es mehrere Errormeldungen, die ich minimieren konnte, nachdem ich die Gothic 1 relevanten Scripte herausgenommen habe. Es kommt nun aber die Meldung U:RAR: Unknown var AIV_Talent_Index. Was fehlt da?
Geändert von Alain Dufont (11.12.2017 um 20:32 Uhr)
-
Die Variablendeklaration steht in der EngineAdr_G*.d, hast du etwa beide Versionen entfernt? Du musst jeweils die "falsche" Version entfernen, d.h. für Gothic 2 musst du die Datei EngineAdr_G1.d löschen (oder umbenennen).
@Siemekk: Thanks for sharing! Don't have time to look at them at the moment, but they look very helpful
-
Zitat von Lehona
Die Variablendeklaration steht in der EngineAdr_G*.d, hast du etwa beide Versionen entfernt? Du musst jeweils die "falsche" Version entfernen, d.h. für Gothic 2 musst du die Datei EngineAdr_G1.d löschen (oder umbenennen).
@Siemekk: Thanks for sharing! Don't have time to look at them at the moment, but they look very helpful
Ja, die bisherigen Errormeldungen, die sich auf Lego beziehen, erscheinen nicht mehr. Dafür kommen nun welche über Variablen von Mud-Freaks Scripten. Aber das kläre ich mit ihm.
-
do u have any example how to use deadulus_hooks nad how to init?
-
Lehona answered this question:
Zitat von Lehona
They are currently Work in Progress, i.e. I'm not sure they work properly. It works like this at the moment:
Code:
func void onDeath() {
Print("ZS_DEAD has been called");
ContinueCall();
};
// Execute this once to initialize the hook
func void setup() {
HookDaedalusFunc(ZS_DEAD, onDeath);
};
Looking at the code it will probably stop working once you save/restart/load the game.
I think you can even "steal" the parameters:
Code:
func void OnGiveTradeInv(var c_npc slf) {
Print(slf.name);
PassArgumentN(slf);
ContinueCall();
};
func void setup() {
HookDaedalusFunc(B_GiveTradeInv, OnGiveTradeInv);
};
-
I have serious problem with "frei zeilung". Gothic 1
after started new game following crash happened. WTF?
Code:
02:09 Fault: 0 Q: [start of stacktrace]
02:09 Fault: 0 Q: MEMINT_HANDLEERROR(3, 'Insufficient LeGo flags for Gothic Free Aim.') + 62 bytes
02:09 Fault: 0 Q: MEM_ERROR('Insufficient LeGo flags for Gothic Free Aim.') + 21 bytes
02:09 Fault: 0 Q: GFA_INITONCE() + 32 bytes
02:09 Fault: 0 Q: GFA_INIT(31) + 169 bytes
02:09 Fault: 0 Q: INIT_GLOBAL() + 20 bytes
02:09 Fault: 0 Q: INIT_WORLD() + 45 bytes
02:09 Fault: 0 Q: STARTUP_WORLD() + 35 bytes
02:09 Fault: 0 Q: [end of stacktrace]
02:09 Fault: 0 Q: Insufficient LeGo flags for Gothic Free Aim.
-
Zitat von pawbuj
I have serious problem with "frei zeilung". Gothic 1
If you manually initialize LeGo you have to add the flags that are required for GFA.
See: Features and Configuration / Required LeGo Packages
"Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
-
Zitat von NicoDE
thanks Nico.
I found a problem . I did not properly paste files to menu.\
Well there is no crash but free zeilung still does not works. there is no aim trigger on the screen.
I do not understand points 6 &7 .
- In _work\data\Anims\Humans.mds add the lines as indicated in _work\data\Anims\Humans.mds.additions.
Do the same analogous for _work\data\Anims\MDS_Overlay
\Humans_BowT2.mds.additions and _work\data\Anims\MDS_Overlay\Humans_CBowT2.mds.additions.
those 2 files are not exist in standard Gothic package .I have copied them to mdsoverlay.
- Backup and delete the following files
- _work\data\Anims\_compiled\HUMANS.MDH
- _work\data\Anims\_compiled\HUMANS_BOWT2.MDH
- _work\data\Anims\_compiled\HUMANS_CBOWT2.MDH
- Do Ineed to copy them o gothic/_work/anims/_compiled/ ??
-
I do not see anywhere in lego.src entry daedalus_hooks.d. is that OK? without that I can not use that feature!
after adding that file I have error in the line 28. expected ":"
-
It probably says "expected ;" and you can just add one on line 27. But as you can see those scripts are not even remotely tested at all...
-
Zitat von Lehona
It probably says "expected ;" and you can just add one on line 27. But as you can see those scripts are not even remotely tested at all...
I am faraway to modify that script. will anyone fix that? hooking funcs from externals is nice feature.
-
That should fix it. Just replace it:
Code:
var int HT_Hooks;
func void Init_Hooks() {
if (!HT_Hooks) {
HT_Hooks = HT_Create();
};
};
func void HookDaedalusFunc(var func hooked, var func hooker) {
var int hookeeID; hookeeID = MEM_GetFuncID(hooked);
var int hookerID; hookerID = MEM_GetFuncID(hooker);
var zCPar_Symbol symb; symb = _^(MEM_GetSymbolByIndex(hookeeID));
var zCPar_Symbol symb_er; symb_er = _^(MEM_GetSymbolByIndex(hookerID));
/* If someone uses the same hook function twice, they'll get a popup (or a slap on the wrist) */
if (HT_Has(HT_Hooks, hookerID)) {
if (HT_Get(HT_Hooks, hookerID) != symb.content) {
SB_New();
SB("Function ");
SB(symb_er.name);
SB(" is already hooking another function. It was trying to hook ");
SB(symb.name);
MEM_InfoBox(SB_ToString());
} else {
MEM_Warn("You're trying to hook a function twice with the same targets. Second hooking ignored, consider yourself sacked.");
};
};
HT_Insert(HT_Hooks, symb.content, hookerID);
symb.content = symb_er.content;
};
func void ContinueCall() {
var int fromID; fromID = MEM_GetFuncIDByOffset(MEM_GetCallerStackPos());
var int to; to = HT_Get(HT_Hooks, fromID);
MEM_CallByOffset(to);
};
func void passArgumentI(var int i) { return +i; };
func void passArgumentS(var string s) {
CALLINT_PushString(s);
};
func void passArgumentN(var int n) {
MEMINT_StackPushInst(n);
};
-
Dada, looks like here is error expeced ":" in that line, so almost atthe end of the script.
Code:
func void passArgumentI(var int i) { return +i; };
-
Has to be "func int ...".
I have to stress again that I'm not very confident those scripts even work. A sidenote: It sounds like you want to hook externals? That won't work.
-
Kann es passieren, dass NPC in einem Trialog weiter ihrem TA nachgehen, wenn sie gerade nicht sprechen / nicht self sind? Ich habe eine Situation, in der der Spieler zwei NPC abfängt, die von einem WP aus zu ihrem neuen TA-WP gehen (sie werden nach "A" teleportiert, aber TA ist an "B"). Meine Tester sagen mir, dass die Npc während des Trialogs vom Helden weg laufen.
Beide Npc werden vor dem Trialog mit TRIA_Invite() eingeladen und kommen auch während des Trialogs zu Wort, das funktioniert auch.
Meine Fragen daher:
1) Ist das tatsächlich Ursache des Problems? Falls nein, andere Ideen?
2) Kann ich da was gegen tun?
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
|