• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Caster deal damage to Caster problem

Status
Not open for further replies.
Level 10
Joined
Mar 17, 2012
Messages
582
Hi guys! Am I crazy? What's wrong with this code? Caster damages target, but doesn't damage himself!

Cast:
  • Death Curse init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Death Curse
    • Actions
      • Set Player_Number_Int = (Player number of (Owner of (Triggering unit)))
      • Set Death_Curse_Caster[Player_Number_Int] = (Triggering unit)
      • Set Death_Curse_Target[Player_Number_Int] = (Target unit of ability being cast)
      • Set Death_Curse_Target_Point[Player_Number_Int] = (Position of Death_Curse_Target[Player_Number_Int])
      • Unit - Create 1 Regular Dummy for (Owner of Death_Curse_Caster[Player_Number_Int]) at Death_Curse_Target_Point[Player_Number_Int] facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Death Curse dummy to (Last created unit)
      • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb Death_Curse_Target[Player_Number_Int]
      • Trigger - Turn on Death Curse loop <gen>
      • Custom script: call RemoveLocation(udg_Death_Curse_Target_Point[udg_Player_Number_Int])
  • Death Curse loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Player_Number_Int) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Death_Curse_Target[Player_Number_Int] has buff Death Curse ) Equal to True
            • Then - Actions
              • Set Death_Curse_Damage_Target[Player_Number_Int] = (((((Real((Level of Death Curse for Death_Curse_Caster[Player_Number_Int]))) x 3.00) + 2.00) + ((Real((Intelligence of Death_Curse_Caster[Player_Number_Int] (Include bonuses)))) x 0.05)) / 5.00)
              • Unit - Cause Death_Curse_Caster[Player_Number_Int] to damage Death_Curse_Target[Player_Number_Int], dealing Death_Curse_Damage_Target[Player_Number_Int] damage of attack type Spells and damage type Fire
              • Set Death_Curse_Damage_Caster[Player_Number_Int] = (((((Real((Level of Death Curse for Death_Curse_Caster[Player_Number_Int]))) x 2.00) + 1.00) + 0.00) / 5.00)
              • Unit - Cause Death_Curse_Caster[Player_Number_Int] to damage Death_Curse_Caster[Player_Number_Int], dealing Death_Curse_Damage_Caster[Player_Number_Int] damage of attack type Spells and damage type Fire
            • Else - Actions
              • Set Death_Curse_Target[Player_Number_Int] = No unit
:ogre_rage:

Okay, now I separated those two actions and placed them into 2 similar triggers and now it works, bit what's the problem?
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
I think this is the problem:

  • Unit - Cause Death_Curse_Caster[Player_Number_Int] to damage Death_Curse_Caster[Player_Number_Int], dealing Death
Plus I think there are problems recognizing [Player_Number_Int] in the loop, I think you'll need to reffer to it in another way. One suggestion is to add the caster to a group then, in the loop you pick the units in the group and set the Player_Number_int to the player number of owner of the picked unit in group.
 
Level 10
Joined
Mar 17, 2012
Messages
582
Huhh the logic looks "okay" to me. Is the caster magic immune?

nope, he's okay )

And check for any null within the loop.

You should be careful with null.

What null are you talking about? I'm sorry, I don't fully understand you :ogre_icwydt:

The problem is you are using Player_Number_Int as indexer and iterative variable.
It's used above and it works. It just doesn't want to run the second damage issue, the first works perfectly. I've put the "damage caster" to another trigger and it now works good. Is it all about using Player_Number_Int variable?
 
Level 7
Joined
Oct 19, 2015
Messages
286
  • Set Death_Curse_Target[Player_Number_Int] = No unit
This should be at the end of "then" actions, not under "else" actions. Think about it, you want to stop tracking the target unit once you deal damage to it, not before.

As for the target being damaged but not the caster, again, my guess is that when you deal damage to the first, it causes a damage event trigger to run which also uses the Player_Number_Int variable. You can easily check if this is the case by using a different variable for this trigger, one which you do not use anywhere else. Doing so should fix your problem if this is indeed the cause.
 
Status
Not open for further replies.
Top