Skip to content

Commit

Permalink
Merge 873393f into 3dcb95c
Browse files Browse the repository at this point in the history
  • Loading branch information
NL0bP committed Jul 25, 2022
2 parents 3dcb95c + 873393f commit 04f0437
Show file tree
Hide file tree
Showing 16 changed files with 213,602 additions and 213,926 deletions.
41 changes: 38 additions & 3 deletions AAEmu.Game/Core/Managers/SkillManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ public void Load()
_effects.Add("TrainCraftEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("SkillController", new Dictionary<uint, EffectTemplate>());
_effects.Add("ResetAoeDiminishingEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("NpcSpawnerSpawnEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("NpcSpawnerDespawnEffect", new Dictionary<uint, EffectTemplate>());

_buffs = new Dictionary<uint, BuffTemplate>();
// TODO
/*
_effects.Add("CinemaEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("NpcControlEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("NpcSpawnerSpawnEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("NpcSpawnerDespawnEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("SpawnFishEffect", new Dictionary<uint, EffectTemplate>());
_effects.Add("PlayLogEffect", new Dictionary<uint, EffectTemplate>());
*/
Expand Down Expand Up @@ -1278,12 +1278,47 @@ public void Load()
template.UseSummonerFaction = reader.GetBoolean("use_summoner_faction", true);
template.LifeTime = reader.GetFloat("life_time");
template.DespawnOnCreatorDeath = reader.GetBoolean("despawn_on_creator_death", true);
template.UseSummoneerAggroTarget = reader.GetBoolean("use_summoner_aggro_target", true);
template.UseSummonerAggroTarget = reader.GetBoolean("use_summoner_aggro_target", true);
// TODO 1.2 // template.MateStateId = reader.GetUInt32("mate_state_id", 0);
_effects["SpawnEffect"].Add(template.Id, template);
}
}
}
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT * FROM npc_spawner_spawn_effects";
command.Prepare();
using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
{
while (reader.Read())
{
var template = new NpcSpawnerSpawnEffect();
template.Id = reader.GetUInt32("id");
template.SpawnerId = reader.GetUInt32("spawner_id", 0);
template.LifeTime = reader.GetFloat("life_time");
template.DespawnOnCreatorDeath = reader.GetBoolean("despawn_on_creator_death", true);
template.UseSummonerAggroTarget = reader.GetBoolean("use_summoner_aggro_target", true);
template.ActivationState = reader.GetBoolean("activation_state", true);
_effects["NpcSpawnerSpawnEffect"].Add(template.Id, template);
}
}
}
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT * FROM npc_spawner_despawn_effects";
command.Prepare();
using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
{
while (reader.Read())
{
var template = new NpcSpawnerDespawnEffect();
template.Id = reader.GetUInt32("id");
template.SpawnerId = reader.GetUInt32("spawner_id");
_effects["NpcSpawnerDespawnEffect"].Add(template.Id, template);
}
}
}

// TODO spawn_fish_effects
using (var command = connection.CreateCommand())
{
Expand Down
61 changes: 51 additions & 10 deletions AAEmu.Game/Core/Managers/World/SpawnManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class SpawnManager : Singleton<SpawnManager>
private HashSet<GameObject> _despawns;

private Dictionary<byte, Dictionary<uint, NpcSpawner>> _npcSpawners;
private Dictionary<byte, Dictionary<uint, NpcSpawner>> _npcEventSpawners;
private Dictionary<byte, Dictionary<uint, DoodadSpawner>> _doodadSpawners;
private Dictionary<byte, Dictionary<uint, TransferSpawner>> _transferSpawners;
private Dictionary<byte, Dictionary<uint, GimmickSpawner>> _gimmickSpawners;
Expand All @@ -44,17 +45,19 @@ public void Load()
_respawns = new HashSet<GameObject>();
_despawns = new HashSet<GameObject>();
_npcSpawners = new Dictionary<byte, Dictionary<uint, NpcSpawner>>();
_npcEventSpawners = new Dictionary<byte, Dictionary<uint, NpcSpawner>>();
_doodadSpawners = new Dictionary<byte, Dictionary<uint, DoodadSpawner>>();
_transferSpawners = new Dictionary<byte, Dictionary<uint, TransferSpawner>>();
_gimmickSpawners = new Dictionary<byte, Dictionary<uint, GimmickSpawner>>();
_playerDoodads = new List<Doodad>();

var worlds = WorldManager.Instance.GetWorlds();
_log.Info("Loading spawns...");
var idx = 1u; // for npc spawner.Id
var idx = 1u; // for spawner.Id
foreach (var world in worlds)
{
var npcSpawners = new Dictionary<uint, NpcSpawner>();
var npcEventSpawners = new Dictionary<uint, NpcSpawner>();
var doodadSpawners = new Dictionary<uint, DoodadSpawner>();
var transferSpawners = new Dictionary<uint, TransferSpawner>();
var gimmickSpawners = new Dictionary<uint, GimmickSpawner>();
Expand Down Expand Up @@ -93,21 +96,37 @@ public void Load()
spawner.Position.Yaw = spawner.Position.Yaw.DegToRad();
spawner.Position.Pitch = spawner.Position.Pitch.DegToRad();
spawner.Position.Roll = spawner.Position.Roll.DegToRad();
var npcSpawnersId = NpcGameData.Instance.GetSpawnersId(spawner.UnitId);
if (!npcSpawners.ContainsKey(idx))
// проверка наличия введенного вручную идентификатора NpcSpawnerId
// check for manually entered NpcSpawnerId
if (spawner.NpcSpawnerId.Count == 0)
{
foreach (var npcSpawnerId in npcSpawnersId)
var npcSpawnersId = NpcGameData.Instance.GetSpawnersId(spawner.UnitId);
if (!npcSpawners.ContainsKey(idx))
{
spawner.NpcSpawnerId.Add(npcSpawnerId);
spawner.Id = idx;
if (!spawner.Template.ContainsKey(npcSpawnerId))
foreach (var npcSpawnerId in npcSpawnersId)
{
spawner.Template.Add(npcSpawnerId, NpcGameData.Instance.GetNpcSpawnerTemplate(npcSpawnerId));
spawner.NpcSpawnerId.Add(npcSpawnerId);
spawner.Id = idx;
if (!spawner.Template.ContainsKey(npcSpawnerId))
{
spawner.Template.Add(npcSpawnerId, NpcGameData.Instance.GetNpcSpawnerTemplate(npcSpawnerId));
}
npcSpawners.Add(idx, spawner);
idx++; //we'll renumber
}
npcSpawners.Add(idx, spawner);
idx++; //we'll renumber
}
}
else
{
// Load NPC Spawns for Events
spawner.Id = idx;
if (!spawner.Template.ContainsKey(spawner.NpcSpawnerId[0]))
{
spawner.Template.Add(spawner.NpcSpawnerId[0], new NpcSpawnerTemplate(spawner.NpcSpawnerId[0]));
}
npcEventSpawners.Add(idx, spawner);
idx++; //we'll renumber
}
}
}
else
Expand Down Expand Up @@ -255,6 +274,7 @@ public void Load()
}

_npcSpawners.Add((byte)world.Id, npcSpawners);
_npcEventSpawners.Add((byte)world.Id, npcEventSpawners);
_doodadSpawners.Add((byte)world.Id, doodadSpawners);
_transferSpawners.Add((byte)world.Id, transferSpawners);
_gimmickSpawners.Add((byte)world.Id, gimmickSpawners);
Expand Down Expand Up @@ -578,5 +598,26 @@ private void CheckRespawns()
Thread.Sleep(1000);
}
}

public List<NpcSpawner> GetNpcSpawner(uint spawnerId, byte worldId)
{
var ret = new List<NpcSpawner>();
_npcEventSpawners.TryGetValue(worldId, out var npcEventSpawners);
if (npcEventSpawners == null)
{
return null;
}

foreach (var spawner in npcEventSpawners.Values.Where(spawner => spawner.NpcSpawnerId[0] == spawnerId))
{
spawner.Template[spawnerId].Npcs[^1].MemberId = spawner.UnitId;
spawner.Template[spawnerId].Npcs[^1].UnitId = spawner.UnitId;
spawner.Template[spawnerId].Npcs[^1].MemberType = "Npc";
ret.Add(spawner);
}

return ret;
}

}
}
Loading

0 comments on commit 04f0437

Please sign in to comment.