| 6 | IMPLEMENT(Race_Jump); |
| 7 | |
| 8 | bool Race_Jump::execute(aithread &thread) const |
| 9 | { |
| 10 | // Retrieve parameters |
| 11 | WORD t_jmp, z_jmp, p_jmp; |
| 12 | thread.readTuple( std::tie(t_jmp, z_jmp, p_jmp) ); |
| 13 | |
| 14 | // should be AI_getClosestEnemyRace; gets closest enemy unit to region |
| 15 | // @TODO: BWAPI: Filters: IsEnemy, IsAlly, IsNeutral? |
| 16 | |
| 17 | // Get enemy race |
| 18 | Race race = Races::None; |
| 19 | if ( Broodwar->enemy() ) |
| 20 | race = Broodwar->enemy()->getRace(); |
| 21 | |
| 22 | /// Set the new script offset |
| 23 | switch ( race ) |
| 24 | { |
| 25 | case Races::Enum::Protoss: |
| 26 | thread.setScriptOffset( p_jmp ); |
| 27 | break; |
| 28 | case Races::Enum::Zerg: |
| 29 | thread.setScriptOffset( z_jmp ); |
| 30 | break; |
| 31 | default: |
| 32 | thread.setScriptOffset( t_jmp ); |
| 33 | break; |
| 34 | } |
| 35 | |
| 36 | // Save debug info and return |
| 37 | thread.saveDebug(Text::Green, this->getOpcode(), "p_%04X p_%04X p_%04X", t_jmp, z_jmp, p_jmp); |
| 38 | return true; |
| 39 | } |