# Player's units' total value calculation

Status
Not open for further replies.

#### RobertMKD

Level 11
Can you give me an idea of how to calculate the total point value of all of the player buildings?

I tried to do it in a few ways but failed, there must be a way but I can't think of it right now cause my brain is blocked from this WE xD

#### Alpun

Level 3
easy, just look in the unit editor. there u can see the value of each given unit type. Then u need to count how many units of a type a player owns (u can do this by trigger numbers of unit in region entire mapowned by player) and then u need to add values by multiplying first and then adding them

#### nedio95

Level 12
Uuugh... @Alpun No.

@RobertMDK You can do this:

• Set TempUnitGroup = (Units in (Playable map area) owned by Player 1 (Red))
• Unit Group - Pick every unit in TempUnitGroup and do (Actions)
• Loop - Actions
• Set TotalPoints = TotalPoints + (Point-value of (Picked unit))
• Custom Script: call DestroyGroup(udg_TempUnitGroup)
TotalPoints is integer variable.
Maybe you would like to put all this in a loop 1 to 12 so you can get teh points of all players or array TotalPoints so you can het the total points for each player, TotalPoints[PlayerNumber]

#### Alright

Level 6
• Actions
• Set tempUnitGroup = (Units in (Playable map area) matching ((((Matching unit) is A structure) Equal to True) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
• Unit Group - Pick every unit in tempUnitGroup and do (Actions)
• Loop - Actions
• Set tempInt = (tempInt + (Point-value of (Picked unit)))
• Custom script: call DestroyGroup(udg_tempUnitGroup)
• Game - Display to (All players) the text: (String(tempInt))
I haven't tested personally but I think you're looking for something like this.

edit: beaten again asdfnjkwenjfkanfdsas

edit2: picked unit > matching unit

#### RobertMKD

Level 11
nedio95

aaah, that was the spark that was lurking inside my brain, but i couldnt remember xD
ty very much

#### RobertMKD

Level 11
now as a result i get 364, instead of 365 (as it should be - i calculated it to test if its correct).. what do you think is causing this problem?

#### nedio95

Level 12
You have one less unit with point value of 1 than you think you do ? (Your fault)
You are calculating wrong ? (Your fault)
Somehow you deducted 1 from TotalPoints ? (Trigger fault (Still your fault ))

#### RobertMKD

Level 11
i just added 1 to the result xD ty anyway

#### nedio95

Level 12
That's... that's not how you solve a problem... That's just hiding it, the problem is still there.

#### RobertMKD

Level 11
I know, but it's not causing other problems...

Status
Not open for further replies.

Replies
5
Views
428
Replies
3
Views
987
Replies
7
Views
853
Replies
14
Views
806
Replies
6
Views
3K