From 91ec5b26eb06e7f4ad3dc24aaff64fcfd2fe06d3 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Tue, 31 May 2011 16:22:57 +0200 Subject: [PATCH] Changed: #1304: mission_compiler objectives: check and script generation mission compiler now checks if we are not asking several guild members to complete an objective whereas the mission is not a guild mission. It also generates the 'nb_guild_members_needed' parameter for objectives in the script. --- .../world_editor_classes.xml | 4 +- .../mission_compiler_lib/mission_compiler.h | 5 ++ .../leveldesign/mission_compiler_lib/step.h | 5 ++ .../mission_compiler_lib/step_content.cpp | 76 ++++++++++++++++--- 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/code/ryzom/common/data_leveldesign/leveldesign/world_editor_files/world_editor_classes.xml b/code/ryzom/common/data_leveldesign/leveldesign/world_editor_files/world_editor_classes.xml index 1e4f9d723..238158bbf 100644 --- a/code/ryzom/common/data_leveldesign/leveldesign/world_editor_files/world_editor_classes.xml +++ b/code/ryzom/common/data_leveldesign/leveldesign/world_editor_files/world_editor_classes.xml @@ -1304,9 +1304,9 @@ - + diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h index 756b3859d..6f993679b 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h @@ -318,6 +318,11 @@ public: bool isThereAJumpTo(const std::string &stepName); + bool isGuildMission() const + { + return _Guild; + } + private: std::string genPreRequisites(); diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h index e93db4524..9d2a053df 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h @@ -192,6 +192,11 @@ protected: std::vector _RoleplayObj; CPhrase _RoleplayPhrase; bool _HideObj; + + // Option nb_guild_members_needed, available for each objective + int _NbGuildMembersNeeded; + + std::string genNbGuildMembersNeededOption(CMissionData &md); public: void init(CMissionData &md, NLLIGO::IPrimitive *prim); diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp index 19d210f0f..c18709b1d 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp @@ -1630,6 +1630,20 @@ void CContentObjective::init(CMissionData &md, IPrimitive *prim) _OverloadPhrase.initPhrase(md, prim, _OverloadObj, numEntry, params); // init the roleplay phrase _RoleplayPhrase.initPhrase(md, prim, _RoleplayObj, numEntry, params); + + // check for the 'nb_guild_members_needed' option and see if it's correct for this mission + string nbGuildMembersNeeded = md.getProperty(prim, "nb_guild_members_needed", false, true); + if (nbGuildMembersNeeded.empty()) + nbGuildMembersNeeded = "1"; + if (!fromString(nbGuildMembersNeeded.c_str(), _NbGuildMembersNeeded)) + _NbGuildMembersNeeded = 1; + + // Check: + if (!md.isGuildMission() && _NbGuildMembersNeeded != 1) + { + string err = toString("primitive(%s): nb_guild_members_needed != 1 for non guild mission.", prim->getName().c_str()); + throw EParseException(prim, err.c_str()); + } } // --------------------------------------------------------------------------- @@ -1649,6 +1663,20 @@ string CContentObjective::genCode(CMissionData &md) return ret; } +// --------------------------------------------------------------------------- +std::string CContentObjective::genNbGuildMembersNeededOption(CMissionData &md) +{ + string ret = ""; + // If we are in a guild mission we add the 'nb_guild_members_needed' option to the script + if (md.isGuildMission()) + { + ret = "; nb_guild_members_needed: "; + ret += toString(_NbGuildMembersNeeded); + } + + return ret; +} + // --------------------------------------------------------------------------- string CContentObjective::genPhrase() { @@ -1949,6 +1977,9 @@ public: if (!_Place.empty()) ret += " : "+_Place; + + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2004,6 +2035,8 @@ public: if (!_Phrase.isEmpty()) ret += " : "+_Phrase.genScript(md); + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2078,6 +2111,8 @@ public: { ret += ": "+_Place; } + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2151,6 +2186,8 @@ public: if (i < _Mps.size()-1) ret += "; "; } + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2276,6 +2313,8 @@ public: if (i < _Items.size()-1) ret += "; "; } + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2349,6 +2388,8 @@ public: if (i < _Items.size()-1) ret += "; "; } + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2479,7 +2520,8 @@ public: if (!_Place.empty()) ret += " : " + _Place; - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2564,6 +2606,8 @@ public: { ret += " : "+_Npc; } + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2645,6 +2689,8 @@ public: { ret += " : "+_Npc; } + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2755,7 +2801,10 @@ public: if (i < _Items.size()-1) ret += "; "; }; - ret += " : "+_Npc +NL; + ret += " : "+_Npc; + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); + ret += NL; return ret; } @@ -2790,7 +2839,10 @@ public: string ret; ret = CContentObjective::genCode(md); - ret += "give_money : "+_Amount+" : "+_Npc+NL; + ret += "give_money : "+_Amount+" : "+_Npc; + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); + ret += NL; return ret; } @@ -2841,7 +2893,8 @@ public: ret += "; "; } } - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2877,7 +2930,8 @@ public: if (_SaveAll) ret += " : save_all"; - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2950,7 +3004,8 @@ public: if (i < _Skills.size()-1) ret += "; "; } - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -2988,7 +3043,8 @@ public: if (i < _Missions.size()-1) ret += "; "; } - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -3026,7 +3082,8 @@ public: if (i < _MsgContent.size()-1) ret += " "; } - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret; @@ -3242,7 +3299,8 @@ public: ret += "ring_scenario : "; ret += _ScenarioTag; - + // Add the 'nb_guild_members_needed' parameter if needed + ret += CContentObjective::genNbGuildMembersNeededOption(md); ret += NL; return ret;