public MonsterDatabaseData() : base() { // TODO: this is just a hack to let status know that this is mob status // find some other way than a none-existing mob.. Status = new WorldObjectStatus(mEmptyMonster); Drops = new MonsterDropList(); Skills = new MonsterSkillList(); ViewData = new WorldObjectViewData(); SpawnInfo = new List <MonsterSpawnInfo>(); }
public int Spawn() { long tick = DateTime.Now.Ticks; LastThinktime = tick; // TODO: check for respawn and bla // Reset status if no respawn Status = new WorldObjectStatus(this); Status.CalculateMonster(true); AttackedID = WorldID.Null; TargetID = WorldID.Null; MoveFailCount = 0; // Respawn timer kill if (SpawnTimer != null) { SpawnTimer.Stop(); } MasterID = WorldID.Null; MasterDistance = 0; Aggressive = ((Database.Status.Mode & EMonsterMode.Angry) > 0 ? true : false); SkillState = EMonsterSkillState.Idle; NextWalktime = tick + (new Random().Next(5000) + 1000); LastLinktime = tick; LastPcNeartime = 0; SkillDelays.Clear(); DamageLog.Clear(); LootItem.Clear(); if (Database.Option != EStatusOption.Nothing) { StatusChange.Option = Database.Option; } // Push to world World.Objects.Add(this); // Push to map Location.Map.OnEnter(this); Network.Packets.WorldObjectSpawn.Send(this, true); //skill_unit_move(&md->bl,tick,1); //mobskill_use(md, tick, MSC_SPAWN); return(1); }
public Character(DatabaseID dbID, bool addToWorld) : base(dbID, addToWorld) { BaseStatus = new WorldObjectStatus(this); BattleStatus = new WorldObjectStatus(this); ViewData = new WorldObjectViewData(); StatusChange = new WorldObjectStatusChangeList(); // TODO: i dont where eAthena initialize them realy.. // they using struct, which cant be null x.x Regen = new WorldObjectRegenerationData(this); HPRegen = new StatusVariationData(); SPRegen = new StatusVariationData(); SRegen = new CharacterRegenerationData(); SSRegen = new CharacterRegenerationData(); }
public MonsterDatabaseData() : base() { // TODO: this is just a hack to let status know that this is mob status // find some other way than a none-existing mob.. Status = new WorldObjectStatus(mEmptyMonster); Drops = new MonsterDropList(); Skills = new MonsterSkillList(); ViewData = new WorldObjectViewData(); SpawnInfo = new List<MonsterSpawnInfo>(); }
public int Spawn() { long tick = DateTime.Now.Ticks; LastThinktime = tick; // TODO: check for respawn and bla // Reset status if no respawn Status = new WorldObjectStatus(this); Status.CalculateMonster(true); AttackedID = WorldID.Null; TargetID = WorldID.Null; MoveFailCount = 0; // Respawn timer kill if (SpawnTimer != null) { SpawnTimer.Stop(); } MasterID = WorldID.Null; MasterDistance = 0; Aggressive = ((Database.Status.Mode & EMonsterMode.Angry) > 0 ? true : false); SkillState = EMonsterSkillState.Idle; NextWalktime = tick + (new Random().Next(5000) + 1000); LastLinktime = tick; LastPcNeartime = 0; SkillDelays.Clear(); DamageLog.Clear(); LootItem.Clear(); if (Database.Option != EStatusOption.Nothing) { StatusChange.Option = Database.Option; } // Push to world World.Objects.Add(this); // Push to map Location.Map.OnEnter(this); Network.Packets.WorldObjectSpawn.Send(this, true); //skill_unit_move(&md->bl,tick,1); //mobskill_use(md, tick, MSC_SPAWN); return 1; }
public static void Load() { if (Loaded == true || Loading == true) { return; } Loading = true; // Trigger events for scripts Events.InvokeWorldLoadStart(); // Our object manager for databsae objects Database = new DatabaseObjectManager(); // Our object manager for world objects (spawned objects) Objects = new WorldObjectManager(); // Delegate for Send() Method mForeachInRangeCallback = new ForeachInRangeVoidDelegate(SendSub); mAddQueue = new Queue <DatabaseObject>(); mDelQueue = new Queue <DatabaseObject>(); // Load globals from config, initialize packets ect ServerConsole.InfoLine("Initialize game symantics..."); Global.Initialize(); WorldObjectStatus.Initialize(); ChatHelper.Initialize(); PlayerCommandHelper.Initialize(); PathHelper.Initialize(); SkillTree.Initialize(); FameListHelper.Initialize(); CharacterJobBonus.Initialize(); CharacterJobModifer.Initialize(); // Real database loading ServerConsole.InfoLine("Begin World loading..."); DataTable table = null; Stopwatch watchAll = Stopwatch.StartNew(); Stopwatch watch = Stopwatch.StartNew(); //------------- loading start ------------- #region Mapcache ServerConsole.Info("\t# loading Maps from mapcache..."); watch.Reset(); watch.Start(); Mapcache.Initialize(); watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Mapcache.Maps.Count + " Maps in " + watch.ElapsedMilliseconds + "ms)"); #endregion #region Items ServerConsole.Info("\t# loading Items..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbitem"); table.TableName = "ItemDB Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Item Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { ItemDatabaseData item; for (int i = 0; i < table.Rows.Count; i++) { item = ItemDatabaseData.Load(table.Rows[i]); if (item == null) { ServerConsole.WarningLine("Failed to load item {0}: #{1} {2}", i, table.Rows[i].Field <int>("itemID"), table.Rows[i].Field <string>("nameEnglish")); continue; } Database.Add(item); //ServerConsole.DebugLine("\tLoad: #{0} {1}", item.NameID.ToString().PadLeft(5), item.Name); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Items.Count + " Items in " + watch.ElapsedMilliseconds + "ms)"); #endregion #region Monster ServerConsole.Info("\t# loading Mobs..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbmob"); table.TableName = "MobDB Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Monster Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { MonsterDatabaseData mob; for (int i = 0; i < table.Rows.Count; i++) { mob = MonsterDatabaseData.Load(table.Rows[i]); if (mob == null) { ServerConsole.WarningLine("Failed to load mob {0}: #{1} {2}", i, table.Rows[i].Field <int>("mobID"), table.Rows[i].Field <string>("nameInter")); continue; } Database.Add(mob); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} drops, {3} skills)", mob.ID.ToString().PadLeft(5), mob.NameInter, mob.Drops.Count, mob.Skills.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Monster.Count + " Mobs in " + watch.ElapsedMilliseconds + "ms)"); ServerConsole.Info("\t# loading Mob Skills..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbmob_skill ORDER BY mobID ASC"); table.TableName = "MobDB Skill Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Mob Skill Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { MonsterSkill mobSkill; for (int i = 0; i < table.Rows.Count; i++) { mobSkill = MonsterSkill.Load(table.Rows[i]); if (mobSkill == null) { throw new Exception(string.Format("Failed to load mob skill #{0}: {1}", table.Rows[i].Field <int>("mobID"), table.Rows[i].Field <string>("info"))); } (Database[EDatabaseType.Mob, mobSkill.MobID] as MonsterDatabaseData).Skills.Add(mobSkill); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms"); ServerConsole.Info("\t# loading Mob Drops..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbmob_drop ORDER BY mobID ASC"); table.TableName = "MobDB Drop Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Mob Drop Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { MonsterDrop drop; for (int i = 0; i < table.Rows.Count; i++) { drop = MonsterDrop.Load(table.Rows[i]); (Database[EDatabaseType.Mob, drop.MobID] as MonsterDatabaseData).Drops.Add(drop); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms"); #endregion #region General Skills ServerConsole.Info("\t# loading Skills..."); watch.Reset(); watch.Start(); table = Core.Database.Query("SELECT * FROM dbskill"); table.TableName = "SkillDB Table"; if (table == null || table.Rows.Count == 0) { if (Core.Database.LastError != null) { ServerConsole.ErrorLine("failed to load Skill Database!"); ServerConsole.WriteLine(Core.Database.LastError.ToString()); } } else { SkillDatabaseData skill; for (int i = 0; i < table.Rows.Count; i++) { skill = SkillDatabaseData.Load(table.Rows[i]); if (skill == null) { ServerConsole.WarningLine("Failed to load skill {0}: #{1} {2}", i, table.Rows[i].Field <int>("skillID"), table.Rows[i].Field <string>("name")); continue; } Database.Add(skill.Index, skill); //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count); } } watch.Stop(); ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Skill.Count + " Skills in " + watch.ElapsedMilliseconds + "ms)"); #endregion // Loading other shit // o.o //------------- loading end ------------- // Trigger event for scripts Events.InvokeWorldLoadFinish(); Loading = false; Loaded = true; ProcessSafetyQueues(); // TODO: Initialize save timer ServerConsole.InfoLine("Finished World loading! Needed {0:F2} sec", watchAll.Elapsed.TotalSeconds); watch.Stop(); watch = null; watchAll.Stop(); watchAll = null; }
public WorldSendUnitIdle(WorldObject obj, bool spawn) : base(0) { string name = WorldObject.GetName(obj); WorldObjectStatus status = WorldObject.GetStatusData(obj); WorldObjectViewData vd = WorldObject.GetViewData(obj); WorldObjectStatusChangeList sc = WorldObject.GetStatusChange(obj); ushort speed = WorldObject.GetSpeed(obj); Writer.Position = 0; Write((short)(spawn ? 0x7f8 : 0x7f9)); Write((short)((spawn ? 62 : 63) + name.Length)); Write((byte)obj.GetPacketType()); Write((uint)(obj is Character ? (obj as Character).Account.ID : obj.ID)); // For Character, send accountID as unique ID Write((ushort)speed); // status_get_speed(bl); Write((short)(sc != null ? sc.Option1 : 0)); // (sc) ? sc->opt1 : 0; Write((short)(sc != null ? sc.Option2 : 0)); // (sc) ? sc->opt2 : 0; Write((int)(sc != null ? sc.Option : 0)); // (sc) ? sc->option : 0; Write((short)(obj is NpcScript ? (obj as NpcScript).Class : (short)vd.Class)); // vd->class_; Write((short)(vd != null ? vd.HairStlye : 0)); // vd->hair_style; Write((short)(vd != null ? vd.Weapon : 0)); // vd->weapon; Write((short)(vd != null ? vd.Shield : 0)); // vd->shield; Write((short)(vd != null ? vd.HeadBottom : 0)); // vd->head_bottom Write((short)(vd != null ? vd.HeadTop : 0)); // vd->head_top; Write((short)(vd != null ? vd.HeadMid : 0)); // vd->head_mid; // TODO: implementieren! /* * if (bl->type == BL_NPC && vd->class_ == FLAG_CLASS) { //The hell, why flags work like this? * WBUFL(buf, 22) = status_get_emblem_id(bl); * WBUFL(buf, 26) = status_get_guild_id(bl); * } */ Write((short)(vd != null ? vd.HairColor : 0)); // vd->hair_color; Write((short)(vd != null ? vd.ClothesColor : 0)); // vd->cloth_color; Write((short)0); // (sd) ? sd->head_dir : 0; Write((int)0); // status_get_guild_id(bl); Write((short)0); // status_get_emblem_id(bl); Write((short)0); // (sd) ? sd->status.manner : 0; Write((int)(sc != null ? sc.Option3 : 0)); // (sc) ? sc->opt3 : 0; Write((byte)0); // (sd) ? sd->status.karma : 0; Write((byte)(vd != null ? vd.Sex : 0)); // vd->sex; Write((obj as WorldObjectUnit).Location); Write((byte)(obj is Character ? 5 : 0)); // (sd) ? 5 : 0; Write((byte)(obj is Character ? 5 : 0)); // (sd) ? 5 : 0; if (!spawn) { Write((byte)(vd != null ? vd.DeadSit : 0)); // vd->dead_sit; } Write((short)WorldObject.GetLevel(obj)); // clif_setlevel(status_get_lv(bl)); Write((short)0); // sd ? sd->state.user_font : 0; int pos = Writer.Position; Write(name); pos = Writer.Position; }