bool CCommandAI::ExecuteStateCommand(const Command& c) { switch (c.id) { case CMD_FIRE_STATE: { owner->fireState = (int)c.params[0]; SetCommandDescParam0(c); selectedUnits.PossibleCommandChange(owner); return true; } case CMD_MOVE_STATE: { owner->moveState = (int)c.params[0]; SetCommandDescParam0(c); selectedUnits.PossibleCommandChange(owner); return true; } case CMD_REPEAT: { repeatOrders = !!c.params[0]; SetCommandDescParam0(c); selectedUnits.PossibleCommandChange(owner); return true; } case CMD_TRAJECTORY: { owner->useHighTrajectory = !!c.params[0]; SetCommandDescParam0(c); selectedUnits.PossibleCommandChange(owner); return true; } case CMD_ONOFF: { if (c.params[0] == 1) { owner->Activate(); } else if (c.params[0] == 0) { owner->Deactivate(); } SetCommandDescParam0(c); selectedUnits.PossibleCommandChange(owner); return true; } case CMD_CLOAK: { if (c.params[0] == 1) { owner->wantCloak = true; } else if(c.params[0]==0) { owner->wantCloak = false; owner->curCloakTimeout = gs->frameNum + owner->cloakTimeout; } SetCommandDescParam0(c); selectedUnits.PossibleCommandChange(owner); return true; } case CMD_STOCKPILE: { int change = 1; if (c.options & RIGHT_MOUSE_KEY) { change *= -1; } if (c.options & SHIFT_KEY) { change *= 5; } if (c.options & CONTROL_KEY) { change *= 20; } stockpileWeapon->numStockpileQued += change; if (stockpileWeapon->numStockpileQued < 0) { stockpileWeapon->numStockpileQued = 0; } UpdateStockpileIcon(); return true; } } return false; }
bool CCommandAI::ExecuteStateCommand(const Command& c) { switch (c.GetID()) { case CMD_FIRE_STATE: { owner->fireState = (int)c.params[0]; SetCommandDescParam0(c); selectedUnitsHandler.PossibleCommandChange(owner); return true; } case CMD_MOVE_STATE: { owner->moveState = (int)c.params[0]; SetCommandDescParam0(c); selectedUnitsHandler.PossibleCommandChange(owner); return true; } case CMD_REPEAT: { if (c.params[0] == 1) { repeatOrders = true; } else if(c.params[0] == 0) { repeatOrders = false; } else { // cause some code parts need it to be either 0 or 1, // we can not accept any other values as valid return false; } SetCommandDescParam0(c); selectedUnitsHandler.PossibleCommandChange(owner); return true; } case CMD_TRAJECTORY: { owner->useHighTrajectory = !!c.params[0]; SetCommandDescParam0(c); selectedUnitsHandler.PossibleCommandChange(owner); return true; } case CMD_ONOFF: { if (c.params[0] == 1) { owner->Activate(); } else if (c.params[0] == 0) { owner->Deactivate(); } else { // cause some code parts need it to be either 0 or 1, // we can not accept any other values as valid return false; } SetCommandDescParam0(c); selectedUnitsHandler.PossibleCommandChange(owner); return true; } case CMD_CLOAK: { if (c.params[0] == 1) { owner->wantCloak = true; } else if(c.params[0] == 0) { owner->wantCloak = false; owner->curCloakTimeout = gs->frameNum + owner->cloakTimeout; } else { // cause some code parts need it to be either 0 or 1, // we can not accept any other values as valid return false; } SetCommandDescParam0(c); selectedUnitsHandler.PossibleCommandChange(owner); return true; } case CMD_STOCKPILE: { int change = 1; if (c.options & RIGHT_MOUSE_KEY) { change *= -1; } if (c.options & SHIFT_KEY) { change *= 5; } if (c.options & CONTROL_KEY) { change *= 20; } stockpileWeapon->numStockpileQued += change; if (stockpileWeapon->numStockpileQued < 0) { stockpileWeapon->numStockpileQued = 0; } UpdateStockpileIcon(); return true; } } // this is a custom lua command, calling CommandFallback // and ignoring the result as this can't stay in the queue if (nonQueingCommands.find(c.GetID()) != nonQueingCommands.end()) { eventHandler.CommandFallback(owner, c); return true; } return false; }