void CHLDMBot :: handleWeapons () { // // Handle attacking at this point // if ( m_pEnemy && !hasSomeConditions(CONDITION_ENEMY_DEAD) && hasSomeConditions(CONDITION_SEE_CUR_ENEMY) && wantToShoot() && isVisible(m_pEnemy) && isEnemy(m_pEnemy) ) { CBotWeapon *pWeapon; pWeapon = getBestWeapon(m_pEnemy,true,true,(m_pEnemy==m_NearestBreakable)&&!rcbot_melee_only.GetBool()); if ( m_bWantToChangeWeapon && (pWeapon != NULL) && (pWeapon != getCurrentWeapon()) && pWeapon->getWeaponIndex() ) { //selectWeaponSlot(pWeapon->getWeaponInfo()->getSlot()); selectWeapon(pWeapon->getWeaponIndex()); } setLookAtTask((LOOK_ENEMY)); ///battack = true; if ( !handleAttack ( pWeapon, m_pEnemy ) ) { m_pEnemy = NULL; m_pOldEnemy = NULL; wantToShoot(false); } } }
void GameHandler::processMessage(NetComputer *computer, MessageIn &message) { GameClient &client = *static_cast<GameClient *>(computer); if (client.status == CLIENT_LOGIN) { if (message.getId() != PGMSG_CONNECT) return; std::string magic_token = message.readString(MAGIC_TOKEN_LENGTH); client.status = CLIENT_QUEUED; // Before the addPendingClient mTokenCollector.addPendingClient(magic_token, &client); return; } else if (client.status != CLIENT_CONNECTED) { return; } switch (message.getId()) { case PGMSG_SAY: handleSay(client, message); break; case PGMSG_NPC_TALK: case PGMSG_NPC_TALK_NEXT: case PGMSG_NPC_SELECT: case PGMSG_NPC_NUMBER: case PGMSG_NPC_STRING: handleNpc(client, message); break; case PGMSG_PICKUP: handlePickup(client, message); break; case PGMSG_USE_ITEM: handleUseItem(client, message); break; case PGMSG_DROP: handleDrop(client, message); break; case PGMSG_WALK: handleWalk(client, message); break; case PGMSG_EQUIP: handleEquip(client, message); break; case PGMSG_UNEQUIP: handleUnequip(client, message); break; case PGMSG_MOVE_ITEM: handleMoveItem(client, message); break; case PGMSG_ATTACK: handleAttack(client, message); break; case PGMSG_USE_SPECIAL_ON_BEING: handleUseSpecialOnBeing(client, message); break; case PGMSG_USE_SPECIAL_ON_POINT: handleUseSpecialOnPoint(client, message); break; case PGMSG_ACTION_CHANGE: handleActionChange(client, message); break; case PGMSG_DIRECTION_CHANGE: handleDirectionChange(client, message); break; case PGMSG_DISCONNECT: handleDisconnect(client, message); break; case PGMSG_TRADE_REQUEST: handleTradeRequest(client, message); break; case PGMSG_TRADE_CANCEL: case PGMSG_TRADE_AGREED: case PGMSG_TRADE_CONFIRM: case PGMSG_TRADE_ADD_ITEM: case PGMSG_TRADE_SET_MONEY: handleTrade(client, message); break; case PGMSG_NPC_BUYSELL: handleNpcBuySell(client, message); break; case PGMSG_RAISE_ATTRIBUTE: handleRaiseAttribute(client, message); break; case PGMSG_LOWER_ATTRIBUTE: handleLowerAttribute(client, message); break; case PGMSG_RESPAWN: // plausibility check is done by character class client.character->respawn(); break; case PGMSG_NPC_POST_SEND: handleNpcPostSend(client, message); break; case PGMSG_PARTY_INVITE: handlePartyInvite(client, message); break; case PGMSG_BEING_EMOTE: handleTriggerEmoticon(client, message); break; default: LOG_WARN("Invalid message type"); client.send(MessageOut(XXMSG_INVALID)); break; } }