Author Topic: Contribution: Permanent Horse - Bug Fixes  (Read 347 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Contribution: Permanent Horse - Bug Fixes
« on: May 04, 2014, 05:06:44 pm »


               

I created a script to solve the Permanent Horse Bug (you are on a horse and you can't get off), below we have two evidences for who unknow:


 


1: Youtube Video


2: http://social.biowar...-4639905-1.html


 


You must add a command to execute the script in "on_respawn" and "on_client_enter" module events.



    //object oPC = GetEnteringObject();
    //object oPC = GetLastRespawnButtonPresser();

    //Permanent Horse - Bug Fixes
    ExecuteScript("permanent_horse", oPC);


Also you need to create a script called permanent_horse and add this code:


 



#include "x3_inc_horse"

void main()
{
    object oPC = OBJECT_SELF;

    if(HorseGetIsMounted(oPC) == TRUE && GetPhenoType(oPC) != PHENOTYPE_NORMAL)
    {
    HorseInstantDismount(oPC);
    return;
    }
    if(HorseGetIsMounted(oPC) == FALSE && GetPhenoType(oPC) != PHENOTYPE_NORMAL)
    {
    //Shadooow debug code
    object oSkin=GetLocalObject(oPC,"oX3_Skin");
    int nPosition;
    if(!GetIsObjectValid(oSkin))
    {
    oSkin=GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
    nPosition = 2;
    }
    else
    {
    nPosition = 1;
    }
    if(!GetIsObjectValid(oSkin))
    {
    oSkin=GetItemPossessedBy(oPC,"x3_it_pchide");
    nPosition = 3;
    }
    WriteTimestampedLogEntry("PERMANENT HORSE BUG - oPC: "+GetName(oPC)+", has skin?: "+IntToString(GetIsObjectValid(oSkin))+", nPosition: "+IntToString(nPosition));
    ////////end debug code

    HorseInstantDismount(oPC);
    SetPhenoType(PHENOTYPE_NORMAL, oPC);
    SetCreatureTailType(CREATURE_TAIL_TYPE_NONE, oPC);
    }
}


To give a sense of reality, we are dismounting always when PC respawn/enter in module, so you can disable first condition.

 

WARNING: HorseInstantDismount does not protect Saddlebags so, it is recommended this only be used in conjunction with HorseInstantMount.   If you need to protect saddlebag contents use HorseDismount().


               
               

               


                     Modifié par WhiteTiger, 07 mai 2014 - 02:44 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Contribution: Permanent Horse - Bug Fixes
« Reply #1 on: May 04, 2014, 05:29:22 pm »


               

I dont understand, my fix doesn't work?


 


I though this is a "losing skin under ILR/ELC" issue. Which I prevented from in my community patch and in my testing the PC was considered mounted after relog.


 


Since you use my patch I wonder why its not working for you. Can you post your OnPlayerUnEquip code?



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Contribution: Permanent Horse - Bug Fixes
« Reply #2 on: May 04, 2014, 06:33:06 pm »


               

Yes, I do. This is for who still have trouble with the permanent horse bug and are searching for



               
               

               


                     Modifié par WhiteTiger, 04 mai 2014 - 06:08 .
                     
                  


            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Contribution: Permanent Horse - Bug Fixes
« Reply #3 on: May 05, 2014, 04:38:10 am »


               

No problems with your fixes, but I considerate the possibility to make a new fix to a second choice. 



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Contribution: Permanent Horse - Bug Fixes
« Reply #4 on: May 07, 2014, 02:17:23 pm »


               


No problems with your fixes, but I considerate the possibility to make a new fix to a second choice. 




Of course. And your script does this job well. But I would like to know why my fix doesn't always works.


 


Could you add this code into your script?



if(HorseGetIsMounted(oPC) == FALSE && GetPhenoType(oPC) != PHENOTYPE_NORMAL)
    {
/////shadooow debug code
object oSkin=GetLocalObject(oPC,"oX3_Skin");
int nPosition;
 if(!GetIsObjectValid(oSkin))
 {
 oSkin=GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
 nPosition = 2;
 }
 else
 {
 nPosition = 1;
 }
 if(!GetIsObjectValid(oSkin))
 {
 oSkin=GetItemPossessedBy(oPC,"x3_it_pchide");
 nPosition = 3;
 }
WriteTimestampedLogEntry("PERMANENT HORSE BUG - oPC: "+GetName(oPC)+", has skin?: "+IntToString(GetIsObjectValid(oSkin))+", nPosition: "+IntToString(nPosition));
////////end debug code  
    //FloatingTextStringOnCreature("Permanent Horse - Bug Fixes", oPC);
    HorseInstantDismount(oPC);
    SetPhenoType(PHENOTYPE_NORMAL, oPC);
    SetCreatureTailType(CREATURE_TAIL_TYPE_NONE, oPC);
    }

Then check the logs occassionally and if you find a line with "PERMANENT HORSE BUG" please send it to me. Might help to reveal whats going on.