• 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] Effect of the spell not shown when casting it while playing as a specific player

Status
Not open for further replies.
Level 3
Joined
Sep 20, 2013
Messages
29
Hi, it's me once again, but this time unfortunately with more complicated problem.
Namely, just like it is written in topic of this thread, one ability - LIFE DRAIN, which execution i've recently coded in gui, including some custom script triggers as i had to use them anyway to set few variables into values that can't be specified without using non gui script, as a part of creating my map that I'm currently developing, doesn't really work properly when it's used by hero controlled by sentinel players on my map (concretely players with numbers from 1 to 6) by not showing the lightning effect of drain of life between caster and target even though it's coded fully correctly, considering that it surprisingly works completely, including showing appropriately the lightning effect, for sccourge players (number:7 to 12). I've no idea why it's happening due to the fact that the trigger sequence that is responsible for execution of this ability, as well as any other contained in my map, doesn't include at all any function related to making this ability less functionable for specified players ;O. Please answer this post quickly as I require help with solving it really badly, because I just can't do it alone, due to the fact that I can't even see the reason of this problem despite the fact that I'm expereincing it from yesterday so far ...
 
Level 3
Joined
Sep 20, 2013
Messages
29
Actually in the case of this post these 3 things are related to each other, because I've created this thread by using just my phone, what i'm also still doing now, due to what I can't upload images showing my triggers and therefore I've described my problem so unnaturally precisely to make it all clear without triggers at least for now. I'll try to post them as soon as I'lll get access to my cmoputer back, what I can't do now, because it's used by my brother.
EDIT:
Deleted outdated images of triggers compared to the ones I posted below ...
 
Last edited:
Level 3
Joined
Sep 20, 2013
Messages
29
Bump, just for adding another post here, as I've added trigger screens to the message that i've created before doing it instead of containing them in a new post like this one.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
Ow, seems like I am a little late here.

Oh well. In order to post the triggers easier follow this tutorial. It makes the triggers easier to read for us who wants to help as well since you split the code into 2 images :)
http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

ok now for some advice.

The trigger that sets the drain value upon level up is not needed. Instead you set a array variable at init. It should look something like.

set Drain_Value[1] = 50
set Drain_Value[2] = 100
set Drain_Value[3] = 150
set Drain_Value[4] = 200

the number inside the "[]" symbolize the level of the ability. So when draining the health you use:

set unit hp to current hp of unit + Drain_Value[level of your ability]

also you should never use the "do nothing" action, just leave it blanc.

Do that and I will take another look at your code ;)

Cheers!

edit: here is an example from a spell of mine. Ignore the parts that you likely wont understand. Just focus on the arrays.
  • HS init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HS_hash = (Last created hashtable)
      • Set HS_damage[1] = 20.00
      • Set HS_damage[2] = 40.00
      • Set HS_damage[3] = 60.00
      • Set HS_speed[1] = 50.00
      • Set HS_speed[2] = 60.00
      • Set HS_speed[3] = 70.00
      • Set HS_charges[1] = 8
      • Set HS_charges[2] = 10
      • Set HS_charges[3] = 12
      • Set HS_destroy_dest = True
      • Set HS_detect_area = 150.00
      • Set HS_cone = 70.00
      • Set HS_effect = Abilities\Spells\Other\HealingSpray\HealBottleMissile.mdl
      • Set HS_effect2 = Abilities\Spells\Items\PotionOfOmniscience\CrystalBallCaster.mdl
      • Set HS_time = 0.50
      • Set HS_ability = Holy Shockwave
      • Set HS_knockup = True
      • Set HS_animation = stand channel
      • Set HS_trigger = HS loop <gen>
      • Custom script: set udg_HS_loop_speed = 0.03125
      • Trigger - Add to HS_trigger the event (Time - Every HS_loop_speed seconds of game time)
 
Level 3
Joined
Sep 20, 2013
Messages
29
Triggers Images

Below are the aforementioned triggers, which images have been optimized better according to last Chaosy's post.

  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set LifeDrainAmmount1[1] = 35.00
      • Set LifeDrainAmmount1[2] = 60.00
      • Set LifeDrainAmmount1[3] = 85.00
      • Set LifeDrainAmmount1[4] = 125.00
  • Life Drain Cast Sylvanas
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cffffcc00(E)|rLife Drain (triggered for Sylvanas)
    • Actions
      • Set LifeDrainLightningNumber1 = 0
      • Set LifeDrainDMGInterval1 = 0.00
      • Set LifeDrainEXInterval1 = 0.00
      • Set loc1 = (Target point of ability being cast)
      • Set LifeDrainRange = (900.00 x 900.00)
      • Set LifeDrainTarget1 = (Target unit of ability being cast)
      • Set LifeDrainCaster1 = (Triggering unit)
      • Trigger - Turn on Life Drain Loop Sylvanas <gen>
  • Life Drain Loop Sylvanas
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Custom script: if udg_zLoc1 == null then
      • Set zLoc1 = (Point(0.00, 0.00))
      • Custom script: endif
      • Set LifeDrainDMGInterval1 = (LifeDrainDMGInterval1 + 0.05)
      • Set LifeDrainEXInterval1 = (LifeDrainEXInterval1 + 0.25)
      • Set x1_1 = (X of (Position of LifeDrainCaster1))
      • Set y1_1 = (Y of (Position of LifeDrainCaster1))
      • Set x2_1 = (X of (Position of LifeDrainTarget1))
      • Set y2_1 = (Y of (Position of LifeDrainTarget1))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LifeDrainCaster1 Not equal to No unit
          • LifeDrainTarget1 Not equal to No unit
          • (LifeDrainTarget1 is alive) Equal to True
          • (LifeDrainCaster1 is alive) Equal to True
          • (LifeDrainTarget1 is Magic Immune) Equal to False
          • (Current order of LifeDrainCaster1) Equal to (Order(channel))
          • (LifeDrainTarget1 is visible to (Owner of LifeDrainCaster1)) Equal to True
          • LifeDrainRange Greater than or equal to (((x1_1 - x2_1) x (x1_1 - x2_1)) + ((y1_1 - y2_1) x (y1_1 - y2_1)))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LifeDrainDMGInterval1 Equal to 1.00
            • Then - Actions
              • Set LifeDrainDMGInterval1 = 0.00
              • Unit - Cause LifeDrainCaster1 to damage LifeDrainTarget1, dealing LifeDrainAmmount1[(Level of |cffffcc00(E)|rLife Drain (triggered for Sylvanas) for LifeDrainCaster1)] damage of attack type Spells and damage type Normal
              • Unit - Set life of LifeDrainCaster1 to ((Life of LifeDrainCaster1) + LifeDrainAmmount1[(Level of |cffffcc00(E)|rLife Drain (triggered for Sylvanas) for LifeDrainCaster1)])
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LifeDrainEXInterval1 Equal to 1.00
            • Then - Actions
              • Set LifeDrainLightningNumber1 = (LifeDrainLightningNumber1 + 1)
              • Set loc1 = (Point(0.00, 0.00))
              • Lightning - Create a Drain Life lightning effect from source loc1 to target loc1
              • Set LifeDrainLightning1[LifeDrainLightningNumber1] = (Last created lightning effect)
              • Custom script: call RemoveLocation( udg_loc1 )
              • Set zLoc1 = (Point(x1_1, y1_1))
              • Custom script: set udg_LocZ1 = GetLocationZ( udg_zLoc1 )
              • Set z1_1 = ((Current flying height of LifeDrainCaster1) + (LocZ1 + 50.00))
              • Set zLoc1 = (Point(x2_1, y2_1))
              • Custom script: set udg_LocZ1 = GetLocationZ( udg_zLoc1 )
              • Set z2_1 = ((Current flying height of LifeDrainTarget1) + (LocZ1 + 35.00))
              • Custom script: call MoveLightningEx( udg_LifeDrainLightning1[udg_LifeDrainLightningNumber1], true, udg_x1_1, udg_y1_1, udg_z1_1, udg_x2_1, udg_y2_1, udg_z2_1 )
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LifeDrainEXInterval1 Equal to 1.00
        • Then - Actions
          • Set LifeDrainEXInterval1 = 0.00
          • Lightning - Destroy LifeDrainLightning1[(LifeDrainLightningNumber1 - 1)]
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Current order of LifeDrainCaster1) Not equal to (Order(channel))
              • (LifeDrainCaster1 is dead) Equal to True
              • (LifeDrainTarget1 is dead) Equal to True
              • LifeDrainCaster1 Equal to No unit
              • LifeDrainTarget1 Equal to No unit
              • (LifeDrainTarget1 is Magic Immune) Equal to True
              • (LifeDrainTarget1 is visible to (Owner of LifeDrainCaster1)) Equal to False
              • LifeDrainRange Less than (((x1_1 - x2_1) x (x1_1 - x2_1)) + ((y1_1 - y2_1) x (y1_1 - y2_1)))
        • Then - Actions
          • Lightning - Destroy LifeDrainLightning1[LifeDrainLightningNumber1]
          • Unit - Order LifeDrainCaster1 to Stop
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (LifeDrainTarget1 is dead) Equal to True
              • (LifeDrainCaster1 is dead) Equal to True
        • Then - Actions
          • Set LifeDrainCaster1 = No unit
          • Set LifeDrainTarget1 = No unit
        • Else - Actions
          • Do nothing
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
Righty, righty. Let's see if we can shorten down the code, and in the process we'll hopefully prevent issues in the progress.

1. remove every single
  • Do nothing
2. In GUI we prefer to use positions instead of raw x/y values (in almost every case). If you do that we can cut of more than a few bits of your code. For example you can replace this part of your code:
  • LifeDrainRange Greater than or equal to (((x1_1 - x2_1) x (x1_1 - x2_1)) + ((y1_1 - y2_1) x (y1_1 - y2_1)))
>
  • (Distance between loc1 and loc2 Greater than or equal to LifeDrainRange
3. instead of turning using one unit variable and constantly basing the spell around it, you should use a unit group that contains the unit(s) that cast the spell. So instead of turning the trigger on when the ability is cast you add the caster to the unit group.

  • some loop trigger
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in my_group and do (Actions)
        • Loop - Actions
          • -------- the rest of the code here --------
Once you have done that, we can remove even more parts of your code.
  • Set LifeDrainCaster1 = No unit
    • Set LifeDrainTarget1 = No unit
>
  • Unit Group - Remove (Picked unit) from my_group
  • LifeDrainCaster1 Equal to No unit
  • LifeDrainTarget1 Equal to No unit
remove all conditions that checks if unit is equal to no unit

I can come with more optimizations as we go, I just want fix the major flaws before getting to details.
 
Level 3
Joined
Sep 20, 2013
Messages
29
But, referring to the 3rd point of your last post, wouldn't it be better to just turn on the loop, that is run every 0.05 seconds of the game, only for the duration of this spell to improve performance of the game, considering that if it will be turn on all the time, then this trigger will be almost always (0.05 second is almost nothing in terms of real time) running and so it will just cause the map to be less smooth? I'm just theorycrafting, as I'm not fully sure if I'm right.

EDIT: To add more, I'm not sure if you have fully understood why is the loop trigger initially turn off ...
Well, in case you haven't fully realized it yet, it must be turned off like that and become turned on when a specified ability is cast in order to make the loop happen only while it is casted, so that it is triggered only when a player uses it and ipso facto it isn't running every 0.05 seconds of the game, what would be just retarded if you know what i mean.
If you still don't know what I mean, then, please, check carefully the connection between the trigger with event "unit starts the effect of an ability" and the loop trigger

BTW I've changed all other actions that you've posted about above
 
Level 3
Joined
Sep 20, 2013
Messages
29
So in this case I should actually delete the trigger that turns on the loop and initally turn on the trigger no matter of the words I've written above, right?
Well, if yes, then I'll do it despite the fact that IMO it's really needed.
I'll just do the backup of the map just in case :)
Also thanks for all your help you've provided to me so far, which effects are shown in this thread
 
Status
Not open for further replies.
Top