Jump to content
TrinityCore
Sign in to follow this  
LordPsyan

Spell Scripting - adding timer countdown then cast secondary spell.

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

  • Upvote 1

Share this post


Link to post
Share on other sites

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));
}

  • Upvote 1

Share this post


Link to post
Share on other sites
16 hours ago, skipperheartbeat said:

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

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MandyDark2
      I'm fixing some core spells and I'm really good at it.

      It turns out that the spell 196608 Eye of the Tiger, of the monk class, must cause damage and at the same time healing in the monk.

      What the spell has two effects that deal with this:

      Effect 0: Id 6 (SPELL_EFFECT_APPLY_AURA)
      Difficulty: Id 0 (DIFFICULTY_NONE)
      BasePoints = 0 + AP * 0.43
      Targets (1, 0) (TARGET_UNIT_CASTER, NO_TARGET)
      Aura Id 8 (SPELL_AURA_PERIODIC_HEAL), value = 0, misc = 0 (0), miscB = 0, amplitude = 0, periodic = 2000

      Effect 1: Id 6 (SPELL_EFFECT_APPLY_AURA)
      Difficulty: Id 0 (DIFFICULTY_NONE)
      BasePoints = 0 + AP * 0.43
      Targets (6, 0) (TARGET_UNIT_TARGET_ENEMY, NO_TARGET)
      Aura Id 3 (SPELL_AURA_PERIODIC_DAMAGE), value = 0, misc = 0 (0), miscB = 0, amplitude = 0, periodic = 2000

      I had never encountered a spell in this way and what happens is that you can only cast the spell on an enemy and never apply the healing effect on the owner. If the aura is applied directly to the caster, apply the damage aura of Effect 1 not the heal of Effect 0.

      Does the core support launching specifically the effect of a spell on a creature? There's another way to solve this?
    • By frostys11
      Hey again,  I'm implementing the script for the Aman'thuls Vision trinket and the procs are working correct although it procs from pretty much anything like mounting etc. Is there anyway I can change that? I know this might have to do with the spellfamily masks in the spellclassoptions.db2 file. However, how does bit mask matching actually work? I tried to add a new bit mask in the spell_proc table in trinitycore but was unable to get it to work correctly. I could hardcode it in the script files to trigger from the spells I want but that would be an ugly solution in my opinion.
      The second question is that I get the wrong stat from Aman'Thul's Grandeur buff (http://www.wowhead.com/spell=256832/amanthuls-grandeur). I noticed it has four different auraeffects. How can i cast a spell in trintycore with a specific aura effect to get the right stat?
      The third question is that I have implemented the Acrid Catalyst trinket proc and the logic works correctly but I'm getting 0 stat for the buffs and the proc chance seems to be slightly off. How could I fix these two things? I guess its a db thing since the stat needs to scale accroding to the ilvl version of the trinket? I tried to look a trinitycore documentation regarding this and I cant seem to find nor can I find it in the mangos documentation
      This is the code for the two trinket implementations:
      enum AcridCatalystInjector
      {
          SPELL_FERVOR_OF_THE_LEGION = 253261, // Haste
          SPELL_BURTALITY_OF_THE_LEGION = 255742, // Critical
          SPELL_MALICE_OF_THE_LEGION = 255744, // Mastery
          SPELL_CYCLE_OF_THE_LEGION = 253260 // Haste, Mastery, and Critical
      };
      // Item - 151955: Acrid Catalyst Injector
      // 253259 - Item - Antorus, the Burning Throne (End raid of legion expansion)
      template <uint32 CriticalSpellId, uint32 HasteSpellId, uint32 MasterySpellId>
      class SpellItemAcridCatalystInjector : public SpellScriptLoader
      {
      public:
          SpellItemAcridCatalystInjector(char const* ScriptName) : SpellScriptLoader(ScriptName) { }
          template <uint32 Critical, uint32 Haste, uint32 Mastery>
          class SpellItemAcridCatalystInjectorAuraScript : public AuraScript
          {
              PrepareAuraScript(SpellItemAcridCatalystInjectorAuraScript);
              bool Validate(SpellInfo const* /*spellInfo*/) override
              {
                  return ValidateSpellInfo(
                      {
                          Critical,
                          Haste,
                          Mastery
                      });
              }
              void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
              {
                  /*if (eventInfo.GetHitMask() & PROC_HIT_CRITICAL)
                  {*/
                      static std::vector<uint32> const triggeredSpells[1] =
                      {
                          { Critical, Haste, Mastery }
                      };
                      PreventDefaultAction();
                      Unit* caster = eventInfo.GetActor();
                      std::vector<uint32> const& randomSpells = triggeredSpells[0];
                      if (randomSpells.empty())
                          return;
                      uint32 spellId = Trinity::Containers::SelectRandomContainerElement(randomSpells);
                      caster->CastSpell(caster, spellId, true, nullptr, aurEff);
                      for (std::vector<uint32>::const_iterator it = randomSpells.begin(); it != randomSpells.end(); ++it)
                      {
                          if (caster->HasAura((*it)))
                          {
                              auto trinketAura = caster->GetAura((*it));
                              if (trinketAura->GetStackAmount() >= 5)
                              {
                                  caster->CastSpell(caster, SPELL_CYCLE_OF_THE_LEGION, true, nullptr, aurEff);
                                  caster->RemoveAura(Critical);
                                  caster->RemoveAura(Haste);
                                  caster->RemoveAura(Mastery);
                                  break;
                              }
                          }
                      }
                  //}
              }
              void Register() override
              {
                  OnEffectProc += AuraEffectProcFn(SpellItemAcridCatalystInjectorAuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
              }
          };
          AuraScript* GetAuraScript() const override
          {
              return new SpellItemAcridCatalystInjectorAuraScript<CriticalSpellId, HasteSpellId, MasterySpellId>();
          }
      };
      enum AmanThulsVision
      {
          SPELL_GLIMPSE_OF_ENLIGHTENMENT = 256818,
          SPELL_AMANTHULS_GRANDEUR = 256832
      };
      // Item - 154172: Aman'Thul's Vision
      // 256817 - Item - Antorus, the Burning Throne (End raid of legion expansion)
      template <uint32 GlimpseOfEnlightenmentSpellId, uint32 AmanthulsGrandeurSpellId>
      class SpellItemAmanThulsVision : public SpellScriptLoader
      {
      public:
          SpellItemAmanThulsVision(char const* ScriptName) : SpellScriptLoader(ScriptName) { }
          template <uint32 GlimpseOfEnlightenment, uint32 AmanthulsGrandeur>
          class SpellItemAmanThulsVisionAuraScript : public AuraScript
          {
              PrepareAuraScript(SpellItemAmanThulsVisionAuraScript);
              bool Validate(SpellInfo const* /*spellInfo*/) override
              {
                  return ValidateSpellInfo(
                      {
                          GlimpseOfEnlightenment,
                          AmanthulsGrandeur
                      });
              }
              void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
              {
                  static std::vector<uint32> const triggeredSpells[1] =
                  {
                      { GlimpseOfEnlightenment, AmanthulsGrandeur }
                  };
                  PreventDefaultAction();
                  Unit* caster = eventInfo.GetActor();
                  caster->CastSpell(caster, GlimpseOfEnlightenment, true, nullptr, aurEff);
                  //AuraEffect* test = caster->GetAuraEffect(256817, EFFECT_2, GetCasterGUID());
            
                  caster->CastSpell(caster, AmanthulsGrandeur, true, nullptr, aurEff); //<--- How do I get the specific aureffect from SPELL_AMANTHULS_GRANDEUR?
                  //AuraEffect* test2 = caster->GetAuraEffect(SPELL_AMANTHULS_GRANDEUR, EFFECT_2, GetCasterGUID());
                  //caster->CastSpell(caster, AmanthulsGrandeur, true, nullptr, aurEff);
              }
              void Register() override
              {
                  OnEffectProc += AuraEffectProcFn(SpellItemAmanThulsVisionAuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
              }
          };
          AuraScript* GetAuraScript() const override
          {
              return new SpellItemAmanThulsVisionAuraScript<GlimpseOfEnlightenmentSpellId, AmanthulsGrandeurSpellId>();
          }
      };
    • By DagothHertil
      Hello everyone. I have a small question about how can I access the spell ID`s used by creatures? In world database in creature_template table there is spell1, spell2, ... spell8 values wich correspond to spells wich I will be able to use when this creature is under Mind Control (as stated in wiki), but these values are set for creatuers up to level ~60 and for creatures from 70-80 none creatures have their spell1 .. spell8 set to any value. So my question is essentialy is where can I obtain the spell ID`s used by cretures? Obviously the creatures in 70-80 range have spell and they use them, but I dont see any values in world database and may be these spell lists come from dbc or something? I would realy appreciate any help 
    • By Chrisseria2520
      Hello once again community! Thanks for all ur help so far, it's really appreciated..  I'll pull out another hand to get caught! ... 

      So my problem is that I can easy buff / nerf a creature npc through World.conf and edit the rates on HP, AP damage, melee damage and so on... Look at: Uploaded Images to see an example!

      So my question is am I able to burf nerf specific creature spell to do less / more dmg and how so? 
      An example could be Razorscale's Devouring Flame!
      Thanks guys
       

×
×
  • Create New...