From 417b42487d65684c6862ee6c6dd23085c8923252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves?= Date: Thu, 21 Nov 2019 14:57:58 +0100 Subject: [PATCH] Merge with Ark --- ryzom/server/src/ai_service/nf_grp_npc.cpp | 1 + .../src/entities_game_service/admin.cpp | 2 + .../entities_game_service/death_penalties.h | 7 ++ .../mission_manager/missions_commands.cpp | 54 +++++++++++- .../player_manager/character.cpp | 2 +- .../player_manager/character.h | 4 +- .../player_manager/character_inlines.h | 9 ++ .../progression/progression_pve.cpp | 88 ++++++++++++++++++- 8 files changed, 163 insertions(+), 4 deletions(-) diff --git a/ryzom/server/src/ai_service/nf_grp_npc.cpp b/ryzom/server/src/ai_service/nf_grp_npc.cpp index 5444a3e3b..dae012df2 100644 --- a/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -2997,6 +2997,7 @@ void setEventCode_sss_(CStateInstance* entity, CScriptStack& stack) strFindReplace(code, "http://", ""); strFindReplace(code, "https://", ""); strFindReplace(code, "/index.php?", " "); + strFindReplace(code, " &", " "); CGroup* group = entity->getGroup(); FOREACH(botIt, CCont, group->bots()) diff --git a/ryzom/server/src/entities_game_service/admin.cpp b/ryzom/server/src/entities_game_service/admin.cpp index a94e88b40..ff24dd444 100644 --- a/ryzom/server/src/entities_game_service/admin.cpp +++ b/ryzom/server/src/entities_game_service/admin.cpp @@ -8207,6 +8207,8 @@ NLMISC_COMMAND(eScript, "executes a script on an event npc group", " pos = arg.find("(eid:"); } + strFindReplace(arg, "#item:", ""); + strFindReplace(arg, "#rrp:", ""); msgout.serial(arg); } CWorldInstances::instance().msgToAIInstance2(instanceNumber, msgout); diff --git a/ryzom/server/src/entities_game_service/death_penalties.h b/ryzom/server/src/entities_game_service/death_penalties.h index 7f9e589ec..02d3e48fb 100644 --- a/ryzom/server/src/entities_game_service/death_penalties.h +++ b/ryzom/server/src/entities_game_service/death_penalties.h @@ -62,6 +62,13 @@ public: updataDb(user); } + double getDeathXPToGain() { return _DeathXPToGain - _CurrentDeathXP; } + void addDeathXP(CCharacter *user, double xp) + { + _CurrentDeathXP += xp; + updataDb(*user); + } + void addDeath(CCharacter& user, float deathPenaltyFactor); uint32 updateResorption( CCharacter& user ); 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 05ff2dc23..24fec4685 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 @@ -36,6 +36,7 @@ #include "team_manager/team.h" #include "team_manager/team_manager.h" #include "weather_everywhere.h" +#include "death_penalties.h" #include "mission_manager/mission_team.h" #include "mission_manager/mission_step_ai.h" #include "mission_manager/mission_guild.h" @@ -3103,6 +3104,30 @@ NLMISC_COMMAND(getPlayerPets, "get player pets", "") return true; } + +//---------------------------------------------------------------------------- +NLMISC_COMMAND(spawnPlayerPet, "spawn player pet", " ") +{ + if (args.size() < 2) + return false; + + GET_ACTIVE_CHARACTER + + uint32 index; + fromString(args[0], index); + + c->setRespawnMainLandInTown(true); + c->spawnCharacterAnimal(index); + c->setRespawnMainLandInTown(false); + + log.displayNL("OK"); + return true; +} + + + + + //---------------------------------------------------------------------------- NLMISC_COMMAND(setPlayerPetName, "change the name of a player pet", " ") { @@ -3113,7 +3138,10 @@ NLMISC_COMMAND(setPlayerPetName, "change the name of a player pet", " setAnimalName(index, customName); log.displayNL("OK"); return true; @@ -3532,6 +3560,30 @@ NLMISC_COMMAND(addXp, "Gain experience in a given skills", " [ return true; } +NLMISC_COMMAND(removeDp, "Update the DP", " ") +{ + if (args.size() < 2) return false; + + GET_ACTIVE_CHARACTER + + + double dpToGain = c->getDeathPenalties().getDeathXPToGain(); + log.displayNL("%d", dpToGain); + + uint32 remove; + NLMISC::fromString(args[1], remove); + + if (remove <= 100 && remove >0) + { + dpToGain = remove * (dpToGain / 100); + c->getDeathPenalties().addDeathXP(c, dpToGain); + } + log.displayNL("%d", dpToGain); + + return true; +} + + NLMISC_COMMAND(addBricks, "Specified player learns given brick", " ") { if (args.size() != 2) return false; 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 234602176..d9bfa8455 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -22514,7 +22514,7 @@ void CCharacter::setMonitoringCSR(const TDataSetRow &csr) //------------------------------------------------------------------------------ -const CDeathPenalties &CCharacter::getDeathPenalties() const +CDeathPenalties &CCharacter::getDeathPenalties() { return *_DeathPenalties; } 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 324e3baab..df65f9922 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.h +++ b/ryzom/server/src/entities_game_service/player_manager/character.h @@ -2260,7 +2260,7 @@ public: void setMonitoringCSR(const TDataSetRow &csr); /// get death penalties - const CDeathPenalties &getDeathPenalties() const; + CDeathPenalties &getDeathPenalties(); float nextDeathPenaltyFactor() const; void resetNextDeathPenaltyFactor(); @@ -2600,6 +2600,8 @@ public: uint32 getLastMountTick() const; uint32 getLastFreeMount() const; uint32 getLastExchangeMount() const; + bool getRespawnMainLandInTown() const; + void setRespawnMainLandInTown(bool status); const std::list &getLastLogStats() const; void updateConnexionStat(); 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 ad13e29fa..0bacf5b68 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 @@ -1049,6 +1049,15 @@ inline uint32 CCharacter::getLastExchangeMount() const return _LastExchangeMount; } +inline bool CCharacter::getRespawnMainLandInTown() const +{ + return _RespawnMainLandInTown; +} + +inline void CCharacter::setRespawnMainLandInTown(bool status) +{ + _RespawnMainLandInTown = status; +} //------------------------------------------------------------------------------ inline const std::list& CCharacter::getLastLogStats() const diff --git a/ryzom/server/src/entities_game_service/progression/progression_pve.cpp b/ryzom/server/src/entities_game_service/progression/progression_pve.cpp index 23e12694c..15d464cab 100644 --- a/ryzom/server/src/entities_game_service/progression/progression_pve.cpp +++ b/ryzom/server/src/entities_game_service/progression/progression_pve.cpp @@ -69,6 +69,7 @@ #include "player_manager/player.h" #include "team_manager/team_manager.h" #include "pvp_manager/pvp.h" +#include "shop_type/named_items.h" #include "pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.h" #include "server_share/r2_variables.h" @@ -355,7 +356,92 @@ void CCharacterProgressionPVE::creatureDeath(TDataSetRow creature) { CCharacter* player = PlayerManager.getChar(*itPlayer); if (player) - player->sendUrl(url); + { + if (url.substr(0, 6) == "#item:") + { + nlinfo("item"); + vector items_infos; + NLMISC::splitString(url, ":", items_infos); + if (items_infos.size() == 5) + { // item sheet:quality:quantity + nlinfo("item sheet"); + INVENTORIES::TInventory selected_inv = INVENTORIES::toInventory(items_infos[1].c_str()); + if (selected_inv != INVENTORIES::temporary && selected_inv !=INVENTORIES::temporary) + selected_inv = INVENTORIES::bag; + + string sheetname = items_infos[2]+".sitem"; + CSheetId sheet = CSheetId(sheetname.c_str()); + if (sheet != CSheetId::Unknown) + { + + uint16 quality; + NLMISC::fromString(items_infos[3], quality); + uint16 quantity; + NLMISC::fromString(items_infos[4], quantity); + + CGameItemPtr item; + if (quantity == 0) + item = GameItemManager.createItem(sheet, quality, false, false); + else + { + CMissionItem mItem; + items_infos[0] = items_infos[2]; + items_infos[1] = items_infos[3]; + items_infos[2] = "0"; + items_infos.resize(3); + mItem.buildFromScript(items_infos); + item = mItem.createItem(quantity); + } + + if (item != NULL) + { + if (player->addItemToInventory(selected_inv, item)) + { + SM_STATIC_PARAMS_3(params, STRING_MANAGER::integer, STRING_MANAGER::item, STRING_MANAGER::integer); + params[0].Int = quantity; + params[1].SheetId = sheet; + params[2].Int = quality; + PHRASE_UTILITIES::sendDynamicSystemMessage(player->getEntityRowId(), "AUTO_LOOT_SUCCESS", params); + } + else + { + item.deleteItem(); + } + } + } + } + else if (items_infos.size() == 4) + { // named item id:quantity + nlinfo("named item"); + INVENTORIES::TInventory selected_inv = INVENTORIES::toInventory(items_infos[1].c_str()); + if (selected_inv != INVENTORIES::temporary && selected_inv !=INVENTORIES::temporary) + selected_inv = INVENTORIES::bag; + string name = items_infos[2]; + + uint16 quantity; + NLMISC::fromString(items_infos[3], quantity); + + CGameItemPtr item = CNamedItems::getInstance().createNamedItem(name, quantity); + if (item != NULL) + { + if (player->addItemToInventory(selected_inv, item)) { + SM_STATIC_PARAMS_2(params, STRING_MANAGER::dyn_string_id, STRING_MANAGER::integer); + params[0].StringId = item->sendNameId(player); + params[1].Int = quantity; + PHRASE_UTILITIES::sendDynamicSystemMessage(player->getEntityRowId(),"MIS_RECV_NAMED_ITEM", params); + } + else + { + item.deleteItem(); + } + } + } + } + else + { + player->sendUrl(url); + } + } } }