khanat-opennel-code/code/ryzom/common/src/game_share/mode_and_behaviour.cpp

162 lines
6 KiB
C++
Raw Normal View History

// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "nel/misc/debug.h"
#include "nel/misc/common.h"
#include "nel/misc/string_conversion.h"
#include "mode_and_behaviour.h"
using namespace std;
namespace NLMISC
{
std::string toString ( const MBEHAV::CBehaviour &b) { return MBEHAV::behaviourToString( b.Behaviour ) + " " + NLMISC::toString(b.Data); }
};
namespace MBEHAV
{
//
// Modes
//
NL_BEGIN_STRING_CONVERSION_TABLE (EMode)
NL_STRING_CONVERSION_TABLE_ENTRY (UNKNOWN_MODE)
NL_STRING_CONVERSION_TABLE_ENTRY (NORMAL)
NL_STRING_CONVERSION_TABLE_ENTRY (COMBAT_FLOAT)
NL_STRING_CONVERSION_TABLE_ENTRY (COMBAT)
NL_STRING_CONVERSION_TABLE_ENTRY (SWIM)
NL_STRING_CONVERSION_TABLE_ENTRY (SIT)
NL_STRING_CONVERSION_TABLE_ENTRY (MOUNT_NORMAL)
NL_STRING_CONVERSION_TABLE_ENTRY (MOUNT_SWIM)
NL_STRING_CONVERSION_TABLE_ENTRY (EAT)
NL_STRING_CONVERSION_TABLE_ENTRY (REST)
NL_STRING_CONVERSION_TABLE_ENTRY (ALERT)
NL_STRING_CONVERSION_TABLE_ENTRY (HUNGRY)
//NL_STRING_CONVERSION_TABLE_ENTRY (RESURECTED)
NL_STRING_CONVERSION_TABLE_ENTRY (DEATH)
NL_STRING_CONVERSION_TABLE_ENTRY (SWIM_DEATH)
//NL_STRING_CONVERSION_TABLE_ENTRY (PERMANENT_DEATH)
//NL_STRING_CONVERSION_TABLE_ENTRY (TELEPORT)
NL_END_STRING_CONVERSION_TABLE(EMode, ModeConversion, UNKNOWN_MODE)
//
// Behaviours
//
NL_BEGIN_STRING_CONVERSION_TABLE (EBehaviour)
NL_STRING_CONVERSION_TABLE_ENTRY (UNKNOWN_BEHAVIOUR)
// init Behaviours
NL_STRING_CONVERSION_TABLE_ENTRY (IDLE)
NL_STRING_CONVERSION_TABLE_ENTRY (STUNNED)
NL_STRING_CONVERSION_TABLE_ENTRY (STUN_END)
// Actions with tools or trade skills
NL_STRING_CONVERSION_TABLE_ENTRY (LOOT_INIT)
NL_STRING_CONVERSION_TABLE_ENTRY (LOOT_END)
NL_STRING_CONVERSION_TABLE_ENTRY (PROSPECTING)
NL_STRING_CONVERSION_TABLE_ENTRY (PROSPECTING_END)
NL_STRING_CONVERSION_TABLE_ENTRY (EXTRACTING)
NL_STRING_CONVERSION_TABLE_ENTRY (EXTRACTING_END)
NL_STRING_CONVERSION_TABLE_ENTRY (CARE)
NL_STRING_CONVERSION_TABLE_ENTRY (CARE_END)
NL_STRING_CONVERSION_TABLE_ENTRY (HARVESTING)
NL_STRING_CONVERSION_TABLE_ENTRY (HARVESTING_END)
NL_STRING_CONVERSION_TABLE_ENTRY (FABER)
NL_STRING_CONVERSION_TABLE_ENTRY (FABER_END)
NL_STRING_CONVERSION_TABLE_ENTRY (REPAIR)
NL_STRING_CONVERSION_TABLE_ENTRY (REPAIR_END)
NL_STRING_CONVERSION_TABLE_ENTRY (REFINE)
NL_STRING_CONVERSION_TABLE_ENTRY (REFINE_END)
NL_STRING_CONVERSION_TABLE_ENTRY (TRAINING)
NL_STRING_CONVERSION_TABLE_ENTRY (TRAINING_END)
//---- SPELL CASTING ------//
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_OFF)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_CUR)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_MIX)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_ACID)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_BLIND)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_COLD)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_ELEC)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_FEAR)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_FIRE)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_HEALHP)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_MAD)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_POISON)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_ROOT)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_ROT)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_SHOCK)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_SLEEP)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_SLOW)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_STUN)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_OFF_FAIL)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_OFF_FUMBLE)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_OFF_SUCCESS)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_OFF_LINK)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_CUR_FAIL)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_CUR_FUMBLE)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_CUR_SUCCESS)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_CUR_LINK)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_MIX_FAIL)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_MIX_FUMBLE)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_MIX_SUCCESS)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_MIX_LINK)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_FAIL)
NL_STRING_CONVERSION_TABLE_ENTRY (CAST_SUCCESS)
//-------------------------//
//--------- COMBAT---------//
NL_STRING_CONVERSION_TABLE_ENTRY (DEFAULT_ATTACK)
NL_STRING_CONVERSION_TABLE_ENTRY (POWERFUL_ATTACK)
NL_STRING_CONVERSION_TABLE_ENTRY (AREA_ATTACK)
NL_STRING_CONVERSION_TABLE_ENTRY (RANGE_ATTACK)
// Combat creature
NL_STRING_CONVERSION_TABLE_ENTRY (CREATURE_ATTACK_0)
NL_STRING_CONVERSION_TABLE_ENTRY (CREATURE_ATTACK_1)
NL_END_STRING_CONVERSION_TABLE(EBehaviour, BehaviourConversion, UNKNOWN_BEHAVIOUR)
// conversion between mode and string
EMode stringToMode (const std::string &str) { return ModeConversion.fromString(str); }
const string & modeToString (EMode mode) { return ModeConversion.toString(mode); }
// conversion between behaviour and string
EBehaviour stringToBehaviour (const std::string &str) { return BehaviourConversion.fromString(str); }
const std::string & behaviourToString (EBehaviour behav) { return BehaviourConversion.toString(behav); }
//-----------------------------------------------
// initMap :
//-----------------------------------------------
void initMap()
{
//--------- EMOTE ----------//
for(uint i = EMOTE_BEGIN; i<EMOTE_END; ++i)
{
BehaviourConversion.insert (NLMISC::toString("EMOTE_%d", i-EMOTE_BEGIN).c_str(), (EBehaviour)i);
}
}
}; // MBEHAV