1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "ai_actions.h"
22 using namespace NLMISC
;
23 //using namespace NLNET;
30 //-------------------------------------------------------------------------
31 // GENERATING BOT MANAGERS & GROUPS
33 NLMISC_COMMAND(setMap
,"set the active map","<name>")
35 if (args
.size() !=1) return false;
37 CAIActions::exec("SET_MAP",args
[0]);
42 NLMISC_COMMAND(setMgr
,"set the active manager within a map","<name>|<slot>")
44 if (args
.size() !=1) return false;
46 // see if we have a number or a name
48 NLMISC::fromString(args
[0], slot
);
50 if (toString(slot
)!=args
[0])
51 CAIActions::exec("SET_MGR",slot
);
53 CAIActions::exec("SET_MGR",-1,args
[0]);
58 NLMISC_COMMAND(setGrp
,"set the active group within a manager","<name>|<slot>")
60 if (args
.size() !=1) return false;
62 // see if we have a number or a name
64 NLMISC::fromString(args
[0], slot
);
66 if (toString(slot
)!=args
[0])
67 CAIActions::exec("SET_GRP",slot
);
69 CAIActions::exec("SET_GRP",-1,args
[0]);
75 NLMISC_COMMAND(newFaunaManager
,"create the fauna manager for a region","<name> [<slot>]")
86 case 2: // <name> <slot>
88 // the slot id is explicit so make sure its a number
89 NLMISC::fromString(args
[1], slot
);
90 if (toString(slot
)!=args
[1])
99 CAIActions::exec("SET_MGR",slot
,args
[0],"FAUNA");
104 NLMISC_COMMAND(newPlaceXYR
,"","<place name> <x> <y> <r> <verticalPos>")
110 NLMISC::fromString(args
[1], x
);
111 NLMISC::fromString(args
[2], y
);
112 sint r
=10; // default value.
113 uint32 vp
= AITYPES::vp_auto
;
114 if (!args
[3].empty())
116 NLMISC::fromString(args
[3], r
);
118 vp
= AITYPES::verticalPosFromString(args
[4]);
120 if (toString(x
)+toString(y
)+toString(r
)!=args
[1]+args
[2]+args
[3])
122 nlinfo("Cumulated numeric parameter test failed: '%s' != '%s'",(toString(x
)+toString(y
)+toString(r
)).c_str(),(args
[1]+args
[2]+args
[3]).c_str());
126 CAIActions::exec("PLACEXYR",args
[0],x
*1000,y
*1000,r
*1000, vp
);
131 NLMISC_COMMAND(newHerbivoreGroup
,"","<group name> ")
133 if(args
.size() !=4) return false;
135 CAIActions::exec("SET_GRP",-1,args
[0],"HERBIVORE");
140 NLMISC_COMMAND(newPredatorGroup
,"","<group name> <spawn point> <eat point> <rest point>")
142 if(args
.size() !=4) return false;
144 CAIActions::exec("SET_GRP",-1,args
[0],"PREDATOR");
149 NLMISC_COMMAND(newPlantGroup
,"","<group name> <spawn point> <eat point> <rest point>")
151 if(args
.size() !=4) return false;
153 CAIActions::exec("SET_GRP",-1,args
[0],"PLANT");
158 NLMISC_COMMAND(newAnimatGroup
,"","<group name> <spawn point> <eat point> <rest point>")
160 if(args
.size() !=4) return false;
162 CAIActions::exec("SET_GRP",-1,args
[0],"ANIMAT");
167 NLMISC_COMMAND(newScavengerGroup
,"","<group name> <spawn point> <eat point> <rest point>")
169 if(args
.size() !=4) return false;
171 CAIActions::exec("SET_GRP",-1,args
[0],"SCAVENGER");
176 NLMISC_COMMAND(addHerbivorePopulation
,"add a population version to the current group","<creature type> <qty> [<type> <qty>] [...] [...]")
178 if ( (args
.size()&1) || args
.size()>8)
181 std::vector
<CAIActions::CArg
> executeArgs
;
184 executeArgs
.push_back(100);
186 // check that every second argument is a number
187 for (uint i
=0;i
<args
.size();i
+=2)
190 NLMISC::fromString(args
[i
+1], count
);
191 if (toString(count
)!=args
[i
+1])
193 executeArgs
.push_back(CAIActions::CArg(args
[i
]));
194 executeArgs
.push_back(count
);
196 CAIActions::execute("POP_ADD",executeArgs
);
203 NLMISC_COMMAND(newUrbanManager
,"create the urban npc manager for a sttlement","<name> [<slot>]")
214 case 2: // <name> <slot>
216 // the slot id is explicit so make sure its a number
217 NLMISC::fromString(args
[1], slot
);
218 if (toString(slot
)!=args
[1])
227 CAIActions::exec("SET_MGR",slot
,args
[0],"URBAN");
232 NLMISC_COMMAND(newStationaryGroup
,"","<group name>")
234 if(args
.size() !=1) return false;
236 CAIActions::exec("SET_GRP",-1,args
[0],"STATIONARY");
241 NLMISC_COMMAND(npcAddGrpPatrol
,"add a group to the manager","<name>")
243 if(args
.size() !=1) return false;
245 CAIActions::exec("SET_GRP",-1,args
[0],"PATROL");
250 NLMISC_COMMAND(npcAddGrpGuard
,"add a group to the manager","<name>")
252 if(args
.size() !=1) return false;
254 CAIActions::exec("SET_GRP",-1,args
[0],"GUARD");
259 NLMISC_COMMAND(npcAddGrpWandering
,"add a group to the manager","<name>")
261 if(args
.size() !=1) return false;
263 CAIActions::exec("SET_GRP",-1,args
[0],"WANDER");
268 NLMISC_COMMAND(npcGrpSetRoute
,"setup a patrol route","<route name>")
273 CAIActions::exec("SETROUTE",args
[0]);
278 NLMISC_COMMAND(npcMgrDefaults
,"setup the manager dummy bot","")
283 CAIActions::exec("SET_BOT");
288 NLMISC_COMMAND(npcGrpDefaults
,"setup the manager dummy bot","")
293 CAIActions::exec("SET_BOT");
298 NLMISC_COMMAND(addNpc
,"create a new npc ","<x> <y> <theta>")
303 uint x
=(uint
)(1000.0*atof(args
[0].c_str()));
304 uint y
=(uint
)(1000.0*atof(args
[1].c_str()));
305 float theta
=(float)atof(args
[2].c_str());
307 CAIActions::exec("SET_BOT",-1,"npc",x
,y
,theta
);
312 NLMISC_COMMAND(npcSetColours
,"set the npc clothing colour scheme","<colour scheme>")
317 CAIActions::exec("COLOURS");
322 NLMISC_COMMAND(npcSetName
,"set npc name","<name>")
327 // concatenate the names on the command line into a single string
328 std::string s
=args
[0];
329 for (uint i
=1;i
<args
.size();++i
)
332 CAIActions::exec("NAME",s
);
337 NLMISC_COMMAND(npcSetGameForm
,"set the .CREATURE sheet to use for game stats","<sheet name>")
342 CAIActions::exec("GAMEFORM",args
[0]);
347 NLMISC_COMMAND(npcSetLookForm
,"set the .CREATURE sheet to use for look on client","<sheet name>")
352 CAIActions::exec("LOOKFORM",args
[0]);
357 NLMISC_COMMAND(npcSetLookType
,"set the possible look types","<keyword>")
362 CAIActions::exec("LOOKTYPE",args
[0]);
367 NLMISC_COMMAND(npcSetChat
,"set the npc chat parameters","<keyword>[...]")
372 // prepare the arguments from the command line for the 'execute' command
373 std::vector
<CAIActions::CArg
> executeArgs
;
374 for (uint i
=0;i
<args
.size();++i
)
375 executeArgs
.push_back(CAIActions::CArg(args
[i
]));
377 CAIActions::execute("CHATTYPE",executeArgs
);
383 // THIS LINE EXISTS TO MAKE SURE THE LINKER DOESN'T THROW OUT THIS MODULE AT LINK TIME!!!
384 bool LinkWithAiActionCommands
=false;
386 } // end of namespace