• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] Trigger which changes spells

Status
Not open for further replies.
Level 4
Joined
Feb 24, 2018
Messages
71
Hi there ! I've added Death Knight's Presences (v1.1) in my map and I've tried to copy the existing triggers and change all the variables in order to change all the spells for the hero. Basically every time he clicks the Spell he will have one active Presence from a pool of three Presences.( Presence Setup and Presence)
I copied the two triggers and renamed all the variables which were used so I can add another spells besides the active Presence. Now when, let's say he has Frost Presence from the first two triggers , he will have Frost Strike too from the copied triggers. But the problem is the index order is not respected on the copied triggers, meaning that when I have Presence_Buff2[2] = Presence (Frost) for example I won't have Presence_Ability_Aura2[2] = Frost Strike and he will have another spell from the remaining two, which is strange because on the first two triggers which were imported it's working fine and all I did was to copy tie first two triggers and change the variables. I think it has to do with hashtables...Any help please?
  • Presence Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ------------------------------------------- --------
      • -------- Create Hashtable: --------
      • Custom script: set udg_Presence_Hash = InitHashtable()
      • -------- ------------------------------------------- --------
      • -------- When Caster's presence change, the abilities below are the respective available presences: --------
      • Set Presence_Ability_Aura[1] = Presence (Blood)
      • Set Presence_Ability_Aura[2] = Presence (Frost)
      • Set Presence_Ability_Aura[3] = Presence (Unholy)
      • -------- The indexes (of the abilities) above they should be COMPATIBLE with the indexes of Buffs. --------
      • -------- ------------------------------------------- --------
      • -------- Ability that allows to Caster, to change of presence: --------
      • Set Presence_Ability_Change = Presence (Change)
      • -------- ------------------------------------------- --------
      • -------- The buffs below are necessary to change them instantly when Death Knight changes presence. --------
      • Set Presence_Buff[1] = Presence (Blood)
      • Set Presence_Buff[2] = Presence (Frost)
      • Set Presence_Buff[3] = Presence (Unholy)
      • -------- The indexes for buff and the indexes of the abilities (of the presences) they should be compatible, for not happening mistakes. --------
      • -------- ------------------------------------------- --------
      • -------- Destroy this Trigger to improve the performance of the spell: --------
      • Custom script: call DestroyTrigger (GetTriggeringTrigger())
      • -------- ------------------------------------------- --------
  • Presence
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Presence_Ability_Change
    • Actions
      • -------- ------------------------------------------- --------
      • -------- Caster (Unit that cast the spell): --------
      • Set Presence_Caster = (Triggering unit)
      • -------- ------------------------------------------- --------
      • -------- Load Caster's key in a handle: --------
      • Custom script: set udg_Presence_Handle = udg_Presence_Caster
      • -------- ------------------------------------------- --------
      • -------- Ability's level capable to change the presences: --------
      • Set Presence_Level = (Level of Presence_Ability_Change for Presence_Caster)
      • -------- In this version it is not more necessary to verify the level of each presence. --------
      • -------- ------------------------------------------- --------
      • -------- Load the index of the current presence in Caster: --------
      • Set Presence_Index_Add = (Load 1 of (Key Presence_Handle) from Presence_Hash)
      • -------- The index will allow the change of presences. --------
      • -------- ------------------------------------------- --------
      • -------- The variable "Presence_Index_Add" allows to choose the next presence. --------
      • -------- The variable "Presence_Index_Remove" allows to remove the old presence. --------
      • -------- ------------------------------------------- --------
      • -------- In the next steps, it is verified which presence will be removed and which will be added. --------
      • Custom script: if udg_Presence_Index_Add == 0 then
      • -------- --------
      • -------- In case it is the first time that Caster chooses the presence, choose a random presence: --------
      • Custom script: set udg_Presence_Index_Add = GetRandomInt(1, 3)
      • -------- Be free to choose which will be the first presence to be activated. --------
      • -------- --------
      • Custom script: else
      • Custom script: if udg_Presence_Index_Add >= 3 then
      • -------- --------
      • -------- In case the current presence is Unholy, change the presence for Blood: --------
      • Custom script: set udg_Presence_Index_Add = 1
      • Custom script: set udg_Presence_Index_Remove = 3
      • -------- In this section it means that the presence reached a limit. --------
      • -------- --------
      • Custom script: else
      • -------- --------
      • -------- In case the presence didn't reach the limit: --------
      • Custom script: set udg_Presence_Index_Remove = udg_Presence_Index_Add
      • Custom script: set udg_Presence_Index_Add = udg_Presence_Index_Add + 1
      • -------- --------
      • Custom script: endif
      • Custom script: endif
      • -------- ------------------------------------------- --------
      • -------- Save the index of the current presence for Caster: --------
      • Hashtable - Save Presence_Index_Add as 1 of (Key Presence_Handle) in Presence_Hash
      • -------- Doesn't care Caster to die, the index will be the same until that Caster changes of presence. --------
      • -------- ------------------------------------------- --------
      • -------- Remove the buff of the old presence in Caster: --------
      • Unit - Remove Presence_Buff[Presence_Index_Remove] buff from Presence_Caster
      • -------- --------
      • -------- Remove the OLD presence of Caster: --------
      • Unit - Remove Presence_Ability_Aura[Presence_Index_Remove] from Presence_Caster
      • -------- --------
      • -------- Add the NEW presence for Caster: --------
      • Unit - Add Presence_Ability_Aura[Presence_Index_Add] to Presence_Caster
      • -------- --------
      • -------- Update the level of the NEW presence for Caster: --------
      • Unit - Set level of Presence_Ability_Aura[Presence_Index_Add] for Presence_Caster to Presence_Level
      • -------- ------------------------------------------- --------
      • -------- The buff of the old presence is removed instantly. --------
      • -------- But, the new presence takes little time to update. --------
      • -------- ------------------------------------------- --------
      • -------- ------------------------------------------- --------
  • Presence Setup First Spell
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ------------------------------------------- --------
      • -------- Create Hashtable: --------
      • Custom script: set udg_Presence_Hash2 = InitHashtable()
      • -------- ------------------------------------------- --------
      • -------- When Caster's presence change, the abilities below are the respective available presences: --------
      • Set Presence_Ability_Aura2[1] = Death Strike
      • Set Presence_Ability_Aura2[2] = Frost Strike
      • Set Presence_Ability_Aura2[3] = Scourge Strike
      • -------- The indexes (of the abilities) above they should be COMPATIBLE with the indexes of Buffs. --------
      • -------- ------------------------------------------- --------
      • -------- Ability that allows to Caster, to change of presence: --------
      • Set Presence_Ability_Change = Presence (Change)
      • -------- ------------------------------------------- --------
      • -------- The buffs below are necessary to change them instantly when Death Knight changes presence. --------
      • Set Presence_Buff2[1] = Presence (Blood)
      • Set Presence_Buff2[2] = Presence (Frost)
      • Set Presence_Buff2[3] = Presence (Unholy)
      • -------- The indexes for buff and the indexes of the abilities (of the presences) they should be compatible, for not happening mistakes. --------
      • -------- ------------------------------------------- --------
      • -------- Destroy this Trigger to improve the performance of the spell: --------
      • Custom script: call DestroyTrigger (GetTriggeringTrigger())
      • -------- ------------------------------------------- --------
  • Presence First Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Presence_Ability_Change
    • Actions
      • -------- ------------------------------------------- --------
      • -------- Caster (Unit that cast the spell): --------
      • Set Presence_Caster = (Triggering unit)
      • -------- ------------------------------------------- --------
      • -------- Load Caster's key in a handle: --------
      • Custom script: set udg_Presence_Handle2 = udg_Presence_Caster
      • -------- ------------------------------------------- --------
      • -------- Ability's level capable to change the presences: --------
      • Set Presence_Level2 = (Level of Presence_Ability_Change for Presence_Caster)
      • -------- In this version it is not more necessary to verify the level of each presence. --------
      • -------- ------------------------------------------- --------
      • -------- Load the index of the current presence in Caster: --------
      • Set Presence_Index_Add2 = (Load 1 of (Key Presence_Handle2) from Presence_Hash2)
      • -------- The index will allow the change of presences. --------
      • -------- ------------------------------------------- --------
      • -------- The variable "Presence_Index_Add" allows to choose the next presence. --------
      • -------- The variable "Presence_Index_Remove" allows to remove the old presence. --------
      • -------- ------------------------------------------- --------
      • -------- In the next steps, it is verified which presence will be removed and which will be added. --------
      • Custom script: if udg_Presence_Index_Add2 == 0 then
      • -------- --------
      • -------- In case it is the first time that Caster chooses the presence, choose a random presence: --------
      • Custom script: set udg_Presence_Index_Add2 = GetRandomInt(1, 3)
      • -------- Be free to choose which will be the first presence to be activated. --------
      • -------- --------
      • Custom script: else
      • Custom script: if udg_Presence_Index_Add2 >= 3 then
      • -------- --------
      • -------- In case the current presence is Unholy, change the presence for Blood: --------
      • Custom script: set udg_Presence_Index_Add2 = 1
      • Custom script: set udg_Presence_Index_Remove2 = 3
      • -------- In this section it means that the presence reached a limit. --------
      • -------- --------
      • Custom script: else
      • -------- --------
      • -------- In case the presence didn't reach the limit: --------
      • Custom script: set udg_Presence_Index_Remove2 = udg_Presence_Index_Add2
      • Custom script: set udg_Presence_Index_Add2 = udg_Presence_Index_Add2 + 1
      • -------- --------
      • Custom script: endif
      • Custom script: endif
      • -------- ------------------------------------------- --------
      • -------- Save the index of the current presence for Caster: --------
      • Hashtable - Save Presence_Index_Add2 as 1 of (Key Presence_Handle2) in Presence_Hash2
      • -------- Doesn't care Caster to die, the index will be the same until that Caster changes of presence. --------
      • -------- ------------------------------------------- --------
      • -------- Remove the buff of the old presence in Caster: --------
      • Unit - Remove Presence_Buff2[Presence_Index_Remove2] buff from Presence_Caster
      • -------- --------
      • -------- Remove the OLD presence of Caster: --------
      • Unit - Remove Presence_Ability_Aura2[Presence_Index_Remove2] from Presence_Caster
      • -------- --------
      • -------- Add the NEW presence for Caster: --------
      • Unit - Add Presence_Ability_Aura2[Presence_Index_Add2] to Presence_Caster
      • -------- --------
      • -------- Update the level of the NEW presence for Caster: --------
      • Unit - Set level of Presence_Ability_Aura2[Presence_Index_Add2] for Presence_Caster to Presence_Level2
      • -------- ------------------------------------------- --------
      • -------- The buff of the old presence is removed instantly. --------
      • -------- But, the new presence takes little time to update. --------
      • -------- ------------------------------------------- --------
 
  • - In case it is the first time that Caster chooses the presence, choose a random presence: --------
  • empty.gif
    join.gif
    page.gif
    Custom script: set udg_Presence_Index_Add2 = GetRandomInt(1, 3)
  • empty.gif
    join.gif
    comment.gif
    -------- Be free to choose which will be the first presence to be activated. --------
-> Starts with 1, 2 or 3.
it would be better to start with a specific one so it does allways match.
It is unlikely that 2 independent random numbers have the same value.

page.gif
Custom script: set udg_Presence_Index_Add2 = GetRandomInt(1, 3)
->
  • Set Presence_Index_Add2 = 1
Edit:
Better would be to change this presence to add multiple abilities at once.
Define a new ability Array variable and add some lines to the presence triggers.
add to "Presence Setup"
  • Set Presence_Ability_SkillAdded[1] = Blood-Strike
  • Set Presence_Ability_SkillAdded[2] = Frost-Strike
  • Set Presence_Ability_SkillAdded[3] = Unholy-Strike
Add to "Presence"
Should be somewhere the other add ability stuff is done.
  • Unit - Remove Presence_Ability_SkillAdded[Presence_Index_Remove] from Presence_Caster
  • Unit - Add Presence_Ability_SkillAdded[Presence_Index_Add] to Presence_Caster
 
Last edited:
Level 4
Joined
Feb 24, 2018
Messages
71
Thank you ! One more thing : the Presence Change spell is based on the troll's headhunter ability berserk and from what I've seen the first 4 levels of the spell don't show the berserk buff at the status of the hero but at level 5 of the spell and after that the buff appears. Do you know why ?
 
Status
Not open for further replies.
Top