What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

onSkillCasting not triggering (some casts)

UnknownUser

New Member
Joined
Jul 15, 2015
Messages
6
Reaction score
0
Being somewhat new to C#, It took me awhile to figure out how to use the onSkillCasting event, but after finally getting it to work, I have found that it does not trigger for a few spells. I think the correlation is not triggering level 55 spells, specifically God's Whip, Fiend's Knell, and Whirlwind's Blessing. It does seem to trigger for Grief's Cadence and Mirror Warp.

So I guess my questions will be: Am I doing something wrong? If so, what? If not, is this intended (ie not a bug)? If intended, is there a workaround? If not intended, any chance for a fix?

I include below my code:
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;


namespace ArcheSampleCode
{
    public class SampleCode : Core
    {
        static int DEBUG = 3; // Set Debug level 0-4
        
        
        //Debug Function - Prints to log is debug level is greater than or equal to d
        public void debug(int d, string message)
        {
            if (d <= DEBUG)
            {
                Log(message, false);
            }
        }

        public static string GetPluginAuthor()
        {
            return "UnknownUser";
        }

        public static string GetPluginVersion()
        {
            return "1.0.0.0";
        }

        public static string GetPluginDescription()
        {
            return "Sample Code";
        }

        public void PluginRun()
        {

            debug(0, "Starting SampleCode Plugin");
            onSkillCasting += SampleCode_onSkillCasting;
            onNewDoodad += SampleCode_onNewDoodad;
            while (true)
            {
                Thread.Sleep(300);
            }
        }

        public void PluginStop()
        {
        }

        public void SampleCode_onSkillCasting(Creature obj, SpawnObject obj2, Skill skill, double x, double y, double z)
        {
            string obj2Name = "";
            if (obj2.type.ToString() == "Player")
            {
                Creature target = (Creature)(obj2);
                obj2Name = target.name;
            }
            if (obj2.type.ToString() == "DoodadObject")
            {
                DoodadObject target = (DoodadObject)(obj2);
                obj2Name = target.name;
            }
            if (obj2.type.ToString() == "Self")
            {
                obj2Name = me.name;
            }
            debug(3, "" + obj.name + " is casting " + skill.name + "(" + skill.id + ")" + " on " + obj2Name + "(" + obj2.type + ")");

        }
        void SampleCode_onNewDoodad(DoodadObject obj)
        {
            debug(3, "New Doodad: " + obj.name + ":" + obj.id);
        }
    }
}
 
This might help you. You might need to remove core.
And you need to have something that is returning a valid target that the plugin will attack.
You also might add skills like this to the plugin

PHP:
        // Sorcery Zauberei
        const uint _FLAMEBOLT = 10752;
        const uint _FREEZING_ARROW = 10667;
        const uint _INSULATING_LENS = 10153;
        const uint _ARC_LIGHTNING = 10670;
        const uint _FREEZING_PATH = 10151;
        const uint _SEARING_RAIN = 11939;
        const uint _FRIGID_TRACKS = 11314;
        const uint _MAGIC_CIRCLE = 12796;
        const uint _CHAIN_LIGHTNING = 11967;
        const uint _FLAME_BARRIER = 14774;
        const uint _METEOR_STRIKE = 10664;
        const uint _GODS_WHIP = 23593;

        // Witchcraft Hexerei
        const uint _EARTHEN_GRIP = 14376;
        const uint _ENERVATE = 10159;
        const uint _BUBBLE_TRAP = 10154;
        const uint _INSIDIOUS_WHISPER = 10409;
        const uint _PURGE = 10712;
        const uint _PLAY_DEAD = 10488;
        const uint _COURAGEOUS_ACTION = 11424;
        const uint _LASSITUDE = 10134;
        const uint _BANSHE_WAIL = 12001;
        const uint _FOCAL_CONCUSSION = 11353;
        const uint _DAHUTAS_BREATH = 11443;
        const uint _FIEND_KNELL = 23588;

        // Auramancy Auramantie
        const uint _THWART = 16486;
        const uint _COMETS_BOON = 18222;
        const uint _CONVERSION_SHIELD = 11869;
        const uint _VICIOUS_IMPLOSION = 10710;
        const uint _TELEPORTATION = 10152;
        const uint _HEALTH_LIFT = 11991;
        const uint _MEDIDATE = 11989;
        const uint _SHRUF_IT_OFF = 11429;
        const uint _LIBERATION = 11380;
        const uint _LEECH = 10104;
        const uint _PROTECTIVE_WINGS = 10714;
        const uint _MIRROR_WARP = 23934;

        // Archery Bogenschießen
        const uint _CHARGED_BOLT = 16210;
        const uint _PIERCING_SHOT = 13564;
        const uint _ENDLESS_ARROWS = 14835;
        const uint _DOUBLE_RECURVE = 11368;
        const uint _DEADEYE = 15073;
        const uint _SNARE = 12133;
        const uint _FLOAT = 10694;
        const uint _BONEYARD = 14760;
        const uint _CONCUSSIVE_ARROW = 11933;
        const uint _MISSILE_RAIN = 13281;
        const uint _INTENSITY = 10708;
        const uint _SNIPE = 23592;

        // Shadowplay Schattenspiel
        const uint _RAPID_STRIKE = 18125;
        const uint _OVERWHELM = 10648;
        const uint _DROP_BACK = 12049;
        const uint _WALLOP = 12029;
        const uint _STALKERS_MARK = 12139;
        const uint _STEALTH = 10082;
        const uint _TOXIC_SHOT = 10481;
        const uint _PIN_DOWN = 13344;
        const uint _SHADOWSMITE = 10496;
        const uint _FREERUNNER = 10189;
        const uint _SHADOW_STEP = 12075;
        const uint _THROW_DAGGER = 23594;

        // Battlerage Kampfeszorn
        const uint _TRIPLE_SLASH = 18132;
        const uint _CHARGE = 11918;
        const uint _WHIRLWIND_SLASH = 13282;
        const uint _SUNDER_EARTH = 10644;
        const uint _LASSO = 12039;
        const uint _TERRIFYING_ROAR = 18308;
        const uint _BOND_BREAKER = 12034;
        const uint _PRECISION_STRIKE = 12026;
        const uint _FRENZY = 10455;
        const uint _BATTLE_FOCUS = 10377;
        const uint _TIGER_STRIKE = 13315;
        const uint _BEHIND_ENEMY_LINES = 23587;


        // Defense Verteidigung
        const uint _SHIELD_SLAM = 10399;
        const uint _REFRESHMENT = 10645;
        const uint _BULL_RUSH = 10501;
        const uint _BOASTFUL_ROAR = 12048;
        const uint _TOUGHEN = 11365;
        const uint _REVITALIZING_CHEER = 12046;
        const uint _REDOUBT = 10375;
        const uint _OLLOS_HAMMER = 18757;
        const uint _MOCKING_HOWL = 10436;
        const uint _IMPRISON = 14529;
        const uint _INVINCIBILITY = 10372;
        const uint _FORTRESS = 23589;

        // Occultism Okkultismus
        const uint _MANA_STARS = 14810;
        const uint _CRIPPLING_MIRE = 10201;
        const uint _HELL_SPEAR = 10135;
        const uint _ABSORB_LIFEFORCE = 11441;
        const uint _SUMMON_CROWS = 11395;
        const uint _MANA_FORCE = 12759;
        const uint _TELEKINESIS = 11504;
        const uint _RETRIBUTION = 10655;
        const uint _STILLNESS = 10665;
        const uint _URGENCY = 11442;
        const uint _SUMMON_WRAITH = 10434;
        const uint _DEAHTS_VENGEANCE = 23591;

        // Songcraft Bardenkunst
        const uint _CRITICAL_DISCORD = 11973;
        const uint _STARTLING_STRAIN = 11934;
        const uint _QUICKSTEP = 10723;
        const uint _DISSONANT = 11943;
        const uint _HEALING_HYMN = 17413;
        const uint _HUMMINGBIRD_DITTY = 11377;
        const uint _ODE_TO_RECOVERY = 10724;
        const uint _RHYTHMIC_RENEWAL = 11948;
        const uint _BULLWARK_BALLAD = 11396;
        const uint _BLOODY_CHANTEY = 10727;
        const uint _ALARM_CALL = 11961;
        const uint _GRIEFS_CADENCE = 23595;

        // Vitalism Vitalismus
        const uint _ANTITHESIS = 10534;
        const uint _MIRROR_LIGHT = 11379;
        const uint _RESURGENCE = 10547;
        const uint _REVIVE = 10546;
        const uint _SKEWER = 13284;
        const uint _MEND = 10720;
        const uint _INFUSE = 16783;
        const uint _ARANZEB_BOON = 16004;
        const uint _RENEWAL = 17412;
        const uint _FERVENT_HEALING = 14929;
        const uint _TWILIGHT = 10721;
        const uint _WHIRLWINDS_BLESSING = 23596;

PHP:
private bool CastSkillAt(uint skillId, Creature target)
        {
            while (core.me.isCasting || core.me.isGlobalCooldown)
                Thread.Sleep(50);

            double x = target.X;
            double z = target.Z;
            double y = target.Y;

            if (!core.UseSkill(skillId, x, y, z))
            {
                if (target != null && core.GetLastError() == LastError.NoLineOfSight)
                {
                    if (core.dist(target) <= 5)
                        core.ComeTo(target, 2);
                    else if (core.dist(core.me.target) <= 10)
                        core.ComeTo(target, 3);
                    else if (core.dist(target) < 20)
                        core.ComeTo(target, 8);
                    else
                        core.ComeTo(target, 8);
                }
            }

With this you can use it like this:
HTML:
CastSkillAt(_METEOR_STRIKE, target);
But you need sth that is returning a valid target otherwise it won't work ;)
 
Thank you Taranira for providing a response, but your solution does not address my questions. Your solution seems to effectively cast a skill and correct a potential line of site error when it is encountered.

My problem appears (in my opinion) to be a bug in ArcheBuddy, in that the event önSkillCasting does not capture all casting that is done, for certain spells. It is certainly possible that I am doing something wrong, but either way, O am asking for a solution, if there is one.
 
well the core is:

PHP:
private bool CastSkillAt(uint skillId, Creature target) 
        { 
            while (core.me.isCasting || core.me.isGlobalCooldown) 
                Thread.Sleep(50); 

            double x = target.X; 
            double z = target.Z; 
            double y = target.Y; }
you need the x z y position from your target. this code will manage it. And you need something that will set your target before you use CastSkillAt. After you have something that get the mob or enemie player you want as a target you can use the code like this:

PHP:
CastSkillAt(_METEOR_STRIKE, target);

PHP:
if (CanCast(_GODS_WHIP))
                {
                    CastSkillAt(_GODS_WHIP, target);
                    CastSkillAt(_GODS_WHIP, target);
                    CastSkillAt(_GODS_WHIP, target);
                    CastSkillAt(_GODS_WHIP, target);
                    CastSkillAt(_GODS_WHIP, target);
                }

If you are wondering what CanCast is
PHP:
private bool CanCast(uint skillId, bool selfTarget = false)
        {
            if (!skills.Contains(skillId)) return false;

            Skill s = core.getSkill(skillId);

            if (s == null) return false;
            if (core.skillCooldown(s) > 0) return false;
            if (s.db.cost > core.mp())
            {
                core.Log("OOM?");
                return false;
            }

            return true;
        }

For everything else, that don't need a x y z position from your target I use this:

PHP:
 private bool UseSkillAndWait(uint skillId, Creature target)
        {
            if (target == null)
                return false;

            core.SetTarget(target);
            return UseSkillAndWait(skillId);
        }

        
        private bool UseSkillAndWait(uint skillId, bool selfTarget = false)
        {
            while (core.me.isCasting || core.me.isGlobalCooldown)
                Thread.Sleep(50);

            Creature target = core.me.target;

            if (!core.UseSkill(skillId, true, selfTarget))
            {
                if (target != null && core.GetLastError() == LastError.NoLineOfSight)
                {
                    if (core.dist(target) <= 5)
                        core.ComeTo(target, 2);
                    else if (core.dist(core.me.target) <= 10)
                        core.ComeTo(target, 3);
                    else if (core.dist(target) < 20)
                        core.ComeTo(target, 8);
                    else
                        core.ComeTo(target, 8);
                }

                return false;
            }

            while (core.me.isCasting || core.me.isGlobalCooldown)
                Thread.Sleep(10);

            return true;
        }

What is isCasting?
http://www.archebuddy.com/API/html/1348195081.htm
 
My code in my first post does nothing more than monitor for 2 events (onSkillCasting and onNewDoodad) and displays some information in the log. It would be my intent at tis point to gather the information to make some reactionary methods. For example :

Code:
        public void SampleCode_onSkillCasting(Creature obj, SpawnObject obj2, Skill skill, double x, double y, double z)
        {
              if (skill.id == _GODSWHIP)
              {
                    SkillUse(_INVULN);
              }

        }

But as of right now, the onSkillCasting event is not triggering for God's Whip (and a few other spells). If you run my code from the first post, you will notice that the log shows almost all skills being cast around me, but if tested, God's whip (and others) do not get registered in the event/log.

Your code provided looks like it will be very effective at casting skills at various targets, but right now I am trying to code a plugin that reacts to certain situations, and currently onSkillCasting is not triggering for all skills that a player/doodad might cast. As noted in the first post, I observe that many (not all) of the 55 skills are not registering in the event, and was curious if they were forgotten to be updated (or updated incorrectly) in the delegate/source as a trigger.

Again, at this point, I am not trying to do anything other than gather information. At some point in the future, I would like to use that information to build an active reactionary system, but I am not there yet. Knowledge is power.

Thank you again for your efforts.
 
Back
Top