Hi everyone! Does anyone know how to make goblin mines to deal damage depending on Intelligence of their master in triggers?)
Do you need them MUI ?
- 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>
that's just an example.
- 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
Note : - Mine_DMG and AOE is a real variables.
- cv is an integer variable.
- u is a unit variable.
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...
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...
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...
- 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
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))
what.... that customscript set bj_wantdestroygroup = true destroys the next unit group ?
then i don't need to use variables?
// 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
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.
NOPE... they are clearly not equal... remove units is just that, removing units... the group will still remain...
but in this case you're not supposed to destroy the group, since he's using the global group bj_lastCreatedGroup... if you destroy it, you're doomed, I assure that...
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))
Check the unit-type, not the exact unit so that it will fire for all goblin mines...
Look at his trigger, he used unit-type as the condition and not a specific unit...
If you will just copy his trigger as it is, you will have no problems... seriously...
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
function IsUnitInGroup condition takes nothing returns boolean
if ( not ( IsUnitInGroup(GetTriggerUnit(), GetLastCreatedGroup()) == true ) ) then
return false
endif
return true
endfunction
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.
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) then
Since you've used the jass conversion then let me make a better one:
JASS:if IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) then