// Ryzom - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#include "stdpch.h"
#include "ai_actions.h"
using namespace NLMISC;
//using namespace NLNET;
using namespace std;
namespace AI_SHARE
{
//-------------------------------------------------------------------------
// GENERATING BOT MANAGERS & GROUPS
NLMISC_COMMAND(setMap,"set the active map","")
{
if (args.size() !=1) return false;
CAIActions::exec("SET_MAP",args[0]);
return true;
}
NLMISC_COMMAND(setMgr,"set the active manager within a map","|")
{
if (args.size() !=1) return false;
// see if we have a number or a name
uint slot;
NLMISC::fromString(args[0], slot);
if (toString(slot)!=args[0])
CAIActions::exec("SET_MGR",slot);
else
CAIActions::exec("SET_MGR",-1,args[0]);
return true;
}
NLMISC_COMMAND(setGrp,"set the active group within a manager","|")
{
if (args.size() !=1) return false;
// see if we have a number or a name
uint slot;
NLMISC::fromString(args[0], slot);
if (toString(slot)!=args[0])
CAIActions::exec("SET_GRP",slot);
else
CAIActions::exec("SET_GRP",-1,args[0]);
return true;
}
NLMISC_COMMAND(newFaunaManager,"create the fauna manager for a region"," []")
{
uint slot;
switch (args.size())
{
case 1: //
{
slot=~0;
break;
}
case 2: //
{
// the slot id is explicit so make sure its a number
NLMISC::fromString(args[1], slot);
if (toString(slot)!=args[1])
return false;
break;
}
default:
return false;
}
CAIActions::exec("SET_MGR",slot,args[0],"FAUNA");
return true;
}
NLMISC_COMMAND(newPlaceXYR,""," ")
{
if(args.size() !=5)
return false;
sint x, y;
NLMISC::fromString(args[1], x);
NLMISC::fromString(args[2], y);
sint r=10; // default value.
uint32 vp = AITYPES::vp_auto;
if (!args[3].empty())
{
NLMISC::fromString(args[3], r);
}
vp = AITYPES::verticalPosFromString(args[4]);
if (toString(x)+toString(y)+toString(r)!=args[1]+args[2]+args[3])
{
nlinfo("Cumulated numeric parameter test failed: '%s' != '%s'",(toString(x)+toString(y)+toString(r)).c_str(),(args[1]+args[2]+args[3]).c_str());
return false;
}
CAIActions::exec("PLACEXYR",args[0],x*1000,y*1000,r*1000, vp);
return true;
}
NLMISC_COMMAND(newHerbivoreGroup,""," ")
{
if(args.size() !=4) return false;
CAIActions::exec("SET_GRP",-1,args[0],"HERBIVORE");
return true;
}
NLMISC_COMMAND(newPredatorGroup,""," ")
{
if(args.size() !=4) return false;
CAIActions::exec("SET_GRP",-1,args[0],"PREDATOR");
return true;
}
NLMISC_COMMAND(newPlantGroup,""," ")
{
if(args.size() !=4) return false;
CAIActions::exec("SET_GRP",-1,args[0],"PLANT");
return true;
}
NLMISC_COMMAND(newAnimatGroup,""," ")
{
if(args.size() !=4) return false;
CAIActions::exec("SET_GRP",-1,args[0],"ANIMAT");
return true;
}
NLMISC_COMMAND(newScavengerGroup,""," ")
{
if(args.size() !=4) return false;
CAIActions::exec("SET_GRP",-1,args[0],"SCAVENGER");
return true;
}
NLMISC_COMMAND(addHerbivorePopulation,"add a population version to the current group"," [ ] [...] [...]")
{
if ( (args.size()&1) || args.size()>8)
return false;
std::vector executeArgs;
// push the weight
executeArgs.push_back(100);
// check that every second argument is a number
for (uint i=0;i []")
{
uint slot;
switch (args.size())
{
case 1: //
{
slot=~0;
break;
}
case 2: //
{
// the slot id is explicit so make sure its a number
NLMISC::fromString(args[1], slot);
if (toString(slot)!=args[1])
return false;
break;
}
default:
return false;
}
CAIActions::exec("SET_MGR",slot,args[0],"URBAN");
return true;
}
NLMISC_COMMAND(newStationaryGroup,"","")
{
if(args.size() !=1) return false;
CAIActions::exec("SET_GRP",-1,args[0],"STATIONARY");
return true;
}
NLMISC_COMMAND(npcAddGrpPatrol,"add a group to the manager","")
{
if(args.size() !=1) return false;
CAIActions::exec("SET_GRP",-1,args[0],"PATROL");
return true;
}
NLMISC_COMMAND(npcAddGrpGuard,"add a group to the manager","")
{
if(args.size() !=1) return false;
CAIActions::exec("SET_GRP",-1,args[0],"GUARD");
return true;
}
NLMISC_COMMAND(npcAddGrpWandering,"add a group to the manager","")
{
if(args.size() !=1) return false;
CAIActions::exec("SET_GRP",-1,args[0],"WANDER");
return true;
}
NLMISC_COMMAND(npcGrpSetRoute,"setup a patrol route","")
{
if ( args.size()!=1)
return false;
CAIActions::exec("SETROUTE",args[0]);
return true;
}
NLMISC_COMMAND(npcMgrDefaults,"setup the manager dummy bot","")
{
if ( args.size()!=0)
return false;
CAIActions::exec("SET_BOT");
return true;
}
NLMISC_COMMAND(npcGrpDefaults,"setup the manager dummy bot","")
{
if ( args.size()!=0)
return false;
CAIActions::exec("SET_BOT");
return true;
}
NLMISC_COMMAND(addNpc,"create a new npc "," ")
{
if ( args.size()!=3)
return false;
uint x=(uint)(1000.0*atof(args[0].c_str()));
uint y=(uint)(1000.0*atof(args[1].c_str()));
float theta=(float)atof(args[2].c_str());
CAIActions::exec("SET_BOT",-1,"npc",x,y,theta);
return true;
}
NLMISC_COMMAND(npcSetColours,"set the npc clothing colour scheme","")
{
if ( args.size()!=1)
return false;
CAIActions::exec("COLOURS");
return true;
}
NLMISC_COMMAND(npcSetName,"set npc name","")
{
if ( args.size()!=1)
return false;
// concatenate the names on the command line into a single string
std::string s=args[0];
for (uint i=1;i")
{
if ( args.size()!=1)
return false;
CAIActions::exec("GAMEFORM",args[0]);
return true;
}
NLMISC_COMMAND(npcSetLookForm,"set the .CREATURE sheet to use for look on client","")
{
if ( args.size()!=1)
return false;
CAIActions::exec("LOOKFORM",args[0]);
return true;
}
NLMISC_COMMAND(npcSetLookType,"set the possible look types","")
{
if ( args.size()!=1)
return false;
CAIActions::exec("LOOKTYPE",args[0]);
return true;
}
NLMISC_COMMAND(npcSetChat,"set the npc chat parameters","[...]")
{
if ( args.size()<1)
return false;
// prepare the arguments from the command line for the 'execute' command
std::vector executeArgs;
for (uint i=0;i