Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guard whacked when stealing from own pack animal. [Fixed]
#11
Ok here is the demo stealing in more detail.

The only way to get some skills in demo is with people ner you,


PHP Code:
 int Q691 = witnessCrime(getLocation(usedon), this, owner, getName(usedon), Q4IB, (getValue(usedon) + 0x04) / 0x05, 0x01); // Can anyone see you?
 
 ///// witnessCrime (Location(XYZ), thief, owner (usedon), name, range, Value of item + 4 / 5, 1)
 
 // we dont have info on witnessCrime function :(
 
 // it is also used in the provo script.
 
 changeKarma(this, 0x00 - 0x1388); // Karma - 5000 for each time steeling? Seems hash 
 
 
  if
(!getCompileFlag(0x01)) // I have no ide what this is.
 
 {
 
   criminalActAdvanced(this, owner, 0x01, 0x06, 0x18 * 0x02, 0x00);
 
 }
 
 
  if
(Q691 > 0x00) // was someone around
 
 {
 
   if(!getCompileFlag(0x01)) // did someone see you?
 
   {
 
     setCriminal(this, 0x01E0); // 0x01E0 = duration 8 min
 
   }
    
    
///// give skill points only if someone can see you
 
   Q4IB = Q569 * Q5YS * 0x1E + 0x64;
 
   if(testAndLearnSkill(this, 0x21, Q4IB, 0x32) <= 0x00)
 
   {
 
     systemMessage(this, "You fail to steal the item.");
 
     return(0x00);
 
   }
    
//////
    
 
 } 


Here is the full script with as mutch as i know comment in it. it took some time Smile

PHP Code:
#include "ENGINE.hpp" /// This is the row that all commands from the internal server exe is included. We dont have the source for them.  Like getObjType, getNumTarget, systemMessage, getCompileFlag and so on.

#include "sk_table.h" // this loads the header of sk_table with includes the global file.

TRIGGER( message , "canUseSkill" )(obj sender, list args) // check if we can use the stealing skill.
{
 
 return(0x00);
}

TRIGGER( callback , 0x4D )() // remove stealing flag if we have one
{
 
 detachScript(this, "stealing");
 
 return(0x00);
}

FUNCTION 
int Q4ZF(obj item) // is the object a game bord or spellbook? 
{
 
 if(getObjType(item) == 0x0FA6)
 
 {
 
   return(0x01);
 
 }
 
 if(isSpellbook(item))
 
 {
 
   return(0x01);
 
 }
 
 return(0x00);
}

TRIGGER( message , "useSkill" )(obj sender, list args) // steal skill is used.
{
 
 callback(this, 0x0A, 0x4D);  // this is two trigger call (0x0a is to check if the thief is standing on a human (that fail stealing (trigger is in human script.)) and 0x4D does remove the stealing flag.)
 
 int Q477;
 
 Q477 = getNumTargets(this); // if we are a target we will be in combat and cant steal.
 
 if(Q477 > 0x00)
 
 {
 
   systemMessage(this, "You cannot attempt to steal in the heat of combat!");
 
   return(0x00);
 
 }
 
 systemMessage(this, "Which item will you attempt to steal?");
 
 targetObj(this, this); // call stealing trigger
 
 return(0x00); // we are done.
}

TRIGGER( oortargetobj )(obj user, obj usedon) // start stealing (target) (the player stealing, the item)
{
 
 if(usedon == NULL()) // if no item found exit
 
 {
 
   return(0x00);
 
 }
 
 if(isDead(this)) // if thief is dead exit.
 
 {
 
   return(0x00);
 
 }
 
 obj Q63P = getTopmostContainer(usedon); // get the top comntainer of the object we are trying to steal.
 
 int Q5F2 = getDistanceInTiles(getLocation(usedon), getLocation(this)); // get distance to the container.
 
 if(getDistanceInTiles(getLocation(usedon), getLocation(this)) > 0x01) // if we are more then 1 tile from then exit.
 
 {
 
   systemMessage(this, "You must be standing next to an item to steal it.");
 
   return(0x00);
 
 }
 
 
  
/// all this have to do with random steal by target mob instead of item.
 
 
  obj owner 
= NULL(); // no one owns the container.
 
 if(Q63P == NULL()) // if top container is NULL check if we target a mobile.
 
 {
 
   if(isMobile(usedon)) // if top container have a mob then set the owner to the mob.
 
   {
 
     owner = usedon;
 
   }
 
 }
 
 else
  
{
 
   if(isMobile(Q63P))
 
   {
 
     owner = Q63P; // if top container have a mob then set the owner to the mob.
 
   }
 
 }
 
 
  
///
 
 
  obj Q5H6
;
 
 if(owner != NULL()) // check if the item is on a container or on a mob.
 
 {
 
   if(owner == this) // you can't steal from your own bag.
 
   {
 
     barkTo(this, this, "You catch yourself red-handed.");
 
     return(0x00);
 
   }
 
   if(isPlayer(owner))
 
   {
 
     if(isEditing(owner) || isGameMaster(owner) || isCounselor(owner)) // thief cant steal from Worldbuilders, GMs and Conselors
 
     {
 
       systemMessage(this, "You can't steal from this.");
 
       return(0x00);
 
     }
 
   }
 
   if(hasScript(owner, "vendor")) // players vendors cant be stolen from.
 
   {
 
     systemMessage(this, "You can't steal from vendors.");
 
     return(0x00);
 
   }
 
   Q5H6 = getBackpack(owner);
 
   if(Q5H6 == NULL())   // if the mob dont have a backpack thief cant steal from it.
 
   {
 
     systemMessage(user, "You can't steal that.");
 
     return(0x00);
 
   }
 
 }
 
 
  
  int Q5YS 
= 0x01; // chance go the spotted while stealing.
 
 if(owner != NULL()) // if container dont have any owner it's normal chance to get spotted.
 
 {
 
   if(owner == usedon) // if this is true we are going a random stealing by target a mob.
 
   {
 
     list Q4YL; // create a list for items
 
     clearList(Q4YL); // reset the list
 
     getContents(Q4YL, Q5H6); // get all items in the backpack
 
     int Q538 = numInList(Q4YL); // get number of items in list.
 
     if(Q538 == 0x00) // no items found the bag is empty so exit.
 
     {
 
       systemMessage(this, "You reach into " + getName(owner) + "'s backpack... but find it's empty.");
 
       return(0x00);
 
     }
 
     usedon = Q4YL[random(0x00, Q538 - 0x01)]; // get a random item.
 
     systemMessage(this, "You reach into " + getName(owner) + "'s backpack... and try to take something.");
 
   }
 
   else
    
{
     
 ////// look for the container to steal the item from in a loop.
 
     obj Q5Z4 = containedBy(usedon);
 
     while(Q5Z4 != Q5H6)
 
     {
 
       if(Q5Z4 == NULL())
 
       {
 
         systemMessage(user, "You can't steal that.");
 
         return(0x00);
 
       }
 
       Q5Z4 = containedBy(Q5Z4);
 
     }
     
 //////
 
     Q5YS = 0x03; // 3x times easier to get spotted if we are target a item in a container and try to steal it.
 
   }
 
 }
 
 
  if
(!isMoveable(usedon, this)) // if the item cant be moved it cant be stolen. this is the standard lock down flag that all items in the world uses.
 
 {
 
   systemMessage(this, "You could not carry this item.");
 
   return(0x00);
 
 }
 
 if(!canHold(this, usedon)) // check if thief can hold the item in his backpack of not he cant steal it.
 
 {
 
   systemMessage(this, "You could not carry this item.");
 
   return(0x00);
 
 }
 
 if(getValue(usedon) == 0x00) // if the value if the item is zero then cant steal it.
 
 {
 
   systemMessage(this, "This item has no value to you.");
 
   return(0x00);
 
 }
 
 if(!isFreelyViewable(usedon, user)) // cant be a wall between the box and thief
 
 {
 
   systemMessage(user, "You can't steal that.");
 
   return(0x00);
 
 }
 
 if(Q4ZF(usedon)) // you cant steal inside game boards (chess pieses) or spellbooks.
 
 {
 
   systemMessage(user, "You can't steal that.");
 
   return(0x00);
 
 }
 
 if(containedBy(usedon) != NULL()) // this is actually a bugfix from early days then players could steal scrolls and chess peses from spellbosk and game bords. Q4ZF(usedon) didnt work 100% in some situations
 
 {
 
   if(Q4ZF(usedon))
 
   {
 
     systemMessage(user, "You can't steal that.");
 
     return(0x00);
 
   }
 
 }
 
 int Q68B = getWeight(usedon); // get the weight of the item(s) we are stealing.
 
 int quantity = getQuantity(usedon); // and how many there is.
 
 if((Q68B > 0x0A) && (quantity <= 0x01) && (owner != NULL())) // if the item is a single item and weight over 10 stones and we have a owner thief cant take it it. (this leaves all boxes in shops open for stealing)
 
 {
 
   systemMessage(this, "This item is too heavy to steal from someone's backpack.");
 
   return(0x00);
 
 }
 
 // if item is over 10 stones  set it to 10 stones in this calculation.
 
 int Q569 = Q68B;
 
 if(Q569 > 0x0A)
 
 {
 
   Q569 = 0x0A;
 
 }
 
 
  
  list Q57W
; // what is this ???? it seems like a left from something before T2A? Many NPC might been able to see you before then we didnt have insta hits?? Just a guess?
 
 int Q5TF = 0x64 + getSkillLevelReal(this, 0x21); // SKILL% = 100 + real Skill level. (1000 = 100%)
 
 int Q4IB = Q569 * Q5YS * 0x1388 / Q5TF; // RANGE = Weight * hard to steal (1 or 3) * 5000 / SKILL%
 
 int Q691 = witnessCrime(getLocation(usedon), this, owner, getName(usedon), Q4IB, (getValue(usedon) + 0x04) / 0x05, 0x01); // Can anyone see you?
 
 ///// witnessCrime (Location(XYZ), thief, owner (usedon), name, RANGE, Value of item + 4 / 5, 1)
 
 // we dont have info on witnessCrime function :(
 
 // it is also used in the provo script.
 
 changeKarma(this, 0x00 - 0x1388); // Karma - 5000 for each time steeling? Seems hash 
 
 
  if
(!getCompileFlag(0x01)) // I have no ide what this is.
 
 {
 
   criminalActAdvanced(this, owner, 0x01, 0x06, 0x18 * 0x02, 0x00);
 
 }
 
 
  if
(Q691 > 0x00) // was someone around
 
 {
 
   if(!getCompileFlag(0x01)) // did someone see you?
 
   {
 
     setCriminal(this, 0x01E0); // 0x01E0 = duration 8 min
 
   }
    
    
///// give skill points only if someone can see you
 
   Q4IB = Q569 * Q5YS * 0x1E + 0x64;
 
   if(testAndLearnSkill(this, 0x21, Q4IB, 0x32) <= 0x00)
 
   {
 
     systemMessage(this, "You fail to steal the item.");
 
     return(0x00);
 
   }
    
//////
    
 
 }
 
 
  
////// ITEM IS STOLEN ////
 
 
  systemMessage
(this, "You successfully steal the item.");
 
 
  
  if
(owner == NULL()) 
 
 {
 
   setCriminal(this, 0x01E0); //0x01E0 = duration 8 min
 
 }
 
 else
  
{
 
   if(!canBeFreelyAggressedBy(owner, this)) // owner can always attack the thief if they wish.
 
   {
 
     int Q4Q1 = addToObjVarListSet(this, "crimeVictimList", owner);
 
   }
 
 }
 
 int Q64H = 0x01; // items to steel
 
 if(quantity > 0x01) // is the item a pile or single item
 
 {
 
   int Q64I = random(0x01, 0x0A); // get a random number between 1 and 10
 
   if(Q64I > Q68B) // if random is over weight of a pile of items.
 
   {
 
     Q64H = quantity; // all will be stolen.
 
   }
 
   else
    
{
 
     Q64H = (quantity * Q64I) / Q68B; // take as manyitem we can based on quantity / weight 
 
     if(Q64H < 0x01) // if less then one take one item from the pile.
 
     {
 
       Q64H = 0x01;
 
     }
 
   }
 
 }
 
 
  obj Q59G 
= getBackpack(this);
 
 if(Q64H < quantity)
 
 {
    
// transfer some items from the container to thief.
 
   obj Q4EV = createNoResObjectIn(getObjType(usedon), Q59G);
 
   transferGeneric(Q4EV, usedon, Q64H);
 
   return(0x01);
 
 }
 
 // take all items.
 
 int Q4EL = putObjContainer(usedon, Q59G);
 
 return(0x01);
} 

There is alot missing in this script compaire how it was in T2A. There is no can only steel 1 stone = 10% 2 stones 20% and so on. I cant see any "guard me" checks and no skill gain without npc's around seems off to and might got changes. The server is a "beta" build of T2A before it was released live so it is a mix of UO gold and T2A . So there is sone things off here and there.

Houseing is a great example of this. there is no house signs in the demo server but in T2A we had them.
Reply
#12
I think getCompileFlag(0x01) is a flag of whether we are still running a pre T2A server or to start using new T2A code. It's used in several other places regarding whether to use the notoriety system.

Code:
setCriminal(this, 0x01E0); // 0x01E0 = duration 8 min

My guess is this isn't 8 minutes, but is the amount of 0.25s ticks (120s).

I don't think we can reliably conclude that the return value of witnessCrime is whether or not someone saw you. We just don't know what it is. There is only 1 other place in the demo scripts it is used, and the return value is never used there. I do think it would be related to whether or not you were stealing from a mobile though.

-5000 karma is likely the cap of how low stealing can take you rather than how much karma you lose per steal. I believe this is actually the same value that is used in RunUO.
[Image: jack-sig.png]
Reply
#13
Yea, the ticks seems more accurate then 8 minutes (a hell lot of time).

getCompileFlag makes sense that was a new thing for me.

witnessCrime is also used in Provo script (UODEMO\SKILLS\incite.m.txt) on line 210 but is still a mystery.

5000 karma cap makes more seens.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)