Spell Scripting - adding timer countdown then cast secondary spell.

I am trying to make a spell script, something I have never messed with before. Simply put, a spell is cast upon you when you touch an object. I have that working, since that is a game object script. it also adds a 30 second duration, which also works, but does not show the countdown timer like many other spells. I think this needs to be done in a spell script, instead of newSpell->SetDuration(30000); in gameobject script.

I cannot figure out how to get the timer working, and then get another spell cast upon the player.

I have this set in my spell script, so if the spell is removed by any other means, the script shouldn’t do anything:

            if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL)
                    return;

so to sum up my question:

spell cast upon player. timer counts down 30 seconds, which gives player enough time to remove the spell, then at end of countdown, another spell cast upon player. Can anyone give me some sample code? I tried working with professor putricide spell codes, and the life bloom spell, but its just not triggering. Yes I added an entry in spell_script_names…

Thanks.

Not to bump this, but figured out how to set the timer. Now I need to set it to cast a spell if the timer runs out. During testing, however, the timer counted down to 4 seconds, then the spell vanished…

Adding this to Unit.h/Unit.cpp will do the Job…

void CastWithDelay(uint32 delay, Unit* victim, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);

void Unit::CastWithDelay(uint32 delay, Unit* victim, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
{
class DelayCastEvent : public BasicEvent
{
public:
DelayCastEvent(Unit caster, Unit victim, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster) : BasicEvent(),
_caster(caster),
_victim(victim),
_spellId(spellId),
_triggered(triggered),
_castItem(castItem),
_triggeredByAura(triggeredByAura),
_originalCaster(originalCaster)
{
;
}

    bool Execute(uint64, uint32)
        {
            _caster->CastSpell(_victim, _spellId, _triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, _castItem, _triggeredByAura, _originalCaster);
            return true;
        }

private:
        Unit *_caster;
        Unit *_victim;
        uint32 _spellId;
        bool _triggered;
        Item *_castItem;
        AuraEffect const* _triggeredByAura;
        ObjectGuid _originalCaster;
    };

m_Events.AddEvent(new DelayCastEvent(this, victim, spellId, triggered, castItem, triggeredByAura, originalCaster), m_Events.CalculateTime(delay));
}

Thanks for this information. I will play around with this, and see if my master plan to dominate the world will come to pass…

You could start you world domination by letting us have a copy of your bots patch :wink:

I’d love to see npcbots in TC as a supported. It’s so much fun to play as a metagame with them in your party and in the world.

If only there was a bounty or similar to make this happen.

You can get bots easily. http://git.realmsofwarcraft.com

I know, I charge for access, but it’s a one time fee of $10 because the server it runs on is a dedicated server and it costs me to rent it. But it is lifetime access.

@gerripeach I could not get that code to work. item not declared, auraeffect not declared. Guess not placing it properly, but I fixed my issue with the spell not counting all the way down to 0. Still am unable to get another spell cast when duration ends. Worst part is, this is the easy part. the rest of what I am attempting is going to be much harder…

Is this just access to your own private server or do you gate access to your own fork of TC 3.3.5 with working bots?

this gets you access to over 60 scripts, including npcbots and lordpsyanbots.