Portal-Zone Gothic-Zone Gothic II-Zone Gothic 3-Zone Gothic 4-Zone Modifikationen-Zone Download-Zone Foren-Zone RPG-Zone Almanach-Zone Spirit of Gothic

 

Ergebnis 1 bis 9 von 9
  1. Beiträge anzeigen #1 Zitieren
    banned
    Registriert seit
    Oct 2017
    Beiträge
    233
     
    Phantom95 ist offline

    GOTHIC - TAMING ANIMAL

    [Video]
    One of the possible features of the so-called "Taming animal" by tossing them food. However, there are bugs with the initialization of the desired item, despite the fact that in the condition of activating the state ZS_MM_EatItem prescribed necessary items, monsters for some reason focus on random items...


    How is it possible to fix this crap at the level of scripts?


    Function while of course test instead of full-fledged status of "Taming" currently:

    Code:
    funcvoidB_MM_AssessItem()// kann auch durch QuietSound aufgerufen werden
    {
        if(Npc_GetDistToItem(self,item) < 1500 && (Hlp_IsItem(item,ItfoApple) && self.guild == GIL_SCAVENGER) || (Hlp_IsItem(item,ItfoMutton) && (self.guild == GIL_WOLF || self.guild == GIL_SHADOWBEAST || self.guild == GIL_ORCDOG || self.guild == GIL_SNAPPER || self.guild == GIL_SCAVENGER || self.guild == GIL_LURKER)))
        {
            AI_StartState    (self, ZS_MM_EatItem, 0 ,"");
        };
    };
    // ----------------------------------------------------------------------------
    func void ZS_MM_EatItem()
    {
        Npc_PercEnable        (self,    PERC_ASSESSDAMAGE,    B_MM_ReactToDamage);
        Npc_PercEnable        (self,    PERC_ASSESSMAGIC,    B_AssessMagic);
        Npc_PercEnable        (self,    PERC_ASSESSENEMY,    B_MM_AssessEnemy);
        Npc_PercEnable        (self,    PERC_ASSESSWARN,    B_MM_AssessWarn);
        PrintScreen(item.name,-1,-1,"font_old_20_white.tga",3);
        if(Hlp_IsItem(item,ItfoApple) || Hlp_IsItem(item,ItfoMutton))
        {
        AI_SetWalkmode        (self, NPC_RUN);
        AI_PlayAni            (self,    "T_PERCEPTION");
        AI_GotoItem            (self,    item);
        AI_PlayAni            (self,    "T_STAND_2_EAT");
        }
        else
        {
        Npc_ClearAIQueue(self);
        Npc_PercDisable        (self,PERC_ASSESSITEM);
        Npc_PercEnable(self,PERC_ASSESSITEM,B_MM_AssessItem);
        };
    };
    
    func int ZS_MM_EatItem_loop()
    {
      if(Hlp_IsItem(item,ItfoApple) || Hlp_IsItem(item,ItfoMutton))
      {
        if (Npc_GetStateTime(self) > 10)
        {
            PrintScreen("ok",-1,-1,"font_old_20_white.tga",3);
            return 1;
        };
        if (!Hlp_IsValidItem(item))    //Item weg
        {
            return 1;
        };
        return 0;
       };
       Npc_SetPercTime(self,0.1);
       return 1;
    };
    
    func void ZS_MM_EatItem_end()
    {
    if(Hlp_IsItem(item,ItfoApple) || Hlp_IsItem(item,ItfoMutton))
    {
        if (Hlp_IsValidItem    (item))
        {
            Wld_RemoveItem    (item);
        };
        AI_PlayAni        (self,    "T_EAT_2_STAND");
        AI_StartState    (self,ZS_MM_SummonedByPC, 0 ,"");
    }; };

  2. Beiträge anzeigen #2 Zitieren
    Local Hero
    Registriert seit
    Feb 2017
    Beiträge
    270
     
    F a w k e s ist offline
    Hi Phantom95,
    How did you add this to your monster AI scripts?
    I would think that function B_MM_AssessItem should be triggered by PERC_ASSESSITEM - and this perception could be enabled for example from ZS_MM_Rtn_Default:
    Code:
    FUNC VOID ZS_MM_Rtn_Default ()
    {
    ...
        Npc_PercEnable (self, PERC_ASSESSITEM, B_MM_AssessItem); 
    ...    
    };

  3. Beiträge anzeigen #3 Zitieren
    banned
    Registriert seit
    Oct 2017
    Beiträge
    233
     
    Phantom95 ist offline
    Zitat Zitat von F a w k e s Beitrag anzeigen
    Hi Phantom95,
    How did you add this to your monster AI scripts?
    I would think that function B_MM_AssessItem should be triggered by PERC_ASSESSITEM - and this perception could be enabled for example from ZS_MM_Rtn_Default:
    Code:
    FUNC VOID ZS_MM_Rtn_Default ()
    {
    ...
        Npc_PercEnable (self, PERC_ASSESSITEM, B_MM_AssessItem); 
    ...    
    };
    Hello..
    Yes, I know, it is already included in Rtn functions, otherwise there would be no reaction to item at all.
    In addition, I decided to put him the first active perception to make it work serviceability:

    Code:
     Npc_PercEnable(self,PERC_ASSESSITEM,B_MM_AssessItem);
        Npc_PercEnable(self,PERC_ASSESSDAMAGE,B_MM_ReactToDamage);
        Npc_PercEnable(self,PERC_ASSESSOTHERSDAMAGE,B_MM_ReactToOthersDamage);
        Npc_PercEnable(self,PERC_ASSESSMURDER,b_mm_reacttomurder);
        Npc_PercEnable(self,PERC_ASSESSMAGIC,B_AssessMagic);
        Npc_PercEnable(self,PERC_ASSESSENEMY,B_MM_AssessEnemy);
        Npc_PercEnable(self,PERC_ASSESSWARN,B_MM_AssessWarn);
        Npc_PercEnable(self,PERC_ASSESSBODY,B_MM_AssessBody);
        Npc_SetPercTime(self,0.1);
    The problem is in the false initialization of the item, which can be in a completely unacceptable place.
    Geändert von Phantom95 (03.04.2019 um 11:22 Uhr)

  4. Beiträge anzeigen #4 Zitieren
    Local Hero
    Registriert seit
    Feb 2017
    Beiträge
    270
     
    F a w k e s ist offline
    Hi Phantom95,
    I just tried to use this in G1 - and crashed with this error below:
    Code:
    ======================================= UNHANDLED EXCEPTION OCCURED ======================================================
    ======================================= CRASH INFOS: =====================================================================
    GOTHIC 1.08k_mod, Parser Version: 50
    =============================================== CALLSTACK : ==============================================================
    0023:00671FC0 (0x00800000 0x196F0DA8 0x1969D6C4 0x00000000) GothicMod.exe, oCItem::HasFlag, D:\dev\gothic\current_work\Gothic\_Ulf\oItem.cpp, line 636
    0023:006B77C3 (0x13894268 0x19486144 0x000003B4 0x1BF02EF8) GothicMod.exe, oCNpc::PerceptionCheck()+963 byte(s), D:\dev\gothic\current_work\Gothic\_Ulf\oNPC.cpp, line 14382+16 byte(s)
    0023:00615EAB (0x19486144 0x0126FB40 0x13894034 0x00000000) GothicMod.exe, oCAIHuman::DoAI()+1115 byte(s), D:\dev\gothic\current_work\Gothic\_Ulf\oAIHuman.cpp, line 2607
    0023:005D773C (0x1BF02EF8 0x0A5EE984 0x00000000 0x0126FCB4) GothicMod.exe, zCVob::DoFrameActivity()+412 byte(s), D:\dev\gothic\current_work\ZenGin\_Dieter\zVob.cpp, line 2050
    0023:0063DC76 (0x0077A8D8 0x03383E8D 0x0126FEC4 0x00000000) GothicMod.exe, oCGame::Render()+150 byte(s), D:\dev\gothic\current_work\Gothic\_Ulf\oGame.cpp, line 2469
    0023:00424F73 (0x007D1078 0x7426D539 0x001E0894 0x0A5EE984) GothicMod.exe, CGameManager::Run()+1155 byte(s), D:\dev\gothic\current_work\Gothic\_Bert\oGameManager.cpp, line 699+25 byte(s)
    0023:006D867B (0x003BE000 0x0000002C 0x00000003 0x00000029) GothicMod.exe, MainProg()+75 byte(s), D:\dev\gothic\current_work\Gothic\_Ulf\Phoenix.cpp, line 115
    0023:004F4326 (0x00400000 0x00000000 0x03383E8D 0x00000001) GothicMod.exe, HandledWinMain()+966 byte(s), D:\dev\gothic\current_work\ZenGin\_Carsten\zWin32.cpp, line 772
    0023:004F3E90 (0x00400000 0x00000000 0x03383E8D 0x00000001) GothicMod.exe, WinMain()+128 byte(s), D:\dev\gothic\current_work\ZenGin\_Carsten\zWin32.cpp, line 684+21 byte(s)
    0023:0077A9B8 (0xA468007E 0x6400779B 0x000000A1 0x89645000) GothicMod.exe, WinMainCRTStartup()+224 byte(s)
    And this reminded me, that I was once trying to use PERC_ASSESSITEM with monsters, but my Gothic kept crashing - as for some reason an empty instance was passed to oCItem::HasFlag.
    So I am not sure if this works properly in G1 - if you use G2A engine, you might be safe here.

    This is what I have used as a workaround at the time:
    Code:
        //This will collect all vobs in range of 1500 m
        NPC_ClearVobList (self);
        NPC_CreateVobList (self, 1500);
    
        //This function will detect only specific item - item_Warg_ItFoMuttonRaw
        var int ptr;
        ptr = NPC_VobList_DetectObject (self, FALSE, oCItem_vtbl, item_Warg_ItFoMuttonRaw);
        
        if (ptr) {
            item = _^ (ptr);
    
            if (NPC_GetDistToItem (self, item) < 1500)
            && (NPC_GetDistToItem (hero, item) > 500)
            {
            ...
    [Video]

    If you want to use the same thing - you will need Ikarus 1.2.1 + these functions from ScriptBin\NPCVoblist.d:
    https://forum.worldofplayers.de/foru...1#post26052199

  5. Beiträge anzeigen #5 Zitieren
    banned
    Registriert seit
    Oct 2017
    Beiträge
    233
     
    Phantom95 ist offline
    Ok, thanks

  6. Beiträge anzeigen #6 Zitieren
    Local Hero
    Registriert seit
    Feb 2013
    Beiträge
    236
     
    pawbuj ist offline

    Thumbs up

    Fawkes, again great solution.

  7. Beiträge anzeigen #7 Zitieren
    Local Hero
    Registriert seit
    Feb 2017
    Beiträge
    270
     
    F a w k e s ist offline
    Hi pawbuj,
    Can you please try to enable PERC_ASSESSITEM in your mod on any NPC (just tested a human NPC - and it is crashing for me)
    I wonder if it works for you - if yes I have probably screwed up something in my scripts

  8. Beiträge anzeigen #8 Zitieren
    banned
    Registriert seit
    Oct 2017
    Beiträge
    233
     
    Phantom95 ist offline
    Crash game when you activate this perception will no longer be with the new version of the system-pack and Union. The original Gothic engine 1 and 2 will crash if you try to activate AssessItem perception with function.

  9. Beiträge anzeigen #9 Zitieren
    Local Hero
    Registriert seit
    Feb 2013
    Beiträge
    236
     
    pawbuj ist offline
    I remind that in a past I have fixed collecting weapon by NPCs like in g3.

    Here is the code it never fails me - u can easily transform for monster reaction. I dont have crash while Perc assessitem is active!

    Code:
    func void ZS_AssessBody_RecoverWeapon2 ()
    {    
        PrintDebugNpc        (PD_ZS_FRAME,    "ZS_AssessBody_RecoverWeapon");
    
        B_SetPerception        (self);
            
        //-------- po walce NPC zabiera twój oręż - edit by Pawbuj for gothic 1--------
        
        Npc_PerceiveAll    (self);
        //newintros ();//nowe intro
        
        if ( Wld_DetectItem (self, ITEM_KAT_NF) || Wld_DetectItem (self, ITEM_KAT_FF) || Wld_DetectItem (self, ITEM_KAT_MAGIC)|| Wld_DetectItem (self, ITEM_KAT_NONE)|| Wld_DetectItem (self,ITEM_KAT_POTIONS)|| Wld_DetectItem (self,ITEM_KAT_FOOD)) 
        {
            if (Hlp_IsValidItem(item))
            {
                if (Npc_GetDistToItem(self,item) < 1000)
                {
                    var C_NPC npc; npc = Hlp_GetNpc(self);
                    
                    
                    AI_GotoItem                (self, item);
                    
                    AI_TakeItem    (self, item);
                    AI_PlayAni        (self, "T_WATCHFIGHT_YEAH");
                    B_Say        (self, self, "$ITAKEYOURWEAPON");
    Geändert von pawbuj (05.04.2019 um 08:07 Uhr)

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
Impressum | Link Us | intern
World of Gothic © by World of Gothic Team
Gothic, Gothic 2 & Gothic 3 are © by Piranha Bytes & Egmont Interactive & JoWooD Productions AG, all rights reserved worldwide