Ikarus (Pakiet skryptów) 412918 1020

O temacie

Autor orcwarrior

Zaczęty 11.06.2010 roku

Wyświetleń 412918

Odpowiedzi 1020

orcwarrior

orcwarrior

The Modders
posty475
Propsy317
Profesjabrak
  • The Modders
no właśnie te zobaczyłem ten twój post na wog i też zrobiłem upload w moich plikach i dalej było to samo ; /.
EDIT dodałem do start up i dalej jak podchodzę do npc to wywala a skrypt to ten woga na zmianę koloru

Tam gdzie jest funkcja zmieniajaca kolor czcionki tj. EVT_UpdateStatus_FocusName


wywal cały skrypt i dla sprawdzenia wpisz tylko:

Print("To działa");

ot prosta metoda na rozeznanie co powoduje błąd, jeżeli nadal będzie wywalać to wskazuje na złe wywołanie funkcji HookEngine (zle parrametry) albo na to że sama funkcja jest nadał błędna. Ja u siebie tą funkcje mam sporo przerobioną, ale mimo to moge sprobować pomoc.

 



orcwarrior

orcwarrior

The Modders
posty475
Propsy317
Profesjabrak
  • The Modders
Obiecany skrypt dzieki któremu w G1 Npc mogą odrazu padać martwi + mój lekko zmodyfikowany HookEngine do G1:

HookEngine.d (parsować w gothic.src gdzies zaraz po Ikarus.d)
Spoiler
/****************************************************\
 * ENGINEHOOKS                                      *
 * Dieses kleine Paket erlaubt Daedalusfunktionen   *
 * an Enginefunktionen zu hängen und somit Zugriff  *
 * auf bestimmte Vorgänge außerhalb der Scripte zu  *
 * bekommen.                                        *
 * Beispiel: Man könnte einen Hook an die Speicher- *
 * funktion der Engine setzen und damit strings die *
 * regulär nicht gespeichert werden noch schnell in *
 * bspw. den Namen eines zCVob legen um sie zu be-  *
 * halten.                                          *
\****************************************************/

//-------------------
// OPCODES
//-------------------
/* 1 Byte */
const int ASMINT_OP_pusha       = 96;    //0x60
const int ASMINT_OP_popa        = 97;    //0x61
const int ASMINT_OP_movMemToEAX = 161;     //0xA1
/* 2 Byte */
const int ASMINT_OP_movECXtoEAX = 49547; //0xC18B
const int ASMINT_OP_movESPtoEAX = 50315; //0xC48B
const int ASMINT_OP_movEAXtoECX = 49545; //0xC189
const int ASMINT_OP_movEBXtoEAX = 55433; //0xD889
const int ASMINT_OP_movEBPtoEAX = 50571; //0xC58B

//-------------------
// KONSTANTEN
//-------------------
const int parser            = ContentParserAddress; //0xAB40C0 zCParser
const int zParser__CallFunc = 7247504;  //0x6E9690  CallFunc(int,...)

//-------------------
// Hooks varibles
//-------------------
var int HookEngine_Hook_PreUnconscious_JmpAdress; //Where jmp adress is placed rite now;
var int HookEngine_Hook_PreDropVob_JmpAdress;

var string HooksReinited;

//-------------------
// RÜCKGABEVARIABLEN
//-------------------
var int EAX;
func int GetEAX() { return EAX; };
func int EAXAdr() {
    GetEAX();
    MEMINT_StackPopInst();
    MEMINT_StackPushInst(zPAR_TOK_PUSHINT);
};
var int ECX;
func int GetECX() { return ECX; };
func int ECXAdr() {
    GetECX();
    MEMINT_StackPopInst();
    MEMINT_StackPushInst(zPAR_TOK_PUSHINT);
};
var int ESP;
func int GetESP() { return ESP; };
func int ESPAdr() {
    GetESP();
    MEMINT_StackPopInst();
    MEMINT_StackPushInst(zPAR_TOK_PUSHINT);
};

var int EBX;
func int GetEBX() { return EBX; };
func int EBXAdr() {
    GetEBX();
    MEMINT_StackPopInst();
    MEMINT_StackPushInst(zPAR_TOK_PUSHINT);
};    

var int EBP;
func int GetEBP() { return EBP; };
func int EBPAdr() {
    GetEBP();
    MEMINT_StackPopInst();
    MEMINT_StackPushInst(zPAR_TOK_PUSHINT);
};    


/*============================*
/* HOOKENGINE                 *
/*============================*
 - address:       Addresse einer Enginefunktion an die die Funktion angehängt werden soll.
 - oldInstr:      Die Länge in Bytes der Anweisung die an 'address' zu finden ist, mindestens 5 Bytes (Notfalls nächste Zeile noch mitnehmen).
                Kann zB. in IDA nachgesehen werden.
 - function:       Die Daedalusfunktion die aufgerufen werden soll.
*/
const int SKIP_INSTR = 0;
const int COPY_INSTR = 1;
func int HookEngine(var int address, var int oldInstr, var string function,var int skipInstr) {
    var int SymbID;   // Symbolindex von 'function'
    var int ptr;      // Pointer auf den Zwischenspeicher der alten Anweisung
    var int relAdr;   // Relative Addresse zum neuen Assemblercode, ausgehend von 'address'
    var int HookEngine_JmpAdr;
    // ----- Sicherheitsabfragen -----
    if(oldInstr < 5) {
        PrintDebug("HOOKENGINE: oldInstr ist zu kurz. Es werden mindestens 5 Bytes erwartet.");
        return -1;
    };

    SymbID = MEM_FindParserSymbol(function);
    if(!SymbID) {
        PrintDebug("HOOKENGINE: Die gegebene Daedalusfunktion kann nicht gefunden werden.");
        return -1;
    };

    MemoryProtectionOverride (address, oldInstr+3);
    // ----- Eventuell geschützen Speicher behandeln -----

    // ----- Die alte Anweisung sichern -----
    ptr = MEM_Alloc(oldInstr);
    MEM_CopyBytes(address, ptr, oldInstr);

    // ----- Einen neuen Stream für den Assemblercode anlegen -----
    ASM_Open(100 + oldInstr);

    // ----- Jump aus der Enginefunktion in den neuen Code einfügen -----
    relAdr = ASMINT_CurrRun-address-5;
    MEM_WriteInt(address + 0, 233);
    MEM_WriteInt(address + 1, relAdr);

    // ----- Neuen Assemblercode verfassen -----
  
    // Alle Register sichern
    
    // EAX in Daedalus Variable sichern
    ASM_2(ASMINT_OP_movEAXToMem);
    ASM_4(EAXAdr());
    ASM_1(ASMINT_OP_pusha);

    // ECX in Daedalus Variable sichern
    ASM_2(ASMINT_OP_movECXtoEAX);
    ASM_2(ASMINT_OP_movEAXToMem);
    ASM_4(ECXAdr());

    // ESP in Daedalus Variable sichern
    ASM_2(ASMINT_OP_movESPtoEAX);
    ASM_2(ASMINT_OP_movEAXToMem);
    ASM_4(ESPAdr());
    
    // EBX in Daedalus Variable sichern
    ASM_2(ASMINT_OP_movEBXtoEAX);
    ASM_2(ASMINT_OP_movEAXtoMem);
    ASM_4(EBXAdr());

    // EBP in Daedalus Variable sichern
    ASM_2(ASMINT_OP_movEBPtoEAX);
    ASM_2(ASMINT_OP_movEAXtoMem);
    ASM_4(EBPAdr());

    // --- Daedalusfunktion aufrufen ---

    ASM_1(ASMINT_OP_pushIm);
    ASM_4(SymbID);

    ASM_1(ASMINT_OP_pushIm);
    ASM_4(parser);

    ASM_1(ASMINT_OP_call);
    ASM_4(zParser__CallFunc-ASM_Here()-4);

    ASM_2(ASMINT_OP_addImToESP);
    ASM_1(8);

    ASM_1(ASMINT_OP_popa);
    
    ASM_1(ASMINT_OP_movMemToEAX);
    ASM_4(ECXAdr());
    ASM_2(ASMINT_OP_movEAXtoECX);
    
    ASM_1(ASMINT_OP_movMemToEAX);
    ASM_4(EAXAdr());

    // Alte Anweisung wieder einfügen
    if(skipInstr == COPY_INSTR)
    {
    MEM_CopyBytes(ptr, ASMINT_Cursor, oldInstr);
    //printdebug_s_i("HOOKENGINE: ASMINT_Cursor(oldinstr):",ASMINT_Cursor);
    ASMINT_Cursor += oldInstr;
    };
    MEM_Free(ptr);

    // Engine function to return
    ASM_1(ASMINT_OP_pushIm);
    HookEngine_JmpAdr = ASMINT_Cursor;
    ASM_4(address + oldInstr);  
    ASM_1(ASMINT_OP_retn);
    ASM_Close();
    return HookEngine_JmpAdr;
};

W pliku startup.d musimy mieć funkcje która wywołuje się z INITów każdego z używanych światów (czyli np. Init_World/Init_OldMine itd.)
Dopisujemy tam:
//Engine Hook's:
    if(!Hlp_StrCmp(HooksReinited, "Yes"))
    {
        HooksReinited="Yes";
        HookEngine_Hook_PreUnconscious_JmpAdress = HookEngine(7630776,6,"HOOK_PREUNCONSCIOUS",COPY_INSTR);
        //HookEngine_Hook_PreDropVob_JmpAdress = HookEngine(7023277,5,"HOOK_PREDROPVOB",COPY_INSTR);
    };


Na koniec sam własciwy skrypt który dodajemy w AI_Inter/ZS_Human/ZS_Unconscious.d:

Spoiler

//Funkcja warunkowa
// -false oCNpc slf będzie odrazu martwy
// -true oCNpc slf upadnie na ziemie
// warunki dowolne
// obawiam się ze moga wydarzyć się wypadki gdy oth nie jest wcale
// oCNPC a jedynie cymś zupełnie losowym, wiec lepiej używać tego ostrożnie!
func int  Npc_CanBeUnconscious(var oCNpc slf,var oCNpc oth)
{

    if((slf.variousFlags & NPC_FLAG_INSTANTDEATH) != false)
    ||((oth.variousFlags & NPC_FLAG_KILLER) != false)
    {
        return FALSE;
    };
    return TRUE;   
};

//Hook caled before oCNpc_DropUnconscious
func void HOOK_PREUNCONSCIOUS()
{
    var oCNpc npc; var oCNpc oth;

    //ECX to oCNPC wiec ECX+0x100 to C_NPC (taki cast nie działa, calość oparta na oCNPC
    MEM_AssignContentInst (npc,GetECX());   
    MEM_AssignContentInst (oth,GetESP()+128);   
   
    //Npc_ClearAiQueue(self) -> but in oCNPC way ;-)
    CALL__thiscall (MEM_InstToPtr(npc), oCNpc__ClearEM_offset);
    CALL__thiscall (npc.anictrl, oCAniCtrl_Human_StopTurnAnis_offset);
   
    if(Npc_CanBeUnconscious(npc,oth))
    {//Npc Normalnie upada na ziemie
    MEM_WriteInt(HookEngine_Hook_PreUnconscious_JmpAdress,7630776+6);   
    }
    else
    {//Npc odrazu umiera (7630776 = 1 arg. wywolania HookEngine w Startup + 6 = 2 arg. wywołania
    MEM_WriteInt(HookEngine_Hook_PreUnconscious_JmpAdress,7632080);   
    };
       
};
Jak widać skorzystałem z dwóch flag dla npc, które w mojej wersji trzeba dopisywać by npc odrazu padał/zabijał innych.


Trzeba je dodać w _Intern/constants.d

Cytuj
CONST INT NPC_FLAG_INSTANTDEATH                            =  1 << 2                ;//Npc dies instantly
CONST INT NPC_FLAG_KILLER                                =  1 << 4                ;//Npc kills enemies instantly


Będzie potrzebne kilka adresów funkcji ja daje wszystkie które do tej pory znalazłem, do wklejenia gdzieś w Ikarus_Const_G1.d




Spoiler

const int zCView_zCView_offset = 7322464;    //0x6FBB60 (void)
const int zCView_InsertItem_offset = 7347872;    //0x701EA0 (zcview*,int)
const int zCView_RemoveItem_offset = 7348448;    //0x7020E0 (zcview*)
const int zCView_Init_offset = 7324512;    //0x6FC360 stdcall(void) /returns zCView*?
const int zCView_Create_offset = 7324512;    //0x6FCC90 thiscall(string&,enum,enum,float,int)
const int zCView_SetPos_offset = 7330320;    //0x6FDA10 thiscall(int,int)
const int zCView_SetSize_offset = 7330816;    //0x6FDC00 thiscall(int,int)
const int zCView_Open_offset = 7327856;    //0x6FD070 thiscall(void)
const int zCView_Close_offset = 7328400;    //0x6FD290 thiscall(void)
const int zCView_Render_offset = 7349744;    //0x7025F0 thiscall(void)
const int zCView_SetAlphaBlendFunc_offset = 7325056;    //0x6FC580 thiscall(enum)
const int zCView_SetTransparency_offset = 7325040;    //thiscall(int)
const int zCView_InsertBack_offset = 7325248;    //thiscall(&string)
const int zCView_CreateText_offset = 7341792;    //0x7006E0 thiscall(int, int, class zSTRING const &)
const int zCView_CalcPixelPos_offset = 7330528;    //0x6FDAE0 thiscall(px,py)
const int zCView_GetPixelPos_offset = 7330592;    //6FDB20 thiscall(px,py)
const int zCView_SetFontColor_offset = 7339392;    //6FFD80 thiscall(zCColor)
const int zCView_SetFont_offset = 7339408;    //6FFD90 thiscall(string font)
 
const int zCViewStatusBar_SetValue_offset = 4629600;    // (float)
const int zCViewStatusBar_Init_offset = 4629200;    // 0x46A2D0 (void)
const int oCViewStatusBar_SetMaxRange_offset = 4432176;    // (float,float)
const int oCViewStatusBar_SetRange_offset = 4432448;    //0x46A3C0 (float,float))
const int oCViewStatusBar_SetValue_offset = 4432640;    //43A300 (char)

const int zCMenuItem__SetText_offset = 5063504;    //0x4D4350 (*ZStr,line,now?) /Crashing on updatesize???
const int zCMenuItem__DrawFront_offset = 5065040;//0x4D4950 ()


const int zCInput_SetState_offset = 4991120;    //43A300 (char,char)

const int oCAniCtrl_Human_SetAlwaysWalk_offset = 6436576;    //6236E0 (state)
const int oCAniCtrl_Human_ToggleWalkMode_offset = 6442544;    //(char?)
const int oCAniCtrl_Human_PC_SlowMove_offset = 6373952;    //0x614240(int?)
const int oCAniCtrl_Human_IsStanding_offset = 6444512;//0x6255E0   (void)
const int oCAniCtrl_Human_IsWalking_offset = 6445024;//0x6255E0   (void)                                  
const int oCAniCtrl_Human_IsStateAniActive_offset = 6444304;//0x6255E0   (void)            
const int oCAniCtrl_Human_GetWalkModeString_offset = 6432560;//             (void) ret string    
const int oCAniCtrl_Human_StopTurnAnis_offset = 6445600;    //0x625A20 (void)      
const int zCAniCtrl_StartAni_offset = 6404000;//0x61B7A0 (oCModelAni*,oCModelAniNxt)
const int JUMPUP_AniID = 4180;

const int zCModel_StartAni_offset = 5640944;//0x5612F0 (oCModelAni*,layer?)
const int zCModel_RemoveChildVobFromNode_offset = 5662496;//0x566721 (oCVob*)
const int zCModel_AttachChildVobToNode_offset = 5662128;//0x5665B0 (oCVob*,*Node)


const int zCVob_RotateWorldY_offset = 6218528;//0x5EE320 (float)

const int  zCRnd_D3D__SetBilerpFilterEnable_offset = 7445792;//(int)
const int  zCRnd_D3D__GetBilerpFilterEnable_offset = 7445920;//(void)
const int  zCRnd_D3D__SetFog_offset = 7445360;//719B70 (int foggy?)
const int  zCRnd_D3D__SetFogRange_offset = 7445600;//0719C60 (float nearz,float farz, int falloff/fogmode?)

const int  oCNpc__CloseDeadNpc_offset = 7060128;//(void)
const int  oCNpc__CloseInventory_offset = 7058160;//(void)
const int  oCNpc__RenderNpc_offset = 6940528;//0x69E770 (zcView*)
const int  oCNpc__RemoveFromSlot_offset = 6971216;//0x6A5F50 (*TNpcSlot,drop_bool)
const int  oCNpc__StringRemoveFromSlot_offset = 6971008;//0x6A5E80 (*TNpcSlot,drop_bool)
const int  oCNpc__DropFromSlot_offset = 6972016;//0x6A6270 (*TNpcSlot)
const int  oCNpc__DoDropVob_offset = 6951152;//0x6A10F0 (*zCVob)
const int  oCNpc__DoSwapMesh_offset = 6947120;//0x6A0130 (ZString node1, zString node2)
const int  oCNpc__SetTorchAni_offset = 6914064;//0x0698010 (int f, int now)
const int  oCNpc__DoExchangeTorch_offset = 6952576;//0x06A1680 (void)
const int  oCNpc__PutInSlot_offset = 6969872;//0x6A5A10 (*TNpcSlot,oCVob)
const int  oCNpc__PutInRightHand_offset = 6913472;//0x697DC0 (*oCVob)
const int  oCNpc__Equip_offset = 6908144;//0x6968F0 (*oCItem)
const int  oCNpc__Disable_offset = 6954272;//0x6A1D20 ()
const int  oCNpc__ai_disabled_adress = 9288604;//bool?
const int  oCNpc__ai_messagesSkip_adress = 9288608;//zfloat
const int  oCNpc__ai_ScriptStatesSkip_adress = 9288616;//zfloat
const int  oCNpc__game_aicon_baseAIenabled_adress = 9283196;//int
const int  oCNpc__game_aicon_messagesSkip_adress = 9283200;//int
const int  oCNpc__SetAsPlayer_offset = 6941408;//0x69EAE0 ()
const int  oCNpc__GetScriptInstance_offset = 6953920;//06A1BC0 (zString instance,int id)
const int  oCNpc__CreateVobList_offset = 7041296;//6B7110 (float distance)
const int  oCNpc__ClearVobList_offset = 7040688;//6B6EB0 ()
const int  oCNpc__DoDie_offset = 6894752;//6934A0 (ocNpc attacker)
const int  oCNpc__StartFadingAway_offset = 6895984;//0x693970 (void)
const int  oCNpc__ClearEM_offset = 6956560;//0x6A2610 (void)

const int  oCNpc__DropUnconscious_offset = 6892560;//692C10 (float azi,ocNpc attacker)
                    

const int  oCGame__SetAsPlayer_offset = 6542288;//0x63D3D0 (InstanceID string)
const int  oCGame__TriggerChangeLevel_offset = 6542464;//0x63D480 (zen_name,wpname)    


const int  oCTriggerChangeLevel__oCTriggerChangeLevel_offset = 4424256;// (void)    
const int  oCTriggerChangeLevel__SetLevelName_offset = 4425392;// (zen_name,wpname)    
const int  oCTriggerChangeLevel__TriggerTarget_offset = 4424560;//0x438370 (vob caller)    

const int  oCWorld__SearchVobByName_adress = 7173120;// (zString,?,?)

const int  zMDL_MAX_FPS = 8208616;//int

const int  oCItem__oCitem_offset = 6754208;//0x0670FA0 (zString,int)
            

const int  zCZone__GetCamPosWeight_offset = 6339472;//0x060BB90 (void) ret zFloat
const int  zCZoneZFog__GetActiveRange_offset = 6340656;//0x060C030 (void) ret zFloat

const int  TNpcSlot__SetVob_offset = 6857884;//0x68A49C (*oCVob)
const int  TNpcSlot__ClearVob_offset = 6876768;//0x68EE60 (void)

const int  zCTexture__SearchName_offset =  6064544;//_cdecl (zString*)
const int  zCTexture__LoadSingle_offset =  6064544;//_cdecl (zString*,int flags)//Needed if tex is still unused (SearchName won't be working)
const int  zCPolygon_TexScale_offset =  5868192;//598AA0 thiscall (float,float)
const int  zCPolygon_Flip_offset =  5867872;//598960 thiscall (void)
const int  zCMesh_Load_offset =  5570976;//5501A0 cdecl (*zString)

const int  zCMaterial__SetTexScale_offset = 5562336;// (float,float)
const int  zCMaterial__SetTex_offset = 5561024;//0x54DAC0 (zString)

const int  oCSkyController_SkyVari_int = 9235392;//0=poly/1=dome (???)
const int  oCSkyController_SkyDomeTex_adr = 9235264;//??
const int  oCSkyController_SkyMesh_adr = 9235380;//??ptr?
const int  oCSkyController_SkyOffset_adr = 9235024;//?
const int  oCSkyController_SkyRainCloudsStr_adr = 8660092;//"SKYRAINCLOUDS.TGA"

const int  Apply_Options_Control = 4371792;   //42B550  cdecl
const int  zCInput_Class_ptr     = 8834208;//86CCA0;
const int  zCInput__BindKeys     = 5003568;//(void)


Gdyby były jakieś problemy mogę pomóc, oczywiscie wymagane jakieś dokładniejsze opisy niż
"Eeee... mi to to nie działa."

Jeżeli zamierzacie użyć tego skryptu wypadałoby wspomnieć o jego autorze, lub modyfikacji którą tworzy.

 



EdekSumo

EdekSumo

Wyspa Khorinis
posty1739
Propsy925
ProfesjaLvl designer
  • Wyspa Khorinis
Udało mi się to uruchomić w złe miejsce wklejałem inicjacje funkcji
 

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy
Witam, mam taki problem przy zmianie wyświetlanej nazwy moba, próbuje zrobić to o co pytał wcześniej pawbuj
wartośc odczytana z her.focus_vob._oCMob_name jest CHest , chest =?   nie wiem co to za stała ale za ten text odpowiada
MOBNAME_CHEST.
Nadpisując her.focus_vob._oCMob_name = "Pusta Skrzynia" efekt jest żaden

Szukając rozwiązania próbowałem też zmienić nazwę moba wywołując ja z gry to ta funkcja
.text:0067AA30 ; public: virtual void __thiscall oCMOB::SetName(class zSTRING const &)
var int ptr;
ptr = her.focus_vob;

CALL_zStringPtrParam(MOBNAME_EMPTYCHEST);
CALL__thiscall(ptr,6793776);
efekt jest taki ze znika nazwa skrzyni
możliwe ze ta funkcja działa dobrze ale nie jest wrzucany na stos(argumenty) dobrze zstring i  nadpisuje ona
nazwe na " "

Dzieki za jakies info ;]
 

inż. Avallach

inż. Avallach

Administrator
posty7661
Propsy5239
NagrodyV
ProfesjaProgramista
  • Administrator

inż. Avallach
Administrator

Ikarus (Pakiet skryptów)
#84 2011-05-07, 13:13(Ostatnia zmiana: 2011-05-07, 13:18)
Może spróbuj po prostu
her.focus_vob._zCObject_objectName = "nowa_nazwa";Nie rozumiem dlaczego próbujesz zmieniać _oCMob_name skoro oCNpc.focus_vob jest typu zCVob, który takiego pola nie posiada. A w rzeczywistości po prostu nie dziedziczy po tej klasie, bo o ile rozumiem w Ikarusowych klasach pola typu innaklasa_zmienna są właśnie odwzorowaniem dziedziczenia. zCVob po zCObject dziedziczy, więc powinno zadziałać.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy

Shothic

Ikarus (Pakiet skryptów)
#85 2011-05-07, 13:45(Ostatnia zmiana: 2011-05-07, 13:45)
Ja złe napisałem, nie napisałem wcześniejszego kodu :
   var int ptr;
    ptr = her.focus_vob;
    //ptr = MEM_ReadInt(ptr);
    Skrzynia = MEM_PtrToInst (her.focus_vob);
    Skrzynia._oCMob_name = MOBNAME_EMPTYCHEST;
her.focus_vob._zCObject_objectName = "nowa_nazwa";

her.focus_vob //zwarca int(pointer skrzyni) nie można tak zmieniće _zCObject_objectName
Skrzynia._zCObject_objectNam = "nowa_nazwa"; //tak jest poprawnie

Ale to nie ta opcja jest za wyświetlanie nazwy moba
 

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
Please use this function from Ikarus (giving just the signature): func void MEM_RenameVob (var int vobPtr, var string newName)it's because you gotta resort the vob into the Hashtable.
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy
Thanks for the post, but this func doesn't work for my
I need to change te show name in game;
Is this func change the focusName ?? In Spacer focusName chest is :
CONST STRING MOBNAME_CHEST         = "Skrzynia";

Hare is my code :
func void HeroFocus() {
    var oCNpc her;
    her = Hlp_GetNpc (hero)
    var int returnState4;
    returnState4 = MEM_KeyState (KEY_LSHIFT);

    Skrzynia = MEM_PtrToInst (her.focus_vob);
    Nazwa = Skrzynia._oCMob_name ;

    var zCObject vob;
    vob = MEM_PtrToInst (her.focus_vob);

 if (returnState4 == KEY_PRESSED)
  {
    Print("Zmiana");
    MEM_RenameVob(her.focus_vob,MOBNAME_EMPTYCHEST);
 };

};
 

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy

Lehona

Ikarus (Pakiet skryptów)
#88 2011-05-09, 15:15(Ostatnia zmiana: 2011-05-09, 15:23)
You should do more research on your own... I just messed up like half an hour with the IDA code and while looking up some offsets found this: var int focusNameIndex;         //int //Index des Parsersymbols, dass den Namen enthält, zum Beispiel Index des Symbols MOBNAME_DOOR.Sure, it's explained in german, but the name (FocusNameIndex) should say it all. It's the index of the symbol, which holds the name. Change the name like this:
MEM_ReinitParser();
var zCPar_Symbol symb;
symb = MEM_PtrToInst(MEM_ReadIntArray (currSymbolTableAddress, oCMob.focusNameIndex));
symb.content = STRINT_GetStringAddress("STRING");
The code is not tested, but basically that's how it should work.
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy
Thanks, this must be it
your code is give Func does not return an instance
But Ok Later I try to write some Thanks
 

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
Maybe you copied the old one, I edited because I swapped MEM_InstToPtr() with MEM_PtrToInst(). Whatver, you will figure out the exact error on your own, I guess. If not you can still ask anyway, of course.
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy

Shothic

Ikarus (Pakiet skryptów)
#91 2011-05-09, 19:55(Ostatnia zmiana: 2011-05-09, 20:11)
All works great!!!!!
Thanks Lehona!
I write two func :]

FocusColor() -- Zmienia color nazwy skrzyni na pomarańczowy jeśli jest zamknięta (tak jak w gothic 3 ;])
Spoiler
func void FocusColor() {

    var oCNpc her;
    her = Hlp_GetNpc (hero);

    var int ptr;
    var oCMobLockable Zamek;
    Zamek = MEM_PtrToInst (her.focus_vob);

    var int col;
    const int zCView__SetFontColor = 7339392; //0x6FFD80 Changed


    if (!her.focus_vob) {
    col = RGBA(255,255,255,255); //Weiß
    ptr = MEM_Alloc(4);
    MEM_WriteInt(ptr, col);
    CALL_IntParam(ptr);
    CALL__thiscall(MEM_ReadInt(screen_offset), zCView__SetFontColor);
    MEM_Free(ptr);
        return;
    };
   
    if (!Hlp_Is_oCMobLockable(her.focus_vob))
    {
    return;
    } else
    {

    };



    if (Zamek.bitfield & oCMobLockable_bitfield_locked)
    {
    col = RGBA(255,180,0,255); //Orange
    } else
    {
    col = RGBA(255,255,255,255); //Weiß
    };

    ptr = MEM_Alloc(4);
    MEM_WriteInt(ptr, col);
    CALL_IntParam(ptr);
    CALL__thiscall(MEM_ReadInt(screen_offset), zCView__SetFontColor);
    MEM_Free(ptr);

};



I ChangeName() -- Zmienia nazwe skrzyni
Spoiler
func void ChangeName() {
    var oCNpc her;
    her = Hlp_GetNpc (hero);



    if (!her.focus_vob) {
        return;
    };
     
    if (!Hlp_Is_oCMobContainer(her.focus_vob)) {
        return;
    };


    var oCMob Mob;
    var oCMobContainer Skrzynia;
   

    Mob = MEM_PtrToInst (her.focus_vob);
    Skrzynia = MEM_PtrToInst (her.focus_vob);

    MEM_ReinitParser();
    var zCPar_Symbol symb;
    symb = MEM_PtrToInst(MEM_ReadIntArray (currSymbolTableAddress, MoB.focusNameIndex));


    if (Skrzynia.containList_next != 0)
    {
    symb.content = STRINT_GetStringAddress("Skrzynia");
    } else
    {
    symb.content = STRINT_GetStringAddress("Pusta Skrzynia");
    };


};

Nie przypuszczałem ze tak ciężko będzie zmienić nazwę skrzyni, ogólnie wszystko działa dobrze.
edit//Jedna rzecz mnie martwi po wyjściu z gothica wyskakują jakie errory MEM_BAD_POINTER nie wiem o co może chodzić ;/


ALL THANKS TO LEHONA !!  :ok:
 

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
I need a tad more information before I can help you :p

In which script does the error occur? Is it reproducable? Does it happen every time or just if the chest is empty? etc.

Just give me as much information as you can.
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy
Errors are  when game quit exit
MEM_BAD_POINTER - SmartHeap this
 

orcwarrior

orcwarrior

The Modders
posty475
Propsy317
Profesjabrak
  • The Modders
W twoim skrypcie zmienna

var oCMob Mob jest zbędna,  zamiast niej możesz raczej bez problemu wykorzystać poprostu Skrzynia, to taka drobnosta ;)

Co do tego MEM_BAD_POINTERA, raczej strzelam ale ja w takich wypadkach zamiast MEM_InstToPtr, uzywam MEM_AssignContentInst, nie wnikam czym to się róźni, ale w kazdym razie ja mem_bad_pointer'ów przy wyłączaniu gothica nie mam :P. Czyli wystarczy podmienic"

Skrzynia = MEM_PtrToInst (her.focus_vob);MEM_AssignContentInst (Skrzynia,her.focus_vob);    
oraz:

 symb = MEM_PtrToInst(MEM_ReadIntArray (currSymbolTableAddress, MoB.focusNameIndex));MEM_AssignContentInst (symb,MEM_ReadIntArray (currSymbolTableAddress, Skrzynia._oCMob_focusNameIndex));    
No jeżeli moje poprawki będa wogole działać to już sukces, a nóż w jakiś sposób pomogą :P. Jeżeli nie to faktycznie napisz czy błąd kiedy:

*Nie mialeś w focusie zadnej skrzyni - o ile dobrze zrozumialem jego funkcjonalność to raczej nie powinno to występować.
*Nie opróźniłeś zadnej skrzyni, ale miałeś jakąś w focusie.
*Opróźniłeś jakąś skrzynie i wyświetliła się nazwa "Pusta skrzynia".

Choć 2 ostatnie przypadki to raczej to samo o ile dobrze wczytałem się w twój skrypt.
 



Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
MEM_PtrToInst() does some badass stackhacking and lets therefore the engine assign the instance, while MEM_AssignInst() or MEM_AssignContentInst() modifies the referring symbol by itself. In theory they should be equal, but hey, it's the zEngine. It's not a bug, it's a feature.
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy
Well I checked all and the erros are show when the name are changing ONLY THEN
I tried to change one time, press key but name is started to change fast, to TICK_TOCK and ASMINT_MYEXTERNAL
Strange ;/
 

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
Well, I guess I know where the mistake is: It's in STRINT_GetStringAddress(). This function is not designed for working permanently - or even longer than a frame or less, it's for insta-use. There probably is another way to get the address of a string/zString, but to confirm one method it would need some time of testing and I hate strings too much to work with them (at least now). So this should be a safe solution (creating your own string):

var string str; str = "YOURNAME"; // More like a constant

var int ptr; ptr = MEM_Alloc(20);
var zString zStr; MEM_AssignInst(zStr, ptr);
var int len; len = STR_Len(str);
zStr.ptr = MEM_Alloc(len);
zStr.len = len;
zStr.res = len;
var zString zs0; MEM_AssignInst(zs0, STRINT_GetStringAddress(str));
MEM_CopyBytes(zs0.ptr, zStr.ptr, len);

symb.content = ptr;

This also should stop the name of your mob changing :p
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.

Shothic

Shothic

Użytkownicy
posty38
Propsy17
  • Użytkownicy
;/ Errors errors errors
Here is code:
Spoiler
if (returnState5 == KEY_PRESSED)
{


MEM_ReinitParser();
var zCPar_Symbol symb;
MEM_AssignContentInst(symb,MEM_ReadIntArray (currSymbolTableAddress, MoB.focusNameIndex));


if (Skrzynia.containList_next == 0)
{
var string str; str = "Pusta Skrzynia"; // More like a constant

var int ptr; ptr = MEM_Alloc(20);
var zString zStr; MEM_AssignInst(zStr, ptr);
var int len; len = STR_Len(str);
zStr.ptr = MEM_Alloc(len);
zStr.len = len;
zStr.res = len;
var zString zs0; MEM_AssignInst(zs0, STRINT_GetStringAddress(str));
MEM_CopyBytes(zs0.ptr, zStr.ptr, len);

symb.content = ptr;

};



};

When I press key name change but errors are when I exit game like this :
Spoiler


I checked something else when I remove symb.content = ptr not have erros
I think is the end things that can be do
 

Lehona

Lehona

Użytkownicy
posty196
Propsy190
  • Użytkownicy
Okay, last try. If this doesn't work, I'll just slap Gothic several times and shoot it or something >.<

MEM_ReinitParser();
var string newName; newName = "Pusta Skrzynia";
var int NameSymbIndex; NameSymbIndex = MEM_FindParserSymbol("NEWNAME"); // NAME OF THE VARIABLE!
Mob.focusNameIndex = NameSymbIndex;
 
Unless specified otherwise, my posts are always about Gothic 2 Night of the Raven.


0 użytkowników i 5 gości przegląda ten wątek.
0 użytkowników
Do góry