Exemplo n.º 1
0
        internal int SummonMonster(MonsterToSummon summon)
        {
            NpcMonster npcmonster = ServerManager.GetNpcMonster(summon.VNum);

            if (npcmonster != null)
            {
                MapMonster mapMonster = new MapMonster
                {
                    MonsterVNum    = npcmonster.NpcMonsterVNum,
                    MapY           = summon.SpawnCell.Y,
                    MapX           = summon.SpawnCell.X,
                    MapId          = Map.MapId,
                    IsMoving       = summon.IsMoving,
                    MapMonsterId   = GetNextMonsterId(),
                    ShouldRespawn  = false,
                    Target         = summon.Target,
                    OnDeathEvents  = summon.DeathEvents,
                    OnNoticeEvents = summon.NoticingEvents,
                    IsTarget       = summon.IsTarget,
                    IsBonus        = summon.IsBonus,
                    IsBoss         = summon.IsBoss,
                    IsHostile      = summon.IsHostile
                };
                mapMonster.Initialize(this);
                AddMonster(mapMonster);
                Broadcast(mapMonster.GenerateIn());
                return(mapMonster.MapMonsterId);
            }
            return(default);
Exemplo n.º 2
0
        internal int SummonMonster(MonsterToSummon monsterToSummon)
        {
            NpcMonster npcMonster = ServerManager.GetNpc(monsterToSummon.VNum);

            if (npcMonster != null)
            {
                MapMonster mapMonster = new MapMonster
                {
                    Owner          = monsterToSummon.Owner,
                    AliveTime      = monsterToSummon.AliveTime,
                    IsKamikaze     = monsterToSummon.IsKamikaze,
                    MonsterVNum    = npcMonster.NpcMonsterVNum,
                    MapX           = monsterToSummon.SpawnCell.X,
                    MapY           = monsterToSummon.SpawnCell.Y,
                    MapId          = Map.MapId,
                    IsMoving       = monsterToSummon.IsMoving,
                    MapMonsterId   = GetNextMonsterId(),
                    ShouldRespawn  = false,
                    Target         = monsterToSummon.Target,
                    OnDeathEvents  = monsterToSummon.DeathEvents,
                    OnNoticeEvents = monsterToSummon.NoticingEvents,
                    IsTarget       = monsterToSummon.IsTarget,
                    IsBonus        = monsterToSummon.IsBonus,
                    IsBoss         = monsterToSummon.IsBoss,
                    NoticeRange    = monsterToSummon.NoticeRange
                };

                mapMonster.Initialize(this);
                mapMonster.IsHostile = monsterToSummon.IsHostile;
                mapMonster.Faction   = monsterToSummon.Faction;
                AddMonster(mapMonster);
                Broadcast(mapMonster.GenerateIn());

                return(mapMonster.MapMonsterId);
            }

            return(0);
        }
Exemplo n.º 3
0
        internal int SummonMonster(MonsterToSummon summon)
        {
            NpcMonster npcMonster = ServerManager.GetNpcMonster(summon.VNum);

            if (npcMonster != null)
            {
                short mapX = summon.SpawnCell.X;
                short mapY = summon.SpawnCell.Y;

                if (mapX == 0 && mapY == 0)
                {
                    MapCell cell = Map.GetRandomPosition();

                    if (cell != null)
                    {
                        mapX = cell.X;
                        mapY = cell.Y;
                    }
                }

                MapMonster mapMonster = new MapMonster
                {
                    MonsterVNum      = npcMonster.NpcMonsterVNum,
                    MapX             = mapX,
                    MapY             = mapY,
                    Position         = 2,
                    MapId            = Map.MapId,
                    IsMoving         = summon.IsMoving,
                    MapMonsterId     = GetNextMonsterId(),
                    ShouldRespawn    = false,
                    OnNoticeEvents   = summon.NoticingEvents,
                    UseSkillOnDamage = summon.UseSkillOnDamage,
                    OnSpawnEvents    = summon.SpawnEvents,
                    IsTarget         = summon.IsTarget,
                    Target           = summon.Target,
                    IsBonus          = summon.IsBonus,
                    IsBoss           = summon.IsBoss,
                    NoticeRange      = summon.NoticeRange,
                    Owner            = summon.Owner,
                    AliveTime        = summon.AliveTime,
                    AliveTimeMp      = summon.AliveTimeMp,
                    BaseMaxHp        = summon.MaxHp,
                    BaseMaxMp        = summon.MaxMp
                };

                if (summon.HasDelay > 0)
                {
                    AddDelayedMonster(mapMonster);
                }

                Observable.Timer(TimeSpan.FromSeconds(summon.HasDelay))
                .Subscribe(o =>
                {
                    mapMonster.Initialize(this);
                    mapMonster.BattleEntity.OnDeathEvents.AddRange(summon.DeathEvents);
                    mapMonster.IsHostile = summon.IsHostile;

                    AddMonster(mapMonster);
                    Broadcast(mapMonster.GenerateIn());
                    RemoveDelayedMonster(mapMonster);

                    if (summon.AfterSpawnEvents.Any())
                    {
                        summon.AfterSpawnEvents.ForEach(e => EventHelper.Instance.RunEvent(e, monster: mapMonster));
                    }

                    if (summon.IsMeteorite)
                    {
                        OnMeteoriteEvents(summon, mapMonster);
                    }
                });

                return(mapMonster.MapMonsterId);
            }

            return(default);