Core/Players: Implemented selecting Exile's Reach during character creation
Port From (https://github.com/TrinityCore/TrinityCore/commit/d54edfeb8bd9e525bac62677b8f9dffbaa5124c3)
This commit is contained in:
@@ -613,8 +613,17 @@ namespace Game.Entities
|
||||
|
||||
if (!ok && HasAtLoginFlag(AtLoginFlags.FirstLogin))
|
||||
{
|
||||
homebind = new WorldLocation(info.MapId, info.PositionX, info.PositionY, info.PositionZ, info.Orientation);
|
||||
homebindAreaId = info.ZoneId;
|
||||
var createPosition = m_createMode == PlayerCreateMode.NPE && info.createPositionNPE.HasValue ? info.createPositionNPE.Value : info.createPosition;
|
||||
|
||||
homebind = new WorldLocation(createPosition.Loc.GetMapId(), createPosition.Loc);
|
||||
if (createPosition.TransportGuid.HasValue)
|
||||
{
|
||||
Transport transport = Global.ObjAccessor.FindTransport(ObjectGuid.Create(HighGuid.Transport, createPosition.TransportGuid.Value));
|
||||
if (transport != null)
|
||||
transport.CalculatePassengerPosition(ref homebind.posX, ref homebind.posY, ref homebind.posZ, ref homebind.Orientation);
|
||||
}
|
||||
|
||||
homebindAreaId = Global.MapMgr.GetAreaId(PhasingHandler.EmptyPhaseShift, homebind);
|
||||
|
||||
saveHomebindToDb();
|
||||
ok = true;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Dynamic;
|
||||
using Game.Achievements;
|
||||
using Game.BattleGrounds;
|
||||
using Game.Chat;
|
||||
@@ -26,7 +27,6 @@ using Game.Mails;
|
||||
using Game.Maps;
|
||||
using Game.Misc;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -269,15 +269,8 @@ namespace Game.Entities
|
||||
|
||||
public class PlayerInfo
|
||||
{
|
||||
public uint MapId;
|
||||
public uint ZoneId;
|
||||
public float PositionX;
|
||||
public float PositionY;
|
||||
public float PositionZ;
|
||||
public float Orientation;
|
||||
|
||||
public uint DisplayId_m;
|
||||
public uint DisplayId_f;
|
||||
public CreatePosition createPosition;
|
||||
public Optional<CreatePosition> createPositionNPE;
|
||||
|
||||
public List<PlayerCreateInfoItem> item = new();
|
||||
public List<uint> customSpells = new();
|
||||
@@ -286,6 +279,12 @@ namespace Game.Entities
|
||||
public List<SkillRaceClassInfoRecord> skills = new();
|
||||
|
||||
public PlayerLevelInfo[] levelInfo = new PlayerLevelInfo[WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel)];
|
||||
|
||||
public struct CreatePosition
|
||||
{
|
||||
public WorldLocation Loc;
|
||||
public ulong? TransportGuid;
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerCreateInfoItem
|
||||
|
||||
@@ -176,8 +176,6 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
Relocate(info.PositionX, info.PositionY, info.PositionZ, info.Orientation);
|
||||
|
||||
var cEntry = CliDB.ChrClassesStorage.LookupByKey(createInfo.ClassId);
|
||||
if (cEntry == null)
|
||||
{
|
||||
@@ -193,8 +191,28 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
SetMap(Global.MapMgr.CreateMap(info.MapId, this));
|
||||
var position = createInfo.UseNPE && info.createPositionNPE.HasValue ? info.createPositionNPE.Value : info.createPosition;
|
||||
|
||||
m_createTime = GameTime.GetGameTime();
|
||||
m_createMode = createInfo.UseNPE && info.createPositionNPE.HasValue ? PlayerCreateMode.NPE : PlayerCreateMode.Normal;
|
||||
|
||||
Relocate(position.Loc);
|
||||
|
||||
SetMap(Global.MapMgr.CreateMap(position.Loc.GetMapId(), this));
|
||||
|
||||
if (position.TransportGuid.HasValue)
|
||||
{
|
||||
Transport transport = Global.ObjAccessor.FindTransport(ObjectGuid.Create(HighGuid.Transport, position.TransportGuid.Value));
|
||||
if (transport != null)
|
||||
{
|
||||
transport.AddPassenger(this);
|
||||
m_movementInfo.transport.pos.Relocate(position.Loc);
|
||||
position.Loc.GetPosition(out float x, out float y, out float z, out float o);
|
||||
transport.CalculatePassengerPosition(ref x, ref y, ref z, ref o);
|
||||
Relocate(x, y, z, o);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePositionData();
|
||||
|
||||
// set initial homebind position
|
||||
@@ -5332,28 +5350,15 @@ namespace Game.Entities
|
||||
|
||||
public void InitDisplayIds()
|
||||
{
|
||||
PlayerInfo info = Global.ObjectMgr.GetPlayerInfo(GetRace(), GetClass());
|
||||
if (info == null)
|
||||
ChrModelRecord model = Global.DB2Mgr.GetChrModel(GetRace(), GetNativeSex());
|
||||
if (model == null)
|
||||
{
|
||||
Log.outError(LogFilter.Player, "Player {0} has incorrect race/class pair. Can't init display ids.", GetGUID().ToString());
|
||||
Log.outError(LogFilter.Player, $"Player {GetGUID()} has incorrect race/gender pair. Can't init display ids.");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (GetNativeSex())
|
||||
{
|
||||
case Gender.Female:
|
||||
SetDisplayId(info.DisplayId_f);
|
||||
SetNativeDisplayId(info.DisplayId_f);
|
||||
break;
|
||||
case Gender.Male:
|
||||
SetDisplayId(info.DisplayId_m);
|
||||
SetNativeDisplayId(info.DisplayId_m);
|
||||
break;
|
||||
default:
|
||||
Log.outError(LogFilter.Player, "Player {0} ({1}) has invalid gender {2}", GetName(), GetGUID().ToString(), GetNativeSex());
|
||||
return;
|
||||
}
|
||||
|
||||
SetDisplayId(model.DisplayID);
|
||||
SetNativeDisplayId(model.DisplayID);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.StateAnimID), Global.DB2Mgr.GetEmptyAnimStateID());
|
||||
}
|
||||
|
||||
|
||||
@@ -5598,8 +5598,8 @@ namespace Game
|
||||
var time = Time.GetMSTime();
|
||||
// Load playercreate
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
SQLResult result = DB.World.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo");
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
SQLResult result = DB.World.Query("SELECT race, class, map, position_x, position_y, position_z, orientation, npe_map, npe_position_x, npe_position_y, npe_position_z, npe_orientation, npe_transport_guid FROM playercreateinfo");
|
||||
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
@@ -5613,11 +5613,10 @@ namespace Game
|
||||
uint currentrace = result.Read<uint>(0);
|
||||
uint currentclass = result.Read<uint>(1);
|
||||
uint mapId = result.Read<uint>(2);
|
||||
uint zoneId = result.Read<uint>(3);
|
||||
float positionX = result.Read<float>(4);
|
||||
float positionY = result.Read<float>(5);
|
||||
float positionZ = result.Read<float>(6);
|
||||
float orientation = result.Read<float>(7);
|
||||
float positionX = result.Read<float>(3);
|
||||
float positionY = result.Read<float>(4);
|
||||
float positionZ = result.Read<float>(5);
|
||||
float orientation = result.Read<float>(6);
|
||||
|
||||
if (!CliDB.ChrRacesStorage.ContainsKey(currentrace))
|
||||
{
|
||||
@@ -5644,32 +5643,43 @@ namespace Game
|
||||
continue;
|
||||
}
|
||||
|
||||
ChrModelRecord maleModel = Global.DB2Mgr.GetChrModel((Race)currentrace, Gender.Male);
|
||||
if (maleModel == null)
|
||||
if (Global.DB2Mgr.GetChrModel((Race)currentrace, Gender.Male) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Missing male model for race {currentrace}, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
ChrModelRecord femaleModel = Global.DB2Mgr.GetChrModel((Race)currentrace, Gender.Female);
|
||||
if (femaleModel == null)
|
||||
if (Global.DB2Mgr.GetChrModel((Race)currentrace, Gender.Female) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Missing female model for race {currentrace}, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerInfo pInfo = new();
|
||||
pInfo.MapId = mapId;
|
||||
pInfo.ZoneId = zoneId;
|
||||
pInfo.PositionX = positionX;
|
||||
pInfo.PositionY = positionY;
|
||||
pInfo.PositionZ = positionZ;
|
||||
pInfo.Orientation = orientation;
|
||||
PlayerInfo info = new();
|
||||
info.createPosition.Loc = new WorldLocation(mapId, positionX, positionY, positionZ, orientation);
|
||||
|
||||
pInfo.DisplayId_m = maleModel.DisplayID;
|
||||
pInfo.DisplayId_f = femaleModel.DisplayID;
|
||||
if (!result.IsNull(7))
|
||||
{
|
||||
info.createPositionNPE.HasValue = true;
|
||||
|
||||
_playerInfo[currentrace][currentclass] = pInfo;
|
||||
info.createPositionNPE.Value.Loc = new WorldLocation(result.Read<uint>(7), result.Read<float>(8), result.Read<float>(9), result.Read<float>(10), result.Read<float>(11));
|
||||
if (!result.IsNull(12))
|
||||
info.createPositionNPE.Value.TransportGuid = result.Read<ulong>(12);
|
||||
|
||||
if (!CliDB.MapStorage.ContainsKey(info.createPositionNPE.Value.Loc.GetMapId()))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Invalid NPE map id {info.createPositionNPE.Value.Loc.GetMapId()} for class {currentclass} race {currentrace} pair in `playercreateinfo` table, ignoring.");
|
||||
info.createPositionNPE.HasValue = false;
|
||||
}
|
||||
|
||||
if (info.createPositionNPE.HasValue && info.createPositionNPE.Value.TransportGuid.HasValue && Global.TransportMgr.GetTransportSpawn(info.createPositionNPE.Value.TransportGuid.Value) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Invalid NPE transport spawn id {info.createPositionNPE.Value.TransportGuid.Value} for class {currentclass} race {currentrace} pair in `playercreateinfo` table, ignoring.");
|
||||
info.createPositionNPE.HasValue = false; // remove entire NPE data - assume user put transport offsets into npe_position fields
|
||||
}
|
||||
}
|
||||
|
||||
_playerInfo[currentrace][currentclass] = info;
|
||||
|
||||
++count;
|
||||
} while (result.NextRow());
|
||||
@@ -6074,10 +6084,6 @@ namespace Game
|
||||
if (pInfo == null)
|
||||
continue;
|
||||
|
||||
// skip non loaded combinations
|
||||
if (pInfo.DisplayId_m == 0 || pInfo.DisplayId_f == 0)
|
||||
continue;
|
||||
|
||||
// skip expansion races if not playing with expansion
|
||||
if (WorldConfig.GetIntValue(WorldCfg.Expansion) < (int)Expansion.BurningCrusade && (race == (int)Race.BloodElf || race == (int)Race.Draenei))
|
||||
continue;
|
||||
@@ -6221,7 +6227,7 @@ namespace Game
|
||||
return null;
|
||||
|
||||
PlayerInfo pInfo = _playerInfo[(int)race][(int)_class];
|
||||
if (pInfo.DisplayId_m == 0 || pInfo.DisplayId_f == 0)
|
||||
if (pInfo == null)
|
||||
return null;
|
||||
|
||||
if (level <= WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel))
|
||||
|
||||
@@ -526,7 +526,7 @@ namespace Game.Maps
|
||||
return _transportAnimations.LookupByKey(entry);
|
||||
}
|
||||
|
||||
TransportSpawn GetTransportSpawn(ulong spawnId)
|
||||
public TransportSpawn GetTransportSpawn(ulong spawnId)
|
||||
{
|
||||
return _transportSpawns.LookupByKey(spawnId);
|
||||
}
|
||||
@@ -649,7 +649,7 @@ namespace Game.Maps
|
||||
public uint TotalTime;
|
||||
}
|
||||
|
||||
public struct TransportSpawn
|
||||
public class TransportSpawn
|
||||
{
|
||||
public ulong SpawnId;
|
||||
public uint TransportGameObjectId; // entry in respective _template table
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
ALTER TABLE `playercreateinfo`
|
||||
ADD `npe_map` int(10) unsigned DEFAULT NULL AFTER `orientation`,
|
||||
ADD `npe_position_x` float DEFAULT NULL AFTER `npe_map`,
|
||||
ADD `npe_position_y` float DEFAULT NULL AFTER `npe_position_x`,
|
||||
ADD `npe_position_z` float DEFAULT NULL AFTER `npe_position_y`,
|
||||
ADD `npe_orientation` float DEFAULT NULL AFTER `npe_position_z`,
|
||||
ADD `npe_transport_guid` bigint(20) unsigned DEFAULT NULL AFTER `npe_orientation`,
|
||||
DROP `zone`;
|
||||
|
||||
DELETE FROM `gameobject_template` WHERE `entry` IN (333479,349879);
|
||||
INSERT INTO `gameobject_template` (`entry`,`type`,`displayId`,`name`,`IconName`,`castBarCaption`,`unk1`,`size`,`Data0`,`Data1`,`Data2`,`Data3`,`Data4`,`Data5`,`Data6`,`Data7`,`Data8`,`Data9`,`Data10`,`Data11`,`Data12`,`Data13`,`Data14`,`Data15`,`Data16`,`Data17`,`Data18`,`Data19`,`Data20`,`Data21`,`Data22`,`Data23`,`Data24`,`Data25`,`Data26`,`Data27`,`Data28`,`Data29`,`Data30`,`Data31`,`Data32`,`Data33`,`ContentTuningId`,`VerifiedBuild`) VALUES
|
||||
(333479,15,61205,'Alliance Ship','','','',1,7748,10,2,0,0,81,2261,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40120), -- Alliance Ship
|
||||
(349879,15,61835,'Horde Transport','','','',1,8099,10,2,0,0,81,2369,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40120); -- Horde Transport
|
||||
|
||||
DELETE FROM `gameobject_template_addon` WHERE `entry` IN (333479,349879);
|
||||
INSERT INTO `gameobject_template_addon` (`entry`,`faction`,`flags`,`mingold`,`maxgold`,`WorldEffectID`,`AIAnimKitID`) VALUES
|
||||
(333479,0,0x28,0,0,0,0),
|
||||
(349879,0,0x28,0,0,0,0);
|
||||
|
||||
SET @ALLIANCE_SHIP := 29;
|
||||
SET @HORDE_SHIP := 30;
|
||||
DELETE FROM `transports` WHERE `guid` IN (@ALLIANCE_SHIP,@HORDE_SHIP);
|
||||
INSERT INTO `transports` (`guid`, `entry`, `name`, `phaseUseFlags`, `phaseid`, `phasegroup`, `ScriptName`) VALUES
|
||||
(29,333479,'NPE - Alliance Ship',0,0,0,''),
|
||||
(30,349879,'NPE - Horde Transport',0,0,0,'');
|
||||
|
||||
UPDATE `playercreateinfo` SET `npe_map`=2175,`npe_position_x`=11.1301,`npe_position_y`=-0.417182,`npe_position_z`=5.18741,`npe_orientation`=3.1484344,`npe_transport_guid`=@ALLIANCE_SHIP WHERE `race` IN (1,3,4,7,11,22,25) AND `class` NOT IN (6,12);
|
||||
UPDATE `playercreateinfo` SET `npe_map`=2175,`npe_position_x`=-10.7291,`npe_position_y`=-7.14635,`npe_position_z`=8.73113,`npe_orientation`=1.563206,`npe_transport_guid`=@HORDE_SHIP WHERE `race` IN (2,5,6,8,9,10,26) AND `class` NOT IN (6,12);
|
||||
Reference in New Issue
Block a user