• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Need help with detecting players + more

Status
Not open for further replies.
Level 4
Joined
Sep 6, 2012
Messages
19
trying to make a trigger/triggers that detects the amount of players then scale enemy HP and damage according to how many players there are playing. Currently have it set to reduce HP and damage by 10% for each -1 player. And an other trigger to activate when a player leaves and the trigger than readjusts the HP and damage of enemy units again

  • [ATTACH type="full"]406496[/ATTACH]
  • [ATTACH type="full"]406502[/ATTACH]
 

Attachments

  • 1662405005348.png
    1662405005348.png
    143.2 KB · Views: 24
  • 1662405162627.png
    1662405162627.png
    168.1 KB · Views: 25
Level 20
Joined
Feb 27, 2019
Messages
593
You didnt explain whats working well or what issues you are experiencing. Lucky for you, I bothered to look into it anyway.


There is no reason to use a wait in the first trigger. In the extremely rare case someone leaves during that 0.01 wait there will be issues. A 0.01 wait is more likely ~0.03-0.11 actual time. Other than that the first trigger gets the job done well enough.

The math is wrong in the second trigger. In a full game it will work for the first leaver, then get progressively worse the more people that leave.

Imagine a game starting with 5 / 10 players and a unit with 100 hit points. That would be 100 x 0.5 = 50. Then if another player leaves it would be 50 x 0.4 = 20.


One option is to first re-calculate their Max HP to their default Max HP before reducing it again.

Player leaves the game
Set Max HP of unit to (10 / 5) x Max HP
(2 x 50 = 100)
Set Max HP of unit to ((5-1) / 10) x Max HP
(0.4 x 100 = 40)
Set Number of Players = Number of Players - 1

Since you are working with integer values they will never be exact and will get progressively offset the more people that leave. I put it out there so that you dont get surprised when the Max HP or Base damage from game to game may differ a tiny bit. If you re-calculate the default Max HP to a real variable instead of actually setting the HP in the first step it will be more precise and efficient.
 
Level 4
Joined
Sep 6, 2012
Messages
19
1662592773783.png

I believe I have the formula for mana and HP working correctly now. However my current issue is with scaling enemy damage. I printed several values seperately; unit base damage, my formula for base damage scaling (Base Damage x (Nplayers / 10 ), Nplayers I would manually set myself, and one or two more that i cant remember right now. They call returned as I expected.

HOWEVER, returning the value of Variable Number_Of_Players returns 0

That variable to set to Player - Count players in player group. player group = Number_Of_Players_Group

tried looking for print player group and to count players in player group to return that as an integer so that i can print that in screen but can't find it in the gui, regardless this tells me the Set Variable Number of players group is not working as intended



EDIT: I figured it out and it now works! :D


1662595150066.png
 
Last edited:
Status
Not open for further replies.
Top