• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Problem with trigger not properly identifying level of ability

Status
Not open for further replies.
Level 4
Joined
Nov 6, 2011
Messages
44
I have an ability which is supposed to create a portal at a targeted area, which then spawns Fel Beasts on Level 1, Fel Stalkers on Level 2 and Fel Ravagers on Level 3(The portal is just for decoration actually). The problem is.. the spell just make Fel beasts(level 1). I've checked much of the trigger.. but can't find the problem. Help would be appreciated :)

DarkPortalPos = Point where the ability is cast
DarkPortalCaster = Caster of the ability
DarkPortalLevel = Level of the ability


  • Dark Portal
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Nether Portal (Archimonde)
    • Actions
      • Set DarkPortalCaster = (Casting unit)
      • Set DarkPortalLevel = (Level of Nether Portal (Archimonde) for (Casting unit))
      • Set DarkPortalPos = (Target point of ability being cast)
      • Wait 0.50 seconds
      • Unit - Create 1 Nether Portal (Level 1) for (Owner of (Casting unit)) at DarkPortalPos facing Default building facing degrees
      • Unit - Add a 11.00 second Generic expiration timer to (Last created unit)
      • Trigger - Turn on Dark Portal Spawn <gen>
      • Wait 11.00 seconds
      • Trigger - Turn off Dark Portal Spawn <gen>
The turned-on trigger :

  • Dark Portal Spawn
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • If (DarkPortalLevel Equal to 1) then do (Unit - Create 1 Fel Beast for (Owner of DarkPortalCaster) at DarkPortalPos facing Default building facing degrees) else do (Do nothing)
      • If (DarkPortalLevel Equal to 2) then do (Unit - Create 1 Fel Stalker for (Owner of DarkPortalCaster) at DarkPortalPos facing Default building facing degrees) else do (Do nothing)
      • If (DarkPortalLevel Equal to 3) then do (Unit - Create 1 Fel Ravager for (Owner of DarkPortalCaster) at DarkPortalPos facing Default building facing degrees) else do (Do nothing)
      • Unit - Add a 20.00 second Generic expiration timer to (Last created unit)
      • Special Effect - Create a special effect at DarkPortalPos using Abilities\Spells\Undead\Darksummoning\DarkSummonTarget.mdl
      • Wait 1.00 seconds
      • Special Effect - Destroy (Last created special effect)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Your trigger is not MUI (Multi-Instance Able). It will bug if more than 1 cast it on the same time. It has leaks and is not very efficient. When you create an ability you try to reduce the parentheses as much as possible setting repetitive things into variable. As example, if you are going to use (Picked Player) several times, you declare (Picked Player) into a Player variable, and use that variable insted. It's easier for you and faster for the system. There are several points of improvement.

· Use Channel as a Base Ability, make it channeling and make it last for 0.50 seconds.

Here's a much better MUI Solution to your problem. Seems a lot longer and harder, but it's really easy. It could be improved with locals and some JASS, but that's not my playground. You can have 12 players casting this ability every 1 second and have hunders of portals at the same time; all of them wil work as supossed without bugging.

In this trigger we use Unit Type variable array "Summons" and we set the index of the variable in the same order the ability will create the summons on each level. Ability Level 2 will create Summon[2]. We also create a Hashtable. You just need one for infinite amount of abilities, since it holds infinite values, you just need to make a good use of it.
  • Dark Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
      • Set Summons[1] = Peasant
      • Set Summons[2] = Footman
      • Set Summons[3] = Knight
· You have to customize your custom channel ability to make it last 0.50 seconds. It will run this trigger.
· We use IntegerVar2 as the Portal ID. Each unit, destructible, item, special effect, Region, etc. has an specific and unique code. It's like market products. What we do is take the PortalID with the "GetHandleId()" custom script.
· We save 6 (total amount of summons) in slot #0 of PortalID in Hash
· We save the ability level in slot #1 of PortalID in Hash
· We remove the point leak.

  • DarkPortal Set
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set PlayerVar = (Triggering player)
      • Set IntegerVar = (Player number of PlayerVar)
      • Set PointVar = (Target point of ability being cast)
      • Unit - Create 1 Footman for PlayerVar at PointVar facing Default building facing degrees
      • Set UnitVar = (Last created unit)
      • Unit Group - Add UnitVar to PortalGroup
      • Custom script: set udg_IntegerVar2 = GetHandleId(udg_UnitVar)
      • Hashtable - Save 6 as 0 of IntegerVar2 in Hash
      • Hashtable - Save (Level of (Ability being cast) for (Triggering unit)) as 1 of IntegerVar2 in Hash
      • Trigger - Turn on Dark Portal On <gen>
      • Custom script: call RemoveLocation(udg_PointVar)
· We use IntegerVar as PortalID
· We use IntegerVar2 as summon count.
· Remember that Summon Count is in slot #0 of PortalID. Every summon will reduce the total by 1, and the portal will be destroyer and removed from the group when ti reaches 0. The Trigger will turn of when there are no portals in the group.
· Remember that Ability Level is in slot #1 of PortalID

  • Dark Portal On
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PortalGroup and do (Actions)
        • Loop - Actions
          • Set UnitVar = (Picked unit)
          • Set PlayerVar = (Owner of UnitVar)
          • Custom script: set udg_IntegerVar = GetHandleId(udg_UnitVar)
          • Set PointVar = (Position of UnitVar)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 0 of IntegerVar from Hash) Greater than 0
            • Then - Actions
              • Unit - Create 1 Summons[(Load 1 of IntegerVar from Hash)] for PlayerVar at PointVar facing Default building facing degrees
              • Unit - Add a 20.00 second Generic expiration timer to (Last created unit)
              • Special Effect - Create a special effect at PointVar using Abilities\Spells\Undead\Darksummoning\DarkSummonTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set IntegerVar2 = ((Load 0 of IntegerVar from Hash) - 1)
              • Hashtable - Save IntegerVar2 as 0 of IntegerVar in Hash
            • Else - Actions
              • Unit Group - Remove UnitVar from PortalGroup
              • Unit - Kill UnitVar
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in PortalGroup) Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_PointVar)
I won't upload a test map because you will learn to create efficient trigger by MAKING them. So, follow the example, understand how it works, and, if we're all lucky, you'll never need help with an ability of this kind. In fact, you may help other.
 
Last edited:
Status
Not open for further replies.
Top