huyenthieugia81
Youtube Master Race
- 24/7/05
- 55
- 0
bạn sài đoạn code này cho common file nhé
PHP:
NPCCombatObject findMonster()
{
int maxhp = 0;
string mi = "";
foreach (NPCCombatObject onpc in ts.oNPCCombat.Values)
{
if (onpc.HP > 0)
{
if (onpc.MAXHP > maxhp)
{
maxhp = onpc.MAXHP;
mi = onpc.Row.ToString() + onpc.Col.ToString();
}
}
}
return ts.oNPCCombat[mi] as NPCCombatObject;
}
void doEatSP(ushort order,int difSp){
for(byte i = 0;i< 25 ;i++){
Slot oSlot = (Slot)ts.MyItems[i];
if (oSlot.itemid == 0) { continue; }
Item oItem = (Item)ts.ITEMS[oSlot.itemid.ToString()];
if(oItem.isSPItem()){
int itemvalue=oItem.getSPValue();
if (itemvalue > difSp){ continue; }
byte eatSpAmt = (byte)((difSp - (difSp % itemvalue)) / itemvalue);
if (eatSpAmt> 0){
if (eatSpAmt > oSlot.num){
eatSpAmt = oSlot.num;
}
ts.EatItem((byte)(i+1),eatSpAmt,order) ;
debug(oItem.itemname+" SP "+itemvalue+" at slot "+((byte)(i+1)).ToString()+" decrease"+eatSpAmt ,0xC08008 );
difSp = difSp - eatSpAmt * itemvalue ;
}
}
}
ts.delay(500);
}
void doEatHP(ushort order,int difHp){
for(byte i = 0;i< 25 ;i++){
Slot oSlot = (Slot)ts.MyItems[i];
if (oSlot.itemid == 0) { continue; }
Item oItem = (Item)ts.ITEMS[oSlot.itemid.ToString()];
if(oItem.isHPItem()){
int itemvalue=oItem.getHPValue();
if (itemvalue > difHp){ continue; }
byte eatHpAmt = (byte)((difHp - (difHp % itemvalue)) / itemvalue );
if (eatHpAmt> 0){
if (eatHpAmt > oSlot.num){
eatHpAmt = oSlot.num;
}
ts.EatItem((byte)(i+1),eatHpAmt,order);
debug(oItem.itemname + " HP " + itemvalue.ToString() + " at slot " + ((byte)(i+1)).ToString() + " decrease " + eatHpAmt.ToString() ,0xC08008 );
difHp = difHp - eatHpAmt * itemvalue ;
}
}
}
ts.delay(500);
}
void FindItemContribute(string ItemName){
Slot s = FindItemInSlot(ItemName);
if(s != null){
ts.Contribute(s.slot);
}
}
void FindItemDrop(string ItemName){
Slot s = FindItemInSlot(ItemName);
if(s != null){
ts.DropItem(s.slot,s.num);
}
}
Slot FindItemInSlot(string ItemName){
for(byte i=0;i<25;i++){
Slot oSlot = (Slot)ts.MyItems[i];
if( oSlot.itemid == 0){ continue; }
Item oItem = (Item)ts.ITEMS[oSlot.itemid.ToString()];
if(oItem.itemname == ItemName){
return oSlot;
}
}
return null;
}
void AutoEatFood(){
if (ts.Character.HP < (ts.Character.MAXHP * hpFractionEat)){
doEatHP(0,(int)((ts.Character.MAXHP * hpFraction)-ts.Character.HP));
}
if (ts.Character.SP < (ts.Character.MAXSP * spFractionEat)){
doEatSP(0,(int)((ts.Character.MAXSP * spFraction)-ts.Character.SP));
}
if (ts.CurrentPartner.HP < (ts.CurrentPartner.MAXHP * hpFractionEat)){
doEatHP((ushort)ts.CurrentPartner.Order,(int)((ts.CurrentPartner.MAXHP * hpFraction)-ts.CurrentPartner.HP));
}
if (ts.CurrentPartner.SP < (ts.CurrentPartner.MAXSP * spFractionEat)){
doEatSP((ushort)ts.CurrentPartner.Order,(int)((ts.CurrentPartner.MAXSP * spFraction)-ts.CurrentPartner.SP));
}
}
int get_random(int min,int max)
{
System.Random rd=new System.Random();
int ranNum= rd.Next(min,max);
return ranNum;
}
void Disconnect(string msg) {
debug(msg,0x0000FF);
ts.Disconnect();
}
void CheckDisconnect(){
if(ts.Character.HP< (DisconnectFlag * ts.Character.MAXHP)){
Disconnect("Disconnected : Character HP is low !!");
}
if(ts.CurrentPartner.HP< (DisconnectFlag * ts.CurrentPartner.MAXHP)){
Disconnect("Disconnected : Warrior HP is low !!");
}
if(ts.CurrentPartner.fai < DisconFai){
Disconnect("Disconnected : Warrior faith is below faith flag !!");
}
}
System.Collections.ArrayList DropItemList = new System.Collections.ArrayList();
System.Collections.ArrayList ContributeItemList = new System.Collections.ArrayList();
void AddDropItemList(string itemname) {
if (!DropItemList.Contains(itemname)) {
DropItemList.Add(itemname);
}
}
bool InDropItemList(string itemname) {
if (DropItemList.Contains(itemname))
return true;
else
return false;
}
void AddContributeItemList(string itemname) {
if (!ContributeItemList.Contains(itemname)) {
ContributeItemList.Add(itemname);
}
}
bool InContributeItemList(string itemname) {
if (ContributeItemList.Contains(itemname))
return true;
else
return false;
}
void ProcessInventoryAction(){
for(byte i=0;i<25;i++)
{
Slot oSlot = (Slot)ts.MyItems[i];
if( oSlot.itemid == 0){ continue; }
Item oItem = (Item)ts.ITEMS[oSlot.itemid.ToString()];
if (InDropItemList(oItem.itemname)) ts.DropItem(oSlot.slot,oSlot.num);
if((oSlot.itemid == 46027 ||
oSlot.itemid == 46033 ||
oSlot.itemid == 26168 ||
oSlot.itemid == 46041 ||
oSlot.itemid == 46013 ||
oSlot.itemid == 27029 ||
oSlot.itemid == 46016 )
&& oSlot.num == 50)
{ts.SendItemTo(171572,oSlot.slot,oSlot.num);}
if(( oSlot.itemid == 26157 ||
oSlot.itemid == 27032)
&& oSlot.num == 50)
{ts.SendItemTo(171572,oSlot.slot,oSlot.num);}
}
}

