Beispiel #1
0
        /// <summary>
        /// Executes a Task 'cast'
        /// </summary>
        /// <param name="Task"></param>
        protected void DoCast(BotTaskCast Task)
        {
            SpellObject spellObject = null;
            StatList    spellStat   = null;
            string      sureTarget  = Task.Target;
            string      sureWhere   = Task.Where;

            // handle selftargeting
            if (sureTarget.ToLower().Equals(SpellBotConfig.XMLVALUE_SELF))
            {
                if (Data.AvatarObject == null)
                {
                    Log("WARN", "Cant execute task 'cast' " + Task.Name + ". Technical interruption changed the target.");
                    return;
                }

                sureTarget = Data.AvatarObject.Name.ToLower();
                sureWhere  = SpellBotConfig.XMLVALUE_ROOM;
            }

            // try to get the spell from the spells
            spellObject = Data.SpellObjects.GetItemByName(Task.Name, false);

            // try to get stat for % value
            if (spellObject != null)
            {
                spellStat = Data.AvatarSpells.GetItemByID(spellObject.ID);
            }

            // one not found
            if (spellObject == null || spellStat == null)
            {
                // log
                Log("WARN", "Cant execute task 'cast'. Spell " + Task.Name + " found.");

                return;
            }

            // handle spells above cap
            if (spellStat.SkillPoints >= Task.Cap)
            {
                if (Task.OnMax.ToLower() == SpellBotConfig.XMLVALUE_QUIT)
                {
                    // log
                    Log("BOT", "Quitting.. spell " + spellObject.Name + " reached 99%.");

                    // prepare quit
                    IsRunning = false;
                    return;
                }
                else if (Task.OnMax.ToLower() == SpellBotConfig.XMLVALUE_SKIP)
                {
                    // log
                    Log("BOT", "Skipped task 'cast' " + spellObject.Name + " (99%)");

                    return;
                }
            }

            // spell doesn't need a target
            if (spellObject.TargetsCount == 0)
            {
                // send castreq
                SendReqCastMessage(spellObject);

                // log
                Log("BOT", "Executed task 'cast' " + spellObject.Name);
            }

            // speed needs a target
            else if (spellObject.TargetsCount > 0)
            {
                // marked to cast on roomobject
                if (sureWhere == SpellBotConfig.XMLVALUE_ROOM)
                {
                    // try to get the target
                    RoomObject roomObject =
                        Data.RoomObjects.GetItemByName(sureTarget, false);

                    // target not found
                    if (roomObject == null)
                    {
                        // log
                        Log("WARN", "Can't execute task 'cast'. RoomObject " + sureTarget + " not found.");

                        return;
                    }

                    // send castreq
                    ReqCastMessage reqCastMsg = new ReqCastMessage(
                        spellObject.ID, new ObjectID[] { new ObjectID(roomObject.ID) });

                    SendGameMessage(reqCastMsg);

                    // log
                    Log("BOT", "Executed task 'cast' " + spellObject.Name);
                }

                // cast on inventory item
                else if (sureWhere == SpellBotConfig.XMLVALUE_INVENTORY)
                {
                    // try to get the target
                    InventoryObject inventoryObject =
                        Data.InventoryObjects.GetItemByName(sureTarget, false);

                    // target not found
                    if (inventoryObject == null)
                    {
                        // log
                        Log("WARN", "Can't execute task 'cast'. Item " + sureTarget + " not found.");

                        return;
                    }

                    // send castreq
                    ReqCastMessage reqCastMsg = new ReqCastMessage(
                        spellObject.ID, new ObjectID[] { new ObjectID(inventoryObject.ID) });

                    SendGameMessage(reqCastMsg);

                    // log
                    Log("BOT", "Executed task 'cast' " + spellObject.Name);
                }
                else
                {
                    // log
                    Log("WARN", "Can't execute task 'cast'. " + sureWhere + " is unknown 'where'.");
                }
            }
        }
Beispiel #2
0
        protected void PerformBuff(RoomObject roomObject, string partnername)
        {
            isBuffingInProcess = true;

            string[] spellName = { "bless",         "resist poison", "super strength", "detect invisible", "free action", "magic shield", "night vision", "deflect", "eagle eyes",
                                   "armor of gort", "meditate" };

            for (int i = 0; i < spellName.Length; i++)
            {
                SpellObject    spellObject = null;
                StatList       spellStat   = null;
                ReqCastMessage reqCastMsg  = null;

                spellObject = Data.SpellObjects.GetItemByName(spellName[i], false);
                if (spellObject != null)
                {
                    spellStat = Data.AvatarSpells.GetItemByID(spellObject.ID);
                }

                if (spellObject == null || spellStat == null)
                {
                    Log("WARN", "Can't find spell " + spellObject.Name + ".");
                    return;
                }

                if (roomObject == null)
                {
                    Log("WARN", "Can't find RoomObject of " + partnername + ".");
                    return;
                }

                if (spellObject.Name == "meditate")
                {
                    if (Data.IsResting)
                    {
                        SendUserCommandStand();
                    }

                    isMeditateInProcess = true;
                    SendReqCastMessage(spellObject);
                    System.Threading.Thread.Sleep(21000);
                    isMeditateInProcess = false;
                    isBuffingInProcess  = false;

                    if (!Data.IsResting)
                    {
                        SendUserCommandRest();
                    }

                    return;
                }

                else if (spellObject.Name == "deflect")
                {
                    if (Data.IsResting)
                    {
                        SendUserCommandStand();
                    }

                    reqCastMsg = new ReqCastMessage(spellObject.ID, new ObjectID[] { new ObjectID(roomObject.ID) });
                    SendGameMessage(reqCastMsg);

                    Log("BOT", "I casted spell " + spellObject.Name + " on target " + partnername + ".");
                    System.Threading.Thread.Sleep(3000);
                }

                else if (spellObject.Name != "deflect" && spellObject.Name != "meditate")
                {
                    if (Data.IsResting)
                    {
                        SendUserCommandStand();
                    }

                    reqCastMsg = new ReqCastMessage(spellObject.ID, new ObjectID[] { new ObjectID(roomObject.ID) });
                    SendGameMessage(reqCastMsg);

                    Log("BOT", "I casted spell " + spellObject.Name + " on target " + partnername + ".");
                    System.Threading.Thread.Sleep(2000);
                }
            }
        }