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.

--HG--
branch : gsoc2011-guildmissions
This commit is contained in:
Fabien_HENON 2011-05-31 16:22:57 +02:00
parent db5248f694
commit bab4b3af21
4 changed files with 79 additions and 11 deletions

View file

@ -1304,9 +1304,9 @@
<CONTEXT_VALUE VALUE="zorai_newbie"/> <CONTEXT_VALUE VALUE="zorai_newbie"/>
</COMBO_VALUES> </COMBO_VALUES>
</PARAMETER> </PARAMETER>
<PARAMETER NAME="nb_guild_members_needed" TYPE="string" VISIBLE="true"> <!--<PARAMETER NAME="nb_guild_members_needed" TYPE="string" VISIBLE="true">
<DEFAULT_VALUE VALUE="1" /> <DEFAULT_VALUE VALUE="1" />
</PARAMETER> </PARAMETER>-->
</PRIMITIVE> </PRIMITIVE>
<PRIMITIVE CLASS_NAME="ring_scenario" TYPE="node" PARENT_CLASS="objective_parent"> <PRIMITIVE CLASS_NAME="ring_scenario" TYPE="node" PARENT_CLASS="objective_parent">

View file

@ -318,6 +318,11 @@ public:
bool isThereAJumpTo(const std::string &stepName); bool isThereAJumpTo(const std::string &stepName);
bool isGuildMission() const
{
return _Guild;
}
private: private:
std::string genPreRequisites(); std::string genPreRequisites();

View file

@ -193,6 +193,11 @@ protected:
CPhrase _RoleplayPhrase; CPhrase _RoleplayPhrase;
bool _HideObj; bool _HideObj;
// Option nb_guild_members_needed, available for each objective
int _NbGuildMembersNeeded;
std::string genNbGuildMembersNeededOption(CMissionData &md);
public: public:
void init(CMissionData &md, NLLIGO::IPrimitive *prim); void init(CMissionData &md, NLLIGO::IPrimitive *prim);

View file

@ -1630,6 +1630,20 @@ void CContentObjective::init(CMissionData &md, IPrimitive *prim)
_OverloadPhrase.initPhrase(md, prim, _OverloadObj, numEntry, params); _OverloadPhrase.initPhrase(md, prim, _OverloadObj, numEntry, params);
// init the roleplay phrase // init the roleplay phrase
_RoleplayPhrase.initPhrase(md, prim, _RoleplayObj, numEntry, params); _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; 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() string CContentObjective::genPhrase()
{ {
@ -1949,6 +1977,9 @@ public:
if (!_Place.empty()) if (!_Place.empty())
ret += " : "+_Place; ret += " : "+_Place;
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2004,6 +2035,8 @@ public:
if (!_Phrase.isEmpty()) if (!_Phrase.isEmpty())
ret += " : "+_Phrase.genScript(md); ret += " : "+_Phrase.genScript(md);
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2078,6 +2111,8 @@ public:
{ {
ret += ": "+_Place; ret += ": "+_Place;
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2151,6 +2186,8 @@ public:
if (i < _Mps.size()-1) if (i < _Mps.size()-1)
ret += "; "; ret += "; ";
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2276,6 +2313,8 @@ public:
if (i < _Items.size()-1) if (i < _Items.size()-1)
ret += "; "; ret += "; ";
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2349,6 +2388,8 @@ public:
if (i < _Items.size()-1) if (i < _Items.size()-1)
ret += "; "; ret += "; ";
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2479,7 +2520,8 @@ public:
if (!_Place.empty()) if (!_Place.empty())
ret += " : " + _Place; ret += " : " + _Place;
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2564,6 +2606,8 @@ public:
{ {
ret += " : "+_Npc; ret += " : "+_Npc;
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2645,6 +2689,8 @@ public:
{ {
ret += " : "+_Npc; ret += " : "+_Npc;
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2755,7 +2801,10 @@ public:
if (i < _Items.size()-1) if (i < _Items.size()-1)
ret += "; "; ret += "; ";
}; };
ret += " : "+_Npc +NL; ret += " : "+_Npc;
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL;
return ret; return ret;
} }
@ -2790,7 +2839,10 @@ public:
string ret; string ret;
ret = CContentObjective::genCode(md); 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; return ret;
} }
@ -2841,7 +2893,8 @@ public:
ret += "; "; ret += "; ";
} }
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2877,7 +2930,8 @@ public:
if (_SaveAll) if (_SaveAll)
ret += " : save_all"; ret += " : save_all";
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2950,7 +3004,8 @@ public:
if (i < _Skills.size()-1) if (i < _Skills.size()-1)
ret += "; "; ret += "; ";
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -2988,7 +3043,8 @@ public:
if (i < _Missions.size()-1) if (i < _Missions.size()-1)
ret += "; "; ret += "; ";
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -3026,7 +3082,8 @@ public:
if (i < _MsgContent.size()-1) if (i < _MsgContent.size()-1)
ret += " "; ret += " ";
} }
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;
@ -3242,7 +3299,8 @@ public:
ret += "ring_scenario : "; ret += "ring_scenario : ";
ret += _ScenarioTag; ret += _ScenarioTag;
// Add the 'nb_guild_members_needed' parameter if needed
ret += CContentObjective::genNbGuildMembersNeededOption(md);
ret += NL; ret += NL;
return ret; return ret;