Other > General Game Discussion

Repair Formula (?)

<< < (2/4) > >>

Wallace:
600 reads and still no answer??

Devs... please say something on that

Crazy:

--- Quote ---// Author: cvet

#include "_macros.fos"
#include "_msgstr.fos"


bool TryRepairItem(Critter& cr, Item& item) // Export
{
   if(not item.IsDeteriorable()) return true;

   if(cr.Timeout[TO_BATTLE]>0)
   {
      cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_TIMEOUT_BATTLE_WAIT);
      return true;
   }

   if(cr.Timeout[TO_SK_REPAIR]>0)
   {
      cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_SKILL_WEARINESS);
      return true;
   }

   if(FLAG(item.BrokenFlags,BI_ETERNAL) || FLAG(item.BrokenFlags,BI_NOTRESC))
   {
      cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_DETERIORATION_NO_RESC);
      return true;
   }

   // Repair
   int repair=cr.Skill[SK_REPAIR];
   uint8 mode=0;
   uint16 activePid=cr.GetSlotProto(SLOT_HAND1,mode).ProtoId;
   if(activePid==PID_MULTI_TOOL)
   {
      repair+=25;
      if(Random(0,30)==0) cr.DeleteItem(PID_MULTI_TOOL,1);
   }
   else if(activePid==PID_SUPER_TOOL_KIT)
   {
      repair+=50;
      if(Random(0,30)==0) cr.DeleteItem(PID_SUPER_TOOL_KIT,1);
   }

   // Repair
   if(FLAG(item.BrokenFlags,BI_BROKEN))
   {
      if(FLAG(item.BrokenFlags,BI_HIGHBROKEN)) repair-=100; //áûëî 150
      else if(FLAG(item.BrokenFlags,BI_NORMBROKEN)) repair-=75; //áûëî 100
      else if(FLAG(item.BrokenFlags,BI_LOWBROKEN)) repair-=25; // áûëî 50

      repair-=item.BrokenCount*50/MAX_BROKENS; //áûëî 100
      repair=CLAMP(repair,6,95);

      if(repair>=Random(1,100))
      {
         item.Deterioration=0;
         UNSETFLAG(item.BrokenFlags,BI_BROKEN);
         cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_DETERIORATION_REPAIR_SUCC);
         cr.StatBase[ST_EXPERIENCE]+=40;
      }
      else
      {
         item.BrokenCount++;
         if(item.BrokenCount>=MAX_BROKENS) SETFLAG(item.BrokenFlags,BI_NOTRESC);
         cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_DETERIORATION_REPAIR_FAIL);
      }
   }
   // Service
   else
   {
      if(FLAG(item.BrokenFlags,BI_SERVICE)) repair-=25;
      repair-=item.BrokenCount*50/MAX_BROKENS;
      repair=CLAMP(repair,6,95);

      if(repair>=Random(1,100))
      {
         SETFLAG(item.BrokenFlags,BI_SERVICE);
         if(activePid==PID_OIL_CAN)
         {
            item.Deterioration=0;
            cr.DeleteItem(PID_OIL_CAN,1);
         }
         else
         {
            int cnt=repair*MAX_DETERIORATION/100;
            if(cnt>item.Deterioration) item.Deterioration=0;
            else item.Deterioration-=cnt;
         }
         cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_DETERIORATION_SERVICE_SUCC);
         cr.StatBase[ST_EXPERIENCE]+=20;
      }
      else
      {
         DeteriorateItem(cr,item,MAX_DETERIORATION/5);
         cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_DETERIORATION_SERVICE_FAIL);
      }
   }

   item.Update();
   cr.TimeoutBase[TO_SK_REPAIR]=REPAIR_TIMEOUT(cr);
   return true;
}

void DeteriorateItem(Critter& cr, Item& item, int deteriorationCount) // Export
{
   if(deteriorationCount<=0 || not item.IsDeteriorable() || FLAG(item.BrokenFlags,BI_ETERNAL) || FLAG(item.BrokenFlags,BI_BROKEN)) return;

   item.Deterioration+=deteriorationCount;
   if(item.Deterioration>=MAX_DETERIORATION)
   {
      item.Deterioration=MAX_DETERIORATION;
      item.BrokenCount++;

      int brokenLvl=Random(0,item.BrokenCount/(MAX_BROKENS/4));

      if(item.BrokenCount>=MAX_BROKENS || brokenLvl>=3) SETFLAG(item.BrokenFlags,BI_NOTRESC);
      else if(brokenLvl==2) SETFLAG(item.BrokenFlags,BI_HIGHBROKEN);
      else if(brokenLvl==1) SETFLAG(item.BrokenFlags,BI_NORMBROKEN);
      else SETFLAG(item.BrokenFlags,BI_LOWBROKEN);
      cr.SayMsg(SAY_NETMSG,TEXTMSG_GAME,STR_DETERIORATION_WEAPON_BROKEN);
   }

   item.Update();
}

void SetDeterioration(Item& item, int deteriorationProcent) // Export
{
   if(not item.IsDeteriorable()) return;
   UNSETFLAG(item.BrokenFlags,BI_BROKEN);
   deteriorationProcent=CLAMP(deteriorationProcent,0,100);
   item.Deterioration=MAX_DETERIORATION*deteriorationProcent/100;
   item.BrokenCount=MAX_BROKENS*deteriorationProcent/100;
   if(deteriorationProcent==100) SETFLAG(item.BrokenFlags,BI_BROKEN);
   item.Update();
}

int GetDeteriorationProcent(Item& item) // Export
{
   if(not item.IsDeteriorable()) return 0;
   if(FLAG(item.BrokenFlags,BI_BROKEN)) return 100;
   int value=item.Deterioration*100/MAX_DETERIORATION;
   return CLAMP(value,0,100);
}
--- End quote ---
From SDK. Have fun.

Ganado:
And that script might not even be what 2238 uses.

Boon Lived:
Don't know the exact formula - but this is what i think.
Also some from this page http://www.fo2238.fodev.net/wiki/Deterioration

-When a weapon isn't broken, you get a -50 skill modifier.
-You also get a -skill modifier depending on its break count
(The break count is invisible - but you can determine roughly depending on its price)

-"It's a little broken." -50
-"It's fairly broken." -100
-"It's almost falling apart." -150

-Chance to repair does NOT depend on the item. Minigun has same chances as a mauser.
-Having a Tool or Super Tool Kit in active slot will add 25% or 50% to repair skill
-Chance to repair an item is capped at 95%.
-Amount you repair depends on your Repair skill, and the break count of what your repairing.
-AND THE MOST IMPORTANT ONE: Repair skill.

Hope that helps some.

Wallace:
The thing is... i can't find any info on how many deterioration points can be fixed at a sigle time

(from my experience it's 1/6 of repair skill but it is capped at 32% - you can't repair more even if one has more than 200 skill in repair which should cause repairing more than 32%)

I want to know if the 32% cap is a feature or a BUG

PLUS how many times item can be fixed (when fixing NOT broken item)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version