1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2011 Fabien HENON
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "mission_compiler.h"
24 #include "nel/ligo/primitive_utils.h"
27 using namespace NLMISC
;
28 using namespace NLLIGO
;
35 IStepContent
*IStepContent::createStepContent(CMissionData
&md
, NLLIGO::IPrimitive
*prim
)
38 prim
->getPropertyByName("class", className
);
40 IStepContentFactory
*factory
= CFactoryIndirect
<IStepContentFactory
, string
>::instance().getFactory(className
);
43 string err
= toString("Can't find factory for class '%s'", className
.c_str());
44 throw EParseException(prim
, err
.c_str());
47 IStepContent
*content
= factory
->createStepContent(md
, prim
);
51 void IStepContent::init(CMissionData
&md
, NLLIGO::IPrimitive
*prim
)
53 prim
->getPropertyByName("name", _ContentName
);
55 // parse the post actions
56 for (uint i
=0; i
<prim
->getNumChildren(); ++i
)
59 prim
->getChild(child
, i
);
63 IStepContent
*sc
= IStepContent::createStepContent(md
, child
);
65 _PostActions
.push_back(sc
);
70 std::string
IStepContent::genStepContentCode(CMissionData
&md
)
73 // call the derived class code generation
76 // generate the code for the post action
77 for (uint i
=0; i
<_PostActions
.size(); ++i
)
79 ret
+= _PostActions
[i
]->genCode(md
);
85 std::string
IStepContent::genStepContentPhrase()
89 // call ther derived class phrase generation
92 // generate the phrase for the post action
93 for (uint i
=0; i
<_PostActions
.size(); ++i
)
95 ret
+= _PostActions
[i
]->genPhrase();
101 void IStepContent::fillJump(CMissionData
&md
, std::set
<TJumpInfo
> &jumpPoints
)
103 for (uint i
=0; i
<_PostActions
.size(); ++i
)
105 _PostActions
[i
]->fillJump(md
, jumpPoints
);
110 ////////////////////// Actions and objectives /////////////////////
112 class CActionJumpTo
: public IStepContent
116 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
121 void init(CMissionData
&md
, IPrimitive
*prim
)
123 IStepContent::init(md
, prim
);
124 _JumpTo
= md
.getProperty(prim
, "target", true, false);
127 string
genCode(CMissionData
&md
)
129 if (!_JumpTo
.empty())
130 return "jump : "+_JumpTo
+NL
;
135 void fillJump(CMissionData
&md
, std::set
<TJumpInfo
> &jumpPoints
)
137 IStepContent::fillJump(md
, jumpPoints
);
138 jumpPoints
.insert(TJumpInfo(_JumpTo
, "", false));
142 REGISTER_STEP_CONTENT(CActionJumpTo
, "jump_to");
145 // ---------------------------------------------------------------------------
146 class CActionRecvMoney
: public IStepContent
151 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
156 void init(CMissionData
&md
, IPrimitive
*prim
)
158 IStepContent::init(md
, prim
);
159 _Amount
= md
.getProperty(prim
, "amount", true, false);
161 _Guild
= md
.getProperty(prim
, "guild", false, true) == "true";
162 // Check: if _Guild is true then check if we are in a guild mission
163 if (_Guild
&& !md
.isGuildMission())
165 string err
= toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim
->getName().c_str());
166 throw EParseException(prim
, err
.c_str());
170 string
genCode(CMissionData
&md
)
172 if (!_Amount
.empty())
175 ret
= "recv_money : "+_Amount
;
186 REGISTER_STEP_CONTENT(CActionRecvMoney
, "recv_money");
189 // ---------------------------------------------------------------------------
190 class CActionRecvChargePoint
: public IStepContent
194 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
199 void init(CMissionData
&md
, IPrimitive
*prim
)
201 IStepContent::init(md
, prim
);
202 _Amount
= md
.getProperty(prim
, "charge_points", true, false);
205 string
genCode(CMissionData
&md
)
207 if (!_Amount
.empty())
210 ret
= "recv_charge_point : "+_Amount
;
219 REGISTER_STEP_CONTENT(CActionRecvChargePoint
, "recv_charge_point");
222 // ---------------------------------------------------------------------------
223 class CActionGiveOutpostControl
: public IStepContent
227 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
232 void init(CMissionData
&md
, IPrimitive
*prim
)
234 IStepContent::init(md
, prim
);
235 _OutpostName
= md
.getProperty(prim
, "outpost_name", true, false);
238 string
genCode(CMissionData
&md
)
240 if (!_OutpostName
.empty())
243 ret
= "give_control : "+_OutpostName
;
252 REGISTER_STEP_CONTENT(CActionGiveOutpostControl
, "give_control");
255 // ---------------------------------------------------------------------------
256 class CActionSpawnMission
: public IStepContent
263 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
268 void init(CMissionData
&md
, IPrimitive
*prim
)
270 IStepContent::init(md
, prim
);
271 _MissionName
= md
.getProperty(prim
, "mission_name", true, false);
272 _GiverName
= md
.getProperty(prim
, "giver_name", true, false);
273 if (_GiverName
.empty())
275 throw EParseException(prim
, "giver_name is empty !");
278 _Guild
= md
.getProperty(prim
, "guild", false, true) == "true";
279 // Check: if _Guild is true then check if we are in a guild mission
280 if (_Guild
&& !md
.isGuildMission())
282 string err
= toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim
->getName().c_str());
283 throw EParseException(prim
, err
.c_str());
287 string
genCode(CMissionData
&md
)
290 if (!_MissionName
.empty())
292 ret
= "spawn_mission : " + _MissionName
+ " : " + _GiverName
;
300 REGISTER_STEP_CONTENT(CActionSpawnMission
, "spawn_mission");
303 // ---------------------------------------------------------------------------
304 class CActionChainMission
: public CActionSpawnMission
308 string
genCode(CMissionData
&md
)
311 if (!_MissionName
.empty())
315 return "chain_mission : " + _MissionName
+ " : " + _GiverName
+ NL
;
322 REGISTER_STEP_CONTENT(CActionChainMission
, "chain_mission");
325 // ---------------------------------------------------------------------------
326 class CActionEncycloUnlock
: public IStepContent
330 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
335 void init(CMissionData
&md
, IPrimitive
*prim
)
337 IStepContent::init(md
, prim
);
338 _AlbumThema
= md
.getProperty(prim
, "album_thema", true, false);
341 string
genCode(CMissionData
&md
)
343 if (!_AlbumThema
.empty())
344 return "encyclo_unlock : " + _AlbumThema
+ NL
;
350 REGISTER_STEP_CONTENT(CActionEncycloUnlock
, "encyclo_unlock");
353 // ---------------------------------------------------------------------------
354 class CActionHandleCreate
: public IStepContent
358 string _DespawnTimer
;
360 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
365 void init(CMissionData
&md
, IPrimitive
*prim
)
367 IStepContent::init(md
, prim
);
368 _Group
= md
.getProperty(prim
, "group", true, false);
369 _DespawnTimer
= md
.getProperty(prim
, "despawn_timer", true, false);
372 string
genCode(CMissionData
&md
)
376 if (!_DespawnTimer
.empty())
377 return "handle_create : " + _Group
+ " : " + _DespawnTimer
+ NL
;
379 return "handle_create : " + _Group
+ NL
;
386 REGISTER_STEP_CONTENT(CActionHandleCreate
, "handle_create");
389 // ---------------------------------------------------------------------------
390 class CActionHandleRelease
: public IStepContent
396 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
401 void init(CMissionData
&md
, IPrimitive
*prim
)
403 IStepContent::init(md
, prim
);
404 _Group
= md
.getProperty(prim
, "group", true, false);
407 string
genCode(CMissionData
&md
)
410 return "handle_release : " + _Group
+ NL
;
416 REGISTER_STEP_CONTENT(CActionHandleRelease
, "handle_release");
419 // ---------------------------------------------------------------------------
420 class CActionSetEventFaction
: public IStepContent
422 string _EventFaction
;
424 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
429 void init(CMissionData
&md
, IPrimitive
*prim
)
431 IStepContent::init(md
, prim
);
432 _EventFaction
= md
.getProperty(prim
, "event_faction", true, false);
435 string
genCode(CMissionData
&md
)
437 if (!_EventFaction
.empty())
438 return "set_event_faction : " + _EventFaction
+ NL
;
444 REGISTER_STEP_CONTENT(CActionSetEventFaction
, "set_event_faction");
447 // ---------------------------------------------------------------------------
448 class CActionSetRespawnPoints
: public IStepContent
451 vector
<string
> _RespawnPoints
;
454 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
459 void init(CMissionData
&md
, IPrimitive
*prim
)
461 IStepContent::init(md
, prim
);
462 _Continent
= md
.getProperty(prim
, "continent", true, false);
465 vs
= md
.getPropertyArray(prim
, "respawn_points", true, false);
467 for (uint i
=0; i
<vs
.size(); ++i
)
470 _RespawnPoints
.push_back(vs
[i
]);
474 s
= md
.getProperty(prim
, "hide_others", true, false);
475 _HideOthers
= NLMISC::toBool(s
);
478 string
genCode(CMissionData
&md
)
482 if (_Continent
.empty() || _RespawnPoints
.empty())
485 ret
= "set_respawn_points : " + _Continent
+ " : ";
487 for (uint i
= 0; i
< _RespawnPoints
.size(); i
++)
489 ret
+= _RespawnPoints
[i
];
490 if (i
< _RespawnPoints
.size() - 1)
494 ret
+= string(" : ") + (_HideOthers
?"true":"false");
501 REGISTER_STEP_CONTENT(CActionSetRespawnPoints
, "set_respawn_points");
504 // ---------------------------------------------------------------------------
505 class CActionRecvFactionPoint
: public IStepContent
510 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
515 void init(CMissionData
&md
, IPrimitive
*prim
)
517 IStepContent::init(md
, prim
);
519 _Faction
= md
.getProperty(prim
, "faction", true, false);
520 _Point
= md
.getProperty(prim
, "point", true, false);
523 string
genCode(CMissionData
&md
)
525 if (!_Faction
.empty() && !_Point
.empty())
526 return string("recv_faction_point : ")+_Faction
+" "+_Point
+NL
;
531 REGISTER_STEP_CONTENT(CActionRecvFactionPoint
, "recv_faction_point");
534 // ---------------------------------------------------------------------------
535 class CActionSDBSet
: public IStepContent
540 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
545 void init(CMissionData
&md
, IPrimitive
*prim
)
547 IStepContent::init(md
, prim
);
548 _SDBPath
= md
.getProperty(prim
, "sdb_path", true, false);
549 _SDBValue
= md
.getProperty(prim
, "sdb_value", true, false);
552 string
genCode(CMissionData
&md
)
556 if (_SDBPath
.empty() || _SDBValue
.empty())
559 ret
= "sdb_set : " + _SDBPath
+ " : " + _SDBValue
+ NL
;
564 REGISTER_STEP_CONTENT(CActionSDBSet
, "sdb_set");
567 // ---------------------------------------------------------------------------
568 class CActionSDBAdd
: public IStepContent
573 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
578 void init(CMissionData
&md
, IPrimitive
*prim
)
580 IStepContent::init(md
, prim
);
581 _SDBPath
= md
.getProperty(prim
, "sdb_path", true, false);
582 _SDBValue
= md
.getProperty(prim
, "sdb_value", true, false);
585 string
genCode(CMissionData
&md
)
589 if (_SDBPath
.empty() || _SDBValue
.empty())
592 ret
= "sdb_add : " + _SDBPath
+ " : " + _SDBValue
+ NL
;
597 REGISTER_STEP_CONTENT(CActionSDBAdd
, "sdb_add");
600 // ---------------------------------------------------------------------------
601 class CActionSDBPlayerAdd
: public IStepContent
606 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
611 void init(CMissionData
&md
, IPrimitive
*prim
)
613 IStepContent::init(md
, prim
);
614 _SDBPath
= md
.getProperty(prim
, "sdb_path", true, false);
615 _SDBValue
= md
.getProperty(prim
, "sdb_value", true, false);
618 string
genCode(CMissionData
&md
)
622 if (_SDBPath
.empty() || _SDBValue
.empty())
625 ret
= "sdb_player_add : " + _SDBPath
+ " : " + _SDBValue
+ NL
;
630 REGISTER_STEP_CONTENT(CActionSDBPlayerAdd
, "sdb_player_add");
633 // ---------------------------------------------------------------------------
634 class CActionSDBSetPvPPath
: public IStepContent
638 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
643 void init(CMissionData
&md
, IPrimitive
*prim
)
645 IStepContent::init(md
, prim
);
646 _SDBPath
= md
.getProperty(prim
, "sdb_path", true, false);
649 string
genCode(CMissionData
&md
)
653 if (_SDBPath
.empty())
656 ret
= "sdb_set_pvp_path : " + _SDBPath
+ NL
;
661 REGISTER_STEP_CONTENT(CActionSDBSetPvPPath
, "sdb_set_pvp_path");
664 // ---------------------------------------------------------------------------
665 class CActionSDBClearPvPPath
: public IStepContent
667 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
672 void init(CMissionData
&md
, IPrimitive
*prim
)
674 IStepContent::init(md
, prim
);
677 string
genCode(CMissionData
&md
)
679 string ret
= "sdb_clear_pvp_path" + NL
;
684 REGISTER_STEP_CONTENT(CActionSDBClearPvPPath
, "sdb_clear_pvp_path");
687 // ---------------------------------------------------------------------------
688 class CActionRecvFame
: public IStepContent
694 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
699 void init(CMissionData
&md
, IPrimitive
*prim
)
701 IStepContent::init(md
, prim
);
703 _Faction
= md
.getProperty(prim
, "faction", true, false);
704 _Fame
= md
.getProperty(prim
, "value", true, false);
706 _Guild
= md
.getProperty(prim
, "guild", false, true) == "true";
707 // Check: if _Guild is true then check if we are in a guild mission
708 if (_Guild
&& !md
.isGuildMission())
710 string err
= toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim
->getName().c_str());
711 throw EParseException(prim
, err
.c_str());
715 string
genCode(CMissionData
&md
)
717 if (!_Faction
.empty() && !_Fame
.empty())
720 ret
= "recv_fame : "+_Faction
+" "+_Fame
;
730 REGISTER_STEP_CONTENT(CActionRecvFame
, "recv_fame");
732 // ---------------------------------------------------------------------------
740 class CActionRecvItem
: public IStepContent
743 vector
<TItemDesc
> _Items
;
748 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
753 void init(CMissionData
&md
, IPrimitive
*prim
)
755 _BotGiver
=md
.getProperty(prim
, "npc_name", true, false);
757 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
758 for (uint i
=0; i
<vs
.size(); ++i
)
763 explode(vs
[i
], string(" "), args
, false);
764 if (args
.size() != 3 && args
.size() != 2)
766 string err
= toString("can't find 2 or 3 part (<item> <quant> [<qual>]) in item line '%s', found %u instead", vs
[i
].c_str(), args
.size());
767 throw EParseException(prim
, err
.c_str());
772 _QualSpec
= (args
.size() == 3);
774 else if (args
.size() == 3 && !_QualSpec
)
776 string err
= toString("can't mix item with quality and item without quality in item line '%s'", vs
[i
].c_str());
777 throw EParseException(prim
, err
.c_str());
781 item
.ItemName
= args
[0];
782 item
.ItemQuant
= args
[1];
784 item
.ItemQual
= args
[2];
786 _Items
.push_back(item
);
791 s
= md
.getProperty(prim
, "group", true, false);
792 _Group
= NLMISC::toBool(s
);
794 _Guild
= md
.getProperty(prim
, "guild", false, true) == "true";
795 // Check: if _Guild is true then check if we are in a guild mission
796 if (_Guild
&& !md
.isGuildMission())
798 string err
= toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim
->getName().c_str());
799 throw EParseException(prim
, err
.c_str());
802 IStepContent::init(md
, prim
);
805 string
genCode(CMissionData
&md
)
808 for (uint i
=0; i
<_Items
.size(); ++i
)
810 TItemDesc
&item
= _Items
[i
];
812 ret
+= "recv_item : "+item
.ItemName
+" "+item
.ItemQuant
;
814 ret
+=" "+item
.ItemQual
;
815 if (!_BotGiver
.empty())
816 ret
+= " : "+_BotGiver
;
828 REGISTER_STEP_CONTENT(CActionRecvItem
, "recv_item");
830 // ---------------------------------------------------------------------------
831 class CActionRecvNamedItem
: public IStepContent
833 vector
<TItemDesc
> _Items
;
837 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
842 void init(CMissionData
&md
, IPrimitive
*prim
)
845 vs
= md
.getPropertyArray(prim
, "item/quantity", true, false);
846 for (uint i
=0; i
<vs
.size(); ++i
)
851 explode(vs
[i
], string(" "), args
, false);
852 if (args
.size() != 1 && args
.size() != 2)
854 string err
= toString("can't find 1 or 2 part (<item> [<quant>]) in item line '%s', found %u instead", vs
[i
].c_str(), args
.size());
855 throw EParseException(prim
, err
.c_str());
859 item
.ItemName
= args
[0];
860 item
.ItemQuant
= "1";
861 if(args
.size()>=2 && atoi(args
[1].c_str())>0)
862 item
.ItemQuant
= args
[1];
864 _Items
.push_back(item
);
869 s
= md
.getProperty(prim
, "group", true, false);
870 _Group
= NLMISC::toBool(s
);
872 _Guild
= md
.getProperty(prim
, "guild", false, true) == "true";
873 // Check: if _Guild is true then check if we are in a guild mission
874 if (_Guild
&& !md
.isGuildMission())
876 string err
= toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim
->getName().c_str());
877 throw EParseException(prim
, err
.c_str());
880 IStepContent::init(md
, prim
);
883 string
genCode(CMissionData
&md
)
886 for (uint i
=0; i
<_Items
.size(); ++i
)
888 TItemDesc
&item
= _Items
[i
];
890 ret
+= "recv_named_item : "+item
.ItemName
+" "+item
.ItemQuant
;
902 REGISTER_STEP_CONTENT(CActionRecvNamedItem
, "recv_named_item");
904 // ---------------------------------------------------------------------------
905 class CActionDestroyItem
: public IStepContent
914 string _BotDestroyer
;
915 vector
<CItemDesc
> _Items
;
918 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
923 void init(CMissionData
&md
, IPrimitive
*prim
)
925 // get the bot who destroys the item
926 _BotDestroyer
=md
.getProperty(prim
, "npc_name", true, false);
928 // read list of items to destroy
930 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
931 for (uint i
=0; i
<vs
.size(); ++i
)
937 explode(vs
[i
], string(" "), args
, false);
938 if (args
.size()<1 || args
.size()>3)
940 string err
= toString("can't find 1, 2 or 3 part (<item> [<quant>] [<qual>]) in item line '%s', found %u instead", vs
[i
].c_str(), args
.size());
941 throw EParseException(prim
, err
.c_str());
944 // add the item in desc
946 item
.Desc
.ItemName
= args
[0];
949 item
.QuantSpec
= true;
950 item
.Desc
.ItemQuant
= args
[1];
955 item
.Desc
.ItemQual
= args
[2];
958 _Items
.push_back(item
);
962 _Guild
= md
.getProperty(prim
, "guild", false, true) == "true";
963 // Check: if _Guild is true then check if we are in a guild mission
964 if (_Guild
&& !md
.isGuildMission())
966 string err
= toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim
->getName().c_str());
967 throw EParseException(prim
, err
.c_str());
970 IStepContent::init(md
, prim
);
973 string
genCode(CMissionData
&md
)
976 for (uint i
=0; i
<_Items
.size(); ++i
)
978 CItemDesc
&item
= _Items
[i
];
980 ret
+= "destroy_item : "+item
.Desc
.ItemName
;
982 ret
+=" "+item
.Desc
.ItemQuant
;
984 ret
+=" "+item
.Desc
.ItemQual
;
985 if (!_BotDestroyer
.empty())
986 ret
+= " : "+_BotDestroyer
;
996 REGISTER_STEP_CONTENT(CActionDestroyItem
, "destroy_item");
998 // ---------------------------------------------------------------------------
999 class CActionRecvXp
: public IStepContent
1004 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1010 void init(CMissionData
&md
, IPrimitive
*prim
)
1012 IStepContent::init(md
, prim
);
1013 _Skill
= md
.getProperty(prim
, "skill", true, false);
1014 _Value
= atoi(md
.getProperty(prim
, "value", true, false).c_str());
1015 if(_Skill
.empty() || tolower(_Skill
[0])!='s' || _Value
<=0)
1017 string err
= toString("Bad skill name or value: '%s' '%d' ", _Skill
.c_str(), _Value
);
1018 throw EParseException(prim
, err
.c_str());
1022 string
genCode(CMissionData
&md
)
1024 if (!_Skill
.empty())
1025 return toString("recv_xp : %s %d", _Skill
.c_str(), _Value
) + NL
;
1030 REGISTER_STEP_CONTENT(CActionRecvXp
, "recv_xp");
1032 // ---------------------------------------------------------------------------
1033 class CActionLearnAction
: public IStepContent
1036 vector
<string
> _Actions
;
1039 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1044 void init(CMissionData
&md
, IPrimitive
*prim
)
1046 _BotGiver
= md
.getProperty(prim
, "npc_name", true, false);
1048 vs
= md
.getPropertyArray(prim
, "actions", true, false);
1050 for (uint i
=0; i
<vs
.size(); ++i
)
1053 _Actions
.push_back(vs
[i
]);
1057 s
= md
.getProperty(prim
, "group", true, false);
1058 _Group
= NLMISC::toBool(s
);
1060 IStepContent::init(md
, prim
);
1063 string
genCode(CMissionData
&md
)
1067 if (_Actions
.empty())
1070 ret
= "learn_action : ";
1071 for (uint i
=0; i
<_Actions
.size(); ++i
)
1074 if (i
< _Actions
.size()-1)
1078 if (!_BotGiver
.empty())
1079 ret
+= " : "+_BotGiver
;
1087 REGISTER_STEP_CONTENT(CActionLearnAction
, "learn_action");
1089 // ---------------------------------------------------------------------------
1090 class CActionLearnBrick
: public IStepContent
1093 vector
<string
> _Bricks
;
1096 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1101 void init(CMissionData
&md
, IPrimitive
*prim
)
1103 _BotGiver
= md
.getProperty(prim
, "npc_name", true, false);
1105 vs
= md
.getPropertyArray(prim
, "bricks", true, false);
1107 for (uint i
=0; i
<vs
.size(); ++i
)
1110 _Bricks
.push_back(vs
[i
]);
1114 s
= md
.getProperty(prim
, "group", true, false);
1115 _Group
= NLMISC::toBool(s
);
1117 IStepContent::init(md
, prim
);
1120 string
genCode(CMissionData
&md
)
1124 // if (_Bricks.empty())
1127 ret
= "learn_brick : ";
1128 for (uint i
=0; i
<_Bricks
.size(); ++i
)
1131 if (i
< _Bricks
.size()-1)
1135 if (!_BotGiver
.empty())
1136 ret
+= " : "+_BotGiver
;
1144 REGISTER_STEP_CONTENT(CActionLearnBrick
, "learn_brick");
1147 // ---------------------------------------------------------------------------
1148 class CActionUnlearnBrick
: public IStepContent
1151 vector
<string
> _Bricks
;
1154 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1159 void init(CMissionData
&md
, IPrimitive
*prim
)
1161 _BotGiver
= md
.getProperty(prim
, "npc_name", true, false);
1163 vs
= md
.getPropertyArray(prim
, "bricks", true, false);
1165 for (uint i
=0; i
<vs
.size(); ++i
)
1168 _Bricks
.push_back(vs
[i
]);
1172 s
= md
.getProperty(prim
, "group", true, false);
1173 _Group
= NLMISC::toBool(s
);
1175 IStepContent::init(md
, prim
);
1178 string
genCode(CMissionData
&md
)
1182 // if (_Bricks.empty())
1185 ret
= "unlearn_brick : ";
1186 for (uint i
=0; i
<_Bricks
.size(); ++i
)
1189 if (i
< _Bricks
.size()-1)
1193 if (!_BotGiver
.empty())
1194 ret
+= " : "+_BotGiver
;
1202 REGISTER_STEP_CONTENT(CActionUnlearnBrick
, "unlearn_brick");
1206 // ---------------------------------------------------------------------------
1207 class CActionBotChat
: public IStepContent
1214 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1219 void init(CMissionData
&md
, IPrimitive
*prim
)
1221 IStepContent::init(md
, prim
);
1223 _BotName
= md
.getProperty(prim
, "npc_name", true, false);
1224 if (_BotName
.empty())
1225 throw EParseException(prim
, "npc_name is empty !");
1227 vs
= md
.getPropertyArray(prim
, "phrase", false, false);
1228 _Phrase
.initPhrase(md
, prim
, vs
);
1230 _ChatMode
= md
.getProperty(prim
, "chat_type", true, false);
1233 string
genCode(CMissionData
&md
)
1237 ret
= "bot_chat : "+_ChatMode
+" : "+_BotName
+" : "+_Phrase
.genScript(md
)+NL
;
1243 return _Phrase
.genPhrase();
1246 REGISTER_STEP_CONTENT(CActionBotChat
, "bot_chat");
1248 // ---------------------------------------------------------------------------
1249 class CActionBotEmote
: public IStepContent
1254 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1259 void init(CMissionData
&md
, IPrimitive
*prim
)
1261 IStepContent::init(md
, prim
);
1263 _BotName
= md
.getProperty(prim
, "npc_name", true, false);
1264 _Emote
= md
.getProperty(prim
, "emote", true, false);
1267 string
genCode(CMissionData
&md
)
1271 ret
= "bot_emot : "+_BotName
+" "+_Emote
+NL
;
1275 REGISTER_STEP_CONTENT(CActionBotEmote
, "bot_emote");
1277 // ---------------------------------------------------------------------------
1278 class CActionAIEvent
: public IStepContent
1281 string _EventNumber
;
1283 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1288 void init(CMissionData
&md
, IPrimitive
*prim
)
1290 IStepContent::init(md
, prim
);
1292 _GroupName
= md
.getProperty(prim
, "group_name", true, false);
1293 _EventNumber
= md
.getProperty(prim
, "event_number", true, false);
1296 string
genCode(CMissionData
&md
)
1300 ret
= "ai_event : "+_GroupName
+"; "+_EventNumber
+NL
;
1304 REGISTER_STEP_CONTENT(CActionAIEvent
, "ai_event");
1306 // ---------------------------------------------------------------------------
1307 class CActionSetTeleport
: public CActionBotChat
1309 string _WorldPosition
;
1312 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1317 void init(CMissionData
&md
, IPrimitive
*prim
)
1319 CActionBotChat::init(md
, prim
);
1321 _WorldPosition
= md
.getProperty(prim
, "world_position", true, false);
1323 prim
->getPropertyByName("once", s
);
1324 _Once
= NLMISC::toBool(s
);
1327 string
genCode(CMissionData
&md
)
1331 ret
= "set_teleport : "+_BotName
+" : "+_WorldPosition
+" : ";
1335 ret
+= _Phrase
.genScript(md
) + NL
;
1339 REGISTER_STEP_CONTENT(CActionSetTeleport
, "set_teleport");
1341 // ---------------------------------------------------------------------------
1342 class CActionTeleport
: public IStepContent
1344 string _WorldPosition
;
1346 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1351 void init(CMissionData
&md
, IPrimitive
*prim
)
1353 IStepContent::init(md
, prim
);
1355 _WorldPosition
= md
.getProperty(prim
, "world_position", true, false);
1358 string
genCode(CMissionData
&md
)
1362 ret
= "teleport : "+_WorldPosition
+NL
;
1367 REGISTER_STEP_CONTENT(CActionTeleport
, "teleport");
1369 // ---------------------------------------------------------------------------
1370 class CActionSetCult
: public IStepContent
1374 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1379 void init(CMissionData
&md
, IPrimitive
*prim
)
1381 IStepContent::init(md
, prim
);
1383 _Cult
= md
.getProperty(prim
, "cult", true, false);
1386 string
genCode(CMissionData
&md
)
1390 ret
= "set_cult : " + _Cult
+ NL
;
1395 REGISTER_STEP_CONTENT(CActionSetCult
, "set_cult");
1397 // ---------------------------------------------------------------------------
1398 class CActionSetCiv
: public IStepContent
1402 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1407 void init(CMissionData
&md
, IPrimitive
*prim
)
1409 IStepContent::init(md
, prim
);
1411 _Civ
= md
.getProperty(prim
, "civ", true, false);
1414 string
genCode(CMissionData
&md
)
1418 ret
= "set_civ : " + _Civ
+ NL
;
1423 REGISTER_STEP_CONTENT(CActionSetCiv
, "set_civ");
1425 // ---------------------------------------------------------------------------
1426 class CActionSetGuildCult
: public IStepContent
1430 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1435 void init(CMissionData
&md
, IPrimitive
*prim
)
1437 IStepContent::init(md
, prim
);
1439 _Cult
= md
.getProperty(prim
, "cult", true, false);
1442 string
genCode(CMissionData
&md
)
1446 ret
= "set_guild_cult : " + _Cult
+ NL
;
1451 REGISTER_STEP_CONTENT(CActionSetGuildCult
, "set_guild_cult");
1453 // ---------------------------------------------------------------------------
1454 class CActionSetGuildCiv
: public IStepContent
1458 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1463 void init(CMissionData
&md
, IPrimitive
*prim
)
1465 IStepContent::init(md
, prim
);
1467 _Civ
= md
.getProperty(prim
, "civ", true, false);
1470 string
genCode(CMissionData
&md
)
1474 ret
= "set_guild_civ : " + _Civ
+ NL
;
1479 REGISTER_STEP_CONTENT(CActionSetGuildCiv
, "set_guild_civ");
1481 // ---------------------------------------------------------------------------
1482 class CActionAddCompass
: public IStepContent
1487 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1492 void init(CMissionData
&md
, IPrimitive
*prim
)
1494 IStepContent::init(md
, prim
);
1496 _NpcName
= md
.getProperty(prim
, "npc_to_add", true, false);
1497 _PlaceName
= md
.getProperty(prim
, "place_to_add", true, false);
1500 string
genCode(CMissionData
&md
)
1504 if (!_NpcName
.empty())
1505 ret
= "add_compass_npc : "+_NpcName
+NL
;
1506 if (!_PlaceName
.empty())
1507 ret
+= "add_compass_place : "+_PlaceName
+NL
;
1511 REGISTER_STEP_CONTENT(CActionAddCompass
, "add_compass");
1513 // ---------------------------------------------------------------------------
1514 class CActionRemoveCompass
: public IStepContent
1519 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1524 void init(CMissionData
&md
, IPrimitive
*prim
)
1526 IStepContent::init(md
, prim
);
1528 _NpcName
= md
.getProperty(prim
, "npc_to_remove", true, false);
1529 _PlaceName
= md
.getProperty(prim
, "place_to_remove", true, false);
1532 string
genCode(CMissionData
&md
)
1536 if (!_NpcName
.empty())
1537 ret
= "remove_compass_npc : "+_NpcName
+NL
;
1538 if (!_PlaceName
.empty())
1539 ret
+= "remove_compass_place : "+_PlaceName
+NL
;
1543 REGISTER_STEP_CONTENT(CActionRemoveCompass
, "remove_compass");
1545 // ---------------------------------------------------------------------------
1546 class CActionFail
: public IStepContent
1549 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1554 void init(CMissionData
&md
, IPrimitive
*prim
)
1556 IStepContent::init(md
, prim
);
1559 string
genCode(CMissionData
&md
)
1561 return string("fail")+NL
;
1564 REGISTER_STEP_CONTENT(CActionFail
, "fail");
1566 // ---------------------------------------------------------------------------
1567 class CActionFailIfSDB
: public IStepContent
1572 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1577 void init(CMissionData
&md
, IPrimitive
*prim
)
1579 IStepContent::init(md
, prim
);
1580 _Condition
= md
.getProperty(prim
, "condition", true, false);
1583 string
genCode(CMissionData
&md
)
1585 return string("fail_if_sdb : ")+_Condition
+NL
;
1588 REGISTER_STEP_CONTENT(CActionFailIfSDB
, "fail_if_sdb");
1590 // ---------------------------------------------------------------------------
1591 class CActionFailMissionCat
: public IStepContent
1594 string _MissionCategory
;
1596 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1601 void init(CMissionData
&md
, IPrimitive
*prim
)
1603 IStepContent::init(md
, prim
);
1604 _MissionCategory
= md
.getProperty(prim
, "category", true, false);
1607 string
genCode(CMissionData
&md
)
1609 return string("fail_mission_cat : ")+_MissionCategory
+NL
;
1612 REGISTER_STEP_CONTENT(CActionFailMissionCat
, "fail_mission_cat");
1614 // ---------------------------------------------------------------------------
1615 class CActionSystemMsg
: public IStepContent
1619 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1624 void init(CMissionData
&md
, IPrimitive
*prim
)
1626 IStepContent::init(md
, prim
);
1628 vector
<string
> vs
= md
.getPropertyArray(prim
, "msg_to_display", false, false);
1630 _Message
.initPhrase(md
, prim
, vs
);
1633 string
genCode(CMissionData
&md
)
1637 ret
= "system_msg : "+_Message
.genScript(md
)+NL
;
1643 return _Message
.genPhrase();
1646 REGISTER_STEP_CONTENT(CActionSystemMsg
, "system_msg");
1648 // ---------------------------------------------------------------------------
1649 class CActionPopupMsg
: public IStepContent
1654 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1659 void init(CMissionData
&md
, IPrimitive
*prim
)
1661 IStepContent::init(md
, prim
);
1663 vector
<string
> vst
= md
.getPropertyArray(prim
, "title_to_display", false, false);
1664 vector
<string
> vsm
= md
.getPropertyArray(prim
, "msg_to_display", false, false);
1666 _Title
.initPhrase(md
, prim
, vst
);
1667 _Message
.initPhrase(md
, prim
, vsm
);
1670 string
genCode(CMissionData
&md
)
1674 ret
= "popup_msg : " + _Title
.genScript(md
) + " : " + _Message
.genScript(md
) + NL
;
1680 return _Title
.genPhrase() + _Message
.genPhrase();
1683 REGISTER_STEP_CONTENT(CActionPopupMsg
, "popup_msg");
1685 // ---------------------------------------------------------------------------
1686 class CActionDeclareWar
: public IStepContent
1689 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1694 void init(CMissionData
&md
, IPrimitive
*prim
)
1696 IStepContent::init(md
, prim
);
1699 string
genCode(CMissionData
&md
)
1701 return string("declare_war")+NL
;
1704 REGISTER_STEP_CONTENT(CActionDeclareWar
, "declare_war");
1706 // ---------------------------------------------------------------------------
1707 class CActionSetConstrains
: public IStepContent
1711 string _InsidePlace
;
1712 string _InsidePlaceDelay
;
1713 string _OutsidePlace
;
1714 string _OutsidePlaceDelay
;
1715 vector
<string
> _Wears
;
1717 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1722 void init(CMissionData
&md
, IPrimitive
*prim
)
1724 IStepContent::init(md
, prim
);
1726 _Timer
= md
.getProperty(prim
, "timer", true, false);
1727 _TimePeriod
= md
.getProperty(prim
, "time_period", true, false);
1728 _InsidePlace
= md
.getProperty(prim
, "inside_place", true, false);
1729 _InsidePlaceDelay
= md
.getProperty(prim
, "inside_place_delay", true, false);
1730 _OutsidePlace
= md
.getProperty(prim
, "outside_place", true, false);
1731 _OutsidePlaceDelay
= md
.getProperty(prim
, "outside_place_delay", true, false);
1732 _Wears
= md
.getPropertyArray(prim
, "wear", true, false);
1735 string
genCode(CMissionData
&md
)
1739 if (!_Timer
.empty())
1740 ret
+= "timer : "+_Timer
+NL
;
1741 if (!_TimePeriod
.empty())
1743 if ( _TimePeriod
== "winter"
1744 || _TimePeriod
== "spring"
1745 || _TimePeriod
== "summer"
1746 || _TimePeriod
== "autumn"
1747 || _TimePeriod
== "none")
1749 ret
+= "season : "+_TimePeriod
+NL
;
1752 ret
+= "day_period : "+_TimePeriod
+NL
;
1754 if (!_InsidePlace
.empty())
1756 if (_InsidePlace
!= "none")
1758 ret
+= "inside : "+_InsidePlace
;
1759 if (!_InsidePlaceDelay
.empty())
1760 ret
+= " : "+_InsidePlaceDelay
;
1766 if (!_OutsidePlace
.empty())
1768 if (_OutsidePlace
!= "none")
1770 ret
+= "outside : "+_OutsidePlace
;
1771 if (!_OutsidePlaceDelay
.empty())
1772 ret
+= " : "+_OutsidePlaceDelay
;
1778 if (!_Wears
.empty())
1779 nlwarning("wear constraint not implemented yet");
1783 REGISTER_STEP_CONTENT(CActionSetConstrains
, "set_constrains");
1785 // ---------------------------------------------------------------------------
1786 class CActionSetDesc
: public IStepContent
1788 CPhrase _Description
;
1790 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1795 void init(CMissionData
&md
, IPrimitive
*prim
)
1797 IStepContent::init(md
, prim
);
1799 std::vector
<string
> vs
= md
.getPropertyArray(prim
, "mission_description", false, false);
1801 _Description
.initPhrase(md
, prim
, vs
);
1804 string
genCode(CMissionData
&md
)
1808 ret
= "set_desc : "+_Description
.genScript(md
)+NL
;
1814 return _Description
.genPhrase();
1818 REGISTER_STEP_CONTENT(CActionSetDesc
, "set_desc");
1820 // *****************
1821 // CContentObjective
1822 // *****************
1823 // base class for step content objectives
1824 // ---------------------------------------------------------------------------
1825 void CContentObjective::init(CMissionData
&md
, IPrimitive
*prim
)
1827 IStepContent::init(md
, prim
);
1829 _HideObj
= md
.getProperty(prim
, "hide_obj", true, false) == "true";
1830 _OverloadObj
= md
.getPropertyArray(prim
, "overload_objective", false, false);
1831 _RoleplayObj
= md
.getPropertyArray(prim
, "roleplay_objective", false, false);
1833 CPhrase::TPredefParams params
;
1834 // ask derived class for predefined params
1835 getPredefParam(numEntry
, params
);
1836 // init the overload phrase
1837 _OverloadPhrase
.initPhrase(md
, prim
, _OverloadObj
, numEntry
, params
);
1838 // init the roleplay phrase
1839 _RoleplayPhrase
.initPhrase(md
, prim
, _RoleplayObj
, numEntry
, params
);
1841 // check for the 'nb_guild_members_needed' option and see if it's correct for this mission
1842 /*string nbGuildMembersNeeded = md.getProperty(prim, "nb_guild_members_needed", false, true);
1843 if (nbGuildMembersNeeded.empty())
1844 nbGuildMembersNeeded = "1";
1845 if (!fromString(nbGuildMembersNeeded.c_str(), _NbGuildMembersNeeded))
1846 _NbGuildMembersNeeded = 1;
1849 if (!md.isGuildMission() && _NbGuildMembersNeeded != 1)
1851 string err = toString("primitive(%s): nb_guild_members_needed != 1 for non guild mission.", prim->getName().c_str());
1852 throw EParseException(prim, err.c_str());
1856 // ---------------------------------------------------------------------------
1857 string
CContentObjective::genCode(CMissionData
&md
)
1861 ret
= "hide_obj"+NL
;
1862 if (!_OverloadObj
.empty())
1864 ret
+= "set_obj : " + _OverloadPhrase
.genScript(md
)+NL
;
1866 if (!_RoleplayObj
.empty())
1868 ret
+= "set_obj_rp : " + _RoleplayPhrase
.genScript(md
)+NL
;
1873 // ---------------------------------------------------------------------------
1874 /*std::string CContentObjective::genNbGuildMembersNeededOption(CMissionData &md)
1877 // If we are in a guild mission we add the 'nb_guild_members_needed' option to the script
1878 if (md.isGuildMission())
1880 ret = ": nb_guild_members_needed ";
1881 ret += toString(_NbGuildMembersNeeded);
1887 // ---------------------------------------------------------------------------
1888 string
CContentObjective::genPhrase()
1890 if (!_OverloadObj
.empty())
1891 return _OverloadPhrase
.genPhrase();
1893 return _RoleplayPhrase
.genPhrase();
1896 // ---------------------------------------------------------------------------
1897 // ---------------------------------------------------------------------------
1899 struct TKillFaunaInfo
1901 TCompilerVarName SheetName
;
1902 TCompilerVarName Quantity
;
1905 struct TKillRaceInfo
1907 TCompilerVarName RaceName
;
1908 TCompilerVarName Quantity
;
1911 struct TKillPlayerInfo
1913 TCompilerVarName ClanName
;
1914 TCompilerVarName MinLevel
;
1915 TCompilerVarName MaxLevel
;
1916 TCompilerVarName Quantity
;
1919 class CContentKill
: public CContentObjective
1921 vector
<TKillFaunaInfo
> _KillFaunas
;
1922 vector
<TKillRaceInfo
> _KillRaces
;
1923 TCompilerVarName _KillGroup
;
1924 vector
<TCompilerVarName
> _KillNpcs
;
1925 TCompilerVarName _KillNpcByNames
;
1926 TCompilerVarName _KillNpcByNamesQuantity
;
1927 TCompilerVarName _KillFactionName
;
1928 TCompilerVarName _KillFactionQuantity
;
1929 vector
<string
> _PredefVarName
;
1930 vector
<TKillPlayerInfo
> _KillPlayers
;
1931 TCompilerVarName _Place
;
1934 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
1936 if (!_KillFaunas
.empty())
1938 numEntry
= (uint32
)_KillFaunas
.size();
1939 predef
.resize(numEntry
);
1940 for (uint i
=0; i
<_KillFaunas
.size(); ++i
)
1942 predef
[i
].resize(2*(i
+1));
1943 for (uint j
=0; j
<i
+1; ++j
)
1945 predef
[i
][2*j
] = _KillFaunas
[j
].SheetName
;
1946 predef
[i
][2*j
+1] = _KillFaunas
[j
].Quantity
;
1950 else if (!_KillRaces
.empty())
1952 numEntry
= (uint32
)_KillRaces
.size();
1953 predef
.resize(numEntry
);
1954 for (uint i
=0; i
<_KillRaces
.size(); ++i
)
1956 predef
[i
].resize(2*(i
+1));
1957 for (uint j
=0; j
<i
+1; ++j
)
1959 predef
[i
][2*j
] = _KillRaces
[j
].RaceName
;
1960 predef
[i
][2*j
+1] = _KillRaces
[j
].Quantity
;
1964 else if (!_KillGroup
.empty())
1968 predef
[0].resize(1);
1969 predef
[0][0] = _KillGroup
;
1971 else if (!_KillNpcs
.empty())
1973 numEntry
= (uint32
)_KillNpcs
.size();
1974 predef
.resize(numEntry
);
1975 for (uint i
=0; i
<_KillNpcs
.size(); ++i
)
1977 predef
[i
].resize(i
+1);
1978 for (uint j
=0; j
<i
+1; ++j
)
1980 predef
[i
][j
] = _KillNpcs
[j
];
1984 else if (!_KillNpcByNames
._VarValue
.empty())
1988 predef
[0].resize(2);
1989 predef
[0][0] = _KillNpcByNames
;
1990 predef
[0][1] =_KillNpcByNamesQuantity
;
1992 else if (!_KillFactionName
._VarValue
.empty())
1996 predef
[0].resize(2);
1997 predef
[0][0] = _KillFactionName
;
1998 predef
[0][1] = _KillFactionQuantity
;
2000 else if(!_KillPlayers
.empty())
2002 numEntry
= _KillPlayers
.size();
2003 predef
.resize(numEntry
);
2004 for (uint i
=0; i
<numEntry
; ++i
)
2006 predef
[i
].resize(4*(i
+1));
2007 for (uint j
=0; j
<i
+1; ++j
)
2009 predef
[i
][j
*4] = _KillPlayers
[j
].ClanName
;
2010 predef
[i
][j
*4+1] = _KillPlayers
[j
].MinLevel
;
2011 predef
[i
][j
*4+2] = _KillPlayers
[j
].MaxLevel
;
2012 predef
[i
][j
*4+3] = _KillPlayers
[j
].Quantity
;
2017 // add optional place
2018 if (!_Place
._VarValue
.empty())
2020 for (uint i
=0; i
<predef
.size(); ++i
)
2022 predef
[i
].push_back(_Place
);
2028 void init(CMissionData
&md
, IPrimitive
*prim
)
2031 vs
= md
.getPropertyArray(prim
, "fauna/quantity", false, false);
2032 for (uint i
=0; i
<vs
.size(); ++i
)
2034 vector
<string
> args
;
2035 explode(vs
[i
], string(" "), args
, true);
2036 if (args
.size() != 2)
2038 string err
= toString("Syntax error in kill fauna : '%s', need <fauna_sheet_name> <quantity>", vs
[i
].c_str());
2039 throw EParseException (prim
, err
.c_str());
2042 kfi
.SheetName
.initWithText(toString("c%u", i
+1), STRING_MANAGER::creature_model
, md
, prim
, args
[0]);
2043 kfi
.Quantity
.initWithText(toString("q%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2044 _KillFaunas
.push_back(kfi
);
2047 vs
= md
.getPropertyArray(prim
, "race/quantity", false, false);
2048 for (uint i
=0; i
<vs
.size(); ++i
)
2050 vector
<string
> args
;
2051 explode(vs
[i
], string(" "), args
, true);
2052 if (args
.size() != 2)
2054 string err
= toString("Syntax error in kill race : '%s', need <race_name> <quantity>", vs
[i
].c_str());
2055 throw EParseException (prim
, err
.c_str());
2058 kri
.RaceName
.initWithText(toString("r%u", i
+1), STRING_MANAGER::creature_model
, md
, prim
, args
[0]);
2059 kri
.Quantity
.initWithText(toString("q%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2060 _KillRaces
.push_back(kri
);
2063 //s = md.getProperty(prim, "group", false, true);
2064 vs
= md
.getPropertyArray(prim
, "group", false, false);
2069 string err
= "Syntax error in kill group";
2070 throw EParseException (prim
, err
.c_str());
2073 _KillGroup
.initWithText("group_name", STRING_MANAGER::bot_name
, md
, prim
, vs
[0] );
2078 vs
= md
.getPropertyArray(prim
, "npc", false, false);
2079 for (uint i
=0; i
<vs
.size(); ++i
)
2081 TCompilerVarName npcname
;
2082 npcname
.initWithText(toString("npc%u", i
+1), STRING_MANAGER::bot
, md
, prim
, vs
[i
]);
2083 _KillNpcs
.push_back(npcname
);
2085 vs
= md
.getPropertyArray(prim
, "clan_name/min_level/max_level/quantity", true, false);
2086 for (uint i
=0; i
<vs
.size(); ++i
)
2088 vector
<string
> args
;
2089 explode(vs
[i
], string(" "), args
, true);
2090 if (args
.size() != 4)
2092 string err
= toString("Invalid player clan infos in '%s', need <clan_name> <min_level> <max_level> <quantity>", vs
[i
].c_str());
2093 throw EParseException(prim
, err
.c_str());
2095 if (atoi(args
[1].c_str()) >= atoi(args
[2].c_str()))
2097 string err
= toString("Invalid player clan infos in '%s', need <min_level> lower than <max_level>", vs
[i
].c_str());
2098 throw EParseException(prim
, err
.c_str());
2100 if (atoi(args
[3].c_str()) <= 0)
2102 string err
= toString("Invalid player clan infos in '%s', need <quantity> upper than 0", vs
[i
].c_str());
2103 throw EParseException(prim
, err
.c_str());
2106 kp
.ClanName
.initWithText(toString("clan%u", i
+1), STRING_MANAGER::clan
, md
, prim
, args
[0]);
2107 kp
.MinLevel
.initWithText(toString("minlvl%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2108 kp
.MaxLevel
.initWithText(toString("maxlvl%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
2109 kp
.Quantity
.initWithText(toString("quantity%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[3]);
2110 _KillPlayers
.push_back(kp
);
2113 s
= md
.getProperty(prim
, "npc_by_name/quantity", false, false);
2116 vector
<string
> args
;
2117 explode(s
, string(" "), args
, true);
2118 if (args
.size() != 2)
2120 string err
= toString("Syntax error in kill npc by name : '%s', need <npc_name> <quantity>", s
.c_str());
2121 throw EParseException(prim
, err
.c_str());
2123 _KillNpcByNames
.initWithText("npc", STRING_MANAGER::bot_name
, md
, prim
, args
[0]);
2124 _KillNpcByNamesQuantity
.initWithText("qt", STRING_MANAGER::integer
, md
, prim
, args
[1]);
2127 s
= md
.getProperty(prim
, "faction/quantity", false, false);
2130 vector
<string
> args
;
2131 explode(s
, string(" "), args
, true);
2132 if (args
.size() != 2)
2134 string err
= toString("Syntax error in kill faction : '%s', need <faction_name> <quantity>", s
.c_str());
2135 throw EParseException (prim
, err
.c_str());
2137 _KillFactionName
.initWithText("faction", STRING_MANAGER::faction
, md
, prim
, args
[0]);
2138 _KillFactionQuantity
.initWithText("qt", STRING_MANAGER::integer
, md
, prim
, args
[1]);
2142 if (!_KillFaunas
.empty())
2144 if (!_KillRaces
.empty())
2147 throw EParseException(prim
, "Merging of multiple kill mode is forbidden !");
2150 if (!_KillGroup
.empty())
2153 throw EParseException(prim
, "Merging of multiple kill mode is forbidden !");
2157 if (!_KillNpcs
.empty())
2160 throw EParseException(prim
, "Merging of multiple kill mode is forbidden !");
2163 if (!_KillNpcByNames
._VarValue
.empty())
2166 throw EParseException(prim
, "Merging of multiple kill mode is forbidden !");
2169 if (!_KillFactionName
.empty())
2172 throw EParseException(prim
, "Merging of multiple kill mode is forbidden !");
2175 if (!_KillPlayers
.empty())
2178 throw EParseException(prim
, "Merging of multiple kill mode is forbidden !");
2182 _Place
.init("p", STRING_MANAGER::place
, md
, prim
, "place");
2184 if (!_Place
.empty() && !_KillGroup
.empty())
2186 throw EParseException(prim
, "Using location with kill group instruction is forbidden!");
2189 CContentObjective::init(md
, prim
);
2193 string
genCode(CMissionData
&md
)
2196 ret
= CContentObjective::genCode(md
);
2198 if (!_KillFaunas
.empty())
2200 ret
+= "kill_fauna : ";
2201 for (uint i
=0; i
<_KillFaunas
.size(); ++i
)
2203 ret
+= _KillFaunas
[i
].SheetName
+" "+_KillFaunas
[i
].Quantity
;
2204 if (i
< _KillFaunas
.size()-1)
2208 else if (!_KillRaces
.empty())
2210 ret
+= "kill_race : ";
2211 for (uint i
=0; i
<_KillRaces
.size(); ++i
)
2213 ret
+= _KillRaces
[i
].RaceName
+" "+_KillRaces
[i
].Quantity
;
2214 if (i
< _KillRaces
.size()-1)
2218 else if (!_KillGroup
.empty())
2220 ret
+= "kill_group : " + _KillGroup
;
2222 else if (!_KillNpcs
.empty())
2224 ret
+= "kill_npc : ";
2225 for (uint i
=0; i
<_KillNpcs
.size(); ++i
)
2227 ret
+= _KillNpcs
[i
];
2228 if (i
< _KillNpcs
.size()-1)
2232 else if (!_KillNpcByNames
.empty())
2234 ret
+= "kill_npc_by_name : "+_KillNpcByNames
+" "+_KillNpcByNamesQuantity
;
2236 else if (!_KillFactionName
.empty())
2238 ret
+= "kill_faction : "+_KillFactionName
+" "+_KillFactionQuantity
;
2240 else if (!_KillPlayers
.empty())
2242 ret
+= "kill_player : ";
2243 for (uint i
=0; i
<_KillPlayers
.size(); ++i
)
2245 ret
+= _KillPlayers
[i
].ClanName
+" "+_KillPlayers
[i
].MinLevel
+" "+_KillPlayers
[i
].MaxLevel
+" "+_KillPlayers
[i
].Quantity
;
2246 if (i
< _KillPlayers
.size()-1)
2251 if (!_Place
.empty())
2252 ret
+= " : "+_Place
;
2254 // Add the 'nb_guild_members_needed' parameter if needed
2255 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2261 REGISTER_STEP_CONTENT(CContentKill
, "kill");
2265 class CContentKillFamedPlayer : public CContentObjective
2267 vector<TKillFamedPlayerInfo> _Clans;
2269 virtual void getPredefParam(uint32 &numEntry, CPhrase::TPredefParams &predef)
2271 numEntry = _Clans.size();
2272 predef.resize(numEntry);
2273 for (uint i=0; i<numEntry; ++i)
2275 predef[i].resize(4*(i+1));
2276 for (uint j=0; j<i+1; ++j)
2278 predef[i][j*4] = _Clans[j].ClanName;
2279 predef[i][j*4+1] = _Clans[j].MinLevel;
2280 predef[i][j*4+2] = _Clans[j].MaxLevel;
2281 predef[i][j*4+3] = _Clans[j].Quantity;
2287 class CContentTalkTo
: public CContentObjective
2289 TCompilerVarName _BotName
;
2292 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2296 predef
[0].resize(1);
2297 predef
[0][0] = _BotName
;
2300 void init(CMissionData
&md
, IPrimitive
*prim
)
2304 _BotName
.init("npc", STRING_MANAGER::bot
, md
, prim
, "npc_name" );
2306 CPhrase::TPredefParams
pp(1);
2307 pp
[0].push_back(_BotName
.getParamInfo());
2310 vs
= md
.getPropertyArray(prim
, "phrase", false, false);
2311 _Phrase
.initPhrase(md
, prim
, vs
, 0, pp
);
2313 // _Phrase.initPhrase(md, prim, vs);
2315 // if (_Phrase.asAdditionnalParams())
2317 // // we need to remove the default 'npc' parameter if add params are found
2319 // temp.initPhrase(md, prim, vs);
2323 CContentObjective::init(md
, prim
);
2326 string
genCode(CMissionData
&md
)
2329 ret
= CContentObjective::genCode(md
);
2331 ret
+= "talk_to : "+_BotName
;
2333 if (!_Phrase
.isEmpty())
2334 ret
+= " : "+_Phrase
.genScript(md
);
2335 // Add the 'nb_guild_members_needed' parameter if needed
2336 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2345 ret
= CContentObjective::genPhrase();
2346 ret
+= _Phrase
.genPhrase();
2351 REGISTER_STEP_CONTENT(CContentTalkTo
, "talk_to");
2353 class CContentCast
: public CContentObjective
2355 vector
<TCompilerVarName
> _Actions
;
2356 TCompilerVarName _Place
;
2358 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2361 numEntry
= (uint32
)_Actions
.size();
2362 predef
.resize(numEntry
);
2363 for (uint i
=0; i
<numEntry
; ++i
)
2365 predef
[i
].resize(i
+1);
2367 for (uint j
=0; j
<i
+1; ++j
)
2369 predef
[i
][j
] = _Actions
[j
];
2374 if (!_Place
.empty())
2376 for (uint i
=0; i
<_Actions
.size(); ++i
)
2378 predef
[i
].push_back(_Place
);
2383 void init(CMissionData
&md
, IPrimitive
*prim
)
2385 _Actions
=TCompilerVarName::getPropertyArrayWithTextStaticDefaultName("action", STRING_MANAGER::sphrase
, md
, prim
, "action");
2386 _Place
.init("p", STRING_MANAGER::place
, md
, prim
, "place");
2390 CContentObjective::init(md
, prim
);
2393 string
genCode(CMissionData
&md
)
2396 ret
= CContentObjective::genCode(md
);
2400 for (uint i
=0; i
<_Actions
.size(); ++i
)
2403 if (i
< _Actions
.size()-1)
2407 if (!_Place
.empty())
2411 // Add the 'nb_guild_members_needed' parameter if needed
2412 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2418 REGISTER_STEP_CONTENT(CContentCast
, "cast");
2422 TCompilerVarName Item
;
2423 TCompilerVarName Qt
;
2424 TCompilerVarName Ql
;
2427 class CContentForage
: public CContentObjective
2429 vector
<TForageInfo
> _Mps
;
2431 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2433 numEntry
= (uint32
)_Mps
.size();
2434 predef
.resize(numEntry
);
2435 for (uint i
=0; i
<numEntry
; ++i
)
2437 predef
[i
].resize(3*(i
+1));
2438 for (uint j
=0; j
<i
+1; ++j
)
2440 predef
[i
][j
*3] = _Mps
[j
].Item
;
2441 predef
[i
][j
*3+1] = _Mps
[j
].Qt
;
2442 predef
[i
][j
*3+2] = _Mps
[j
].Ql
;
2447 void init(CMissionData
&md
, IPrimitive
*prim
)
2450 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
2452 for (uint i
=0; i
<vs
.size(); ++i
)
2454 vector
<string
> args
;
2455 explode(vs
[i
], string(" "), args
, true);
2456 if (args
.size() != 3)
2458 string err
= toString("Invalid forage item in '%s', need <item> <quantity> <quality>", vs
[i
].c_str());
2459 throw EParseException(prim
, err
.c_str());
2463 fi
.Item
.initWithText(toString("i%u", i
+1), STRING_MANAGER::item
, md
, prim
, args
[0]);
2464 fi
.Qt
.initWithText(toString("qt%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2465 fi
.Ql
.initWithText(toString("qual%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
2470 CContentObjective::init(md
, prim
);
2473 string
genCode(CMissionData
&md
)
2476 ret
= CContentObjective::genCode(md
);
2480 for (uint i
=0; i
<_Mps
.size(); ++i
)
2482 ret
+= _Mps
[i
].Item
+" "+_Mps
[i
].Qt
+" "+_Mps
[i
].Ql
;
2483 if (i
< _Mps
.size()-1)
2486 // Add the 'nb_guild_members_needed' parameter if needed
2487 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2493 REGISTER_STEP_CONTENT(CContentForage
, "forage");
2497 TCompilerVarName Item
;
2498 TCompilerVarName Qt
;
2499 TCompilerVarName Ql
;
2502 class CContentLoot
: public CContentObjective
2512 vector
<TLootInfo
> _Items
;
2514 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2516 if (_Mode
== lm_item
)
2518 numEntry
= (uint32
)_Items
.size();
2519 predef
.resize(numEntry
);
2520 for (uint i
=0; i
<numEntry
; ++i
)
2522 predef
[i
].resize(i
+1);
2523 for (uint j
=0; j
<i
+1; ++j
)
2525 predef
[i
][j
] = _Items
[j
].Item
;
2529 else if (_Mode
== lm_mp
)
2531 numEntry
= (uint32
)_Items
.size();
2532 predef
.resize(numEntry
);
2533 for (uint i
=0; i
<numEntry
; ++i
)
2535 predef
[i
].resize(3*(i
+1));
2536 for (uint j
=0; j
<i
+1; ++j
)
2538 predef
[i
][j
*3] = _Items
[j
].Item
;
2539 predef
[i
][j
*3+1] = _Items
[j
].Qt
;
2540 predef
[i
][j
*3+2] = _Items
[j
].Ql
;
2550 void init(CMissionData
&md
, IPrimitive
*prim
)
2554 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
2556 for (uint i
=0; i
<vs
.size(); ++i
)
2558 vector
<string
> args
;
2559 explode(vs
[i
], string(" "), args
, true);
2560 if (args
.size() != 1 && args
.size() != 3)
2562 string err
= toString("Invalid loot item in '%s', need <item> or <item> <quantity> <quality>", vs
[i
].c_str());
2563 throw EParseException(prim
, err
.c_str());
2566 if (args
.size() == 1)
2569 throw EParseException(prim
, "Can't mix item and mps loot");
2572 else if (args
.size() == 3)
2574 if (_Mode
== lm_item
)
2575 throw EParseException(prim
, "Can't mix item and mps loot");
2580 li
.Item
.initWithText(toString("i%u", i
+1), STRING_MANAGER::item
, md
, prim
, args
[0]);
2582 if (args
.size() > 1)
2584 li
.Qt
.initWithText(toString("qt%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2586 li
.Ql
.initWithText(toString("qual%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
2589 _Items
.push_back(li
);
2592 CContentObjective::init(md
, prim
);
2595 string
genCode(CMissionData
&md
)
2598 ret
= CContentObjective::genCode(md
);
2600 if (_Mode
== lm_item
)
2601 ret
+= "loot_item : ";
2603 ret
+= "loot_mp : ";
2605 for (uint i
=0; i
<_Items
.size(); ++i
)
2607 ret
+= _Items
[i
].Item
;
2609 ret
+= " "+_Items
[i
].Qt
+" "+_Items
[i
].Ql
;
2610 if (i
< _Items
.size()-1)
2613 // Add the 'nb_guild_members_needed' parameter if needed
2614 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2620 REGISTER_STEP_CONTENT(CContentLoot
, "loot");
2624 TCompilerVarName Item
;
2625 TCompilerVarName Qt
;
2626 TCompilerVarName Ql
;
2629 class CContentCraft
: public CContentObjective
2631 vector
<TCraftInfo
> _Items
;
2634 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2636 numEntry
= (uint32
)_Items
.size();
2637 predef
.resize(numEntry
);
2638 for (uint i
=0; i
<numEntry
; ++i
)
2640 predef
[i
].resize(3*(i
+1));
2641 for (uint j
=0; j
<i
+1; ++j
)
2643 predef
[i
][j
*3] = _Items
[j
].Item
;
2644 predef
[i
][j
*3+1] = _Items
[j
].Qt
;
2645 predef
[i
][j
*3+2] = _Items
[j
].Ql
;
2650 void init(CMissionData
&md
, IPrimitive
*prim
)
2653 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
2655 for (uint i
=0; i
<vs
.size(); ++i
)
2657 vector
<string
> args
;
2658 explode(vs
[i
], string(" "), args
, true);
2659 if (args
.size() != 3)
2661 string err
= toString("Invalid craft item in '%s', need <item> <quantity> <quality>", vs
[i
].c_str());
2662 throw EParseException(prim
, err
.c_str());
2666 ci
.Item
.initWithText(toString("i%u", i
+1), STRING_MANAGER::item
, md
, prim
, args
[0]);
2667 ci
.Qt
.initWithText(toString("qt%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2668 ci
.Ql
.initWithText(toString("qual%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
2669 _Items
.push_back(ci
);
2672 CContentObjective::init(md
, prim
);
2675 string
genCode(CMissionData
&md
)
2678 ret
= CContentObjective::genCode(md
);
2682 for (uint i
=0; i
<_Items
.size(); ++i
)
2684 ret
+= _Items
[i
].Item
+" "+_Items
[i
].Qt
+" "+_Items
[i
].Ql
;
2685 if (i
< _Items
.size()-1)
2688 // Add the 'nb_guild_members_needed' parameter if needed
2689 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2695 REGISTER_STEP_CONTENT(CContentCraft
, "craft");
2697 class CContentTarget
: public CContentObjective
2700 vector
<TCompilerVarName
> _Npcs
;
2701 vector
<TCompilerVarName
> _Faunas
;
2702 vector
<TCompilerVarName
> _Races
;
2703 TCompilerVarName _Place
;
2704 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2706 // phrase 0 - 1 parameter
2707 // phrase 1 - 2 parameters
2708 // etc ... as many (bots,faunas,race) as specified
2713 numEntry
= (uint32
)_Npcs
.size();
2714 predef
.resize(numEntry
);
2715 for (uint i
=0; i
<numEntry
; ++i
)
2717 predef
[i
].resize(1*(i
+1));
2718 for (uint j
=0; j
<i
+1; ++j
)
2720 predef
[i
][j
] = _Npcs
[j
];
2724 else if (!_Faunas
.empty())
2726 numEntry
= (uint32
)_Faunas
.size();
2727 predef
.resize(numEntry
);
2728 for (uint i
=0; i
<numEntry
; ++i
)
2730 predef
[i
].resize(1*(i
+1));
2731 for (uint j
=0; j
<i
+1; ++j
)
2733 predef
[i
][j
] = _Faunas
[j
];
2737 else if (!_Races
.empty())
2739 numEntry
= (uint32
)_Races
.size();
2740 predef
.resize(numEntry
);
2741 for (uint i
=0; i
<numEntry
; ++i
)
2743 predef
[i
].resize(1*(i
+1));
2744 for (uint j
=0; j
<i
+1; ++j
)
2746 predef
[i
][j
] = _Races
[j
];
2751 // If there is a place add the param for text to all phrases (predef[x] is a phrase)
2752 if (!_Place
.empty())
2754 for (uint i
= 0; i
< predef
.size(); ++i
)
2756 predef
[i
].push_back( _Place
);
2762 void init(CMissionData
&md
, IPrimitive
*prim
)
2764 _Npcs
= TCompilerVarName::getPropertyArrayWithText("npc", STRING_MANAGER::bot
, md
, prim
, "npcs_to_target");
2765 _Faunas
= TCompilerVarName::getPropertyArrayWithText("fauna", STRING_MANAGER::creature_model
, md
, prim
, "faunas_to_target" );
2766 _Races
= TCompilerVarName::getPropertyArrayWithText("race", STRING_MANAGER::race
, md
, prim
, "races_to_target" );
2767 _Place
.init("place", STRING_MANAGER::place
, md
, prim
, "place" );
2770 if (!_Npcs
.empty() && !_Faunas
.empty())
2771 throw EParseException(prim
, "Can't mix npc and fauna target");
2773 if (!_Npcs
.empty() && !_Races
.empty())
2774 throw EParseException(prim
, "Can't mix npc and race target");
2776 if (!_Faunas
.empty() && !_Races
.empty())
2777 throw EParseException(prim
, "Can't mix fauna and race target");
2779 CContentObjective::init(md
, prim
);
2782 string
genCode(CMissionData
&md
)
2785 ret
= CContentObjective::genCode(md
);
2789 ret
+= "target_npc : ";
2790 for (uint i
=0; i
<_Npcs
.size(); ++i
)
2793 if (i
< _Npcs
.size()-1)
2797 else if (!_Faunas
.empty())
2799 ret
+= "target_fauna : ";
2800 for (uint i
=0; i
<_Faunas
.size(); ++i
)
2803 if (i
< _Faunas
.size()-1)
2807 else if (!_Races
.empty())
2809 ret
+= "target_race : ";
2810 for (uint i
=0; i
<_Races
.size(); ++i
)
2813 if (i
< _Races
.size()-1)
2818 if (!_Place
.empty())
2819 ret
+= " : " + _Place
;
2820 // Add the 'nb_guild_members_needed' parameter if needed
2821 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2827 REGISTER_STEP_CONTENT(CContentTarget
, "target");
2831 TCompilerVarName Item
;
2832 TCompilerVarName Qt
;
2833 TCompilerVarName Ql
;
2836 class CContentSell
: public CContentObjective
2838 vector
<TSellInfo
> _Items
;
2839 TCompilerVarName _Npc
;
2841 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2843 numEntry
= (uint32
)_Items
.size();
2844 predef
.resize(numEntry
);
2845 for (uint i
=0; i
<numEntry
; ++i
)
2847 predef
[i
].resize(3*(i
+1));
2848 for (uint j
=0; j
<i
+1; ++j
)
2850 predef
[i
][j
*3] = _Items
[j
].Item
;
2851 predef
[i
][j
*3+1] = _Items
[j
].Qt
;
2852 predef
[i
][j
*3+2] = _Items
[j
].Ql
;
2857 predef
[i
].push_back(_Npc
);
2862 void init(CMissionData
&md
, IPrimitive
*prim
)
2865 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
2867 for (uint i
=0; i
<vs
.size(); ++i
)
2869 vector
<string
> args
;
2870 explode(vs
[i
], string(" "), args
, true);
2871 if (args
.size() != 3)
2873 string err
= toString("Invalid sell item in '%s', need <item> <quantity> <quality>", vs
[i
].c_str());
2874 throw EParseException(prim
, err
.c_str());
2878 si
.Item
.initWithText(toString("i%u", i
+1), STRING_MANAGER::item
, md
, prim
, args
[0]);
2879 si
.Qt
.initWithText(toString("qt%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2880 si
.Ql
.initWithText(toString("qual%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
2881 _Items
.push_back(si
);
2884 _Npc
.init("npc", STRING_MANAGER::bot
, md
, prim
, "npc_name");
2886 CContentObjective::init(md
, prim
);
2889 string
genCode(CMissionData
&md
)
2892 ret
= CContentObjective::genCode(md
);
2896 for (uint i
=0; i
<_Items
.size(); ++i
)
2898 ret
+= _Items
[i
].Item
+" "+_Items
[i
].Qt
+" "+_Items
[i
].Ql
;
2899 if (i
< _Items
.size()-1)
2906 // Add the 'nb_guild_members_needed' parameter if needed
2907 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2913 REGISTER_STEP_CONTENT(CContentSell
, "sell");
2917 TCompilerVarName Item
;
2918 TCompilerVarName Qt
;
2919 TCompilerVarName Ql
;
2922 class CContentBuy
: public CContentObjective
2924 vector
<TBuyInfo
> _Items
;
2925 TCompilerVarName _Npc
;
2928 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
2930 numEntry
= (uint32
)_Items
.size();
2931 predef
.resize(numEntry
);
2932 for (uint i
=0; i
<numEntry
; ++i
)
2934 predef
[i
].resize(3*(i
+1));
2935 for (uint j
=0; j
<i
+1; ++j
)
2937 predef
[i
][j
*3] = _Items
[j
].Item
;
2938 predef
[i
][j
*3+1] = _Items
[j
].Qt
;
2939 predef
[i
][j
*3+2] = _Items
[j
].Ql
;
2941 predef
[i
].push_back(_Npc
);
2945 void init(CMissionData
&md
, IPrimitive
*prim
)
2948 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
2950 for (uint i
=0; i
<vs
.size(); ++i
)
2952 vector
<string
> args
;
2953 explode(vs
[i
], string(" "), args
, true);
2954 if (args
.size() != 3)
2956 string err
= toString("Invalid buy item in '%s', need <item> <quantity> <quality>", vs
[i
].c_str());
2957 throw EParseException(prim
, err
.c_str());
2961 bi
.Item
.initWithText(toString("i%u", i
+1), STRING_MANAGER::item
, md
, prim
, args
[0]);
2962 bi
.Qt
.initWithText(toString("qt%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
2963 bi
.Ql
.initWithText(toString("qual%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
2964 _Items
.push_back(bi
);
2967 _Npc
.init("npc", STRING_MANAGER::bot
, md
, prim
, "npc_name");
2969 CContentObjective::init(md
, prim
);
2972 string
genCode(CMissionData
&md
)
2975 ret
= CContentObjective::genCode(md
);
2979 for (uint i
=0; i
<_Items
.size(); ++i
)
2981 ret
+= _Items
[i
].Item
+" "+_Items
[i
].Qt
+" "+_Items
[i
].Ql
;
2982 if (i
< _Items
.size()-1)
2989 // Add the 'nb_guild_members_needed' parameter if needed
2990 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
2997 REGISTER_STEP_CONTENT(CContentBuy
, "buy");
3001 TCompilerVarName Item
;
3002 TCompilerVarName Qt
;
3003 TCompilerVarName Ql
;
3006 class CContentGive
: public CContentObjective
3008 vector
<TGiveInfo
> _Items
;
3009 TCompilerVarName _Npc
;
3012 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3014 numEntry
= (uint32
)_Items
.size();
3015 predef
.resize(numEntry
);
3016 for (uint i
=0; i
<numEntry
; ++i
)
3020 predef
[i
].resize(3*(i
+1));
3021 for (uint j
=0; j
<i
+1; ++j
)
3023 predef
[i
][j
*3] = _Items
[j
].Item
;
3024 predef
[i
][j
*3+1] = _Items
[j
].Qt
;
3025 predef
[i
][j
*3+2] = _Items
[j
].Ql
;
3030 predef
[i
].resize(2*(i
+1));
3031 for (uint j
=0; j
<i
+1; ++j
)
3033 predef
[i
][j
*2] = _Items
[j
].Item
;
3034 predef
[i
][j
*2+1] = _Items
[j
].Qt
;
3038 predef
[i
].push_back(_Npc
);
3043 void init(CMissionData
&md
, IPrimitive
*prim
)
3046 vs
= md
.getPropertyArray(prim
, "item/quantity/quality", true, false);
3048 for (uint i
=0; i
<vs
.size(); ++i
)
3050 vector
<string
> args
;
3051 explode(vs
[i
], string(" "), args
, true);
3052 if (args
.size() != 3 && args
.size() != 2)
3054 string err
= toString("Invalid give item in '%s', need <item> <quantity> [<quality>]", vs
[i
].c_str());
3055 throw EParseException(prim
, err
.c_str());
3060 _QualSpec
= args
.size() == 3;
3064 if (_QualSpec
&& args
.size() == 2)
3066 string err
= toString("Invalid give item in '%s', mixing of item with quality and item without quality is not supported", vs
[i
].c_str());
3067 throw EParseException(prim
, err
.c_str());
3072 gi
.Item
.initWithText(toString("i%u", i
+1), STRING_MANAGER::item
, md
, prim
, args
[0]);
3073 gi
.Qt
.initWithText(toString("qt%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
3076 gi
.Ql
.initWithText(toString("qual%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[2]);
3078 _Items
.push_back(gi
);
3081 _Npc
.init("npc", STRING_MANAGER::bot
, md
, prim
, "npc_name");
3083 CContentObjective::init(md
, prim
);
3086 string
genCode(CMissionData
&md
)
3089 ret
= CContentObjective::genCode(md
);
3091 ret
+= "give_item : ";
3093 for (uint i
=0; i
<_Items
.size(); ++i
)
3095 ret
+= _Items
[i
].Item
+" "+_Items
[i
].Qt
;
3097 ret
+= " "+_Items
[i
].Ql
;
3098 if (i
< _Items
.size()-1)
3102 // Add the 'nb_guild_members_needed' parameter if needed
3103 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3109 REGISTER_STEP_CONTENT(CContentGive
, "give_item");
3111 class CContentGiveMoney
: public CContentObjective
3113 TCompilerVarName _Amount
;
3114 TCompilerVarName _Npc
;
3116 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3120 predef
[0].resize(2);
3122 predef
[0][0] = _Amount
;
3123 predef
[0][1] = _Npc
;
3127 void init(CMissionData
&md
, IPrimitive
*prim
)
3129 _Amount
.init("amount", STRING_MANAGER::integer
, md
, prim
, "amount");
3130 _Npc
.init("npc", STRING_MANAGER::bot
, md
, prim
, "npc_name");
3131 CContentObjective::init(md
, prim
);
3134 string
genCode(CMissionData
&md
)
3137 ret
= CContentObjective::genCode(md
);
3139 ret
+= "give_money : "+_Amount
+" : "+_Npc
;
3140 // Add the 'nb_guild_members_needed' parameter if needed
3141 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3147 REGISTER_STEP_CONTENT(CContentGiveMoney
, "give_money");
3149 class CContentVisit
: public CContentObjective
3151 TCompilerVarName _Place
;
3152 TCompilerVarName _PlaceVar
;
3153 vector
<TCompilerVarName
> _Items
;
3155 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3159 predef
[0].resize(1+_Items
.size());
3160 predef
[0][0] = _Place
;
3162 for (uint i
=0; i
<_Items
.size(); ++i
)
3163 predef
[0][i
+1] = _Items
[i
];
3167 void init(CMissionData
&md
, IPrimitive
*prim
)
3170 _Place
.init("place", STRING_MANAGER::place
, md
, prim
, "place");
3171 _Items
= TCompilerVarName::getPropertyArrayWithText("i", STRING_MANAGER::item
, md
, prim
, "items_worn" );
3173 CContentObjective::init(md
, prim
);
3176 string
genCode(CMissionData
&md
)
3179 ret
= CContentObjective::genCode(md
);
3181 ret
+= "visit : "+_Place
;
3183 if (!_Items
.empty())
3186 for (uint i
=0; i
<_Items
.size(); ++i
)
3189 if (i
< _Items
.size()-1)
3193 // Add the 'nb_guild_members_needed' parameter if needed
3194 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3200 REGISTER_STEP_CONTENT(CContentVisit
, "visit");
3202 class CContentEscort
: public CContentObjective
3207 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3212 void init (CMissionData
&md
, IPrimitive
*prim
)
3214 _GroupName
= md
.getProperty(prim
, "group_to_escort", true, false);
3215 string s
= md
.getProperty(prim
, "save_all", true, false);
3216 _SaveAll
= NLMISC::toBool(s
);
3218 CContentObjective::init(md
, prim
);
3221 string
genCode(CMissionData
&md
)
3224 ret
= CContentObjective::genCode(md
);
3226 ret
+= "escort : "+_GroupName
;
3229 ret
+= " : save_all";
3230 // Add the 'nb_guild_members_needed' parameter if needed
3231 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3237 REGISTER_STEP_CONTENT(CContentEscort
, "escort");
3241 TCompilerVarName _SkillName
;
3242 TCompilerVarName _Level
;
3245 class CContentSkill
: public CContentObjective
3247 vector
<TSkillInfo
> _Skills
;
3249 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3251 numEntry
= (uint32
)_Skills
.size();
3252 predef
.resize(numEntry
);
3254 for (uint i
=0; i
<numEntry
; ++i
)
3256 predef
[i
].resize(2*(i
+1));
3257 for (uint j
=0; j
<i
+1; ++j
)
3259 predef
[i
][j
*2] = _Skills
[j
]._SkillName
;
3260 predef
[i
][j
*2+1] = _Skills
[j
]._Level
;
3266 void init(CMissionData
&md
, IPrimitive
*prim
)
3269 vs
= md
.getPropertyArray(prim
, "skill_name/level", true, false);
3271 for (uint i
=0; i
<vs
.size(); ++i
)
3273 vector
<string
> args
;
3274 explode(vs
[i
], string(" "), args
, true);
3276 if (args
.size() != 2)
3278 string err
= toString("Invalid skill in '%s', need <skill_name> <skill_level>", vs
[i
].c_str());
3279 throw EParseException(prim
, err
.c_str());
3283 si
._SkillName
.initWithText(toString("s%u", i
+1), STRING_MANAGER::skill
, md
, prim
, args
[0]);
3284 si
._Level
.initWithText(toString("level%u", i
+1), STRING_MANAGER::integer
, md
, prim
, args
[1]);
3285 _Skills
.push_back(si
);
3288 CContentObjective::init(md
, prim
);
3291 string
genCode(CMissionData
&md
)
3294 ret
= CContentObjective::genCode(md
);
3298 for (uint i
=0; i
<_Skills
.size(); ++i
)
3300 ret
+= _Skills
[i
]._SkillName
+" "+_Skills
[i
]._Level
;
3301 if (i
< _Skills
.size()-1)
3304 // Add the 'nb_guild_members_needed' parameter if needed
3305 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3311 REGISTER_STEP_CONTENT(CContentSkill
, "skill");
3313 class CContentMission
: public CContentObjective
3315 vector
<string
> _Missions
;
3317 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3323 CContentMission(): _Prim(0) {}
3325 void init(CMissionData
&md
, IPrimitive
*prim
)
3327 _Missions
= md
.getPropertyArray(prim
, "mission_names", true, false);
3330 CContentObjective::init(md
, prim
);
3333 string
genCode(CMissionData
&md
)
3336 ret
= CContentObjective::genCode(md
);
3338 ret
+= "mission : ";
3340 for (uint i
=0; i
<_Missions
.size(); ++i
)
3342 ret
+= _Missions
[i
];
3343 if (i
< _Missions
.size()-1)
3346 // We check to see if we specified a number after the mission name. If so, we check if it's a guild mission
3347 std::size_t pos
= _Missions
[i
].find_first_of(" \t");
3348 if (pos
!= std::string::npos
&& !md
.isGuildMission())
3350 string err
= toString("primitive(%s): CContentMission: Number of members needed to complete the mission specified but the mission is not a guild mission.", _Prim
->getName().c_str());
3351 throw EParseException(_Prim
, err
.c_str());
3354 // Add the 'nb_guild_members_needed' parameter if needed
3355 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3363 REGISTER_STEP_CONTENT(CContentMission
, "do_mission");
3365 class CContentWaitAIMsg
: public CContentObjective
3367 vector
<string
> _MsgContent
;
3369 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3375 void init(CMissionData
&md
, IPrimitive
*prim
)
3377 _MsgContent
= md
.getPropertyArray(prim
, "msg_content", true, false);
3379 CContentObjective::init(md
, prim
);
3382 string
genCode(CMissionData
&md
)
3385 ret
= CContentObjective::genCode(md
);
3387 ret
+= "wait_msg : ";
3389 for (uint i
=0; i
<_MsgContent
.size(); ++i
)
3391 ret
+= _MsgContent
[i
];
3392 if (i
< _MsgContent
.size()-1)
3395 // Add the 'nb_guild_members_needed' parameter if needed
3396 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3402 REGISTER_STEP_CONTENT(CContentWaitAIMsg
, "wait_ai_msg");
3408 class CContentQueueStart
: public CContentObjective
3413 vector
<string
> _AIInstances
;
3414 vector
<string
> _GroupsToSpawn
;
3416 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3422 void init(CMissionData
&md
, IPrimitive
*prim
)
3424 _StepName
= md
.getProperty(prim
, "step_name", true, true);
3425 _QueueName
= md
.getProperty(prim
, "queue_name", true, false);
3426 if (_StepName
.empty())
3427 _StepName
= "queue_start_" + _QueueName
;
3429 _Timer
= md
.getProperty(prim
, "timer", true, false);
3430 _GroupsToSpawn
= md
.getPropertyArray(prim
, "groups_to_spawn", true, true);
3431 if (_GroupsToSpawn
.empty())
3432 _AIInstances
= md
.getPropertyArray(prim
, "ai_instances", true, true);
3434 _AIInstances
= md
.getPropertyArray(prim
, "ai_instances", true, false);
3436 CContentObjective::init(md
, prim
);
3439 string
genCode(CMissionData
&md
)
3443 ret
= CContentObjective::genCode(md
);
3445 ret
+= "jump_point : " + _StepName
+ NL
;
3446 ret
+= "queue_start : " + _QueueName
+ " : " + _Timer
+ NL
;
3449 if (!_GroupsToSpawn
.empty())
3451 // crash : ai_instance_1 : ai_instance_2 : ...
3453 nlassert(!_AIInstances
.empty());
3454 for (i
= 0; i
< _AIInstances
.size(); ++i
)
3455 ret
+= " : " + _AIInstances
[i
];
3458 for (i
= 0; i
< _GroupsToSpawn
.size(); ++i
)
3459 ret
+= "handle_release : " + _GroupsToSpawn
[i
] + NL
;
3461 ret
+= "/crash" + NL
;
3464 ret
+= "failure" + NL
;
3465 for (i
= 0; i
< _GroupsToSpawn
.size(); ++i
)
3466 ret
+= "handle_release : " + _GroupsToSpawn
[i
] + NL
;
3467 ret
+= "/failure" + NL
;
3471 ret
+= "player_reconnect" + NL
;
3472 for (i
= 0; i
< _GroupsToSpawn
.size(); ++i
)
3473 ret
+= "handle_release : " + _GroupsToSpawn
[i
] + NL
;
3474 ret
+= "jump : " + _StepName
+ NL
;
3475 ret
+= "/player_reconnect" + NL
;
3478 for (i
= 0; i
< _GroupsToSpawn
.size(); ++i
)
3479 ret
+= "handle_create : " + _GroupsToSpawn
[i
] + NL
;
3484 REGISTER_STEP_CONTENT(CContentQueueStart
, "queue_start");
3490 class CActionQueueEnd
: public IStepContent
3494 // Find the following info in the queue_start node
3495 vector
<string
> _AIInstances
;
3496 vector
<string
> _GroupsToSpawn
;
3498 void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3503 void init(CMissionData
&md
, IPrimitive
*prim
)
3505 IStepContent::init(md
, prim
);
3506 _ActionName
= md
.getProperty(prim
, "action_name", true, true);
3507 _QueueName
= md
.getProperty(prim
, "queue_name", true, false);
3508 if (_ActionName
.empty())
3509 _ActionName
= "queue_end_" + _QueueName
;
3511 // Search in the queue_start node
3512 IPrimitive
*primParent
= prim
;
3513 while (primParent
->getParent() != NULL
)
3516 if (primParent
->getPropertyByName("class", className
))
3517 if (className
== "mission_tree")
3519 primParent
= primParent
->getParent();
3521 TPrimitiveClassPredicate
condClass("queue_start");
3522 CPrimitiveSet
<TPrimitiveClassPredicate
> s
;
3524 s
.buildSet(primParent
, condClass
, ps
);
3526 TPrimitivePropertyPredicate
condProp("queue_name", _QueueName
);
3527 CPrimitiveSetFilter
<TPrimitivePropertyPredicate
> filter
;
3528 TPrimitiveSet psFinal
;
3529 filter
.filterSet(ps
, condProp
, psFinal
);
3531 if (psFinal
.size() == 0)
3533 string err
= toString("Can't find queue_start for queue_end : '%s'", _QueueName
.c_str());
3534 throw EParseException(prim
, err
.c_str());
3536 if (psFinal
.size() > 1)
3538 string err
= toString("More than 1 queue_start for queue_end : '%s'", _QueueName
.c_str());
3539 throw EParseException(prim
, err
.c_str());
3542 _GroupsToSpawn
= md
.getPropertyArray(psFinal
[0], "groups_to_spawn", true, true);
3543 if (_GroupsToSpawn
.empty())
3544 _AIInstances
= md
.getPropertyArray(psFinal
[0], "ai_instances", true, true);
3546 _AIInstances
= md
.getPropertyArray(psFinal
[0], "ai_instances", true, false);
3550 string
genCode(CMissionData
&md
)
3555 if (!_GroupsToSpawn
.empty())
3557 for (i
= 0; i
< _GroupsToSpawn
.size(); ++i
)
3558 ret
+= "handle_release : " + _GroupsToSpawn
[i
] + NL
;
3562 if (!_AIInstances
.empty())
3565 for (i
= 0; i
< _AIInstances
.size(); ++i
)
3566 ret
+= " : " + _AIInstances
[i
];
3568 ret
+= "/crash" + NL
;
3572 ret
+= "failure" + NL
;
3573 ret
+= "/failure" + NL
;
3576 ret
+= "player_reconnect" + NL
;
3577 ret
+= "/player_reconnect" + NL
;
3579 ret
+= "queue_end : " +_QueueName
+ NL
;
3585 REGISTER_STEP_CONTENT(CActionQueueEnd
, "queue_end");
3588 class CContentRingScenario
: public CContentObjective
3590 string _ScenarioTag
;
3592 virtual void getPredefParam(uint32
&numEntry
, CPhrase::TPredefParams
&predef
)
3598 void init(CMissionData
&md
, IPrimitive
*prim
)
3600 _ScenarioTag
= md
.getProperty(prim
, "scenario_tag", true, false);
3602 CContentObjective::init(md
, prim
);
3605 string
genCode(CMissionData
&md
)
3608 ret
= CContentObjective::genCode(md
);
3610 ret
+= "ring_scenario : ";
3611 ret
+= _ScenarioTag
;
3612 // Add the 'nb_guild_members_needed' parameter if needed
3613 //ret += CContentObjective::genNbGuildMembersNeededOption(md);
3619 REGISTER_STEP_CONTENT(CContentRingScenario
, "ring_scenario");