예제 #1
0
        public MonsterEvent(ScriptedEventPrefab prefab)
            : base(prefab)
        {
            characterFile = prefab.ConfigElement.GetAttributeString("characterfile", "");

            int defaultAmount = prefab.ConfigElement.GetAttributeInt("amount", 1);

            minAmount = prefab.ConfigElement.GetAttributeInt("minamount", defaultAmount);
            maxAmount = Math.Max(prefab.ConfigElement.GetAttributeInt("maxamount", 1), minAmount);

            var spawnPosTypeStr = prefab.ConfigElement.GetAttributeString("spawntype", "");

            if (string.IsNullOrWhiteSpace(spawnPosTypeStr) ||
                !Enum.TryParse(spawnPosTypeStr, true, out spawnPosType))
            {
                spawnPosType = Level.PositionType.MainPath;
            }

            spawnDeep         = prefab.ConfigElement.GetAttributeBool("spawndeep", false);
            characterFileName = Path.GetFileName(Path.GetDirectoryName(characterFile)).ToLower();

            if (GameMain.NetworkMember != null)
            {
                List <string> monsterNames = GameMain.NetworkMember.ServerSettings.MonsterEnabled.Keys.ToList();
                string        tryKey       = monsterNames.Find(s => characterFileName == s.ToLower());

                if (!string.IsNullOrWhiteSpace(tryKey))
                {
                    if (!GameMain.NetworkMember.ServerSettings.MonsterEnabled[tryKey])
                    {
                        disallowed = true;                                                                //spawn was disallowed by host
                    }
                }
            }
        }
예제 #2
0
            static void AddEvent(EventDebugStats stats, ScriptedEventPrefab eventPrefab)
            {
                if (eventPrefab.EventType == typeof(MonsterEvent))
                {
                    float spawnProbability = eventPrefab.ConfigElement.GetAttributeFloat("spawnprobability", 1.0f);
                    if (Rand.Value(Rand.RandSync.Server) > spawnProbability)
                    {
                        return;
                    }

                    string character = eventPrefab.ConfigElement.GetAttributeString("characterfile", "");
                    System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(character));
                    int amount    = eventPrefab.ConfigElement.GetAttributeInt("amount", 0);
                    int minAmount = eventPrefab.ConfigElement.GetAttributeInt("minamount", amount);
                    int maxAmount = eventPrefab.ConfigElement.GetAttributeInt("maxamount", amount);

                    int count = Rand.Range(minAmount, maxAmount + 1);
                    if (count <= 0)
                    {
                        return;
                    }

                    if (!stats.MonsterCounts.ContainsKey(character))
                    {
                        stats.MonsterCounts[character] = 0;
                    }
                    stats.MonsterCounts[character] += count;
                }
            }
예제 #3
0
        public MalfunctionEvent(ScriptedEventPrefab prefab)
            : base(prefab)
        {
            targetItems = new List <Item>();

            minItemAmount = prefab.ConfigElement.GetAttributeInt("minitemamount", 1);
            maxItemAmount = prefab.ConfigElement.GetAttributeInt("maxitemamount", minItemAmount);

            decreaseConditionAmount = prefab.ConfigElement.GetAttributeFloat("decreaseconditionamount", 0.0f);
            duration = prefab.ConfigElement.GetAttributeFloat("duration", 0.0f);

            targetItemIdentifiers = prefab.ConfigElement.GetAttributeStringArray("itemidentifiers", new string[0]);
        }
예제 #4
0
        public WanderingMonsterEvent(ScriptedEventPrefab prefab, String speciesNameIn, int amount, int minAmountIn, int maxAmountIn, String spawnTypeStr, bool spawnDeepIn)
            : base(prefab)
        {
            speciesName = speciesNameIn;
            CharacterPrefab characterPrefab = CharacterPrefab.FindByFilePath(speciesName);

            if (characterPrefab != null)
            {
                speciesName = characterPrefab.Identifier;
            }

            if (string.IsNullOrEmpty(speciesName))
            {
                throw new Exception("speciesname is null!");
            }

            int defaultAmount = amount;

            minAmount = minAmountIn;
            maxAmount = Math.Max(maxAmountIn, minAmount);

            offset  = 0;    //Cx change needs looked at
            scatter = 1000; //CX change needs looked at

            String spawnPosTypeStr = spawnTypeStr;

            if (string.IsNullOrWhiteSpace(spawnPosTypeStr) ||
                !Enum.TryParse(spawnPosTypeStr, true, out spawnPosType))
            {
                spawnPosType = Level.PositionType.MainPath;
            }

            spawnDeep = spawnDeepIn;

            if (GameMain.NetworkMember != null)
            {
                List <string> monsterNames = GameMain.NetworkMember.ServerSettings.MonsterEnabled.Keys.ToList();
                string        tryKey       = monsterNames.Find(s => speciesName.ToLower() == s.ToLower());

                if (!string.IsNullOrWhiteSpace(tryKey))
                {
                    if (!GameMain.NetworkMember.ServerSettings.MonsterEnabled[tryKey])
                    {
                        disallowed = true; //spawn was disallowed by host
                    }
                }
            }
        }
예제 #5
0
        public MonsterEvent(ScriptedEventPrefab prefab)
            : base(prefab)
        {
            speciesName = prefab.ConfigElement.GetAttributeString("characterfile", "");
            CharacterPrefab characterPrefab = CharacterPrefab.FindByFilePath(speciesName);

            if (characterPrefab != null)
            {
                speciesName = characterPrefab.Identifier;
            }

            if (string.IsNullOrEmpty(speciesName))
            {
                throw new Exception("speciesname is null!");
            }

            int defaultAmount = prefab.ConfigElement.GetAttributeInt("amount", 1);

            minAmount = prefab.ConfigElement.GetAttributeInt("minamount", defaultAmount);
            maxAmount = Math.Max(prefab.ConfigElement.GetAttributeInt("maxamount", 1), minAmount);

            var spawnPosTypeStr = prefab.ConfigElement.GetAttributeString("spawntype", "");

            if (string.IsNullOrWhiteSpace(spawnPosTypeStr) ||
                !Enum.TryParse(spawnPosTypeStr, true, out spawnPosType))
            {
                spawnPosType = Level.PositionType.MainPath;
            }

            spawnDeep = prefab.ConfigElement.GetAttributeBool("spawndeep", false);
            offset    = prefab.ConfigElement.GetAttributeFloat("offset", 0);
            scatter   = Math.Clamp(prefab.ConfigElement.GetAttributeFloat("scatter", 1000), 0, 3000);

            if (GameMain.NetworkMember != null)
            {
                List <string> monsterNames = GameMain.NetworkMember.ServerSettings.MonsterEnabled.Keys.ToList();
                string        tryKey       = monsterNames.Find(s => speciesName.ToLower() == s.ToLower());

                if (!string.IsNullOrWhiteSpace(tryKey))
                {
                    if (!GameMain.NetworkMember.ServerSettings.MonsterEnabled[tryKey])
                    {
                        disallowed = true; //spawn was disallowed by host
                    }
                }
            }
        }
예제 #6
0
 public ArtifactEvent(ScriptedEventPrefab prefab)
     : base(prefab)
 {
     if (prefab.ConfigElement.Attribute("itemname") != null)
     {
         DebugConsole.ThrowError("Error in ArtifactEvent - use item identifier instead of the name of the item.");
         string itemName = prefab.ConfigElement.GetAttributeString("itemname", "");
         itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
         if (itemPrefab == null)
         {
             DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name " + itemName);
         }
     }
     else
     {
         string itemIdentifier = prefab.ConfigElement.GetAttributeString("itemidentifier", "");
         itemPrefab = MapEntityPrefab.Find(null, itemIdentifier) as ItemPrefab;
         if (itemPrefab == null)
         {
             DebugConsole.ThrowError("Error in ArtifactEvent - couldn't find an item prefab with the identifier " + itemIdentifier);
         }
     }
 }
예제 #7
0
 public ScriptedEvent(ScriptedEventPrefab prefab)
 {
     this.prefab = prefab;
 }