# Is there a percentage function in the editor?

Discussion in 'World Editor Help Zone' started by Anteep, Oct 9, 2008.

1. ### Anteep

Joined:
Feb 28, 2005
Messages:
123
Resources:
3
Maps:
3
Resources:
3
I can see that there is a "Maths - Random Percentage" function, which I don't want, but I can't see a percentage function or maybe i'm not looking right. Is there one?

2. ### raid1000

Joined:
May 1, 2008
Messages:
1,017
Resources:
0
Resources:
0
math- random number
math- random angle
math- random percentage

3. ### Angry_Bovine

Joined:
Oct 7, 2007
Messages:
593
Resources:
1
Maps:
1
Resources:
1
What exactly are you trying to change into a percentage? This can be done manually in almost all cases.

4. ### raid1000

Joined:
May 1, 2008
Messages:
1,017
Resources:
0
Resources:
0
sorry for not understanding d'ohh but random percentage doesn't have any functions but if this helps u can use it like this

• Unit - Set mana of (Triggering unit) to (Random percentage)%

random percentage can be used in autocasting spells (%= number betwen 0 and 100)

Last edited: Oct 9, 2008
5. ### Anteep

Joined:
Feb 28, 2005
Messages:
123
Resources:
3
Maps:
3
Resources:
3
What I'm doing is:
Events
Unit - A unit Is attacked
Conditions
(Unit-type of (Attacked unit)) Equal to Lumber Mill

Now, in order to do the action I need a percentage function so I can put in 50% for example.
I want, when the lumber mill's health drops below 50%, the player attacking it captures it.

6. ### raid1000

Joined:
May 1, 2008
Messages:
1,017
Resources:
0
Resources:
0
• Events
• Unit - A unit Is attacked
• Conditions
• ((Unit-type of (Attacked unit)) Equal to lumbermill) and ((Life of (Attacked unit)) Less than or equal to 50.00)

find the second condition under "real comparison" - "unit percentage life"

7. ### Angry_Bovine

Joined:
Oct 7, 2007
Messages:
593
Resources:
1
Maps:
1
Resources:
1
Raid1000, that doesn't work as intended. Life of Attacked Unit doesn't return a percentage.

Anteep, here's your simple solution since you've finally made it clear what you wanted to:

((Life of (Attacked Unit) / Max Life of (Attacked Unit)) less than or equal to 50)

A percentage is just a number over the intended. In this case, the current over the maximum.

8. ### TheBlooddancer

Joined:
Jun 24, 2008
Messages:
2,911
Resources:
0
Resources:
0
Use integrers loop A/B?

9. ### Anteep

Joined:
Feb 28, 2005
Messages:
123
Resources:
3
Maps:
3
Resources:
3
Thanks all, this is the trigger I ended up doing and it works:

Events
Unit - A unit Is attacked
Conditions
((Unit-type of (Attacked unit)) Equal to Quarry [1]) and ((Percentage life of (Attacked unit)) Less than or equal to 50.00)
Actions
Unit - Change ownership of (Attacked unit) to (Owner of (Attacking unit)) and Change color
Unit - Set life of (Attacked unit) to 100.00%

10. ### PoZoR

Joined:
Oct 3, 2008
Messages:
101
Resources:
1
Maps:
1
Resources:
1
in the trigger u proposed, u will need to use 0.5 instead of 50

11. ### Angry_Bovine

Joined:
Oct 7, 2007
Messages:
593
Resources:
1
Maps:
1
Resources:
1
Ah, my apologies. Wasn't thinking. Yes, PoZoR is correct. Please use 0.5 instead or it will trigger every time. Percentages are out of 1... I was thinking, multiplied by 100. Thanks for clearing that up.