• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Hero costs

Status
Not open for further replies.
Level 4
Joined
Aug 31, 2011
Messages
88
Hi guys,

How to make that 1st hero u create costs nothing, just like in the melee maps?

PS: I removed "Create starting units trigger" for gameplay purposes
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Create starting units contains amongst many other code this line:
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
Use a custom script inside a loop to apply it for every player:
  • For each (Integer A) from 0 to 11, do (Actions)
    • Loop - Actions
      • Custom script: call SetPlayerState(Player(bj_forLoopAIndex), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)
 
Level 4
Joined
Aug 31, 2011
Messages
88
Can I use this custom script inside a player group loop, since I already have player group loop for some other stuffs?

And I just have to replace "forLoopAIndex" with my variable or?
 
Level 4
Joined
Aug 31, 2011
Messages
88
So I tried by typing this:

"call SetPlayerState(Player(bj_udg_player_group), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"
"call SetPlayerState(Player(udg_player_group), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"
"call SetPlayerState(Force(udg_player_group), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"

And every time it gives me "Expected a name" error

Dunno what's wrong... :/
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
The first argument must be a player expression. You can use a player variable, the Player(int) function to convert an integer to a player or the GetEnumPlayer() function to get the picked player.
You said you want to use it in a player group, so you should use:

"call SetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"
 
Status
Not open for further replies.
Top