• 🏆 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!

random player name changes??

Status
Not open for further replies.
Level 2
Joined
Aug 24, 2017
Messages
18
Hello everyone! So uhms, this is perhaps my very first post here in Hive but sksk anyways we'll let that slide.

So in some maps I player, or perhaps a few, there is this thing(?) where they have different names (Yes I'm referring to maps with AI Bots). Like for example there are AI bots that are named Oliver or Kelvin or maybe uhmm Naisha. And then for another point, their names changed, like it can be Casper or Tyrande or maybe Jaina. It's like, these maps have a list of names that were randomly assigned to the computer bots and everytime you start a new game on those maps, the bots have different names; like it doesn't stick with one name. And because of this, I personally find it really cool and I want to know how do people do that? Like what's the formula behind this?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
If these are custom maps then they are likely using triggers to change the player name of the AI players in a sort of personality system.

A possible implementation would be a pair of arrays holding data for AI file names (string) and a player name (string) for that AI. A random index from this array pair is taken to populate the AI with personality. The chosen AI file is started for them and their player name set to the accompanying player name.

Of course this could be extended. If there are enough AI personalities to select from then duplicate selections could be avoided by treating the AI pair as a list/set data structure and removing personalities from it that get selected. It might also be desirable to have multiple player names for the same AI personality, in which case the player name array could be turned into a 2 dimensional array with the second index being used to support multiple player names.
 
Level 2
Joined
Aug 24, 2017
Messages
18
A possible implementation would be a pair of arrays holding data for AI file names (string) and a player name (string) for that AI. A random index from this array pair is taken to populate the AI with personality. The chosen AI file is started for them and their player name set to the accompanying player name.

That definitely sounds complex. But exactly what triggers were implemented in this case? I mean like what are the Events, Conditions and Actions used in order for such implementation to be functional?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
You can always see how they were implemented in the maps you were referring to. Even if "protected" you can still extract the JASS map script using MPQEdit and take a peek.

There would need to be a trigger run at map initialization to populate (set) the array pair full of data. This is pretty much hard coded and would involve AI file path strings and name strings.

Generally the decision of AI personalities should be run at either the map initialization, or when race selection occurs (in the case of more complex modified melee maps where there may be a selection dialog). Conditions are likely not needed. The actions would be something like a loop for each computer player, possibly with an if/then/else action to detect computer slots. For each computer player it then selects a random index in the array pair to load their AI from. It would start the AI script at the corresponding path and then set the player's name to the corresponding name.
 
Status
Not open for further replies.
Top