Ejemplo n.º 1
0
 public override Boolean CheckSpellPreconditions(Monster p_monster)
 {
     try
     {
         GridSlot             slot     = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_monster.Position);
         IList <MovingEntity> entities = slot.Entities;
         for (Int32 i = 0; i < entities.Count; i++)
         {
             if (entities[i] is Monster)
             {
                 Monster            monster  = (Monster)entities[i];
                 List <MonsterBuff> buffList = monster.BuffHandler.BuffList;
                 for (Int32 j = 0; j < buffList.Count; j++)
                 {
                     if (buffList[j].IsDebuff && (buffList[j].StaticID != 3 || monster != p_monster))
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LegacyLogger.LogError(ex.Message);
     }
     return(false);
 }
 public AddLorebookInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex)
 {
     m_parent = Grid.FindInteractiveObject(m_parentID);
     if (m_parent == null)
     {
         LegacyLogger.LogError("Not found parent trigger ID: " + p_parentID);
     }
 }
 public void UnlockPrivilege(String p_key)
 {
     if (m_isRendezVousConnected)
     {
         LegacyLogger.LogError("try to unlock key");
         RendezVousInvokes.LegacyRendezVousActivateAnyKey(p_key);
     }
 }
Ejemplo n.º 4
0
 public void Invoke(T args)
 {
     try
     {
         Event?.Invoke(args);
     }
     catch (Exception ex)
     {
         LegacyLogger.LogError(String.Concat("Event exception '", args.GetType().Name, "'\n", ex), true);
     }
 }
Ejemplo n.º 5
0
 public BaseButtonInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex)
 {
     m_parent = Grid.FindInteractiveObject(m_parentID);
     if (m_parent == null)
     {
         LegacyLogger.LogError("Not found parent trigger ID: " + p_parentID);
     }
     m_targetButton = Grid.FindInteractiveObject(m_targetSpawnID);
     if (m_targetButton == null)
     {
         LegacyLogger.LogError("Not found target trigger ID: " + m_targetSpawnID);
     }
 }
        public override void Trigger(ConversationManager p_manager)
        {
            InteractiveObject interactiveObject = LegacyLogic.Instance.WorldManager.FindObjectBySpawnerId <InteractiveObject>(TargetSpawnerID);

            if (interactiveObject != null)
            {
                interactiveObject.ClearInteractions();
                interactiveObject.Execute(LegacyLogic.Instance.MapLoader.Grid);
                interactiveObject.Update();
            }
            else
            {
                LegacyLogger.LogError("InteractiveObject spawnerID not found! ID: " + TargetSpawnerID);
            }
        }
Ejemplo n.º 7
0
        public void TryInvoke(Func <T> args)
        {
            try
            {
                Action <T> evt = Event;
                if (evt == null)
                {
                    return;
                }

                evt(args());
            }
            catch (Exception ex)
            {
                LegacyLogger.LogError(String.Concat("Event exception '", args.GetType().Name, "'\n", ex), true);
            }
        }
Ejemplo n.º 8
0
        protected override void LoadStaticData()
        {
            m_staticData = StaticDataHandler.GetStaticData <NpcStaticData>(EDataType.NPC, StaticID);
            if (m_staticData == null)
            {
                LegacyLogger.Log("npc staticdata id " + StaticID + " not found");
            }
            try
            {
                NpcConversationStaticData staticData = XmlStaticDataHandler <NpcConversationStaticData> .GetStaticData(StaticData.ConversationKey);

                if (staticData == null)
                {
                    LegacyLogger.Log(String.Concat(new Object[]
                    {
                        "npc staticdata id: ",
                        StaticID,
                        ", Conversation staticdata ",
                        StaticData.ConversationKey,
                        " not found"
                    }));
                }
                m_conversation     = new NpcConversation(staticData);
                m_tradingInventory = new TradingInventoryController(staticData, this);
                m_tradingSpells    = new TradingSpellController(staticData, this);
            }
            catch (Exception ex)
            {
                LegacyLogger.LogError(String.Concat(new Object[]
                {
                    "Error load NPC data\nStaticId: ",
                    StaticID,
                    ", ConversationKey: ",
                    StaticData.ConversationKey,
                    "\n",
                    ex
                }));
            }
            m_identifyController = new IdentifyInventoryController(this);
            m_repairController   = new RepairInventoryController();
        }
        internal void ExecuteAction()
        {
            Grid  grid  = LegacyLogic.Instance.MapLoader.Grid;
            Party party = LegacyLogic.Instance.WorldManager.Party;
            ESpiritBeaconAction action = Action;

            if (action != ESpiritBeaconAction.TRAVEL)
            {
                if (action == ESpiritBeaconAction.SET_POINT)
                {
                    if (party.Position != m_SpiritBeacon.Position || grid.Name != m_SpiritBeacon.Mapname || grid.LocationLocaName != m_SpiritBeacon.LocalizedMapnameKey)
                    {
                        m_SpiritBeacon = new SpiritBeaconPosition(party.Position, grid.Name, grid.LocationLocaName, grid.WorldMapPointID);
                        m_Existent     = true;
                        LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.SPIRIT_BEACON_UPDATE, EventArgs.Empty);
                    }
                }
            }
            else if (m_Existent)
            {
                if (grid.Name != m_SpiritBeacon.Mapname)
                {
                    party.SelectedInteractiveObject = null;
                    LegacyLogic.Instance.EventManager.RegisterEvent(EEventType.SAVEGAME_SAVED, new EventHandler(OnGameSaved));
                    LegacyLogic.Instance.WorldManager.HighestSaveGameNumber++;
                    LegacyLogic.Instance.WorldManager.CurrentSaveGameType = ESaveGameType.AUTO;
                    LegacyLogic.Instance.WorldManager.SaveGameName        = Localization.Instance.GetText("SAVEGAMETYPE_AUTO");
                    LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.SAVEGAME_STARTED_SAVE, EventArgs.Empty);
                }
                else if (party.Position != m_SpiritBeacon.Position)
                {
                    OnPartyPositionSet(null, EventArgs.Empty);
                }
            }
            else
            {
                LegacyLogger.LogError("No beacon defined cannot travel!");
            }
            Action = ESpiritBeaconAction.None;
        }
Ejemplo n.º 10
0
        public void Load(SaveGameData p_data)
        {
            Int32 num = p_data.Get <Int32>("NpcFactoryCount", 0);

            for (Int32 i = 0; i < num; i++)
            {
                Int32 num2 = p_data.Get <Int32>("NpcID" + i, 0);
                Npc   npc  = Get(num2);
                if (npc != null)
                {
                    SaveGameData saveGameData = p_data.Get <SaveGameData>("Npc" + i, null);
                    if (saveGameData != null)
                    {
                        npc.Load(saveGameData);
                    }
                    else
                    {
                        LegacyLogger.LogError("Fail load NPC savegame: " + num2);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public Npc Get(Int32 p_staticID)
        {
            Npc npc;

            if (!m_npcs.TryGetValue(p_staticID, out npc) && p_staticID != 0)
            {
                npc = new Npc(p_staticID);
                if (npc.StaticData != null && npc.ConversationData != null)
                {
                    m_npcs.Add(p_staticID, npc);
                }
                else
                {
                    npc = null;
                }
            }
            if (npc == null)
            {
                LegacyLogger.LogError("Fail load NPC static ID:" + p_staticID);
            }
            return(npc);
        }
Ejemplo n.º 12
0
        public void Load(SaveGameData p_data)
        {
            m_name = p_data.Get <String>("Name", null);
            Int32 num = p_data.Get <Int32>("ObjectCount", 0);

            for (Int32 i = 0; i < num; i++)
            {
                SaveGameData saveGameData = p_data.Get <SaveGameData>("InteractiveObject" + i, null);
                if (saveGameData != null)
                {
                    try
                    {
                        Int32             p_staticID        = saveGameData.Get <Int32>("StaticID", 0);
                        Int32             p_spawnID         = saveGameData.Get <Int32>("SpawnerID", 0);
                        EObjectType       p_type            = saveGameData.Get <EObjectType>("ObjectType", EObjectType.NONE);
                        InteractiveObject interactiveObject = (InteractiveObject)EntityFactory.Create(p_type, p_staticID, p_spawnID);
                        interactiveObject.Load(saveGameData);
                        m_objects.Add(interactiveObject);
                    }
                    catch (Exception p_message)
                    {
                        LegacyLogger.LogError(p_message);
                    }
                }
            }
            Int32 num2 = p_data.Get <Int32>("MonsterCount", 0);

            for (Int32 j = 0; j < num2; j++)
            {
                SaveGameData saveGameData2 = p_data.Get <SaveGameData>("Monster" + j, null);
                if (saveGameData2 != null)
                {
                    try
                    {
                        Monster monster = new Monster();
                        monster.Load(saveGameData2);
                        m_monster.Add(monster);
                    }
                    catch (Exception p_message2)
                    {
                        LegacyLogger.LogError(p_message2);
                    }
                }
            }
            SaveGameData saveGameData3 = p_data.Get <SaveGameData>("InvalidSpawns", null);

            if (saveGameData3 != null)
            {
                List <Int32> collection = SaveGame.CreateArrayFromData <Int32>(saveGameData3);
                m_invalidSpawns.AddRange(collection);
            }
            SaveGameData saveGameData4 = p_data.Get <SaveGameData>("TerrainMatrix", null);

            if (saveGameData4 != null)
            {
                m_terrainDataHeight = saveGameData4.Get <Int32>("MatrixHeight", 0);
                m_terrainDataWidth  = saveGameData4.Get <Int32>("MatrixWidth", 0);
                m_terrainData       = new TerrainTypeData[m_terrainDataWidth * m_terrainDataHeight];
                for (Int32 k = 0; k < m_terrainDataHeight; k++)
                {
                    for (Int32 l = 0; l < m_terrainDataWidth; l++)
                    {
                        SaveGameData saveGameData5 = saveGameData4.Get <SaveGameData>(String.Concat(new Object[]
                        {
                            "terrain_",
                            l,
                            "_",
                            k
                        }), null);
                        if (saveGameData5 != null)
                        {
                            TerrainTypeData terrainTypeData = default(TerrainTypeData);
                            terrainTypeData.Load(saveGameData5);
                            m_terrainData[k * m_terrainDataWidth + l] = terrainTypeData;
                        }
                    }
                }
            }
        }
            public void Update(Dialog newDialog)
            {
                if (newDialog.m_entries == null || newDialog.m_entries.Length == 0)
                {
                    return;         // Not implemented
                }
                var result  = new LinkedList <DialogEntry>(m_entries);
                var current = new Dictionary <String, LinkedListNode <DialogEntry> >(m_entries.Length);

                if (result.Count > 0)
                {
                    for (var node = result.First; node != null; node = node.Next)
                    {
                        current[node.Value.GetKeyFromText()] = node;
                    }
                }

                foreach (DialogEntry ent in newDialog.m_entries)
                {
                    DialogEntry entry = ent;
                    if (entry.m_injection == null)
                    {
                        result.AddLast(entry);
                    }
                    else
                    {
                        // Remove injection to avoid memory growing
                        DialogEntryInjection injection = entry.m_injection;
                        entry.m_injection = null;

                        LinkedListNode <DialogEntry> node;
                        if (current.TryGetValue(injection.TextKey, out node))
                        {
                            switch (injection.InjectionType)
                            {
                            case EDialogInjectionType.InsertAfter:
                                result.AddAfter(node, entry);
                                break;

                            case EDialogInjectionType.InsertBefore:
                                result.AddBefore(node, entry);
                                break;

                            case EDialogInjectionType.Replace:
                                result.AddAfter(node, entry);
                                result.Remove(node);
                                break;

                            default:
                                throw new NotImplementedException(injection.InjectionType.ToString());
                            }
                        }
                        else
                        {
                            result.AddLast(entry);
                            LegacyLogger.LogError($"Cannot find injection target [{injection.TextKey}] in the dialog.");
                        }
                    }
                }

                m_entries = result.ToArray();
            }
Ejemplo n.º 14
0
 public override void UpdateTurn()
 {
     base.UpdateTurn();
     if (State == EState.IDLE)
     {
         Position position = LegacyLogic.Instance.WorldManager.Party.Position;
         Grid     grid     = LegacyLogic.Instance.MapLoader.Grid;
         for (Int32 i = m_invalidSpawners.Count - 1; i >= 0; i--)
         {
             Spawn spawn = m_invalidSpawners[i];
             if (spawn.ObjectType == EObjectType.MONSTER && spawn.InSpawnRange(position) && !m_spawnObjects.Contains(spawn))
             {
                 m_invalidSpawners.RemoveAt(i);
                 m_spawnObjects.Add(spawn);
             }
         }
         if (m_spawnObjects.Count > 0)
         {
             m_spawnedInteractiveObjects.Clear();
             for (Int32 j = m_spawnObjects.Count - 1; j >= 0; j--)
             {
                 Spawn      spawn2     = m_spawnObjects[j];
                 BaseObject baseObject = LegacyLogic.Instance.WorldManager.FindObjectBySpawnerId(spawn2.ID);
                 if (baseObject == null && spawn2.ObjectType == EObjectType.MONSTER && !spawn2.InSpawnRange(position))
                 {
                     m_spawnObjects.RemoveAt(j);
                     m_invalidSpawners.Add(spawn2);
                     spawn2.SetCanRespawn();
                 }
                 else if (baseObject == null)
                 {
                     BaseObject baseObject2 = spawn2.SpawnObject();
                     if (baseObject2 != null)
                     {
                         spawn2.EndTurn();
                         LegacyLogic.Instance.UpdateManager.SpawnTurnActor.RemoveSpawner(spawn2);
                         LegacyLogic.Instance.WorldManager.InvalidSpawner.Add(spawn2.ID);
                         Boolean flag = false;
                         if (baseObject2 is MovingEntity)
                         {
                             MovingEntity movingEntity = (MovingEntity)baseObject2;
                             if (!grid.AddMovingEntity(movingEntity.Position, movingEntity))
                             {
                                 LegacyLogger.LogError(String.Concat(new Object[]
                                 {
                                     "Cannot add object to GRID! SpawnerID: ",
                                     movingEntity.SpawnerID,
                                     ", staticID: ",
                                     movingEntity.StaticID
                                 }));
                             }
                             else
                             {
                                 flag = true;
                             }
                         }
                         else if (baseObject2 is InteractiveObject)
                         {
                             InteractiveObject interactiveObject = (InteractiveObject)baseObject2;
                             grid.AddInteractiveObject(interactiveObject);
                             interactiveObject.OnAfterCreate(grid);
                             interactiveObject.OnAfterSpawn(grid);
                             m_spawnedInteractiveObjects.Add(interactiveObject);
                             flag = true;
                         }
                         if (flag)
                         {
                             LegacyLogic.Instance.WorldManager.SpawnObject(baseObject2, spawn2.Position);
                         }
                     }
                 }
             }
             foreach (InteractiveObject interactiveObject2 in m_spawnedInteractiveObjects)
             {
                 interactiveObject2.OnPrewarm(grid);
             }
             m_stateMachine.ChangeState(EState.RUNNING);
         }
         else
         {
             m_stateMachine.ChangeState(EState.FINISHED);
         }
     }
     else if (State == EState.RUNNING)
     {
         Boolean flag2 = true;
         foreach (Spawn spawn3 in m_spawnObjects)
         {
             if (spawn3.State != Spawn.EState.ACTION_FINISHED && spawn3.State != Spawn.EState.IDLE)
             {
                 flag2 = false;
                 break;
             }
         }
         if (flag2)
         {
             if (m_isFirstUpdate)
             {
                 LegacyLogic.Instance.MapLoader.OnLevelLoaded();
                 m_isFirstUpdate = false;
             }
             m_stateMachine.ChangeState(EState.FINISHED);
             foreach (Spawn spawn4 in m_spawnObjects)
             {
                 spawn4.TurnIdle.Trigger();
             }
         }
     }
     foreach (Spawn spawn5 in m_spawnObjects)
     {
         spawn5.Update();
     }
 }
Ejemplo n.º 15
0
 public void Update(IXmlStaticData additionalData)
 {
     LegacyLogger.LogError("The method Update of the type CreditsData isn't implemented.");
 }