- Joined
- Dec 6, 2022
- Messages
- 3
Hello there! I am creating a new ability to my hero called Plunder. The skill itself is a point-and-click damaging skill that, if kills an unit, gives the player gold.
The problem is: Whenever I try a new solution, two of the scenarios happen: 1) The player gains gold even if it doesnt kill the unit or 2) Nothing happens at all. I have tried using the GUI and the JASS (I will show both of them down bellow).
My logic - Check if the ability Plunder was used and compare if the target of the ability is dead. If true, do effects. I have tried putting a timer on it, because I thought the game wouldnt have time to compare if the unit is dead just after the skill was used. I have tried checking if unit is dead and checking if the HP of the target is less than 1 (Because I have seen somewhere that a unit doesnt actually dies with 0 hp).
Maybe I am missing something? I have seen somewhere that the game cannot see whom killed the unit after it was killed, and right now I am a bit clueless of what to do. Could you give me some hand on what / where to fix? If you read up to here, I already thank your attention
The problem is: Whenever I try a new solution, two of the scenarios happen: 1) The player gains gold even if it doesnt kill the unit or 2) Nothing happens at all. I have tried using the GUI and the JASS (I will show both of them down bellow).
My logic - Check if the ability Plunder was used and compare if the target of the ability is dead. If true, do effects. I have tried putting a timer on it, because I thought the game wouldnt have time to compare if the unit is dead just after the skill was used. I have tried checking if unit is dead and checking if the HP of the target is less than 1 (Because I have seen somewhere that a unit doesnt actually dies with 0 hp).
Maybe I am missing something? I have seen somewhere that the game cannot see whom killed the unit after it was killed, and right now I am a bit clueless of what to do. Could you give me some hand on what / where to fix? If you read up to here, I already thank your attention
-
Events
- Unit - A unit Starts the effect of an ability.
-
Conditions
- (Ability being cast) Equal to Plunder.
-
Actions
- Wait 1.00 seconds
- If (All conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Life of (Target unit of ability being cast)) less than 1.00
-
Then - Actions
- Special Effect - Create special effect at (Position of (Triggering unit) using UI\Feedback\GoldCredit\GoldCredit.mdl
- Player - Set (Owner of (Triggering unit)).Current gold to (((Owner of (Triggering unit)) Current gold + 25)
-
Else - Actions
- Do nothing
JASS:
function checkIfDead takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
function Trig_Plunder_Passive_Test_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'S004' ) and checkIfDead ( GetSpellTargetUnit() ) == false ) then
return false
endif
return true
endfunction
function Trig_Plunder_Passive_Test_Actions takes nothing returns nothing
call AddSpecialEffectLocBJ( GetUnitLoc(GetTriggerUnit()), "UI\\Feedback\\GoldCredit\\GoldCredit.mdl" )
endfunction
//===========================================================================
function InitTrig_Plunder_Passive_Test takes nothing returns nothing
set gg_trg_Plunder_Passive_Test = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Plunder_Passive_Test, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Plunder_Passive_Test, Condition( function Trig_Plunder_Passive_Test_Conditions ) )
call TriggerAddAction( gg_trg_Plunder_Passive_Test, function Trig_Plunder_Passive_Test_Actions )
endfunction