/** \file commands.cpp * File with all the commands for the console. * * $Id: commands.cpp,v 1.8 2004/06/23 15:03:04 lecroart Exp $ */ ////////////// // Includes // ////////////// #include "stdpch.h" // Game Share #include "game_share/generic_xml_msg_mngr.h" #include "game_share/visual_slot_manager.h" // Misc. #include "nel/misc/command.h" #include "nel/misc/i18n.h" #include "nel/misc/bit_mem_stream.h" // 3D Interface. #include "nel/3d/u_scene.h" #include "nel/3d/u_landscape.h" #include "nel/3d/u_play_list.h" #include "nel/3d/u_animation_set.h" #include "nel/3d/u_animation.h" #include "nel/3d/u_track.h" #include "nel/3d/u_play_list_manager.h" // Client. #include "interface_manager.h" #include "commands.h" #include "user_entity.h" #include "entity_animation_manager.h" #include "firework.h" #include "view.h" #include "time_client.h" #include "entities.h" #include "world_database_manager.h" #include "continent_manager.h" #include "continent.h" #include "ig_client.h" #include "ingame_database_manager.h" #include "client_chat_manager.h" #include "net_manager.h" #include "pacs_client.h" #include "teleport.h" #include "misc.h" #include "sheet_manager.h" #include "demo.h" #include "sound_manager.h" #include "cdb_leaf.h" #include "debug_client.h" #include "input_handler_manager.h" // game share #include "game_share/brick_types.h" #include "game_share/player_visual_properties.h" #include "game_share/ryzom_version.h" #include "game_share/mode_and_behaviour.h" #include "brick_manager.h" //////////// // DEFINE // //////////// //#define _LIMITED_COMMAND_ // Disable some commands #define _CMD_CHEAT_ON_ // Activate cheat commands #define _CMD_TEST_ON_ // Activate test commands #define _CMD_DEBUG_ON_ // Activate debug commands //////////////// // Namespaces // //////////////// using namespace NLMISC; using namespace NL3D; using namespace NLNET; using namespace std; ///////////// // Externs // ///////////// extern CUserEntity UserEntity; extern UScene * Scene; extern ULandscape * Landscape; extern CEntityAnimationManager * EAM; extern CFirework * Firework; extern CClientChatManager ChatMngr; extern CGenericXmlMsgHeaderManager GenericMsgHeaderMngr; extern ::CNetManagerMulti NetMngr; extern CInterfaceManager *IM; ////////////// // COMMANDS // ////////////// //////////////////// // FINAL COMMANDS // //----------------------------------------------- // 'emote' : play an emote. //----------------------------------------------- NLMISC_COMMAND(emote, "play an emote.", "") { const uint nbEmotes = EAM->getNbEmots(); // Check parameters. if(args.size() == 1) { // Check the number is valid. uint num = atoi(args[0].c_str()); if(num < nbEmotes) { // Create the message and send. const string msgName = "COMMAND:EMOTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { MBEHAV::EBehaviour behaviour = (MBEHAV::EBehaviour)(MBEHAV::EMOTE_BEGIN + num); out.serialEnum(behaviour); NetMngr.push(out); } else nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); // Command Well done. return true; } } CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 1 paramter and this must be one of the following number :")); CAnimationState::TAnimStateId result; for(uint i = 0; igetEmot(i, result); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString("%d - %s", i, CAnimationState::getAnimationStateName(result).c_str ()))); } // Command Well done. return true; }// chat_mode // //----------------------------------------------- // 'guildSymbol' : Show/Hide the Guild Symbol. //----------------------------------------------- NLMISC_COMMAND(guildSymbol, "Show/Hide the Guild Symbol.", "") { // Check parameters. if(args.size() != 0) return false; // Invert the state. GuildSymbol.Active = !GuildSymbol.Active; // Command Well done. return true; }// chat_mode // //----------------------------------------------- // 'chatMode' : To specify how you will speak and who will be able to hear you. //----------------------------------------------- NLMISC_COMMAND(chatMode, "To specify how will you speak and who will be able to hear you.", "") { // Check parameters. if(args.size() != 1) return false; CInputHandlerManager *pIHM = CInputHandlerManager::getInstance(); uint8 mode ; if (args[0] == "say") mode = 0; else if(args[0] == "shout") mode = 1; else if(args[0] == "universe") mode = 2; else if(args[0] == "team") mode = 3; else if(args[0] == "clade") mode = 4; else { nlwarning("Command 'chatMode': unknown chat mode '%s'.", args[0].c_str()); return false; } // Display debug info. nlinfo("Command 'chatMode': '%s' mode.", args[0].c_str()); // Set the chat mode. ChatMngr.setChatMode(mode); // Command Well done. return true; }// chat_mode // //----------------------------------------------- // 'tell' : send a private message to a unique player. //----------------------------------------------- NLMISC_COMMAND(tell, "send a private message to a unique player", "") { // Check parameters. if(args.size() < 2) return false; // Compute the message. string message; for(uint i=1; i") { const char *brname[] = { "bug_report.exe", "bug_report_r.exe", "bug_report_rd.exe", "bug_report_df.exe", "bug_report_d.exe" }; string brn; for (uint i = 0; i < sizeof(brname)/sizeof(brname[0]); i++) { if (CFile::fileExists (brname[i])) { brn = brname[i]; break; } } if (brn.empty()) { log.displayNL("bug_report*.exe not found"); return false; } string sys; sys = "Language "+CI18N::getCurrentLanguageName().toString() +" "; if (args.size()>0) { uint8 quality = atoi (args[0].c_str()); if (quality == 0) quality = 80; CBitmap btm; Driver->getBuffer(btm); string filename = CFile::findNewFile ("screenshot.jpg"); COFile fs(filename); btm.writeJPG(fs, quality); sys += "AttachedFile "+filename+" "; } sys += "ClientVersion "RYZOM_VERSION" "; // for now, set the same version than client one sys += "ShardVersion "RYZOM_VERSION" "; if (ClientCfg.Local) sys += "ShardName OFFLINE "; FILE *fp = fopen ("bug_report.txt", "wb"); if (fp != NULL) { // must put \r\n each line fprintf (fp, "UserPosition: %.2f %.2f %.2f\r\n", View.viewPos().x, View.viewPos().y, View.viewPos().z); fprintf (fp, "ServerTick: %u\r\n", NetMngr.getCurrentServerTick() ); fprintf (fp, "LocalAddress: %s\r\n", NetMngr.getAddress().asString().c_str() ); // TODO add debug information for the bug report fclose (fp); sys += "DumpFilename bug_report.txt "; } nlinfo ("Calling for bug report : '%s %s'", brn.c_str(), sys.c_str()); launchProgram(brn, sys); return true; } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /////////// COMMANDS after should NOT appear IN the FINAL VERSION /////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// #if !FINAL_VERSION NLMISC_COMMAND(missionReward, "debug"," ") { if (args.size() == 1) { uint8 index = atoi( args[1].c_str() ); CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("BOTCHAT:COMPLETE_MISSION", out)) { out.serial(index); NetMngr.push(out); } else nlwarning(" : unknown message name : BOTCHAT:COMPLETE_MISSION"); return true; } return false; } NLMISC_COMMAND(missionProgress, "debug"," ") { if (args.size() == 1) { uint8 index = atoi( args[1].c_str() ); CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("BOTCHAT:PROGRESS_MISSION", out)) { out.serial(index); NetMngr.push(out); } else nlwarning(" : unknown message name : BOTCHAT:PROGRESS_MISSION"); return true; } return false; } /* NLMISC_COMMAND( displayDBModifs, "display server database modification in the chat window"," ") { if ( VerboseDatabase ) CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already in verbose mode"),CRGBA(255,255,255,255)); else { CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is now in verbose mode"),CRGBA(255,255,255,255)); VerboseDatabase = true; } return true; } NLMISC_COMMAND( hideDBModifs, "stop displaying server database modification in the chat window"," ") { if ( !VerboseDatabase ) CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already not in verbose mode"),CRGBA(255,255,255,255)); else { CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is not in verbose mode anymore"),CRGBA(255,255,255,255)); VerboseDatabase = false; } return true; } */ NLMISC_COMMAND(save_sentences, "save sentences"," ") { // CSentenceDisplayer::saveSentences(); return true; } NLMISC_COMMAND(get_sheet_id, "get_sheet_id","") { if (args.size() != 1) return false; CSheetId id(args[0]); char buf[10]; itoa( id.asInt(),buf,10 ); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(buf)); return true; } NLMISC_COMMAND(get_sheet_name, "get_sheet_name","") { if (args.size() != 1) return false; CSheetId id( atoi(args[0].c_str()) ); string name = id.toString(); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name)); return true; } NLMISC_COMMAND(forget_all, "forget all bricks", "") { // Check parameters. if(args.size() != 0) { return false; } char buf[100]; for (uint i = 0;i<20;i++) { sprintf(buf,"SERVER:BRICK_FAMILY:%d:BRICKS",i); CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(buf); node->setValue64(0); } return true; } // forget_all // //----------------------------------------------- // 'use_preprog_magic' //----------------------------------------------- NLMISC_COMMAND(use_preprog_magic, "use the specified magic preprog sentence", "") { // Check parameters. if(args.size() != 1) { return false; } // Create the message for the server to execute a phrase. const string msgName = "SENTENCE:EXECUTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("SENTENCE:EXECUTE", out)) { uint8 phrase = atoi(args[0].c_str() ); out.serial(phrase); BRICK_TYPE::EBrickType type = BRICK_TYPE::MAGIC; out.serialEnum( type ); NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // use_preprog_magic // //----------------------------------------------- // 'use_preprog_combat' //----------------------------------------------- NLMISC_COMMAND(use_preprog_combat, "use the specified combat preprog sentence", "") { // Check parameters. if(args.size() != 1) { return false; } // Create the message for the server to execute a phrase. const string msgName = "SENTENCE:EXECUTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("SENTENCE:EXECUTE", out)) { uint8 phrase = atoi(args[0].c_str() ); out.serial(phrase); BRICK_TYPE::EBrickType type = BRICK_TYPE::COMBAT; out.serialEnum( type ); NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // use_preprog_combat // //----------------------------------------------- // 'engage' //----------------------------------------------- NLMISC_COMMAND(engage, "engage target in combat", "") { // Create the message for the server to execute a phrase. const string msgName = "COMBAT:ENGAGE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // engage // //----------------------------------------------- // 'default_attack' //----------------------------------------------- NLMISC_COMMAND(default_attack, "use default attack on target", "") { // Default attack on the current selection. UserEntity.attack(); // Well Done. return true; }// default_attack // //----------------------------------------------- // 'disengage' //----------------------------------------------- NLMISC_COMMAND(disengage, "disengage from combat", "") { // Disengage from combat. UserEntity.disengage(); // Well Done. return true; }// disengage // //----------------------------------------------- // 'create_team' //----------------------------------------------- NLMISC_COMMAND(create_team, "create a new team", "") { // Create the message for the server to execute a phrase. const string msgName = "TEAM:CREATE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // create_team // //----------------------------------------------- // 'leave_team' //----------------------------------------------- NLMISC_COMMAND(leave_team, "leave team", "") { // Create the message for the server to execute a phrase. const string msgName = "TEAM:LEAVE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // leave_team // //----------------------------------------------- // 'join_team' //----------------------------------------------- NLMISC_COMMAND(join_team, "join the specified team", "") { // Create the message for the server to execute a phrase. const string msgName = "TEAM:JOIN"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // join_team // //----------------------------------------------- // 'join_team_proposal' //----------------------------------------------- NLMISC_COMMAND(join_team_proposal, "propose to current target to join the team", "") { // Create the message for the server to execute a phrase. const string msgName = "TEAM:JOIN_PROPOSAL"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // join_team_proposal // //----------------------------------------------- // 'join_team_decline' //----------------------------------------------- NLMISC_COMMAND(join_team_decline, "decline a join team proposal", "") { // Create the message for the server to execute a phrase. const string msgName = "TEAM:JOIN_PROPOSAL_DECLINE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // join_team_decline // //----------------------------------------------- // 'kick_teammate' //----------------------------------------------- NLMISC_COMMAND(kick_teammate, "kick someone from your team", "") { // Create the message for the server to execute a phrase. const string msgName = "TEAM:KICK"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); return true; } // kick_teammate // //----------------------------------------------- // 'cancel_current_sentence' //----------------------------------------------- NLMISC_COMMAND(cancel_current_sentence, "cancel the sentence being executed", "") { // no parameter needed // Create the message for the server to cancel the phrase being executed const string msgName = "SENTENCE:CANCEL_CURRENT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("command : unknown message name : '%s'.", msgName.c_str()); return true; } // cancel_current_sentence // //----------------------------------------------- // 'cancel_all_sentences' //----------------------------------------------- NLMISC_COMMAND(cancel_all_sentences, "cancel all the sentences being executed", "") { // no parameter needed // Create the message for the server to cancel the phrase being executed const string msgName = "SENTENCE:CANCEL_ALL"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { NetMngr.push(out); } else nlwarning("command : unknown message name : '%s'.", msgName.c_str()); return true; } // cancel_all_sentences // //----------------------------------------------- // 'ignore' //----------------------------------------------- NLMISC_COMMAND(ignore, "add or remove a player from the ignore list", "") { // Check parameters. if(args.size() < 1) { return false; } // send info string player = args[0]; ChatMngr.ignore( player ); return true; } // ignore // /* //----------------------------------------------- // drop : //----------------------------------------------- NLMISC_COMMAND(drop,"drop an item to the ground","") { if( args.size() < 1 ) { return false; } uint32 id = atoi( args[0].c_str() ); CEntityId itemId(RYZOMID::object,id); sint32 x = (sint32)UserEntity.pos().x * 1000; sint32 y = (sint32)UserEntity.pos().y * 1000; sint32 z = (sint32)UserEntity.pos().z * 1000; CBitMemStream bms; string msgType = "ITEM:DROP"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( itemId ); bms.serial( x ); bms.serial( y ); bms.serial( z ); NetMngr.push( bms ); nldebug(" sending 'ITEM:DROP' message to server"); } else { nlwarning(" unknown message name : ITEM:DROP"); } return true; }// drop // */ ////////// // DEMO // class CDummyProgress : public IProgressCallback { void progress (float value) {}; }; #ifndef _LIMITED_COMMAND_ //----------------------------------------------- // teleport : // Teleport the User somewhere else. //----------------------------------------------- void teleport(const CVectorD &pos) { if(!ClientCfg.Local) { // Create the message for the server to teleport the character. CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("TP:WANTED", out)) { sint32 x = (sint32)(pos.x*1000.0); sint32 y = (sint32)(pos.y*1000.0); sint32 z = (sint32)(pos.z*1000.0); out.serial( x ); out.serial( y ); out.serial( z ); // Add the message to the send list. NetMngr.push(out); // send TELEPORT nldebug("teleport: TELEPORT sent"); } else nlwarning("teleport: unknown message name : 'TP:WANTED'."); } else { // Remove the selection. UserEntity.selection(CLFECOMMON::INVALID_SLOT); // Remove the target. UserEntity.targetSlot(CLFECOMMON::INVALID_SLOT); // Change the position of the entity and in Pacs. UserEntity.pos(pos); // Select the closest continent from the new position. CDummyProgress dummy; ContinentMngr.select(pos, dummy); // Change the position of the entity and in Pacs. UserEntity.pacsPos(pos); } }// teleport // //----------------------------------------------- // 'pos' : Command To change the user position. //----------------------------------------------- NLMISC_COMMAND(pos, "Change the position of the user.", " OR 1 name of 'tp.teleport_list'. or a bot name") { CVectorD newPos; // Named destination. if(args.size() == 1) { string dest = args[0]; newPos = CTeleport::getPos(NLMISC::strlwr(dest)); if(newPos == CTeleport::Unknown) { //here we try to teleport to a bot destination CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("TP:BOT", out)) { string str = args[0]; out.serial( str ); nldebug("/pos: TP:BOT sent"); NetMngr.push(out); } else nlwarning("/pos: unknown message name : 'TP:BOT'."); return true; } } // Teleport to anywhere. else if(args.size() == 2 || args.size() == 3) { newPos.x = atof(args[0].c_str()); newPos.y = atof(args[1].c_str()); if(args.size() == 3) newPos.z = atof(args[2].c_str()); else newPos.z = 0.0; } // Bad argument number. else return false; // Teleport to the right destination. teleport(newPos); // Command well done. return true; } //----------------------------------------------- // 'entity' : Create an entity on the user or just remove it if Form not valid. //----------------------------------------------- NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form not valid.", "
") { // Check parameters. if(args.size() != 2) return false; // Try to create the sheet with the parameter as a string. CSheetId sheetId; if(!sheetId.build(args[1])) { // Try to create the sheet with the parameter as an int. sheetId = atoi(args[1].c_str()); if(sheetId == CSheetId::Unknown) { nlwarning("Command 'entity': '%s' is not a valid form.", args[1]); return false; } } // The slot where the new entity will be. CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); // Debug Infos nldebug("Command 'entity' : AddNewEntity with form %s in the slot %d.", args[1].c_str(), slot); // Remove the old entity. EntitiesMngr.remove(slot, false); // Create the new entity. CEntityCL *entity = EntitiesMngr.create(slot, sheetId.asInt()); if(entity) { // Update VP if Player if(dynamic_cast(entity)) { SPropVisualA visualA; visualA.PropertySubData.Sex = ClientCfg.Sex; SPropVisualB visualB; SPropVisualC visualC; sint64 *prop = (sint64 *)&visualB; IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); prop = (sint64 *)&visualC; IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); prop = (sint64 *)&visualA; IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); } // Compute the position. sint64 x = (sint64)((UserEntity.pos().x+UserEntity.front().x*2.0)*1000.0); sint64 y = (sint64)((UserEntity.pos().y+UserEntity.front().y*2.0)*1000.0); sint64 z = (sint64)((UserEntity.pos().z+UserEntity.front().z*2.0)*1000.0); // Write the position in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); // Update the position. EntitiesMngr.updateVisualProperty(0, slot, 0); // Set the direction entity->front(UserEntity.front()); entity->dir(UserEntity.front()); nlinfo("entity: slot: %d \"%s\", \"%f\", \"%f\", \"%f\", \"%f\", \"%f\", \"%f\" ",slot,args[1].c_str(), (UserEntity.pos().x+UserEntity.front().x*2.0), (UserEntity.pos().y+UserEntity.front().y*2.0), (UserEntity.pos().z+UserEntity.front().z*2.0)); // UserEntity.front().x, UserEntity.front().y, UserEntity.front().z ); } else nldebug("command 'entity' : entity in slot %d removed.", slot); // Command well done. return true; }// entity // //////////////////// // DEBUG COMMANDS // #include "string_manager_client.h" #ifdef ENABLE_INCOMING_MSG_RECORDER //----------------------------------------------- // record //----------------------------------------------- NLMISC_COMMAND(record, "Start Recording", "name") { // Check parameters. if(args.size() != 1) return false; // Warning when already recording. if(NetMngr.isRecording()) { IM->displaySystemInfo(ucstring("Already Recording. Stop the current Record first")); return true; } // Save entities and DB. dump(args[0]); // On/Off record. if(!ClientCfg.Local) NetMngr.setRecordingMode(true, args[0]+"_net.rec"); return true; }// record // //----------------------------------------------- // replay //----------------------------------------------- NLMISC_COMMAND(replay, "replay", "name") { // Check parameters. if(args.size() != 1) return false; // Load entities and DB. loadDump(args[0]); // On/Off record. if(ClientCfg.Local) NetMngr.setReplayingMode(!NetMngr.isReplaying(), args[0]+"_net.rec"); return true; }// replay // //----------------------------------------------- // stopRecord //----------------------------------------------- NLMISC_COMMAND(stopRecord, "Stop Recording", "") { // Check parameters. if(args.size() != 0) return false; // On/Off record. if(!ClientCfg.Local) NetMngr.setRecordingMode(false); return true; }// stopRecord // #endif // ENABLE_INCOMING_MSG_RECORDER //----------------------------------------------- // 'dump' : command to create a file with the current state of the client. //----------------------------------------------- NLMISC_COMMAND(dump, "Command to create a file with the current state of the client.", " = default]") { if(args.size() > 1) return false; string dumpName; if(args.size() == 1) dumpName = args[0]; else dumpName = "default"; dump(dumpName); return true; }// dump // //----------------------------------------------- // 'loadDump' : command to load a dump file. //----------------------------------------------- NLMISC_COMMAND(loadDump, "Ccommand to load a dump file.", "[ = default]") { if(args.size() > 1) return false; string dumpName; if(args.size() == 1) dumpName = args[0]; else dumpName = "default"; loadDump(dumpName); return true; }// loadDump // //----------------------------------------------- // 'watchEntity' : Choose the entity to watch. //----------------------------------------------- NLMISC_COMMAND(sheet2idx, "Return the index ", " ") { if(args.size() != 2) return false; string result; NLMISC::CSheetId sheetId; if(sheetId.build(args[0])) { uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)atoi(args[1].c_str())); result = NLMISC::toString("Index = %d", idx); } else result = NLMISC::toString("sheet '%s' not valid.", args[0].c_str()); IM->displaySystemInfo(ucstring(result)); nlinfo("'sheet2idx': %s", result.c_str()); return true; } //----------------------------------------------- // 'watchEntity' : Choose the entity to watch. //----------------------------------------------- NLMISC_COMMAND(watchEntity, "Choose the entity to watch.", "") { if(args.size() != 1) return false; // Set the new debug entity slot. WatchedEntitySlot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); return true; }// watchEntity // //----------------------------------------------- // 'dynstr' //----------------------------------------------- NLMISC_COMMAND(dynstr, "display a dyn string value", "") { if (args.size() != 1) return false; uint dynId = atoi(args[0].c_str()); ucstring result; STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynId, result); CInterfaceManager::getInstance()->displaySystemInfo(result); return true; }// dynstr // NLMISC_COMMAND(serverstr, "display a server string value", "") { if (args.size() != 1) return false; uint dynId = atoi(args[0].c_str()); ucstring result; STRING_MANAGER::CStringManagerClient::instance()->getString(dynId, result); CInterfaceManager::getInstance()->displaySystemInfo(result); return true; }// serverstr // //----------------------------------------------- // 'verboseAnimSelection' : Enable/Disable the animation log for the current selection. //----------------------------------------------- NLMISC_COMMAND(verboseAnimSelection, "Enable/Disable the animation log for the current selection.", "") { // Check parameters. if(args.size() != 0) return false; VerboseAnimSelection = !VerboseAnimSelection; if(VerboseAnimSelection) nlinfo("Enable VerboseAnimSelection"); else nlinfo("Disable VerboseAnimSelection"); return true; }// verboseAnimSelection // //----------------------------------------------- // 'verboseAnimUser' : Enable/Disable the animation log for the user. //----------------------------------------------- NLMISC_COMMAND(verboseAnimUser, "Enable/Disable the animation log for the user.", "") { // Check parameters. if(args.size() != 0) return false; VerboseAnimUser = !VerboseAnimUser; if(VerboseAnimUser) nlinfo("Enable VerboseAnimUser"); else nlinfo("Disable VerboseAnimUser"); return true; }// VerboseAnimUser // //----------------------------------------------- // 'verboseDatabase' : Enable/Disable the log for the database. //----------------------------------------------- NLMISC_COMMAND(verboseDatabase, "Enable/Disable the log for the database.", "") { // Check parameters. if(args.size() != 0) return false; VerboseDatabase = !VerboseDatabase; if(VerboseDatabase) nlinfo("Enable VerboseDatabase"); else nlinfo("Disable VerboseDatabase"); return true; }// verboseDatabase // //----------------------------------------------- // 'verboseVP' : Enable/Disable the visual properties log. //----------------------------------------------- NLMISC_COMMAND(verboseVP, "Enable/Disable the visual properties log.", "") { // Check parameters. if(args.size() != 0) return false; VerboseVP = !VerboseVP; if(VerboseVP) nlinfo("Enable verboseVP"); else nlinfo("Disable verboseVP"); return true; }// verboseVP // //----------------------------------------------- // verbosePropertiesLoggingMode //----------------------------------------------- NLMISC_COMMAND(verbosePropertiesLoggingMode, "Set logging mode", "") { // Check parameters. if(args.size() != 0) return false; CNetworkConnection::LoggingMode = !CNetworkConnection::LoggingMode; if(CNetworkConnection::LoggingMode) nlinfo("Enable LoggingMode"); else nlinfo("Disable LoggingMode"); return true; } //----------------------------------------------- // 'where' : display player position (on the server) //----------------------------------------------- NLMISC_COMMAND(where, "display player position (on the server)", " ") { // Check parameters. if(args.size() != 0) return false; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:WHERE", out)) NetMngr.push(out); else nlwarning("mainLoop : unknown message name DEBUG:WHERE"); return true; }// chat_mode // //----------------------------------------------- // 'who' : Display all players currently in game //----------------------------------------------- NLMISC_COMMAND(who, "Display all players currently in game"," ") { // Check parameters. if(args.size() != 0) return false; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:WHO", out)) NetMngr.push(out); else nlwarning("mainLoop : unknown message name DEBUG:WHO"); return true; }// who // //----------------------------------------------- // 'cmd' : Send a command to a server //----------------------------------------------- NLMISC_COMMAND(cmd, "Send a command to a server"," ") { // Check parameters. if(args.size() < 2) return false; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:CMD", out)) { bool addentity = false; string dest = args[0]; string cmd = args[1]; string arg; for (uint i = 2; i < args.size(); i++) { arg += args[i] + " "; } out.serial(addentity); out.serial(dest); out.serial(cmd); out.serial(arg); NetMngr.push(out); } else nlwarning("mainLoop : unknown message name DEBUG:CMD"); return true; }// cmd // //----------------------------------------------- // 'cmd' : Send a command to a server //----------------------------------------------- NLMISC_COMMAND(cmde, "Send a command to a server with entityid"," ") { // Check parameters. if(args.size() < 2) return false; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:CMD", out)) { bool addentity = true; string dest = args[0]; string cmd = args[1]; string arg; for (uint i = 2; i < args.size(); i++) { arg += args[i] + " "; } out.serial(addentity); out.serial(dest); out.serial(cmd); out.serial(arg); NetMngr.push(out); } else nlwarning("mainLoop : unknown message name DEBUG:CMD"); return true; }// cmde // //----------------------------------------------- // 'services' : Ask the server all services up. //----------------------------------------------- NLMISC_COMMAND(services, "Ask the server all services up.", "") { CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:SERVICES", out)) { // Add the message to the send list. NetMngr.push(out); // send TELEPORT nlinfo("command 'services': 'DEBUG:SERVICES' sent."); } else nlwarning("command 'services': unknown message named 'DEBUG:SERVICES'."); return true; } //----------------------------------------------- // 'mode' : Command To change the mode for an entity in a slot. //----------------------------------------------- NLMISC_COMMAND(mode, "Command To change the mode for an entity in a slot.", " ") { // Check parameters. if(args.size() != 2) { // Help CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 paramters :")); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the mode wanted for the entity, one of the following number :")); for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i)))); } // Right parameters number else { // Compute parameters CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); MBEHAV::EMode mod = (MBEHAV::EMode)atoi(args[1].c_str()); // Compute the position. CEntityCL *entity = EntitiesMngr.entity(slot); if(entity) { // Write the behaviour in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_MODE), mod); // Update the behaviour. entity->updateVisualProperty(NetMngr.getCurrentServerTick()+10, CLFECOMMON::PROPERTY_MODE); } // Invalid slot. else CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot.")); } // Command well done. return true; }// mode // //----------------------------------------------- // 'behaviour' : Command To change the behaviour for an entity in a slot. //----------------------------------------------- NLMISC_COMMAND(behaviour, "Command To change the behaviour for an entity in a slot.", " [] []") { // Check parameters. if(args.size() < 2 || args.size() > 4) { // Help CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); } else { // COmpute parameters CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); MBEHAV::EBehaviour beh = (MBEHAV::EBehaviour)atoi(args[1].c_str()); // Make the behaviour MBEHAV::CBehaviour behaviour(beh); // Get the Power if(args.size() >= 3) behaviour.Combat.AttackIntensity = atoi(args[2].c_str()); if(args.size() >= 4) behaviour.Combat.ImpactIntensity = atoi(args[3].c_str()); // Compute the position. CEntityCL *entity = EntitiesMngr.entity(slot); if(entity) { // Cast into an uint32. uint32 b = behaviour; // Write the behaviour in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_BEHAVIOUR), b); // Update the behaviour. entity->updateVisualProperty(NetMngr.getCurrentServerTick()+10, CLFECOMMON::PROPERTY_BEHAVIOUR); } else CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot.")); } // Command well done. return true; }// behaviour // //----------------------------------------------- // 'magic' : Command to cast a spell. //----------------------------------------------- NLMISC_COMMAND(magic, "Command to cast a spell.", "\n" " : the one who cast the spell\n" " : 0->GOOD 1->Bad 2->NEUTRAL\n" " : 0->success 1->Fail 2->Fumble\n" " : \n" " : \n" " : 0->not resisted, any other->resisted.\n") { // Check parameters. if(args.size() != 6) { // Help // CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); // for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); // CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); } else { // Compute parameters CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); // Magic Type (good bad neutral) uint type = atoi(args[1].c_str())%3; MBEHAV::EBehaviour behTmp = (MBEHAV::EBehaviour)(MBEHAV::CASTING_GOOD+type); MBEHAV::CBehaviour castingBeh(behTmp); // Result MBEHAV::CBehaviour behaviour; uint result = atoi(args[2].c_str())%3; if (type==0) behaviour.Behaviour = (MBEHAV::EBehaviour)(MBEHAV::END_CASTING_GOOD_SUCCESS + result); else if(type==1) behaviour.Behaviour = (MBEHAV::EBehaviour)(MBEHAV::END_CASTING_BAD_SUCCESS + result); else behaviour.Behaviour = (MBEHAV::EBehaviour)(MBEHAV::END_CASTING_NEUTRAL_SUCCESS + result); // Spell Power behaviour.Magic.SpellPower = atoi(args[3].c_str()); // Impact Intensity behaviour.Magic.ImpactIntensity = atoi(args[4].c_str()); // Resist behaviour.Magic.TargetResists = (atoi(args[5].c_str()) != 0); // Get the entity CEntityCL *entity = EntitiesMngr.entity(slot); if(entity) { // Cast into an uint32. uint32 b = castingBeh; // Write the behaviour in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_BEHAVIOUR), b); // Update the behaviour. entity->updateVisualProperty(NetMngr.getCurrentServerTick()+10, CLFECOMMON::PROPERTY_BEHAVIOUR); b = behaviour; // Write the behaviour in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_BEHAVIOUR), b); // Update the behaviour. entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); } else CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot.")); } // Command well done. return true; }// magic // //----------------------------------------------- // 'target' : Set the target for an entity. Do not set the target slot to remove the target. //----------------------------------------------- NLMISC_COMMAND(target, "Set a target for an entity. Do not set the target slot to remove the target.", " []") { CLFECOMMON::TCLEntityId targetSlot = CLFECOMMON::INVALID_SLOT; // Check parameters. switch(args.size()) { // Set the target for the entity. case 2: targetSlot = (CLFECOMMON::TCLEntityId)atoi(args[1].c_str()); // Remove the target for the entity. case 1: { uint entitySlot = (uint)atoi(args[0].c_str()); CEntityCL *entity = EntitiesMngr.entity(entitySlot); if(entity) entity->targetSlot(targetSlot); else nlwarning("command 'target': there is no entity in the slot %d.", entitySlot); } break; // Bad command. default: return false; } // Well done. return true; } //----------------------------------------------- // 'particle' : Create a particle at the the user position //----------------------------------------------- NLMISC_COMMAND(particle, "Create a particule at the user position (play FireWorkA_with_sound.ps by default)", "[]") { string fn; // Check parameters. if(args.size() == 0) { fn = "FireWorkA_with_sound.ps"; } else if(args.size() == 1) { fn = args[0]; } else return false; UInstance *fx = Scene->createInstance(fn); // not found if(fx == NULL) { log.displayNL ("Can't create instance '%s'", fn.c_str()); return false; } fx->setPos(UserEntity.pos()); fx->setClusterSystem(UserEntity.skeleton()->getClusterSystem()); // Command well done. return true; } //----------------------------------------------- // 'move' : Move an entity. //----------------------------------------------- NLMISC_COMMAND(move, "Move an entity.", "Form ID; Slot: [1-254]") { // Check parameters. if(args.size() != 1) return false; CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); // Compute the position. CEntityCL *entity = EntitiesMngr.entity(slot); if(entity) { sint64 x = (sint64)((entity->pos().x+UserEntity.front().x*10.0)*1000.0); sint64 y = (sint64)((entity->pos().y+UserEntity.front().y*10.0)*1000.0); sint64 z = (sint64)((entity->pos().z+UserEntity.front().z*10.0)*1000.0); // Write the position in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); // Update the position. EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+30, slot, 0); x = (sint64)((entity->pos().x)*1000.0); y = (sint64)((entity->pos().y)*1000.0); z = (sint64)((entity->pos().z)*1000.0); // Write the position in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); // Update the position. EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+60, slot, 0); } else nlwarning("command 'move' : there is no entity allocated in slot %d.", slot); // Command well done. return true; } //----------------------------------------------- // 'move_to' : Move an entity to another one. //----------------------------------------------- NLMISC_COMMAND(move_to, "Move an entity to another one.", ":[1-254], :[0-254] default 0") { sint64 x, y, z; // Check parameters. if(args.size() == 1) { x = (sint64)(UserEntity.pos().x*1000.0); y = (sint64)(UserEntity.pos().y*1000.0); z = (sint64)(UserEntity.pos().z*1000.0); } else if(args.size() == 2) { CLFECOMMON::TCLEntityId slotDest = (CLFECOMMON::TCLEntityId)atoi(args[1].c_str()); // Compute the position. CEntityCL *entity = EntitiesMngr.entity(slotDest); if(entity) { x = (sint64)(entity->pos().x*1000.0); y = (sint64)(entity->pos().y*1000.0); z = (sint64)(entity->pos().z*1000.0); } else { // Command is correct but not all the parameters are valid. nlwarning("command 'move_to' : there is no entity allocated for the dest in slot %d.", slotDest); return true; } } // Wrong number of parameters. else return false; CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); // Write the position in the DB. IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); // Update the position. EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+30, slot, 0); // Command well done. return true; } //----------------------------------------------- // 'setMode' : Set The Mode for an Entity without to add a stage for it. //----------------------------------------------- NLMISC_COMMAND(setMode, "Set The Mode for an Entity without to add a stage for it.", " ") { // Check parameters. if(args.size() != 2) return false; // Get the Slot and the Mode. CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); MBEHAV::EMode mod = (MBEHAV::EMode)atoi(args[1].c_str()); // Compute the position. CEntityCL *entity = EntitiesMngr.entity(slot); if(entity) entity->mode(mod); else nlwarning("command 'setMode' : there is no entity allocated in slot '%d'.", slot); // Command well done. return true; } //----------------------------------------------- // 'logEntities' : Write the position and orientation af all entities in the vision in the file 'entities.txt'. //----------------------------------------------- NLMISC_COMMAND(logEntities, "Write the position and orientation af all entities in the vision in the file 'entities.txt'.", "") { // Check parameters if(args.size() != 0) return false; // Log entities EntitiesMngr.writeEntities(); // Command well done. return true; } //----------------------------------------------- // 'log' : Command to Add/Del Positive/Negative Filters for logs. //----------------------------------------------- NLMISC_COMMAND(log, "Add/Del Positive/Negative Filters for logs.", "Log System , Type , Filter ") { // check args, if there s not the right number of parameter, return bad if(args.size() < 2 || args.size() > 3) return false; CLog *logSys; // Debug log system. if (string(args[0].c_str()) == "debug") logSys = DebugLog; // Info log system. else if(string(args[0].c_str()) == "info") logSys = InfoLog; // Warning log system. else if(string(args[0].c_str()) == "warning") logSys = WarningLog; // Assert log system. else if(string(args[0].c_str()) == "assert") logSys = AssertLog; // Unknown Log System -> return false. else return false; // Add a positive filter. if (string(args[1].c_str()) == "pos") logSys->addPositiveFilter(args[2].c_str()); // Add a negative filter. else if(string(args[1].c_str()) == "neg") logSys->addNegativeFilter(args[2].c_str()); // Removes a filter by name (in both filters). else if(string(args[1].c_str()) == "del") logSys->removeFilter(args[2].c_str()); // Reset both filters. else if(string(args[1].c_str()) == "reset") logSys->resetFilters(); // Unknown Filter -> return false. else return false; // Command well done. return true; } //----------------------------------------------- // 'db' : Command to change some variables in the database or to get it //----------------------------------------------- NLMISC_COMMAND(db, "Modify Database"," ") { int size = args.size(); if (size == 2) { // Convert the string into an sint64. sint64 value = atoiInt64(args[1].c_str()); // Set the property. CInterfaceManager::getInstance()->getDbProp(args[0])->setValue64(value); } else if (size == 1) { sint64 prop = CInterfaceManager::getInstance()->getDbProp(args[0])->getValue64(); string str = toString(prop); CInterfaceManager *pIM = CInterfaceManager::getInstance(); pIM->displaySystemInfo(ucstring(str)); nlinfo("%s", str.c_str()); return true; } else return false; return true; }// db // //----------------------------------------------- // 'exec' : Execute a scipt file //----------------------------------------------- extern CLog g_log; NLMISC_COMMAND(exec, "Execute a scipt file","") { int size = args.size(); if (size != 1) return false; CIFile iFile; if (iFile.open(CPath::lookup(args[0], false))) { char line[512]; char *buffer; // Read line by line and execute each line bool eof = false; while (!eof) { buffer = &line[0]; uint read = 0; while (true) { if (read == 512 -1) { *buffer = '\0'; break; } try { // read one byte iFile.serialBuffer ((uint8 *)buffer, 1); } catch (EFile &) { *buffer = '\0'; eof = true; break; } if (*buffer == '\n') { *buffer = '\0'; break; } // skip '\r' char if (*buffer != '\r') { buffer++; read++; } } if (strlen(line) > 0) ICommand::execute(line, g_log); if (iFile.eof()) eof = true; } iFile.close(); } else { CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Cannot open file")); } return true; }// exec // //----------------------------------------------- // 'vP' : Modify the Visual Property. //----------------------------------------------- NLMISC_COMMAND(vP, "Modify the Visual Property.", "\n" " of the entity to change.\n" " the property to change :\n" " 0->CHEST\n" " 1->LEG\n" " 2->ARM\n" " 3->HEAD\n" " 4->WEAPON_R\n" " 5->WEAPON_L\n" " 6->FEET\n" " 7->HAND\n" " 8->EYES\n" " 9->SEX (0: Male, 1: Female)\n" " for the property.\n") { // Check parameters if(args.size() != 3) return false; // Get the database entry. SPropVisualA vA; SPropVisualB vB; SPropVisualC vC; uint slot = atoi(args[0].c_str()); const string propNameA = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPC); vA.PropertyA = CInterfaceManager::getInstance()->getDbProp(propNameA)->getValue64(); vB.PropertyB = CInterfaceManager::getInstance()->getDbProp(propNameB)->getValue64(); vC.PropertyC = CInterfaceManager::getInstance()->getDbProp(propNameC)->getValue64(); // Get the visual item index uint value = atoi(args[2].c_str()); // Get the visual slot to change. uint type = atoi(args[1].c_str()); switch(type) { case 0: vA.PropertySubData.JacketModel = value; break; case 1: vA.PropertySubData.TrouserModel = value; break; case 2: vA.PropertySubData.ArmModel = value; break; case 3: vA.PropertySubData.HatModel = value; break; case 4: vA.PropertySubData.WeaponRightHand = value; break; case 5: vA.PropertySubData.WeaponLeftHand = value; break; case 6: vB.PropertySubData.FeetModel = value; break; case 7: vB.PropertySubData.HandsModel = value; break; case 8: vC.PropertySubData.EyesColor = value; break; case 9: vA.PropertySubData.Sex = value; break; default: nlwarning("command 'vP': type not valid."); return false; break; } // Set the database. CInterfaceManager::getInstance()->getDbProp(propNameA)->setValue64((sint64)vA.PropertyA); CInterfaceManager::getInstance()->getDbProp(propNameB)->setValue64((sint64)vB.PropertyB); CInterfaceManager::getInstance()->getDbProp(propNameC)->setValue64((sint64)vC.PropertyC); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); // Done. return true; }// vP // //----------------------------------------------- // 'altLook' : Modify the Visual Property. //----------------------------------------------- NLMISC_COMMAND(altLook, "Modify the Alternative Look Property.", "\n" " of the entity to change.\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n") { // Check parameters if(args.size() != 8) return false; // Get the database entry. uint slot = atoi(args[0].c_str()); const string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); // Get the old value (not useful since we change the whole property). SAltLookProp altLookProp; altLookProp.Summary = CInterfaceManager::getInstance()->getDbProp(propName)->getValue64(); altLookProp.Element.ColorTop = atoi(args[1].c_str()); altLookProp.Element.ColorBot = atoi(args[2].c_str()); altLookProp.Element.WeaponRightHand = atoi(args[3].c_str()); altLookProp.Element.WeaponLeftHand = atoi(args[4].c_str()); altLookProp.Element.Seed = atoi(args[5].c_str()); altLookProp.Element.ColorHair = atoi(args[6].c_str()); altLookProp.Element.Hat = atoi(args[7].c_str()); // Set the database. CInterfaceManager::getInstance()->getDbProp(propName)->setValue64((sint64)altLookProp.Summary); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); // Done. return true; }// altLook // //----------------------------------------------- // 'color' : Command to color an entity. //----------------------------------------------- NLMISC_COMMAND(color, "Command to color an entity.", "\n" ": whole number (if <0 slot will be the current selection)\n" ": whole number\n" ": whole number\n" ": whole number\n" "[]: whole number\n" " default=the whole body\n" " 0=CHEST\n" " 1=LEG\n" " 2=HEAD\n" " 3=ARMS\n" " 4=HANDS\n" " 5=FEET\n") { // Check parameters. if(args.size() != 4 && args.size() != 5) return false; // Witch part to dye ? sint part = -1; if(args.size() == 5) part = atoi(args[4].c_str()); // Get the entity slot to dye. sint slotTmp = atoi(args[0].c_str()); CLFECOMMON::TCLEntityId slot; if(slotTmp >= 0) slot = (CLFECOMMON::TCLEntityId)slotTmp; else slot = (CLFECOMMON::TCLEntityId)UserEntity.selection(); CEntityCL *entity = EntitiesMngr.entity(slot); if(entity) entity->changeColors(atoi(args[1].c_str()), atoi(args[2].c_str()), atoi(args[3].c_str()), part); else nlwarning("command 'changeColors': there is no entity allocated in slot '%d'.", slot); // Command well done. return true; }// color // #endif // #ifndef _LIMITED_COMMAND_ //----------------------------------------------- // 'fire' : Command to launch the firework. //----------------------------------------------- NLMISC_COMMAND(fire, "launch the firework","") { Firework->start(T1); return true; } //----------------------------------------------- // 'save_int_cfg' : save the interface config file. //----------------------------------------------- NLMISC_COMMAND(save_int_cfg, "save the interface config file","") { CInterfaceManager::getInstance()->saveConfig ("interface.cfg"); return true; } //----------------------------------------------- // 'harvest_deposit' //----------------------------------------------- NLMISC_COMMAND(harvest_deposit, "harvest a deposit", "") { // no parameter needed // Create the message for the server CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("HARVEST:DEPOSIT", out)) { NetMngr.push(out); // open the interface CInterfaceManager::getInstance()->getWindowFromId("ui:interface:harvest")->setActive(true); } else nlwarning("command : unknown message name : 'HARVEST:DEPOSIT'."); return true; } // harvest_deposit // //----------------------------------------------- // 'training' //----------------------------------------------- NLMISC_COMMAND(training, "start a training action", "") { // no parameter needed // Create the message for the server CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("TRAINING", out)) { NetMngr.push(out); } else nlwarning("command : unknown message name : 'TRAINING'."); return true; } // training // //----------------------------------------------- // 'mount' : Set the entity to mount. //----------------------------------------------- NLMISC_COMMAND(mount, "Set the entity to mount."," []") { CLFECOMMON::TCLEntityId slot; CLFECOMMON::TCLEntityId mount = CLFECOMMON::INVALID_SLOT; switch(args.size()) { case 2: mount = (CLFECOMMON::TCLEntityId) atoi(args[1].c_str()); case 1: slot = (CLFECOMMON::TCLEntityId) atoi(args[0].c_str()); break; default: return false; break; } // Set the database. string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(mount); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); // Command well done return true; }// mount // //----------------------------------------------- // 'rider' : Set the rider. //----------------------------------------------- NLMISC_COMMAND(rider, "Set the rider."," []") { CLFECOMMON::TCLEntityId slot; CLFECOMMON::TCLEntityId rider = CLFECOMMON::INVALID_SLOT; switch(args.size()) { case 2: rider = (CLFECOMMON::TCLEntityId) atoi(args[1].c_str()); case 1: slot = (CLFECOMMON::TCLEntityId) atoi(args[0].c_str()); break; default: return false; break; } // Set the database. string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(rider); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); // Command well done return true; }// rider // #ifndef _LIMITED_COMMAND_ #ifdef _CMD_CHEAT_ON_ //////////////////// // CHEAT COMMANDS // NLMISC_COMMAND(learn_all, "learn all bricks", "all magic combat") { // Check parameters. if(args.size() > 1) return false; uint type = 0; if(args.size() == 1) { if (args[0] == "magic" || args[0] == "1") type = 1; if (args[0] == "combat" || args[0] == "2") type = 2; } char buf[100]; if (ClientCfg.Local) { CBrickManager * pBM = CBrickManager::getInstance(); uint i = 0; for (; i < pBM->getNumberOfFamily(); i++ ) { sint64 flag = 0; if ( pBM->getFamilySize(i) ) { CBrickSheet *brick= pBM->getBrick(pBM->getBrickSheet(i, 0)); if(brick) { if ( type == 0 || (brick->BrickType == BRICK_TYPE::COMBAT && type == 2) || (brick->BrickType == BRICK_TYPE::MAGIC && type == 1) ) { for (uint j = 0; j < pBM->getFamilySize(i);j++) { flag |= (sint64)1 << (sint64)j; } sprintf(buf,"SERVER:BRICK_FAMILY:%d:BRICKS",i); CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(buf); node->setValue64(flag); } } } } //set all career to 25 for (i = 0; i < ROLES::role_unknown; i++ ) { string role = string("SERVER:CHARACTER_INFO:CAREER")+toString(3); string prop = role +string(":LEVEL"); CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(prop); node->setValue64(25); for (uint j = 0; j < 8; j++ ) { prop = role + string(":JOB") + toString(j) + string(":LEVEL"); node= CInterfaceManager::getInstance()->getDbProp(prop); node->setValue64(25); } } // Learn all Faber Plans. For all database entries uint faberPlanMId= 0; while(true) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCDBNodeLeaf *leaf= pIM->getDbProp("SERVER:FABER_PLANS:"+toString(faberPlanMId)+":KNOWN", false); if(!leaf) break; leaf->setValue64(0xFFFFFFFFFFFFFFFF); faberPlanMId++; } } else { // Create the message for the server to learn all bricks CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:LEARN_ALL_BRICKS", out)) { // Add the message to the send list. NetMngr.push(out); // send TELEPORT nlinfo("command 'learn_all': learn all bricks Asked."); } else nlwarning("command 'learn_all': unknown message named 'CHEAT:LEARN_ALL_BRICKS'."); } return true; } // learn_all // NLMISC_COMMAND(learnAllFaberPlans, "learn all faber plans", "") { if (ClientCfg.Local) { // Learn all Faber Plans. For all database entries uint faberPlanMId= 0; while(true) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCDBNodeLeaf *leaf= pIM->getDbProp("SERVER:FABER_PLANS:"+toString(faberPlanMId)+":KNOWN", false); if(!leaf) break; leaf->setValue64(0xFFFFFFFFFFFFFFFF); faberPlanMId++; } } else { // Create the message for the server to learn all bricks CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:LEARN_ALL_FABER_PLANS", out)) { // Add the message to the send list. NetMngr.push(out); // send TELEPORT nlinfo("command 'learnAllFaberPlans': learn all faber plans Asked."); } else nlwarning("command 'learnAllFaberPlans': unknown message named 'CHEAT:LEARN_ALL_FABER_PLANS'."); } return true; } // learnAllFaberPlans // //----------------------------------------------- // 'god' : To be invulnerable. //----------------------------------------------- NLMISC_COMMAND(god, "To be invulnerable","") { // Check parameters. if(args.size() != 0) return false; // Create the message for the server to teleport the character. CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:GOD", out)) { // Add the message to the send list. NetMngr.push(out); // send TELEPORT nlinfo("command 'god': God Mode Asked."); } else nlwarning("command 'god': unknown message named 'CHEAT:GOD'."); // Done. return true; }// god // //----------------------------------------------- // 'createItem' : Create an item in the hand of the user. //----------------------------------------------- NLMISC_COMMAND(createItem, "Create an item in the hand of the user."," [] []") { CSheetId sheetId; uint16 quantity = 1; uint16 quality = 1; // Check parameters. switch(args.size()) { case 3: quality = atoi(args[2].c_str()); case 2: quantity = atoi(args[1].c_str()); case 1: // Try to create the sheet with the parameter as a string. if(!sheetId.build(args[0])) { // Try to create the sheet with the parameter as an int. sheetId = atoi(args[0].c_str()); } break; // Bad number of parameters. default: nlwarning("Command 'createItem': invalid number of parameter."); return false; } // Check Sheet Id. if(sheetId == CSheetId::Unknown) { nlwarning("Command 'createItem': '%s' is not a valid form.", args[0].c_str()); return false; } // Create the message for the server to teleport the character. CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:CREATE_ITEM_IN_BAG", out)) { uint32 sheet = sheetId.asInt(); out.serial(sheet); out.serial(quantity); out.serial(quality); // Add the message to the send list. NetMngr.push(out); // send TELEPORT nlinfo("Command 'createItem': CREATE_ITEM_IN_BAG sent"); } else nlwarning("Command 'createItem': unknown message named 'CHEAT:CREATE_ITEM_IN_BAG'."); // Command well done. return true; }// createItem // //----------------------------------------------- // 'xp' : To gain XP in a given Skill. //----------------------------------------------- NLMISC_COMMAND(xp, "To gain XP in a given Skill."," ") { // Check parameters. if(args.size() != 2) return false; // Create the message for the server to teleport the character. CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:XP", out)) { uint32 xp = atoi(args[1].c_str()); string skill = args[0]; out.serial( skill ); out.serial(xp); // Add the message to the send list. NetMngr.push(out); // send CHEAT:XP nlinfo("command 'xp': CHEAT:XP pushed."); } else nlwarning("command 'xp': unknown message named 'CHEAT:XP'."); // Done. return true; }// xp // //----------------------------------------------- // 'money' : To earn Money. // \todo //----------------------------------------------- NLMISC_COMMAND(money, "To earn Money."," [] [] []") { sint32 a = 0; sint32 b = 0; sint32 c = 0; sint32 d = 0; // Check parameters. switch(args.size()) { case 4: d = atoi(args[3].c_str()); case 3: c = atoi(args[2].c_str()); case 2: b = atoi(args[1].c_str()); case 1: a = atoi(args[0].c_str()); break; default: return false; } // Create the message for the server to teleport the character. CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:MONEY", out)) { out.serial(a); out.serial(b); out.serial(c); out.serial(d); // Add the message to the send list. NetMngr.push(out); // send CHEAT:MONEY nlinfo("command 'money': CHEAT:MONEY pushed."); } else nlwarning("command 'money': unknown message named 'CHEAT:MONEY'."); // Done. return true; }// money // //----------------------------------------------- // 'setTime' : To set Ryzom time on server. //----------------------------------------------- NLMISC_COMMAND(setTime, "To set Ryzom time on server.","