From bb3b0bd598af8fa1d34dae6dee6b2aca2b74f0df Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 27 Jun 2010 01:29:49 +0200 Subject: [PATCH] [10109] Add and use actual bounding_radius/combat_reach per model for characters. Data are stored in same table as for creature (like dbc models data), and provides the default values for playable races. Currently the bounding and reach are applied only at creation and load. Note that these values are modified by scale. For player case, scale is always 1.0 as default. For later, auras and spell effects that change scale and/or modelid must in addition make sure bounding_radius are updated accordingly to the new scale and/or model (combat_reach does not seem to be affected by such changes, and is always 1.5 for players). Signed-off-by: NoFantasy --- sql/mangos.sql | 22 ++++++++++- .../10109_01_mangos_creature_model_info.sql | 22 +++++++++++ sql/updates/Makefile.am | 2 + src/game/Player.cpp | 38 ++++++++++++++----- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 6 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 sql/updates/10109_01_mangos_creature_model_info.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 6fd209e9e..c6c36ae14 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_10107_01_mangos_mangos_string` bit(1) default NULL + `required_10109_01_mangos_creature_model_info` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -970,7 +970,25 @@ CREATE TABLE `creature_model_info` ( LOCK TABLES `creature_model_info` WRITE; /*!40000 ALTER TABLE `creature_model_info` DISABLE KEYS */; INSERT INTO `creature_model_info` VALUES -(10045, 1, 1.5, 2, 0); +(49, 0.3060, 1.5, 0, 50), +(50, 0.2080, 1.5, 1, 49), +(51, 0.3720, 1.5, 0, 52), +(52, 0.2360, 1.5, 1, 51), +(53, 0.3470, 1.5, 0, 54), +(54, 0.3470, 1.5, 1, 53), +(55, 0.3890, 1.5, 0, 56), +(56, 0.3060, 1.5, 1, 55), +(59, 0.9747, 1.5, 0, 60), +(60, 0.8725, 1.5, 1, 59), +(1478, 0.3060, 1.5, 0, 1479), +(1479, 0.3060, 1.5, 1, 1478), +(1563, 0.3519, 1.5, 0, 1564), +(1564, 0.3519, 1.5, 1, 1563), +(10045, 1.0000, 1.5, 2, 0), +(15475, 0.3830, 1.5, 1, 15476), +(15476, 0.3830, 1.5, 0, 15475), +(16125, 1.0000, 1.5, 0, 16126), +(16126, 1.0000, 1.5, 1, 16125); /*!40000 ALTER TABLE `creature_model_info` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/10109_01_mangos_creature_model_info.sql b/sql/updates/10109_01_mangos_creature_model_info.sql new file mode 100644 index 000000000..c35c88916 --- /dev/null +++ b/sql/updates/10109_01_mangos_creature_model_info.sql @@ -0,0 +1,22 @@ +ALTER TABLE db_version CHANGE COLUMN required_10107_01_mangos_mangos_string required_10109_01_mangos_creature_model_info bit; + +DELETE FROM creature_model_info WHERE modelid IN (49,50,51,52,53,54,55,56,59,60,1478,1479,1563,1564,15475,15476,16125,16126); +INSERT INTO creature_model_info (modelid, bounding_radius, combat_reach, gender, modelid_other_gender) VALUES +(49, 0.3060, 1.5, 0, 50), +(50, 0.2080, 1.5, 1, 49), +(51, 0.3720, 1.5, 0, 52), +(52, 0.2360, 1.5, 1, 51), +(53, 0.3470, 1.5, 0, 54), +(54, 0.3470, 1.5, 1, 53), +(55, 0.3890, 1.5, 0, 56), +(56, 0.3060, 1.5, 1, 55), +(59, 0.9747, 1.5, 0, 60), +(60, 0.8725, 1.5, 1, 59), +(1478, 0.3060, 1.5, 0, 1479), +(1479, 0.3060, 1.5, 1, 1478), +(1563, 0.3519, 1.5, 0, 1564), +(1564, 0.3519, 1.5, 1, 1563), +(15475, 0.3830, 1.5, 1, 15476), +(15476, 0.3830, 1.5, 0, 15475), +(16125, 1.0000, 1.5, 0, 16126), +(16126, 1.0000, 1.5, 1, 16125); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 6b9a7dcc2..02f418fb3 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -94,6 +94,7 @@ pkgdata_DATA = \ 10106_01_mangos_command.sql \ 10106_02_mangos_mangos_string.sql \ 10107_01_mangos_mangos_string.sql \ + 10109_01_mangos_creature_model_info.sql \ README ## Additional files to include when running 'make dist' @@ -168,4 +169,5 @@ EXTRA_DIST = \ 10106_01_mangos_command.sql \ 10106_02_mangos_mangos_string.sql \ 10107_01_mangos_mangos_string.sql \ + 10109_01_mangos_creature_model_info.sql \ README diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 490536c19..91026bbe6 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -681,23 +681,33 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 uint8 powertype = cEntry->powerType; - SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); - SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f); - setFactionForRace(race); uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 ); SetUInt32Value(UNIT_FIELD_BYTES_0, ( RaceClassGender | ( powertype << 24 ) ) ); + InitDisplayIds(); + + if (CreatureModelInfo const* modelInfo = sObjectMgr.GetCreatureModelInfo(GetDisplayId())) + { + // bounding_radius and combat_reach is normally modified by scale, but player is always 1.0 scale by default so no need to modify values here. + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, modelInfo->bounding_radius); + SetFloatValue(UNIT_FIELD_COMBATREACH, modelInfo->combat_reach); + } + else + { + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); + SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f); + } + SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP ); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // fix cast time showed in spell tooltip on client SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // default for players in 3.0.3 - // -1 is default value - SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, -1); + SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, -1); // -1 is default value SetUInt32Value(PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24))); SetUInt32Value(PLAYER_BYTES_2, (facialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24))); @@ -14994,8 +15004,20 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadIntoDataField(fields[60].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE); _LoadIntoDataField(fields[63].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2); - SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); - SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f); + InitDisplayIds(); + + if (CreatureModelInfo const* modelInfo = sObjectMgr.GetCreatureModelInfo(GetDisplayId())) + { + // bounding_radius and combat_reach is normally modified by scale, but player is always 1.0 scale by default so no need to modify values here. + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, modelInfo->bounding_radius); + SetFloatValue(UNIT_FIELD_COMBATREACH, modelInfo->combat_reach); + } + else + { + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); + SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f); + } + SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); uint32 money = fields[8].GetUInt32(); @@ -15014,8 +15036,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) SetUInt32Value(PLAYER_AMMO_ID, fields[62].GetUInt32()); SetByteValue(PLAYER_FIELD_BYTES, 2, fields[64].GetUInt8()); - InitDisplayIds(); - // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7a7041f42..a5e09251c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10108" + #define REVISION_NR "10109" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index ebee55bbb..c4393a84e 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_10051_01_characters_character_aura" - #define REVISION_DB_MANGOS "required_10107_01_mangos_mangos_string" + #define REVISION_DB_MANGOS "required_10109_01_mangos_creature_model_info" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__