• 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.

Goblin Mines Triggered Damage

Status
Not open for further replies.
Level 12
Joined
Sep 11, 2011
Messages
1,176
Hi everyone! Does anyone know how to make goblin mines to deal damage depending on Intelligence of their master in triggers?):ogre_icwydt:

  • Setting Damage
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Mine - exploding (Goblin Land Mine)
    • Actions
      • Set u = (Triggering unit)
      • Set cv = (Custom value of u)
      • Set MINE_DMG[cv] = ((Real((Intelligence of (Triggering unit) (Exclude bonuses)))) x 50.00)
      • Set AOE[cv] = 256.00
      • Trigger - Turn on Dealing Damage <gen>
  • Dealing Damage
    • Events
      • Unit - A unit comes within 256.00 of Your Mine
    • Conditions
    • Actions
      • Unit - Cause u to damage circular area after 0.00 seconds of radius AOE[cv] at (Position of (Triggering unit)), dealing MINE_DMG[cv] damage of attack type Spells and damage type Normal
that's just an example.

Note : - Mine_DMG and AOE is a real variables.
- cv is an integer variable.
- u is a unit variable.
 
Level 10
Joined
Mar 17, 2012
Messages
582
Do you need them MUI ?

no) thx)

  • Setting Damage
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Mine - exploding (Goblin Land Mine)
    • Actions
      • Set u = (Triggering unit)
      • Set cv = (Custom value of u)
      • Set MINE_DMG[cv] = ((Real((Intelligence of (Triggering unit) (Exclude bonuses)))) x 50.00)
      • Set AOE[cv] = 256.00
      • Trigger - Turn on Dealing Damage <gen>
  • Dealing Damage
    • Events
      • Unit - A unit comes within 256.00 of Your Mine
    • Conditions
    • Actions
      • Unit - Cause u to damage circular area after 0.00 seconds of radius AOE[cv] at (Position of (Triggering unit)), dealing MINE_DMG[cv] damage of attack type Spells and damage type Normal
that's just an example.

Note : - Mine_DMG and AOE is a real variables.
- cv is an integer variable.
- u is a unit variable.

Thanks I'll try it))) It looks great!
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
i did a little changes and added some notes.

  • Setting Damage
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Item Place Goblin Land Mines
    • Actions
      • Set u = (Triggering unit)
      • Set cv = (Custom value of u)
      • Set MINE_DMG[cv] = ((Real((Intelligence of (Triggering unit) (Exclude bonuses)))) x 50.00)
      • Set AOE[cv] = 256.00
      • Trigger - Turn on Dealing Damage <gen>
  • Dealing Damage
    • Events
      • Unit - A unit comes within 256.00 of Goblin Land Mines
    • Conditions
    • Actions
      • Unit - Cause u to damage circular area after 0.00 seconds of radius AOE[cv] at (Position of (Triggering unit)), dealing MINE_DMG[cv] damage of attack type Spells and damage type Normal
Notes :
- Mine_DMG and AOE is a real variables.
- cv is an integer variable.
- u is a unit variable.
- Item Place Goblin Land Mines is located at Abilities > Special > Items > Item Place Goblin Land Mines
- Goblin Land Mines can be found on Neutral Hostile > Campaign > Goblin Land Mines.
- If you want to Include Intelligence bonus, set it to ((Real((Intelligence of (Triggering unit) (Include bonuses))))
- Dealing Damage trigger should be "Initially on"
- In Abilities > Specials > Units > AOE Damage Upon Death (Goblin Mine), set the
Data - Full damage amount to 0
Data - Full damage radius to 0
Data - Partial damage amount to 0
Data - Partial damage radius to 0


because we've triggered all of them already, so they are no longer needed.
 
Last edited:
Use starts the effect of ability instead of finishes casting... because finishes casting runs when the unit finishes casting which includes playing all animations included for the cast, which in a normal scenario doesn't happen much as the user normally already issues another order before the unit actually finishes casting...
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
Use starts the effect of ability instead of finishes casting... because finishes casting runs when the unit finishes casting which includes playing all animations included for the cast, which in a normal scenario doesn't happen much as the user normally already issues another order before the unit actually finishes casting...

Changed, thanks a lot for the information.

Edit :
@darkzxx :ogre_haosis: fixed!
 
because it doesn't need to... You trigger the damage when a unit comes near the mine which is also when it blows up so no need to check the ability itself...

though his trigger has errors... first it isn't MUI... second it doesn't check if the unit can actually trigger the mine or not (it triggers for all units passing near the mine)... third, unit in range takes a direct unit as an event (it cannot take unit-types) so you need to register every appearing goblin mine to that trigger...
 
Level 10
Joined
Mar 17, 2012
Messages
582
because it doesn't need to... You trigger the damage when a unit comes near the mine which is also when it blows up so no need to check the ability itself...

though his trigger has errors... first it isn't MUI... second it doesn't check if the unit can actually trigger the mine or not (it triggers for all units passing near the mine)... third, unit in range takes a direct unit as an event (it cannot take unit-types) so you need to register every appearing goblin mine to that trigger...

I agree... But you mean that every summoned Goblin Land Mine have to be called like Goblin_Mine_1, Goblin_Mine_2... or how do do it?
 
  • Events
    • Unit - A unit enters the map
  • Conditions
    • Unit-type of triggering unit equal to Goblin Mine
  • Actions
    • Trigger- Add to EXPLOSION_TRIGGER the event Unit - A unit comes within 256.0 of Triggering unit
Though this way is a bit inefficient and causes event leaks... you might actually just want to check when a unit of type goblin mine dies...
 
Level 10
Joined
Mar 17, 2012
Messages
582
  • Events
    • Unit - A unit enters the map
  • Conditions
    • Unit-type of triggering unit equal to Goblin Mine
  • Actions
    • Trigger- Add to EXPLOSION_TRIGGER the event Unit - A unit comes within 256.0 of Triggering unit
Though this way is a bit inefficient and causes event leaks... you might actually just want to check when a unit of type goblin mine dies...

Im working on it!) Now I'll try to test what you all told me...
P.S. I don't have much time for triggering right now... That's why I do it so slowly :ogre_kawaii:
 
Level 10
Joined
Mar 17, 2012
Messages
582
Okay, look what I've done:

Goblin Land Mines Caster
  • Events
  • Unit - A unit Starts the effect of an ability
  • Conditions
  • (Ability being cast) Equal to Goblin Land Mine (tinker)
  • Actions
  • Set Goblin_Mine_Caster = (Casting unit)
Goblin Land Mines lvl 1
  • Events
  • Unit - A unit enters (Playable map area)
  • Conditions
  • (Unit-type of (Entering unit)) Equal to 1. Goblin Land Mine
  • Actions
  • Set Goblin_Mine_1 = (Entering unit)
  • Wait 2:00 seconds
  • Trigger - Add to Goblin Land Mines Damage 1 <gen> the event (Unit - A unit comes within 200.00 of Goblin_Mine_1)
Goblin Land Mines Damage 1
  • Events
  • Conditions
  • Actions
  • Set Goblin_Mine_Group_1 = (Units within (((Real((Level of Goblin Land Mine(tinker) for Goblin_Mine_Caster))) x 25) + 125.00) of (Position of Goblin_Mine_1) matching ((((Matching unit) belongs to an enemy of (Owner of Goblin_Mine_Caster)) Equal to True and ((((Matching unit ) is A structure) Not equal to True) and (((Matching unit) is alive) Equal to True)
  • Unit Group - Pick every unit in Goblin_Mine_Group_1 and do (Actions)
  • Loop - Actions
  • Unit - Cause Goblin _Mine_Caster to damage Picked unit, dealing ((Real((Intelligence of Goblin_Mine_Caster (Include bonuses)))) x 50) damage of attack type Spells and damage type Fire
... now it damages units that are in region when my hero was casting this spell, but doesn't deal Int-damage if I place mine before enemy comes to it... Have any ideas?
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Too complex. I would do something similar to this:

What it basically does is detect the Mine entering the map, and saving the Intelligence of the Caster on the Mine Handle Id. When the Mine Dies, it retrieves the Intelligence saved on it's Id, and deal that damage to units around.

  • Events
    • Unit - A unit is summoned
  • Conditions
    • Unit Type of (Triggering Unit) is Equal to Goblin Land Mine
  • Actions
    • Set Stat = Intelligence of (Summong Unit)
    • Custom script: call SaveReal(udg_HashtableName, GetHandleId(GetTriggerUnit()), 0, udg_Stat)
  • Events
    • Unit - A unit dies
  • Conditions
    • Unit type of (Triggering Unit) equal to Goblin Land Mine
  • Actions
    • Custom script: set udg_RealVariable = LoadReal(udg_HashtableName, GetHandleId(GetTriggerUnit()), 0)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick Every unit in 350 radius and do (Actions)
      • Loop - (Actions)
        • Unit - Make Triggering cause RealVariable damage to (Picked Unit)
    • Hashtable - Flush Child Hash of Key(Handle(Triggering Unit))
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
Too complex. I would do something similar to this:

What it basically does is detect the Mine entering the map, and saving the Intelligence of the Caster on the Mine Handle Id. When the Mine Dies, it retrieves the Intelligence saved on it's Id, and deal that damage to units around.

  • Events
    • Unit - A unit is summoned
  • Conditions
    • Unit Type of (Triggering Unit) is Equal to Goblin Land Mine
  • Actions
    • Set Stat = Intelligence of (Summong Unit)
    • Custom script: call SaveReal(udg_HashtableName, GetHandleId(GetTriggerUnit()), 0, udg_Stat)
  • Events
    • Unit - A unit dies
  • Conditions
    • Unit type of (Triggering Unit) equal to Goblin Land Mine
  • Actions
    • Custom script: set udg_RealVariable = LoadReal(udg_HashtableName, GetHandleId(GetTriggerUnit()), 0)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick Every unit in 350 radius and do (Actions)
      • Loop - (Actions)
        • Unit - Make Triggering cause RealVariable damage to (Picked Unit)
    • Hashtable - Flush Child Hash of Key(Handle(Triggering Unit))

:thumbs_up::thumbs_up::thumbs_up:this is very understandable :thumbs_up::thumbs_up:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
There are some cases when you need to declare the Group into a variable, and some where you can just use that set bj_wantDestroyGroup = true script.

If you use some custom scripts you can even optimize the thing and even avoid having to create/destroy a group, like the following:

JASS:
// This function automatically clears the group before adding new units to it.
call GroupEnumUnitsInRange(bj_lastCreatedGroup, radius, X, Y, null)
loop
 set u = FirstOfGroup(bj_lastCreatedGroup)
 exitwhen u = null
 if u == *Your Conditions* then
  Do your thing
 endif
 call GroupRemoveUnit(u, bj_lastCreatedGroup)
endloop

Adding/removing units from an already created group is a lot faster than creating a group, adding units, then destroying the group.
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
There are some cases when you need to declare the Group into a variable, and some where you can just use that set bj_wantDestroyGroup = true script.

If you use some custom scripts you can even optimize the thing and even avoid having to create/destroy a group, like the following:

JASS:
// This function automatically clears the group before adding new units to it.
call GroupEnumUnitsInRange(bj_lastCreatedGroup, radius, X, Y, null)
loop
 set u = FirstOfGroup(bj_lastCreatedGroup)
 exitwhen u = null
 if u == *Your Conditions* then
  Do your thing
 endif
 call GroupRemoveUnit(u, bj_lastCreatedGroup)
endloop

Adding/removing units from an already created group is a lot faster than creating a group, adding units, then destroying the group.

:vw_death: do removing units from a Unit group means destroying the group ?
 
Level 10
Joined
Mar 17, 2012
Messages
582
Too complex. I would do something similar to this:

What it basically does is detect the Mine entering the map, and saving the Intelligence of the Caster on the Mine Handle Id. When the Mine Dies, it retrieves the Intelligence saved on it's Id, and deal that damage to units around.

  • Events
    • Unit - A unit is summoned
  • Conditions
    • Unit Type of (Triggering Unit) is Equal to Goblin Land Mine
  • Actions
    • Set Stat = Intelligence of (Summong Unit)
    • Custom script: call SaveReal(udg_HashtableName, GetHandleId(GetTriggerUnit()), 0, udg_Stat)
  • Events
    • Unit - A unit dies
  • Conditions
    • Unit type of (Triggering Unit) equal to Goblin Land Mine
  • Actions
    • Custom script: set udg_RealVariable = LoadReal(udg_HashtableName, GetHandleId(GetTriggerUnit()), 0)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick Every unit in 350 radius and do (Actions)
      • Loop - (Actions)
        • Unit - Make Triggering cause RealVariable damage to (Picked Unit)
    • Hashtable - Flush Child Hash of Key(Handle(Triggering Unit))

You know, Im not sure that
Unit - A unit dies
Conditions
Unit type of (Triggering Unit) equal to Goblin Land Mine
will work... but if it works than i could do it long time ago))) :ogre_rage:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I know that feel bro. Of course it works xD Because you have a Mine that's a unit and explodes (dies). You can detect that event and do what you want :p.

If you happen to use Bribe's Unit Indexer system this would get a bit easier ;)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
It's a system you can find here in HiveWorkshop that assigns each unit an specific and unrepeatable Custom Value. You can then access to any unit data in the map by it's custom value, instead of having to use a Hashtable and the HandleId of the unit.

Replaces this:
  • Hashtable - Save 5 as Key(Handle(Triggering Unit)) of 1 in Hashtable
with this
  • Set Value[Custom value of (Triggering Unit)] = 5.
That makes codes easier to read, and faster to create/save/load/execute
 
Level 10
Joined
Mar 17, 2012
Messages
582
Spartipilo, there are 1 problem... I have 4 units of goblin mines))) 1. Goblin Mine, 2. Goblin mine... e.t.c.

I've made a trigger that sets Goblin_Mine_1 = 1. Goblin mine.... BUT:
when I summon 2-nd mine - 1-st mine deals no Int damage... what can you advice me?) :ogre_kawaii:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You can make a small chain of If/Then/Else to save an specific value (like Intx1, Intx2, Intx3, Intx4) based on the mine that's being summoned, instead of creating 1 trigger for each one.

You can also add them to a UnitGroup (Mines) so the condition for "A unit dies" is "Unit is in Mines group". It's still better than having 4 triggers with different condition for each mine type.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
So This
JASS:
function OR Conditions takes nothing returns boolean
    if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return true
    endif
    return false
endfunction

Is better than this + group
JASS:
function IsUnitInGroup condition takes nothing returns boolean
    if ( not ( IsUnitInGroup(GetTriggerUnit(), GetLastCreatedGroup()) == true ) ) then
        return false
    endif
    return true
endfunction
 
Level 10
Joined
Mar 17, 2012
Messages
582
You can make a small chain of If/Then/Else to save an specific value (like Intx1, Intx2, Intx3, Intx4) based on the mine that's being summoned, instead of creating 1 trigger for each one.

You can also add them to a UnitGroup (Mines) so the condition for "A unit dies" is "Unit is in Mines group". It's still better than having 4 triggers with different condition for each mine type.

I agree) :thumbs_up: thanks!) Now it works perfectly :ogre_haosis:

You know, you have a special talent to turn my brain on))) I almost lost my hope to make this ability and you showed me how easy it is :thumbs_up::thumbs_up::thumbs_up:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I know in JASS it's a lot better :p But since he's working on GUI, the "or" conditions are written that way, making it... "worse" than using the Group, right?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Don't worry, this is an offtopic discussion about condition effectivenes between Adiktuz and me :D You're good to go with the triggers you already have (as you've said it).
 
Status
Not open for further replies.
Top