Jump to content

Cast spell without targeting.


Mykoplazma

Recommended Posts

Hi is this possible to cast spell on player without targeting that player before? There was many pqr profiles for ( healing ones ) which was casting all healing spells on friendly target without taking the target slot. It was easy to reproduce using wow plus hack ( for example ) on cata doing simple thing like CastSpellByName("Flash Heal",target.guid) where the target guid is not blizzard crap ( "target","player","pet" etc ) but numerical value of guid ( 123423423423 ) or maybe memory adress of the target player structure anyway it was working , and this is also working too on pqr so is that possible on wrobot to? Now I must find the target, check hp, target it, cast spell. But without that interaction thing is that possible?

Link to comment
Share on other sites

On 6.2.2017 at 8:05 AM, forerun said:

Hi is this possible to cast spell on player without targeting that player before? There was many pqr profiles for ( healing ones ) which was casting all healing spells on friendly target without taking the target slot. It was easy to reproduce using wow plus hack ( for example ) on cata doing simple thing like CastSpellByName("Flash Heal",target.guid) where the target guid is not blizzard crap ( "target","player","pet" etc ) but numerical value of guid ( 123423423423 ) or maybe memory adress of the target player structure anyway it was working , and this is also working too on pqr so is that possible on wrobot to? Now I must find the target, check hp, target it, cast spell. But without that interaction thing is that possible?

Yes it is possible

                if (target.Guid == ObjectManager.Me.Guid)
                {
                    // Cast on self
                    Lua.LuaDoString($"CastSpellByID({spell.Id}, \"player\")");
                }
                else
                {
                    // Cast on target
                    Lua.LuaDoString($"CastSpellByID({spell.Id}, \"{target.Name}\")");
                }

 

Link to comment
Share on other sites

Ok thank you for answer that method is working - you don't need a target but you must be in party otherwise it  will not work. Second question - sometimes object manager don't have access to name field? The result name is Unknown despite all other values are correct and visible . How to get rid of that Unknown thing without lua guid comparasion ( because it's eating resources like crazy )

Link to comment
Share on other sites

1 hour ago, forerun said:

Ok thank you for answer that method is working - you don't need a target but you must be in party otherwise it  will not work. Second question - sometimes object manager don't have access to name field? The result name is Unknown despite all other values are correct and visible . How to get rid of that Unknown thing without lua guid comparasion ( because it's eating resources like crazy )

You don't need to be in a party the only thing you need is a valid WoWUnit/Player object.
No clue about your other problem never had such issue.

Link to comment
Share on other sites

Ok. Go to a city with a disco priest. Take a name of anyplayer around with afk write Lua.DoString("CastSpellById(17,\"THATPLAYERNAME\")") and look what will happen ( 17 is power world : shield ). You will cast it on yourself. Always with your snippet the situation is identical. Alawys on self but if in party then ok.

Second thing using that example for object manager iteration:

 

   if (!ObjectManager.Me.IsDead && Party.IsInGroup() && !Usefuls.IsLoadingOrConnecting && Usefuls.InGame)
                {
                    foreach (var playerGuid in Party.GetPartyGUID())
                    {
                        if (playerGuid > 0)
                        {
                            var p = new WoWPlayer(0);
                            var obj = ObjectManager.GetObjectByGuid(playerGuid);
                            if (obj.IsValid && obj.Type == WoWObjectType.Player)
                            {
                                p = new WoWPlayer(obj.GetBaseAddress);
                            }
                            if (p.IsValid && !p.IsDead)
                            {

                                   Logging.Write(p.name);

                            }

}

}

That p.name sometimes return value Unknown instead of player name all other values are correct.

 

 

 

Link to comment
Share on other sites

24 minutes ago, forerun said:

Ok. Go to a city with a disco priest. Take a name of anyplayer around with afk write Lua.DoString("CastSpellById(17,\"THATPLAYERNAME\")") and look what will happen ( 17 is power world : shield ). You will cast it on yourself. Always with your snippet the situation is identical. Alawys on self but if in party then ok.

Second thing using that example for object manager iteration:

 

   if (!ObjectManager.Me.IsDead && Party.IsInGroup() && !Usefuls.IsLoadingOrConnecting && Usefuls.InGame)
                {
                    foreach (var playerGuid in Party.GetPartyGUID())
                    {
                        if (playerGuid > 0)
                        {
                            var p = new WoWPlayer(0);
                            var obj = ObjectManager.GetObjectByGuid(playerGuid);
                            if (obj.IsValid && obj.Type == WoWObjectType.Player)
                            {
                                p = new WoWPlayer(obj.GetBaseAddress);
                            }
                            if (p.IsValid && !p.IsDead)
                            {

                                   Logging.Write(p.name);

                            }

}

}

That p.name sometimes return value Unknown instead of player name all other values are correct.

 

 

 

Well i'm using a bit different method. I'm searching the player object first, validate it and using its name, works fine for me without party.

This is the way I use to cast a heal spell:

        /// <summary>
        /// Cast a heal
        /// </summary>
        /// <param name="spell">The heal you want to cast</param>
        /// <param name="target">The target you want to heal</param>
        /// <param name="healthProcent">The health procent we want to heal</param>
        /// <param name="canMove">Indicates if we are able to move</param>
        /// <param name="buffTimeLeft">Recast if buff is under the given time</param>
        /// <param name="stacks">How much stacks you want at the target</param>
        /// <param name="debuff">The debuff we are looking for</param>
        /// <param name="owner">Flag that determines if we need to be the owner</param>
        /// <returns>Returns true if we can cast the spell otherwise false</returns>
        public static bool CastHeal(Spell spell, WoWUnit target, int healthProcent = 100, bool canMove = true, double buffTimeLeft = 0, int stacks = 0, Spell debuff = null, bool owner = true)
        {
            // Check if the spell is known
            if (!IsSpellKnown(spell))
            {
                // Skip
                return false;
            }

            // Need heal?
            if (target.HealthPercent > healthProcent)
            {
                // Skip
                return false;
            }

            // Are we allowed to move?
            if (ObjectManager.Me.GetMove == true && !canMove)
            {
                // Skip
                return false;
            }

            // Wait until global cooldown is done
            Thread.Sleep(SpellManager.GlobalCooldownTimeLeft());

            // Check if buff exists
            bool hasDebuff;
            if (debuff != null)
            {
                hasDebuff = Functions.HasBuff(debuff, target, buffTimeLeft, stacks, owner);
            }
            else
            {
                hasDebuff = Functions.HasBuff(spell, target, buffTimeLeft, stacks, owner);
            }

            // Validate spell
            if (!ObjectManager.Me.IsStunned && !ObjectManager.Me.IsDead && !ObjectManager.Me.IsCast && !target.IsDead && spell.IsSpellUsable && spell.IsDistanceGood && !hasDebuff && !TraceLine.TraceLineGo(target.Position))
            {
                if (target.Guid == ObjectManager.Me.Guid)
                {
                    // Cast on self
                    Lua.LuaDoString($"CastSpellByID({spell.Id}, \"player\")");
                }
                else
                {
                    // Cast on target
                    Lua.LuaDoString($"CastSpellByID({spell.Id}, \"{target.Name}\")");
                }

                // Log
                Logging.WriteDebug($"Cast: {spell.NameInGame}");

                // Return
                return true;
            }

            // Return
            return false;
        }

You need to find another way for spell.IsDistanceGood to validate the distance since we don't have a target.

To get the party member I'm using

Party.GetPartyHomeAndInstance().Where(p => p.Type == WoWObjectType.Player)

May its a way that works for you.

Link to comment
Share on other sites

4 minutes ago, forerun said:

Thank you for your example it's very usefull and full of usefull tips.

You are welcome. For the distance issue you could use something like (ObjectManager.Me.Position.DistanceTo(target.Position) <= spell.MaxRange)

Link to comment
Share on other sites

6 minutes ago, forerun said:

And sorry again one more question - how to check LOS?

!TraceLine.TraceLineGo(target.Position)

For some reasons if it is false you are able to see the object.

Ask as much as you want because thats what the forum is for :wink:

Link to comment
Share on other sites

  • 2 years later...

Hello , 

I know this post is somewhat old but i wanted to give a little update on how to go around needing to use Lua, I don't use a lot of lua because its a 80 Ms to inject into the wow client. 

this method works on Wotlk and able to help heal self and or players.

SpellManager.CastSpellByNameOn("Rejuvenation", p.Name);

or 

SpellManager.CastSpellByNameOn("Rejuvenation","PlayerName");

or 

SpellManager.CastSpellByNameOn("Rejuvenation", ObjectManager.Me.Name);

Really any code with a name string will work

Link to comment
Share on other sites

if (p.HealthPercent <= 90 && !p.HaveBuff("Wild Growth") && Wild.KnownSpell && Wild.IsSpellUsable)
{
		if (p.HealthPercent >= 1)
	{
		SpellManager.CastSpellByNameOn("Wild Growth", p.Name);
		Usefuls.WaitIsCasting();
	}	
}

Updated code that i made for someone. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...