From 1b5f2ed0031173b3b3415deb5d85897dd019f154 Mon Sep 17 00:00:00 2001 From: Ulukyn Date: Tue, 4 Feb 2020 00:24:57 +0100 Subject: [PATCH] Merge branch 'ark' --- .../src/entities_game_service/admin.cpp | 13 +- .../mission_manager/missions_commands.cpp | 143 ++++++++++++++++-- .../player_manager/character.cpp | 32 ++++ .../player_manager/character.h | 8 + .../player_manager/character_inlines.h | 7 + 5 files changed, 186 insertions(+), 17 deletions(-) diff --git a/ryzom/server/src/entities_game_service/admin.cpp b/ryzom/server/src/entities_game_service/admin.cpp index 8375b4f91..faf29ecf4 100644 --- a/ryzom/server/src/entities_game_service/admin.cpp +++ b/ryzom/server/src/entities_game_service/admin.cpp @@ -9057,14 +9057,21 @@ NLMISC_COMMAND(openTargetApp, "open target app", "") } //---------------------------------------------------------------------------- -NLMISC_COMMAND(openTargetUrl, "Open target url", " ") +// (ulukyn) Very special case to use with ARK. +// !!! Never let user call openTargetUrl with a custom url or player +// will able to sign any url with server salt. +// It's why the url are hardcoded here +NLMISC_COMMAND(openTargetUrl, "Open target url", " [bullying]") { - if (args.size() < 2) + if (args.size() < 1) return false; GET_CHARACTER - c->sendUrl(args[1]); + if (args.size() > 1 && args[1] == "1") + c->sendUrl("app_arcc action=mScript_Run&script_name=TalkNpc&bullying=1&command=reset_all"); + else + c->sendUrl("app_arcc action=mScript_Run&script_name=TalkNpc&command=reset_all"); } diff --git a/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp b/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp index 41f27c0c9..b5797331c 100644 --- a/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp +++ b/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp @@ -4027,16 +4027,33 @@ NLMISC_COMMAND(stopMoveBot,"stop move of a bot"," []") GET_ACTIVE_CHARACTER2 if (c) + { + const CEntityId &target = c->getTarget(); + if (target == CEntityId::Unknown) + { + log.displayNL("ERR: target"); + return true; + } + + TargetRowId = TheDataset.getDataSetRow(target); + TDataSetRow stoppedNpc = c->getStoppedNpc(); + if (stoppedNpc == TargetRowId) + return true; + + if (TheDataset.isAccessible(stoppedNpc)) + { + CharacterBotChatBeginEnd.BotChatEnd.push_back(c->getEntityRowId()); + CharacterBotChatBeginEnd.BotChatEnd.push_back(stoppedNpc); + } CharacterBotChatBeginEnd.BotChatStart.push_back(c->getEntityRowId()); - - const CEntityId &target = c->getTarget(); - if (target == CEntityId::Unknown) + c->setStoppedNpc(TargetRowId); + c->setStoppedNpcTick(); + } + else { - log.displayNL("ERR: target"); + log.displayNL("ERR: user"); return true; } - - TargetRowId = TheDataset.getDataSetRow(target); } else { @@ -4058,7 +4075,7 @@ NLMISC_COMMAND(stopMoveBot,"stop move of a bot"," []") } -NLMISC_COMMAND(startMoveBot,"start move of a bot"," []") +NLMISC_COMMAND(startMoveBot,"start move bot or previous stopped bot"," []") { if ( args.size() < 1 ) return false; @@ -4073,17 +4090,16 @@ NLMISC_COMMAND(startMoveBot,"start move of a bot"," []") GET_ACTIVE_CHARACTER2 if (c) + { CharacterBotChatBeginEnd.BotChatEnd.push_back(c->getEntityRowId()); - - const CEntityId &target = c->getTarget(); - if (target == CEntityId::Unknown) + TargetRowId = c->getStoppedNpc(); + c->setStoppedNpc(TDataSetRow()); + } + else { - log.displayNL("ERR: target"); + log.displayNL("ERR: user"); return true; } - - log.displayNL("%s", target.toString().c_str()); - TargetRowId = TheDataset.getDataSetRow(target); } else { @@ -4104,3 +4120,102 @@ NLMISC_COMMAND(startMoveBot,"start move of a bot"," []") CharacterBotChatBeginEnd.BotChatEnd.push_back(TargetRowId); log.displayNL("OK"); } + + +NLMISC_COMMAND(manageBuilding, "Manage a building", " ") +{ + if (args.size() < 2) return false; + + GET_ACTIVE_CHARACTER + + string action = args[1]; // trigger_in, trigger_out, add_guild_room, add_player_room + + if (action == "trigger_in" && args.size() == 3) + { + uint32 liftId; + NLMISC::fromString(args[2], liftId); + CBuildingManager::getInstance()->addTriggerRequest(c->getEntityRowId(), liftId); + } + else if (action == "trigger_out") + { + CBuildingManager::getInstance()->removeTriggerRequest(c->getEntityRowId()); + + } + else if (action == "add_guild_room" && args.size() == 3) + { + CBuildingPhysicalGuild * building = dynamic_cast(CBuildingManager::getInstance()->getBuildingPhysicalsByName(args[2])); + if (building) + building->addGuild(c->getGuildId()); + else + { + log.displayNL("KO: no building"); + return true; + } + } + else if (action == "add_player_room" && args.size () == 3) + { + CBuildingPhysicalPlayer * building = dynamic_cast(CBuildingManager::getInstance()->getBuildingPhysicalsByName(args[2])); + if (building) + building->addPlayer(c->getId()); + else + { + log.displayNL("KO: no building"); + return true; + } + } + else if (action == "buy_guild_room" && args.size () == 3) + { + CBuildingPhysicalGuild * building = dynamic_cast(CBuildingManager::getInstance()->getBuildingPhysicalsByName(args[2])); + if (building) + { + CGuild * guild = CGuildManager::getInstance()->getGuildFromId(c->getGuildId()); + if (guild != NULL) + guild->setBuilding(building->getAlias()); + else + { + log.displayNL("KO: no guild"); + return true; + } + } + } + else if (action == "buy_player_room" && args.size () == 3) + { + CBuildingPhysicalPlayer * building = dynamic_cast(CBuildingManager::getInstance()->getBuildingPhysicalsByName(args[2])); + if ( building ) + CBuildingManager::getInstance()->buyBuilding(c->getId(), building->getAlias()); + else + { + log.displayNL("KO: no building"); + return true; + } + } + else if (action == "set_player_room" && args.size () == 3) + { + /* CBuildingPhysicalPlayer * building = dynamic_cast(CBuildingManager::getInstance()->getBuildingPhysicalsByName(args[2])); + if ( building ) + { + c->getRoomInterface().setBuilding(building); + building->addPlayer(c->getId()); + } + else + { + log.displayNL("KO: no building"); + return true; + }*/ + } + else if (action == "get_access_room" && args.size () == 3) + { + + CCharacter *owner = PlayerManager.getCharacterByName(CShardNames::getInstance().makeFullNameFromRelative(c->getHomeMainlandSessionId(), args[2])); + if (owner) + owner->addRoomAccessToPlayer(c->getId()); + else + { + log.displayNL("KO: no owner"); + return true; + } + } + + log.displayNL("OK"); + return true; +} diff --git a/ryzom/server/src/entities_game_service/player_manager/character.cpp b/ryzom/server/src/entities_game_service/player_manager/character.cpp index 057f3fef0..349b9e1a3 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -396,6 +396,7 @@ CCharacter::CCharacter() _LastTickSufferGooDamage = CTickEventHandler::getGameCycle(); _LastTickSaved = CTickEventHandler::getGameCycle(); _LastTickCompassUpdated = CTickEventHandler::getGameCycle(); + _LastTickNpcStopped = 0; // harvest related resetHarvestInfos(); _HarvestOpened = false; @@ -1617,6 +1618,21 @@ uint32 CCharacter::tickUpdate() removeMissionFromHistories(missionAlias); } } + + if (_LastTickNpcStopped && CTickEventHandler::getGameCycle() > _LastTickNpcStopped) + { + nlinfo("ULU: CTickEventHandler::getGameCycle() > _LastTickNpcStopped"); + TDataSetRow stoppedNpc = getStoppedNpc(); + if (TheDataset.isAccessible(stoppedNpc)) + { + nlinfo("ULU: stop bot"); + CharacterBotChatBeginEnd.BotChatEnd.push_back(getEntityRowId()); + CharacterBotChatBeginEnd.BotChatEnd.push_back(stoppedNpc); + } + _LastTickNpcStopped = 0; + setStoppedNpc(TDataSetRow()); + } + return nextUpdate; } // tickUpdate // @@ -22520,6 +22536,22 @@ CAdminProperties &CCharacter::getAdminProperties() return *_AdminProperties; } +//------------------------------------------------------------------------------ + +void CCharacter::setStoppedNpc(const TDataSetRow &npc) +{ + _StoppedNpc = npc; +} + +//------------------------------------------------------------------------------ + +void CCharacter::setStoppedNpcTick() +{ + nlinfo("ULU: setStopNpcTick in 60s"); + _LastTickNpcStopped = CTickEventHandler::getGameCycle() + 10*60; +} + + //------------------------------------------------------------------------------ void CCharacter::setMonitoringCSR(const TDataSetRow &csr) diff --git a/ryzom/server/src/entities_game_service/player_manager/character.h b/ryzom/server/src/entities_game_service/player_manager/character.h index 735a6ceb1..fdc7e4a63 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.h +++ b/ryzom/server/src/entities_game_service/player_manager/character.h @@ -2259,6 +2259,11 @@ public: const TDataSetRow &getMonitoringCSR(); void setMonitoringCSR(const TDataSetRow &csr); + /// accessors to the stopped npc + const TDataSetRow &getStoppedNpc(); + void setStoppedNpc(const TDataSetRow &npc); + void setStoppedNpcTick(); + /// get death penalties CDeathPenalties &getDeathPenalties(); @@ -3344,6 +3349,7 @@ private: NLMISC::TGameCycle _LastTickSaved; NLMISC::TGameCycle _LastTickCompassUpdated; + NLMISC::TGameCycle _LastTickNpcStopped; /// permanent score modifiers (given by bricks) sint32 _ScorePermanentModifiers[SCORES::NUM_SCORES]; @@ -3696,6 +3702,8 @@ private: /// number of creatures attacking the player uint8 _AggroCount; + TDataSetRow _StoppedNpc; + /// guild id of the player uint32 _GuildId; /// guild id of the player diff --git a/ryzom/server/src/entities_game_service/player_manager/character_inlines.h b/ryzom/server/src/entities_game_service/player_manager/character_inlines.h index 0bacf5b68..1b2261da8 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character_inlines.h +++ b/ryzom/server/src/entities_game_service/player_manager/character_inlines.h @@ -742,6 +742,13 @@ inline const TDataSetRow& CCharacter::getMonitoringCSR() //------------------------------------------------------------------------------ +inline const TDataSetRow& CCharacter::getStoppedNpc() +{ + return _StoppedNpc; +} + +//------------------------------------------------------------------------------ + inline float CCharacter::nextDeathPenaltyFactor() const { return _NextDeathPenaltyFactor;