/**************************************************** * All weight function are coded here * * Done by Moongraven * ****************************************************/ #include "uox3.h" #define GOLD_WEIGHT 0.02 float calcweight(int p) //First let's grab all item that player wear { int p1, p2, p3, p4; unsigned int i; float totalweight=0; tile_st tile; p1=chars[p].ser1; p2=chars[p].ser2; p3=chars[p].ser3; p4=chars[p].ser4; for (i=0;i=totalweight) return 0; else { sysmessage(chars,"Your backpack are full!"); return 1; } } int checkweight(int s, int k) // Check when player is walking if overloaded { if ((chars[s].weight > (chars[s].st*WEIGHT_PER_STR)+30)) { float res=(chars[s].weight - ((chars[s].st*WEIGHT_PER_STR)+30))*2; chars[s].stm -= (int)res; if (chars[s].stm<=0) { chars[s].stm=0; return 0; } } return 1; } void additemweight(int i, int s) //add weight of this item on player's weight { tile_st tile; seektile((items[i].id1*256)+items[i].id2, &tile); if (items[i].type==1||items[i].type==8) //if item is container add container { //and all item weight chars[s].weight +=tile.weight; chars[s].weight += calcweightpack(i); } else { if (tile.weight==0) { if(items[i].id1==0x0E && items[i].id2==0xED) chars[s].weight += (items[i].amount*GOLD_WEIGHT); else chars[s].weight += (items[i].amount*0.1); } else chars[s].weight += (items[i].amount*tile.weight); } } void subtractitemweight(int i, int s) //subtract weight of this item on player's weight { tile_st tile; seektile((items[i].id1*256)+items[i].id2, &tile); if (items[i].type==1||items[i].type==8) //if item is container subtract container { //and all item weight chars[s].weight -= tile.weight; chars[s].weight -= calcweightpack(i); } else { if (tile.weight==0) { if(items[i].id1==0x0E&&items[i].id2==0xED) chars[s].weight -= (items[i].amount*GOLD_WEIGHT); else chars[s].weight -= (items[i].amount*0.1); } else chars[s].weight -= (items[i].amount*tile.weight); } } int checkwhereitem( int pack, int i, int s) { if (!((items[i].cont1==items[pack].ser1 && items[i].cont2==items[pack].ser2 && items[i].cont3==items[pack].ser3 && items[i].cont4==items[pack].ser4 )|| (items[i].cont1==chars[currchar[s]].ser1&&items[i].cont2==chars[currchar[s]].ser2&& items[i].cont3==chars[currchar[s]].ser3&&items[i].cont4==chars[currchar[s]].ser4))) return 1; else return 0; } void subtractquanweight(int i, int s, int total) //subtract weight of this item on player's weight { tile_st tile; seektile((items[i].id1*256)+items[i].id2, &tile); if (tile.weight==0) { if(items[i].id1==0x0E&&items[i].id2==0xED) chars[s].weight -= (total*GOLD_WEIGHT); else chars[s].weight -= (total*0.1); } else chars[s].weight -= (total*tile.weight); } void addamountweight(int i, int s, int amount) //add weight of this item on player's weight { tile_st tile; seektile((items[i].id1*256)+items[i].id2, &tile); if (tile.weight==0) { if(items[i].id1==0x0E && items[i].id2==0xED) chars[currchar[s]].weight += (amount*GOLD_WEIGHT); else chars[currchar[s]].weight += (amount*0.1); } else chars[currchar[s]].weight += (amount*tile.weight); } int whereitem( int p, int i, int s) // To find if item are in possesion of player { // If return is 1 item are not on player otherwise they are on if ((items[i].cont1==255 && items[i].cont2==255 && items[i].cont3==255 && items[i].cont4==255)|| (items[p].cont1==255 && items[p].cont2==255 && items[p].cont3==255 && items[p].cont4==255)|| (items[p].id1==0x09 && items[p].id2==0xAB)) return 1; else if ((items[i].cont1==items[p].ser1 && items[i].cont2==items[p].ser2 && items[i].cont3==items[p].ser3 && items[i].cont4==items[p].ser4)|| (items[i].cont1==chars[currchar[s]].ser1 && items[i].cont2==chars[currchar[s]].ser2 && items[i].cont3==chars[currchar[s]].ser3 && items[i].cont4==chars[currchar[s]].ser4)) return 0; else return (wheresub(i,p)); } int wheresub(int i, int p) // If item are in a subcontainer posseded by player { // If return is 1 item are not on player otherwise they are on for (unsigned int a=0;a