• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Damage transfer, item cost calculation, etc.

Status
Not open for further replies.
Level 2
Joined
Mar 14, 2008
Messages
5
There are some questions I haven't been able to solve on my own, so I'd like to ask for some assistance with them.

1. I'm making a bodyguard/enforcer sort of summon unit and want to give it an ability where the "master" Hero is damaged and it "takes the bullet", so to speak. Meaning that damage is "deducted" from the "master" and put on the summon. Is there any way to detect damage value dealt without creating a variable for every single enemy Unit Type?

2. With regards to the bodyguard/enforcer summon just mentioned, I want to add a "racket" passive ability where gold is instantly returned to the controlling player upon buying an item. This would, in theory, simulate a discount. I can't find an Integer comparison condition for cost of item, though. What can I do about this that doesn't involve using variables to track costs inefficiently?

3. I'm trying to make an "Omnislash" based off Tinki3's version, but it's bugging out. The Hero attacks only twice before he stops, even when there's clearly more than enough targets to hit. Below is my code; I use array variables with "player number of owner of triggering unit" to simulate MUI, but I don't know if that's causing the problem. Advice would be appreciated.

  • OmniThing
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Anbarum Ex Deus
    • Actions
      • Set ADE_User[(Player number of (Owner of (Triggering unit)))] = (Casting unit)
      • Set ADE_target[(Player number of (Owner of (Triggering unit)))] = (Target unit of ability being cast)
      • Set ADE_targetloc[(Player number of (Owner of (Triggering unit)))] = (Position of ADE_target[(Player number of (Owner of (Triggering unit)))])
      • Set ADE_loops[(Player number of (Owner of (Triggering unit)))] = (1 + ((Level of Anbarum Ex Deus for ADE_User[(Player number of (Owner of (Triggering unit)))]) x 7))
      • Unit - Make ADE_User[(Player number of (Owner of (Triggering unit)))] Invulnerable
      • Animation - Change ADE_User[(Player number of (Owner of (Triggering unit)))]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
      • Selection - Remove ADE_User[(Player number of (Owner of (Triggering unit)))] from selection
      • Unit - Move ADE_User[(Player number of (Owner of (Triggering unit)))] instantly to ADE_targetloc[(Player number of (Owner of (Triggering unit)))]
      • Custom script: call RemoveLocation(udg_ADE_targetloc[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
      • Animation - Play ADE_User[(Player number of (Owner of (Triggering unit)))]'s attack animation
      • Unit - Cause ADE_User[(Player number of (Owner of (Triggering unit)))] to damage ADE_target[(Player number of (Owner of (Triggering unit)))], dealing (Real((Random integer number between ((Agility of ADE_User[(Player number of (Owner of (Triggering unit)))] (Include bonuses)) + 2) and ((Agility of ADE_User[(Player number of (Owner of (Triggering unit)))] (Include bonuses)) + 16)))) damage of attack type Chaos and damage type Divine
      • Special Effect - Create a special effect attached to the chest of ADE_User[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • For each (Integer A) from 1 to ADE_loops[(Player number of (Owner of (Triggering unit)))], do (Actions)
        • Loop - Actions
          • Wait 0.30 game-time seconds
          • Set ADE_User_CurrentLoc[(Player number of (Owner of (Triggering unit)))] = (Position of ADE_User[(Player number of (Owner of (Triggering unit)))])
          • Set ADE_newgrp[(Player number of (Owner of (Triggering unit)))] = (Units within 1024.00 of ADE_User_CurrentLoc[(Player number of (Owner of (Triggering unit)))] matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Player((Player number of (Owner of (Triggering unit)))))) Equal t
          • Set ADE_newgrp_rand[(Player number of (Owner of (Triggering unit)))] = (Random 1 units from ADE_newgrp[(Player number of (Owner of (Triggering unit)))])
          • Custom script: call RemoveLocation(udg_ADE_User_CurrentLoc[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in ADE_newgrp[(Player number of (Owner of (Triggering unit)))]) Greater than 0
            • Then - Actions
              • Unit Group - Pick every unit in ADE_newgrp_rand[(Player number of (Owner of (Triggering unit)))] and do (Actions)
                • Loop - Actions
                  • Set ADE_Picked[(Player number of (Owner of (Triggering unit)))] = (Picked unit)
                  • Set ADE_PickedLoc[(Player number of (Owner of (Triggering unit)))] = (Position of ADE_Picked[(Player number of (Owner of (Triggering unit)))])
                  • Selection - Remove ADE_User[(Player number of (Owner of (Triggering unit)))] from selection
                  • Unit - Move ADE_User[(Player number of (Owner of (Triggering unit)))] instantly to ADE_PickedLoc[(Player number of (Owner of (Triggering unit)))]
                  • Custom script: call RemoveLocation(udg_ADE_PickedLoc[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
                  • Animation - Play ADE_User[(Player number of (Owner of (Triggering unit)))]'s attack animation
                  • Unit - Cause ADE_User[(Player number of (Owner of (Triggering unit)))] to damage ADE_Picked[(Player number of (Owner of (Triggering unit)))], dealing (Real((Random integer number between ((Agility of ADE_User[(Player number of (Owner of (Triggering unit)))] (Include bonuses)) + 2) and ((Agility of ADE_User[(Player number of (Owner of (Triggering unit)))] (Include bonuses)) + 24)))) damage of attack type Chaos and damage type Divine
                  • Special Effect - Create a special effect attached to the chest of ADE_User[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Custom script: call DestroyGroup(udg_ADE_newgrp[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
              • Custom script: call DestroyGroup(udg_ADE_newgrp_rand[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
            • Else - Actions
              • Custom script: call DestroyGroup(udg_ADE_newgrp[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
              • Custom script: call DestroyGroup(udg_ADE_newgrp_rand[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
              • Selection - Add ADE_User[(Player number of (Owner of (Triggering unit)))] to selection for (Owner of (Triggering unit))
              • Animation - Change ADE_User[(Player number of (Owner of (Triggering unit)))]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Unit - Make ADE_User[(Player number of (Owner of (Triggering unit)))] Vulnerable
      • Selection - Add ADE_User[(Player number of (Owner of (Triggering unit)))] to selection for (Owner of (Triggering unit))
      • Animation - Change ADE_User[(Player number of (Owner of (Triggering unit)))]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
      • Unit - Make ADE_User[(Player number of (Owner of (Triggering unit)))] Vulnerable
4. I'm trying to create this ability for a ranged unit where, if an enemy approaches within a certain distance for close combat, there is a chance that a flamethrower will fire, dealing damage and making the enemy retreat. I know how to use the Special Effect and "order unit to damage unit", but I can't figure out how to make the enemy retreat. What do I need to do?

5. Is there any way to detect when a unit is not moving? I would like to work that into an ability, but I'm not sure what I need to enable this.

All preferably in GUI if possible please.

Thanks in advance.
 
Last edited:
Level 3
Joined
Mar 2, 2008
Messages
62
wow.. thats a big omnislash. id have used the generic 'pick random 1 unit in group units in range of triggering unit' thing in a loop.

ill try to answer as much as i can

1. after you cast the ability, set a variable equal to the summoned unit, and use a damage taken trigger. unit takes damage, then add hp back to caster equal to damage dealt and subtract from summoned.

2. perhaps use the item's level in the calculation instead of a variable? problem is thats a lot of pre-meditating there and its not as realistic.

3. i dont know why it wouldnt work, but it looks needlessly complicated.

4. order the unit to move in a direction opposite to the position of caster? use polar coordinates and angle between points.

5. i need something like this too.. only way i can think of is to check positions after a small wait.


hope some of that helped you in any way, and sorry if it didnt
 
Level 4
Joined
Mar 6, 2007
Messages
73
5- This is pretty hard to explain. As I know, you must create a dummy unit at position of your unit, giving it a variable such as Dummy_Checker and look with a periodic time event trigger (spell NOT MUI) if the distance between your unit and Dummy_Checker greater than or equal to lets say 10. So if the distance is under 10, the unit is not moving and you can use this as a condition for trigger spells.
Hope it help
 
Level 2
Joined
Mar 14, 2008
Messages
5
wow.. thats a big omnislash. id have used the generic 'pick random 1 unit in group units in range of triggering unit' thing in a loop.

I'm not sure how that helps...? Could you please enlighten me?

ill try to answer as much as i can

1. after you cast the ability, set a variable equal to the summoned unit, and use a damage taken trigger. unit takes damage, then add hp back to caster equal to damage dealt and subtract from summoned.

So, there's no way to refund a specific amount of health and take into account the specific spell cast? And damage taken trigger seems to only work with "Specific Unit", but not "Generic Unit".

2. perhaps use the item's level in the calculation instead of a variable? problem is thats a lot of pre-meditating there and its not as realistic.

I guess so. I might have to give it a miss. :hohum:

3. i dont know why it wouldnt work, but it looks needlessly complicated.

I've linked to the original one I based it on; Maybe comparing the two will give an idea as to what I forgot, since Tinki's works but mine doesn't.

4. order the unit to move in a direction opposite to the position of caster? use polar coordinates and angle between points.

Is it something like this, or have I got my degrees mixed up?

  • Unit - Order (Attacking unit) to Move To ((Position of (Attacking unit)) offset by ((Facing of (Attacking unit)) - 180.00) towards (Random real number between 300.00 and 1200.00) degrees)

5. i need something like this too.. only way i can think of is to check positions after a small wait.

5- This is pretty hard to explain. As I know, you must create a dummy unit at position of your unit, giving it a variable such as Dummy_Checker and look with a periodic time event trigger (spell NOT MUI) if the distance between your unit and Dummy_Checker greater than or equal to lets say 10. So if the distance is under 10, the unit is not moving and you can use this as a condition for trigger spells.
Hope it help

Create, as in put one down at the start of the map? Or only when the Hero in question is trained/chosen? I'm a bit confused as to this... :wconfused:

hope some of that helped you in any way, and sorry if it didnt

I think it did help some, so thanks.
 
Level 4
Joined
Mar 6, 2007
Messages
73
Create, as in put one down at the start of the map? Or only when the Hero in question is trained/chosen? I'm a bit confused as to this... :wconfused:
For mine, I have an initializing trigger that look like this.(when the ability is learn)
  • Setting
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Your Spell
    • Actions
      • Set HeroWithYourSpell = (Learning Hero)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of YourSpell for (Triggering unit)) Equal to 1
        • Then - Actions
          • Unit - Create 1 Checkdummy for Neutral Passive at (Position of HeroWithYourSpell) facing Default building facing (270.0) degrees
          • Set Dummy_Cheker = (Last created unit)
        • Else - Actions
This should work. Hope it help.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
5. You need to use a cool trigger that I made in Jass (it can be done in GUI too though).

Should I share it ? :xxd:

Nah, too lazy to make it in GUI, GUI is slow and sucks.

Guide line:
1. Put all the units you want to check in a group.
3. Loop between 1 to numberOfUnits in your group.
4. Pick 1 random unit from the group.
...

Ok actually since it has to use arrayes and its gonna be really annoying in GUI ill just create it in Jass again >.<

Actualy, tell me what you want exacly and ill make it, not gonna make some random codes that won't even help you.
 
Status
Not open for further replies.
Top