private void DoBuffsPart2() { Globals.BuffListLock.EnterReadLock(); Globals.BuffsGivenLock.EnterWriteLock(); try { foreach (BuffTargetClass bft in BotOptions.BuffTargets) { if (bft.Active == true && bft.IsReady()) { for (int name_i = 0; name_i < bft.TargetNames.Count; name_i++) { found = false; foreach (CharBuffTimer cbt in Globals.gamedata.BuffsGiven) { if (System.String.Equals(cbt.Name, ((string)bft.TargetNames[name_i]))) { found = true; needs_buff = false; switch (cbt.Has_Buff(bft)) { case BuffState.DoesntHave: //doesnt have the buff cbt.Add_Buff(bft); needs_buff = true; break; case BuffState.Needs://needs buff needs_buff = true; break; case BuffState.Has://doesnt need buff //needs_buff = false; break; }//end of switch on buffstate if (needs_buff) { if (ServerPackets.TrySkill(((string)bft.TargetNames[name_i]), cbt, bft)) { Globals.gamedata.Set_Char_To_Buffing(); breaktotop = true; return; } else { //the target is too far or something for us to buff it //set it to have an extra delay of 20 seconds cbt.Add_Time(bft.SkillID, Globals.FAILED_BUFF); } } break; } }//end of foreach cbt if (breaktotop) return; if (!found) { //need to add this name to the list CharBuffTimer cbuff = new CharBuffTimer(); cbuff.Name = ((string)bft.TargetNames[name_i]).ToUpperInvariant(); Globals.gamedata.BuffsGiven.Add(cbuff); cbuff.Add_Buff(bft); if (cbuff.Has_Buff(bft) != BuffState.Has) { if (ServerPackets.TrySkill(((string)bft.TargetNames[name_i]), cbuff, bft)) { Globals.gamedata.Set_Char_To_Buffing(); breaktotop = true; return; } else { //the target is too far for us to buff it or something //set it to have an extra delay of 20 seconds cbuff.Add_Time(bft.SkillID, Globals.FAILED_BUFF); } } } }//end of foreach name }//end of isActive if (breaktotop) return; }//end of for buffs }//unlock catch { Globals.l2net_home.Add_Error("crash: DoBuffsPart2"); } finally { Globals.BuffsGivenLock.ExitWriteLock(); Globals.BuffListLock.ExitReadLock(); Globals.gamedata.my_char.isAttacking = false; } }
public static bool TrySkill(string name, CharBuffTimer cbt, BuffTargetClass bft) { uint tmp_id; if (System.String.Equals("PET", name.ToUpperInvariant())) { tmp_id = Globals.gamedata.my_pet.ID; } if (System.String.Equals("PET1", name.ToUpperInvariant())) { tmp_id = Globals.gamedata.my_pet1.ID; } if (System.String.Equals("PET2", name.ToUpperInvariant())) { tmp_id = Globals.gamedata.my_pet2.ID; } if (System.String.Equals("PET3", name.ToUpperInvariant())) { tmp_id = Globals.gamedata.my_pet3.ID; } else { tmp_id = Util.GetCharID(name); } if (Util.Distance(tmp_id) > bft.Range) { //cant buff them now //Globals.gamedata.my_char.BuffTarget = 0; return false; } else { //do we actually need a target? Globals.gamedata.my_char.LastBuffTime = System.DateTime.Now; Globals.gamedata.my_char.BuffSkillID = bft.SkillID; Globals.gamedata.my_char.BuffTarget = tmp_id; Globals.gamedata.my_char.LastTarget = Globals.gamedata.my_char.TargetID; Globals.gamedata.BOT_STATE = BotState.Buffing; if (bft.NeedTarget == 1) { Globals.gamedata.my_char.BuffNeedTarget = 1; if (!Globals.gamedata.my_char.CanBuff()) { int x = 0, y = 0, z = 0; Util.GetCharLoc(Globals.gamedata.my_char.BuffTarget, ref x, ref y, ref z); Target(Globals.gamedata.my_char.BuffTarget, x, y, z, false); } } else { Globals.gamedata.my_char.BuffNeedTarget = 0; } return true; } }