Yeah i need some trigger help.
what i want to happen is when the Armory gets down to 10% health it transfers ownership to the attacker and restores hp.
heres what i did.
Armory 1
Events
Unit - A unit Is attacked
Conditions
(Unit-type of (Attacked unit)) Equal to Armory
(Life of (Attacked unit)) Less than or equal to (0.10 x (Percentage life of (Attacked unit)))
Actions
Unit - Change ownership of (Attacked unit) to (Owner of (Attacking unit)) and Change color
Unit - Set life of Ability Emporium 0116 <gen> to 100.00%
Transfer Building Ownership
Moderator: Cheaters
-
- Forum Staff
- Posts: 506
- Joined: August 5th, 2007, 1:38 pm
- Title: Gui Expert
- Location: *Unknown*
Re: Transfer Building Ownership
I will help you out with your trigger, when i get home i will do some testing and repost the trigger.
(Life of (Attacked unit)) Less than or equal to (0.10 x (Percentage life of (Attacked unit)))
This part is your problem b.c it uses the % life of the current life has has rather than his max life.
Armory Transfer
Event:
-
Condition:
-
Action:
-
(Life of (Attacked unit)) Less than or equal to (0.10 x (Percentage life of (Attacked unit)))
This part is your problem b.c it uses the % life of the current life has has rather than his max life.
Armory Transfer
Event:
-
Condition:
-
Action:
-
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Transfer Building Ownership
Change the second condition to this:
(Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit)))
(Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit)))
-
- Member
- Posts: 62
- Joined: October 3rd, 2007, 4:17 am
- Title: Dragon
- Location: The land of dragons.
Re: Transfer Building Ownership
That would work...but it seems like you are overcomplicating it. =/
(Percentage life of (Attacked unit)) Less than or equal to 10.00
(Percentage life of (Attacked unit)) Less than or equal to 10.00
Dragons FTW!
^ Made by Windflamedmon.
^ Made by Windflamedmon.
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Transfer Building Ownership
It seems intuitive to assume that but analyse it a bit...
Case 1:
(Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit)))
This converts to...
Conclusion:
Calls 4 functions in total (Excluding Trigger Unit).
Arithmatic involved: Multiplication by 0.1 or division by 10.
Total comparisons: 1
------------------------------------------------------------------------------------------------
Case 2:
(Percentage life of (Attacked unit)) Less than or equal to 10.00
This converts to
Conclusion:
Calls 4 functions in total (Excluding Trigger Unit).
Arithmatic involved: Real division, multiplication by 100.
Total comparisons: 3
---------------------------------------------------------
So overall, using [ (Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit))) ] is more strait forward and and I would imagine faster.
Though ideally you use jass:
Calls 2 functions in total (Excluding Trigger Unit).
Arithmatic involved: Multiplication by 0.1
Total comparisons: 1
Here is a perfect example of the efficiency of jass and why I encourage people to learn it.
On the side, [Triggering Unit] is a faster function call than [Attacking Unit] so it's best to use Triggering Unit when they are interchangeable.
Case 1:
(Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit)))
This converts to...
Code: Select all
return(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())<=GetUnitStateSwap(UNIT_STATE_MAX_LIFE,GetTriggerUnit())*0.1)
Code: Select all
function GetUnitStateSwap takes unitstate whichState, unit whichUnit returns real
return GetUnitState(whichUnit, whichState)
endfunction
Calls 4 functions in total (Excluding Trigger Unit).
Arithmatic involved: Multiplication by 0.1 or division by 10.
Total comparisons: 1
------------------------------------------------------------------------------------------------
Case 2:
(Percentage life of (Attacked unit)) Less than or equal to 10.00
This converts to
Code: Select all
return(GetUnitLifePercent(GetTriggerUnit())<= 10.)
Code: Select all
function GetUnitLifePercent takes unit whichUnit returns real
return GetUnitStatePercent(whichUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)
endfunction
Code: Select all
function GetUnitStatePercent takes unit whichUnit, unitstate whichState, unitstate whichMaxState returns real
local real value = GetUnitState(whichUnit, whichState)
local real maxValue = GetUnitState(whichUnit, whichMaxState)
// Return 0 for null units.
if (whichUnit == null) or (maxValue == 0) then
return 0.0
endif
return value / maxValue * 100.0
endfunction
Calls 4 functions in total (Excluding Trigger Unit).
Arithmatic involved: Real division, multiplication by 100.
Total comparisons: 3
---------------------------------------------------------
So overall, using [ (Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit))) ] is more strait forward and and I would imagine faster.
Though ideally you use jass:
Code: Select all
return GetWidgetLife(GetTriggerUnit()) <= GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE)*0.1
Arithmatic involved: Multiplication by 0.1
Total comparisons: 1
Here is a perfect example of the efficiency of jass and why I encourage people to learn it.
On the side, [Triggering Unit] is a faster function call than [Attacking Unit] so it's best to use Triggering Unit when they are interchangeable.