Author Topic: armor manager for pvm  (Read 1537 times)

0 Members and 1 Guest are viewing this topic.

Offline FiggaTopic starter

  • Restricted
  • *
  • Posts: 3
  • Activity:
    0%
  • Reputation Power: 1
  • Figga has no influence.
  • Referrals: 0
    • View Profile
armor manager for pvm
« on: October 26, 2023, 08:40:52 PM »
this is part of my pvm bot. responsible for the repair of armor. it may be useful to someone . in this form, the script repairs the armor, after that, he goes into an endless cycle where he checks the durability of the weapon and repairs it.
there is also a function to check the durability of armor and repair damaged REPAIT_BROKEN_ARMOR() . BUT you need to call this function separately from your code

 works for a warrior with metal armor . for leather armor , you will need to slightly change the BOT_armor_REP function( serial , repait_tool_TYPE, Color )

to start script, run the function  ARM . after that , the script will check the availability of the armor. will repair the armor and through the Journal will track the breakdown of the weapon and repair it if necessary

 This script is configured for the      -= REMOVED LINK  =-     server and Checking the durability through the Journal. perhaps you can do it better on your server


functions of the script :
          ARM()  -     main function with variable initialization
          BOT_DRESS_INIT(SET_NAME)    -   DRESS sorting   (need for choose the right repair tools)   
          REPAIR_ALL()      -   repair ALL
          REPAIT_BROKEN_ARMOR()       - repair broken armor   (ONLY ARMOR)      variables -   armor_dur_toREPAIT And  rags_dur_toREPAIT
          PlateArm_CHECK()   - checkinf for missing armor parts
          EQUIP_damg_scan   -INFINITE LOOP to check for weapon damage

Code: [Select]


// This script is configured for the      -=  https://oldp.net/  =-     server
// Checking the durability through the Journal. perhaps you can do it better on your server


// THIS SCRIPT REPAIR ONLY WEAPON !!!!!!!!
// For checking the durability of ARMOR and repairing damaged  REPAIT_BROKEN_ARMOR() . you need to call this function separately from your code


// YOU NEED CHANGE THIS VARIABLES!!!!!!!!!!
//  SET_NAME
// armor_dur_toREPAIT
// rags_dur_toREPAIT
// MAX_DAMAGE     


 //        REPAIR_ALL()                          -   repair ALL
//         REPAIT_BROKEN_ARMOR()       - repair broken armor   (ONLY ARMOR)      variables -   armor_dur_toREPAIT And  rags_dur_toREPAIT
//         PlateArm_CHECK() - checkinf for missing armor parts (precautions before starting the bot)
//         EQUIP_damg_scan()       -INFINITE LOOP to check for weapon damage and REPAIR (inFINITE LOOP !!!!)

   

function ARM()
{
//=============================ARMOR SETS  ==============================
//одно имя для нескольких работающих скриптов приведет к большим проблемам

//enter the name of   all your clothes and weapons SET in the variable SET_NAME
var SET_NAME = "-=NAME_OF_YOUR_SET=-";     //*******************************

// MAX durability of ARMOR before need repair
var armor_dur_toREPAIT = 32;   //  for metal armor*******************************
var rags_dur_toREPAIT = 12;      //  for textil armor********************************




var axe = Orion.ObjAtLayer(1);
var d = check_DUR_f(axe.Serial());

var MAX_DAMAGE = 2;   // MAX damage to repair WEAPOT    **********************
if (d[2] ==="100" ) MAX_DAMAGE = 4; //if weapon have 100 maxdurab   =>  repair after evry 4 damage
if (d[2] ==="50" ) MAX_DAMAGE = 2;  //   or after 2
Orion.Say("weapon repair after" +  MAX_DAMAGE + "dam");





   //Сreates different sets for textiles and metal    and ignores jewelry
var BOT_ALL_ARMOR_SET = "BOT_ALL_ARMOR_SET";     //сет совсем шмотом
var BOT_METEL_ARMOR_SET = "BOT_METEL_ARMOR_SET";   //for REPAIR TOOL
var BOT_RAGS_ARMOR_SET = "BOT_RAGS_ARMOR_SET";       //for REPAIR SEWING KIT
var BOT_ARM_SET = "BOT_ARM_SET";                                   //WEAPON


//Orion.UnsetArm(BOT_ALL_ARMOR_SET);
Orion.SetArm(BOT_ALL_ARMOR_SET);
var temp1 = Orion.GetDressList (BOT_ALL_ARMOR_SET);
Orion.SetDress(BOT_ALL_ARMOR_SET);
var temp2 = Orion.GetDressList (BOT_ALL_ARMOR_SET);
var temp3 = temp1.concat(temp2);
Orion.SetDressList (BOT_ALL_ARMOR_SET, temp3);    //push all armor and weapon to 1 list



var PlateArm_obj =[ 
   Orion.ObjAtLayer(1),
   Orion.ObjAtLayer(2),
   Orion.ObjAtLayer(6),
   Orion.ObjAtLayer(7),
   Orion.ObjAtLayer(10),
   Orion.ObjAtLayer(13),
   Orion.ObjAtLayer(19),
   Orion.ObjAtLayer(24)
];

var all_Arm_obj = [];
var all_Arm_ser = [];
var all_Arm_name = [];
var all_Arm_dur =[];

var armor = [];
var weapot = [];
var rags = [];





BOT_DRESS_INIT(SET_NAME) ;       // DRESS sorting
PlateArm_CHECK() ; // CHECK for missing armor BEFORE start BOT
REPAIR_ALL( );                                 //  Repair all amunition before start


//REPAIT_BROKEN_ARMOR();
EQUIP_damg_scan();    //  INFITE LOOP  for checking weapon damage







msgg = [ " Your Glory War Axe crafted by Dante-dmc (Monster Slayer +19) may have been damaged",
"You damage the Plazma Heater Shield crafted by Figga",
   "You damage the  Platemail ",
"Gold Platemail Arms crafted by Figga",
"[Durability: 20/40]",
"You must have 11 Titanium Ingot to repair Titanium War Axe",
"*You repaired"

  ];
   
//PlateArm_INIT();
//Orion.SetDressList (BOT_ALL_ARMOR_SET, PlateArm_ser);


// WEapon repair MIN DURAB ======================================

//BOT_armor_REP(axe.Serial());
//Armor_repait();




// var shield = Orion.ObjAtLayer(2);
//var ser =   axe.Serial();
// Orion.Click(ser);    
// Orion.Info (ser); 



function REPAIR_ALL()
{
//BOT_DRESS_INIT("SET_NAME")
var armor_list  = Orion.GetDressList (BOT_METEL_ARMOR_SET)
for (i = 0; i < armor_list.length; i ++)
{
BOT_armor_REP(armor_list[i], "0x1865", "0x0000");
}

armor_list  = Orion.GetDressList (BOT_RAGS_ARMOR_SET)
for (i = 0; i < armor_list.length; i ++)
{
BOT_armor_REP(armor_list[i], "0x0F9D", "0x0032");
}
armor_list  = Orion.GetDressList (BOT_ARM_SET)
for (i = 0; i < armor_list.length; i ++)
{
BOT_armor_REP(armor_list[i], "0x1865" , "0x0000");
}

return;
}


function BOT_DRESS_INIT( name )
{

var SHMOT = Orion.GetDressList (name);
if(SHMOT.length === 0) { ARMOR_ERROR();}

for (i = 0; i < SHMOT.length; i ++)
{
var obj =  Orion.FindObject( SHMOT[i]) ;
var layer = obj.EquipLayer();

//============= WAPON  =============
if ( ( layer  == 1  ) || ( layer  == 2  ))
{ weapot.push(SHMOT[i]);  continue; }
//============= ignore RINGs =============
if  (( layer  == 8  ) || ( layer  == 9  ) || ( layer  == 18  ) || ( layer  == 14  ) )
{ continue; }
//=============SHOES ' Ы =============
if  ( layer  == 3  )
{
rags.push(SHMOT[i]);
continue;
}
//============= Textil   =============
if  (( layer  == 20  ) || ( layer  == 22  ) || ( layer  == 23  ) || ( layer  == 12  ) || ( layer  == 17  ))
{
rags.push(SHMOT[i]);
continue;
}
//============= ARMOR  =============
if (layer)   //else armor
armor.push(SHMOT[i]);
}


Orion.SetDressList (BOT_METEL_ARMOR_SET, armor);
Orion.SetDressList (BOT_RAGS_ARMOR_SET, rags);
Orion.SetDressList (BOT_ARM_SET, weapot);


var temp = armor;
temp = temp.concat(rags);
temp = temp.concat(weapot);
Orion.SetDressList (BOT_ALL_ARMOR_SET, temp);  //dress list without  inored items  (rings)

for (i = 0 ; i < temp.length; i ++)
{
obj = Orion.FindObject(temp[i]);
all_Arm_obj[i] = obj;
all_Arm_name [i] = obj.Name();
//all_Arm_dur[i] = check_DUR(temp[i]) ;
}


return ;
}




   
function PlateArm_CHECK()
{


for (var i = 0; i < PlateArm_obj.length; i ++)
{
if (!PlateArm_obj[i] )
{
TextWindow.Open();
TextWindow.Print ('-=============NOT ALL PLATMAIL ARMOR FOUND==============-');
TextWindow.Print ('-==================SCRIPT PAUSED=====================-');
TextWindow.Print ('-===== You can delete  PlateArm_CHECK() or change  PlateArm_obj[] =====-');

Orion.PauseScript();
}   
}

return ;
}

function EQUIP_damg_scan()
{
var dam = 0;
while (true)
{
var xz = Orion.GetDressList(BOT_ARM_SET);

if (Orion.ObjAtLayer(1) != Orion.FindObject(xz[0]) )
{
//Orion.Say (' \n .arm');   //                                    ARM!!!!!!!!!!!!!!!!!!
Orion.Equip(xz[0]);
Orion.Wait(300);
}



Orion.Wait(500);
if (Orion.InJournal("may have been damaged"))
{
Orion.ClearJournal();
dam++;
if (dam >= MAX_DAMAGE )
{
var is_ok = BOT_armor_REP(xz[0], "0x1865", "0x0000");

if (!is_ok )
{
is_ok = BOT_armor_REP(xz[0], "0x1865", "0x0000");
if (!is_ok )
{
TextWindow.Print ('-======!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========-');
TextWindow.Print ('-======!!WEAPON REPAIR PROBLEM!!========-');
TextWindow.Print ('-======!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========-');
Orion.CloseUO();
}
}
dam = 0;
Orion.Equip(xz[0]);
}
}
}



return ;
}


}

function ARMOR_ERROR()
{

TextWindow.Open();
TextWindow.Print ('-======!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========-');
TextWindow.Print ('-======ARMOR SET NOT FOUND!!!!!!!========-');
TextWindow.Print ('-======!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========-');
// Orion.PauseScript();


}




function BOT_armor_REP( serial , repait_tool_TYPE, Color )
{

var ser = serial;
var obj = Orion.FindObject(ser);
Orion.ClearJournal();



//=============снятие ШМОТКИ!!===================
Orion.Unequip(obj.EquipLayer());
Orion.Wait(700);


var tt = Orion.Now() +5000;
while (true )
{
Orion.Wait (100);
obj = Orion.FindObject(ser);
var my_backpad = Orion.FindObject(backpack).Serial();
if  (obj.Container()  === my_backpad)
{
break;
}

if (tt < Orion.Now())
{
TextWindow.Open();
TextWindow.Print ( obj.Container() + "      "   + my_backpad);
return 0;
}

}

repTool = Orion.FindType(repait_tool_TYPE, Color, 'backpack');
Orion.UseObject(repTool[0]);
Orion.WaitTargetObject(ser);

Orion.Wait (400);

if  (Orion.InJournal ("You must have ", "sys") )
{
TextWindow.Open();
TextWindow.Print ('-==============NO MATERIAL FOR REPAIR==================-');
TextWindow.Print ('-==================SCRIPT PAUSED=====================-');
return 0;
}


//=============одевание ШМОТКИ!!===================
Orion.Equip(ser);


var tt = Orion.Now() +5000;
while (true )
{
Orion.Equip(ser);
var layer = obj.EquipLayer();
if (Orion.ObjAtLayer(layer) && Orion.ObjAtLayer(layer).Serial() === ser )
{
break;
}
Orion.Wait (100);
if (tt < Orion.Now())
{
TextWindow.Open();
TextWindow.Print ("CAN'T WEAR !!!!!  " + layer + "    " + Orion.ObjAtLayer(layer));
return 0;
}
}

return 1;
}





 function check_DUR( serial )
{
    var serr = serial;  //id of item
Orion.ClearJournal();
Orion.Click(serr);
var msgg = Orion.WaitJournal ("Durability", (Orion.Now() - 3000) , (Orion.Now() + 3000), "", serr);
//var dur = parseInt(msgg.Text().substring(13, 21)) ;
var dur = msgg.Text().substring(13, 21)
//var ddur = dur.split(/(  \/ | \] \[  )/) ;

var ddur = dur.split( /(\/|: |])/ ) ;

//TextWindow.Open();  //test !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//TextWindow.Print(Orion.FindObject(serr).Name() + "  =   " + ddur);
    //TextWindow.Print(dur);
//PlateArm_dur[iii] =  dur;
   
return ddur[0] ;
}

 function check_DUR_f( serial )
{
    var serr = serial;  //id of item
Orion.ClearJournal();
Orion.Click(serr);
var msgg = Orion.WaitJournal ("Durability", (Orion.Now() - 3000) , (Orion.Now() + 3000), "", serr);
var dur = msgg.Text().substring(13, 21)
var ddur = dur.split( /(\/|: |])/ ) ;
return ddur;
}


function info()
{
Orion.Info();


}

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
NewScript1.oajs
« Last Edit: November 05, 2023, 03:57:00 PM by Crisis »

Offline Crisis

  • Global Moderator
  • *
  • *
  • Posts: 3016
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Referrals: 2
    • View Profile
Re: armor manager for pvm
« Reply #1 on: November 05, 2023, 03:58:01 PM »
Too bad you wouldn't take the minute or two to make an introduction. We could use more Orion scripters here.

Tags: