Game Warcraft

GitHub – szszss/SWATCodeGen: A Code Generator for SWAT:Aftermath the WC3 map

Video Warcraft 3 swat

SWATCodeGen is a Code Generator for a WC3 map named “SWAT Aftermath”. It can generate a code with any ranks, any classes, any talents(Anyway,restricted by class) and any medals.

SkyDrive: 中文 English

DropBox: 中文 English

Bạn đang xem: GitHub – szszss/SWATCodeGen: A Code Generator for SWAT:Aftermath the WC3 map

BaiduPan: 中文

#Known Problems An player’s id which contains SPECIAL non-ascii character may cause the generated code unusable. That means most Unicode names such as “phrātēr”, “幽幽sama一生推” and “安らかに眠れ” are ( at least, “should be” ) available. However, in a few status, it will fail. I don’t know why it happen. Maybe it depends on the amount of Unicode character, or… just some mum f**kers don’t know how to use a such easy software. Sometime the auto-copy may fail, but you can manually copy it.

All right, cracker boy, I’m sure that you don’t care about a crude gui program. So let’s talk about the damn algorithm of SWAT:AM.

This algorith has three stages : Raw codes generating, Mixing, and Disordering.

Raw code generating is the first and most important stage, it has two passes, both pass are parallel. Every pass will generate a raw code. So this stage will generate two raw codes.

  • The pass one is relative simple. First, it will pick a random even integer from 0, 2, 4, 6, and 8. We name it the Seed.
  • Second, it will generate the Normalized Talent by player’s Class Code and Talent Code.

Class (Class Code)) Talent (Talent Code) Normalized Talent Covert Sniper (0) Courage (0) 0 Wiring (1) 1 Running (2) 2 Thinkering (5) 3 Field Medic (1) Courage (0) 0 Wiring (1) 1 Toughness (4) 2 Hacking (6) 3 Tactician (2) Courage (0) 0 Wiring (1) 1 Running (2) 2 Hacking (6) 3 Psychologist (3) Courage (0) 0 Wiring (1) 1 Spotting (3) 2 Hacking (6) 3 Heavy Ordnance (4) Courage (0) 0 Running (2) 1 Toughness (4) 2 Thinkering (5) 3 Demolitions (5) Courage (0) 0 Running (2) 1 Toughness (4) 2 Spotting (3) 3 Cyborg (6) Courage (0) 0 Spotting (3) 1 Running (2) 2 Hacking (6) 3 Pyrotechnician (7) Courage (0) 0 Spotting (3) 1 Thinkering (5) 2 Toughness (4) 3 Watchman (8~9) Courage (0) 0 Toughness (4) 1 Thinkering (5) 2 Spotting (3) 3 Maverick (10~14) Courage (0) 0 Running (2) 1 Hacking (6) 2 Thinkering (5) 3 Tech Ops (15) Courage (0) 0 Wiring (1) 1 Thinkering (5) 2 Hacking (6) 3 Umbrella Lolita (16) Courage (0) 0 Wiring (1) 1 Spotting (3) 2 Toughness (4) 3

Notice that the Watchman and the Maverick have multiple class, because they have multiple weapon. And not all normalizations are ordered. Maybe it’s designer’s mistake, or… a crack counter-measure?

  • And then, there are some normalizing.

Class (Class Code)) Normalizing Cyborg (6) Armour Code = 2 Watchman (8) Armour Code = 0; Class Code = 6 Watchman (9) Armour Code = 1; Class Code = 6 Maverick,TechOps,Lolita(>9) Class Code -= 10 ; Seed++

Oh, and this is the Armour Code table:

Armour (Armour Code)) Light (0) Medium (1) Heavy (2) Advanced (3)

  • After normalizing, if Armour Code > 2, clamp it to 2. (In fact, it’s impossible that the Armour Code is greater than 2, since it has been normalized.)
  • And then, it will obscure the Level Code, the level code equals subtracting one from player’s level. ( Level Code = Level – 1, i.e. a level 1 player’s level code is 0, a level 12 player’s level code is 11 )

The medalX are The Medal Amount X, which are the amounts of six kinds of medal that player has got.

Medal (X) Max amount Key to the City (1) 1 Medal of Honor (2) 1 Police Combat Cross (3) 1 Commendation Bar (4) 1 Life Saving Award (5) 1 Recognition for Exceptional Merit (6) 3

The diff is the Difficulty Code, means the hardest difficulty that the player has defeated.

Sorry but I forgot to record the meaning of Difficulty Code… Anyway, it’s certainly that 4 is the maximum.

For short, it is:

Remember that all divisions in this algorithm are exact divisions:

It’s no doubt that the trait, spec are the Trait Code and the Spec Code.

Trait (Trait Code)) Skilled (0) Gifted (1) Survivalist (2) Dragoon (3) Acrobat (4) Swift Learner (5) Healer (6) Flower Child (7) Chem. Reliant (8) Rad. Resistant (9) Gadgeteer (10) Prowler (11) Energizer (12) Pack Rat (13) Engineer (14) Reckless (15) Specialization (Spec Code)) Weaponry (0) Power Armor (1) Energy Cells (2) Cybernetics (3) Triage (4) Chemistry (5) Leadership (6) Robotics (7) Espionage (8)

  • As you see, now we got an integer. However, we have to stringize it.

FixLength is used to ensure the iCodeA has enough length. It will fill ‘0’ in the head of string if it is too short.

  • Now, we have the first Raw code.
  • We are going to talk about the pass two. However, I wanna stress again that both passes are parallel. Neither of them requires the other’s result. THAT MEANS THE NORMALIZATIONS AND OBSCURING IN PASS ONE WON’T AFFECT PASS TWO!
  • The pass two has some redundant codes. I skip them since they won’t affect the result.
  • First, it will hash player’s name, generates the Hashed Name.

You may noticed that the hashing of Unicode character is very simple. That means hashing “古明地恋” and “芙兰朵露” will get same results, and the players whose hashed names are equal can share codes.

  • And then, it will generate code and stringize it.

The talent is the Talent Code.

Talent (Talent Code)) Courage (0) Wiring (1) Running (2) Spotting (3) Toughness (4) Thinkering (5) Hacking (6)

  • Now, we got the second Raw code!

Mixing is the second stage, and it requires the result of stage one. It will mix two raw codes generated by stage one.


This is a C# code, if you want to port it to Java or Jass, don’t forget the difference of Substring between different languages.

Disordering is the last stage, it will disorder the MixedCode. ( However, the mixing is also a disordering, isn’t? )

  • As you see, first, it will pick the first number of Mixed Code, and use it as factor.
  • The first number will keep its position, and the next 15 numbers will be disordered by the factor.
  • And now, you get the Final Code!

Related Articles

Back to top button