Jump to content

How to cast revive once?


Recommended Posts

I am writing a fight class in C# and got it to cast revive on dead party members but it will spam it.

This is what I used

Quote

                                if (p.IsValid && p.IsDead)
                                {
                                    SpellManager.CastSpellByNameOn("Revive", p.Name);
                                    Usefuls.WaitIsCasting();
                                 }


Btw, huge thanks to @Sye for taking his time to show me around on how to write a fight class in C# I am very grateful

Link to comment
Share on other sites

Use a timer you set when using SpellManager.CastSpellByName and add to the condiiton that the timer needs to be ready
Edit: Ideally you want one timer per unit guid you tried to rezz

Edited by Matenia
Link to comment
Share on other sites

Because you don´t have a cooldown on your revive ability and usefuls.waitiscast just wait until the Cast is done. So when the target don´t accept the ressurrection immediatly he get´s spammed over and over again. Therefore just use a timer for each target you already casted revive on, so it won´t spam revive on the same target again and again.

Link to comment
Share on other sites

using Timer = robotManager.Helpful.Timer;

public Spell rezz = new Spell("revive");

if (p.IsDead && ObjectManager.Me.IsAlive && !Fight.InFight && _time.IsReady)
                                    {
                                        if (ObjectManager.Me.Target != p.Guid)
                                            Interact.InteractGameObject(p.GetBaseAddress);
                                        rezz.Launch();
                                        Usefuls.WaitIsCasting();
                                        _time.Reset();

                                    }

I helped him,

Link to comment
Share on other sites

Works, thanks

 

                var corpse = ObjectManager.GetObjectWoWCorpse().FirstOrDefault();
                if (corpse.IsValid)
                {
                    Lua.LuaDoString("print('corpse exists, name: ["+corpse.Name+"], guid: ["+corpse.Guid+"], baseadress: ["+corpse.GetBaseAddress+"]')");
                    SpellManager.CastSpellByNameLUA("Revive");
                    Interact.InteractGameObject(corpse.GetBaseAddress);
                }

 

Link to comment
Share on other sites

13 hours ago, Sye said:

This should work (untested)

 


using System;
using System.Linq;
using wManager.Wow;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;
using Timer = robotManager.Helpful.Timer;




    public static class untested
{
    public static Timer _time = new Timer(5000);

    public static void Revive(string spellname, int vector)
    {
        var corpse = ObjectManager.GetObjectWoWCorpse().FirstOrDefault(o => o.Name == o.Name && o.Position.DistanceTo(ObjectManager.Me.Position) < vector);
        uint mouseover = 0x00BD07A0;
        if (_time.IsReady)
        {
            Memory.WowMemory.Memory.WriteUInt64(mouseover, corpse.Guid);
            SpellManager.CastSpellByNameOn(spellname, "mouseover");
            Usefuls.WaitIsCasting();
            ObjectManager.BlackListGetUnitAttackPlayerGuidTime.Add(corpse.Guid, DateTime.Now + TimeSpan.FromMinutes(1));
            _time.Reset();
        }
    }
}

use this to call for it in your fightclass 


untested.Revive("Spellname", 25);

 

your code is illogical, mouseover is in wrobot API you don't need to write in memory manually, why do "o.Name == o.Name" ? Why blacklist corpse in blacklist for hostile unit? (and search corpse without check if corpse is in this blacklist). 
It's nice to help, but this type of code can mislead users.

 

 

Code (not tested) with target should look like:

var revive = new Spell("Revive", false);
if (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !ObjectManager.Me.IsCast && revive.KnownSpell && revive.IsSpellUsable)
{
    var corpse = ObjectManager.GetObjectWoWCorpse().Where(c => !wManager.wManagerSetting.IsBlackListed(c.Guid)).FirstOrDefault();
    if (corpse != null && corpse.IsValid)
    {
        Interact.ClearTarget(); // or  Interact.InteractGameObject(corpse.GetBaseAddress);
        revive.Launch();
        Interact.InteractGameObject(corpse.GetBaseAddress);
        wManager.wManagerSetting.AddBlackList(corpse.Guid, 1000 * 60 * 10);
    }
}

with focus should look like:

var revive = new Spell("Revive", false);
if (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !ObjectManager.Me.IsCast && revive.KnownSpell && revive.IsSpellUsable)
{
    var corpse = ObjectManager.GetObjectWoWCorpse().Where(c => !wManager.wManagerSetting.IsBlackListed(c.Guid)).FirstOrDefault();
    if (corpse != null && corpse.IsValid)
    {
        var old = ObjectManager.Me.FocusGuid;
        ObjectManager.Me.FocusGuid = corpse.Guid;
        revive.Launch(true, true, false, "focus");
        ObjectManager.Me.FocusGuid = old;
        wManager.wManagerSetting.AddBlackList(corpse.Guid, 1000 * 60 * 10);
    }
}

 

 

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...