Exemple #1
0
 // Token: 0x06001C38 RID: 7224 RVA: 0x0009988C File Offset: 0x00097C8C
 public NPCZombieKillsCondition(ushort newID, short newValue, EZombieSpeciality newZombie, bool newSpawn, byte newNav, string newText, bool newShouldReset) : base(newText, newShouldReset)
 {
     this.id     = newID;
     this.value  = newValue;
     this.zombie = newZombie;
     this.spawn  = newSpawn;
     this.nav    = newNav;
 }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            // Try to spawn the zombie just like ZombieManager does
            // In a finished version, this would also need to be configurable
            UnturnedPlayer    untPlayer  = (UnturnedPlayer)caller;
            EZombieSpeciality speciality = EZombieSpeciality.NORMAL;
            byte    type  = 1;
            byte    shirt = (byte)Random.Range(0, 1);
            byte    pants = (byte)Random.Range(0, 1);
            byte    hat   = (byte)Random.Range(0, 1);
            byte    gear  = (byte)Random.Range(0, 1);
            byte    move  = (byte)Random.Range(0, 4);
            byte    idle  = (byte)Random.Range(0, 3);
            Vector3 point = untPlayer.Position;

            point.y += 0.1f;
            byte bound = untPlayer.Player.movement.bound;
            // The newewst zombie will have this id
            ushort zombieId = (ushort)ZombieManager.regions[bound].zombies.Count;

            // Add the zombie
            ZombieManager.instance.addZombie(bound, type, (byte)speciality, shirt, pants, hat, gear, move, idle, point, Random.Range(0f, 360f), false);

            // Get the Zombie by it's new id
            Zombie zombie = ZombieManager.getZombie(point, zombieId);

            /*zombie.sendRevive
             * (
             *  type,
             *  (byte)speciality,
             *  shirt,
             *  pants,
             *  hat,
             *  gear,
             *  untPlayer.Position,
             *  0
             * );*/

            UnturnedChat.Say("Spawned zombie with id " + zombieId);
        }
        // Token: 0x06003447 RID: 13383 RVA: 0x00154C10 File Offset: 0x00153010
        public static void readConditions(Data data, Local localization, string prefix, INPCCondition[] conditions, string errorMessageSource)
        {
            for (int i = 0; i < conditions.Length; i++)
            {
                if (!data.has(prefix + i + "_Type"))
                {
                    Assets.errors.Add(string.Concat(new object[]
                    {
                        "Missing condition ",
                        prefix,
                        i,
                        " type"
                    }));
                    throw new NotSupportedException(string.Concat(new object[]
                    {
                        "Missing condition ",
                        prefix,
                        i,
                        " type"
                    }));
                }
                ENPCConditionType enpcconditionType = (ENPCConditionType)Enum.Parse(typeof(ENPCConditionType), data.readString(prefix + i + "_Type"), true);
                string            text = localization.read(prefix + i);
                text = ItemTool.filterRarityRichText(text);
                bool          newShouldReset = data.has(prefix + i + "_Reset");
                ENPCLogicType newLogicType   = ENPCLogicType.NONE;
                if (data.has(prefix + i + "_Logic"))
                {
                    newLogicType = (ENPCLogicType)Enum.Parse(typeof(ENPCLogicType), data.readString(prefix + i + "_Logic"), true);
                }
                switch (enpcconditionType)
                {
                case ENPCConditionType.EXPERIENCE:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Experience condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCExperienceCondition(data.readUInt32(prefix + i + "_Value"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.REPUTATION:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Reputation condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCReputationCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.FLAG_BOOL:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Bool flag condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Bool flag condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCBoolFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readBoolean(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.FLAG_SHORT:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Short flag condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Short flag condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCShortFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.QUEST:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Quest condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Status"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Quest condition ",
                            prefix,
                            i,
                            " missing _Status in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCQuestCondition(data.readUInt16(prefix + i + "_ID"), (ENPCQuestStatus)Enum.Parse(typeof(ENPCQuestStatus), data.readString(prefix + i + "_Status"), true), data.has(prefix + i + "_Ignore_NPC"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.SKILLSET:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Skillset condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCSkillsetCondition((EPlayerSkillset)Enum.Parse(typeof(EPlayerSkillset), data.readString(prefix + i + "_Value"), true), newLogicType, text);
                    break;

                case ENPCConditionType.ITEM:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Item condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Amount"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Item condition ",
                            prefix,
                            i,
                            " missing _Amount in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCItemCondition(data.readUInt16(prefix + i + "_ID"), data.readUInt16(prefix + i + "_Amount"), text, newShouldReset);
                    break;

                case ENPCConditionType.KILLS_ZOMBIE:
                {
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                            {
                                "Zombie kills condition ",
                                prefix,
                                i,
                                " missing _ID in: ",
                                errorMessageSource
                            }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                            {
                                "Zombie kills condition ",
                                prefix,
                                i,
                                " missing _Value in: ",
                                errorMessageSource
                            }));
                    }
                    EZombieSpeciality newZombie = EZombieSpeciality.NONE;
                    if (data.has(prefix + i + "_Zombie"))
                    {
                        newZombie = (EZombieSpeciality)Enum.Parse(typeof(EZombieSpeciality), data.readString(prefix + i + "_Zombie"), true);
                    }
                    else
                    {
                        Assets.errors.Add(string.Concat(new object[]
                            {
                                "Zombie kills condition ",
                                prefix,
                                i,
                                " missing _Zombie in: ",
                                errorMessageSource
                            }));
                    }
                    conditions[i] = new NPCZombieKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), newZombie, data.has(prefix + i + "_Spawn"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;
                }

                case ENPCConditionType.KILLS_HORDE:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Horde kills condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Horde kills condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Nav"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Horde kills condition ",
                            prefix,
                            i,
                            " missing _Nav in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCHordeKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;

                case ENPCConditionType.KILLS_ANIMAL:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Animal kills condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Animal kills condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Animal"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Animal kills condition ",
                            prefix,
                            i,
                            " missing _Animal in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCAnimalKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.readUInt16(prefix + i + "_Animal"), text, newShouldReset);
                    break;

                case ENPCConditionType.COMPARE_FLAGS:
                    if (!data.has(prefix + i + "_A_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Compare flags condition ",
                            prefix,
                            i,
                            " missing _A_ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_B_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Compare flags condition ",
                            prefix,
                            i,
                            " missing _B_ID in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCCompareFlagsCondition(data.readUInt16(prefix + i + "_A_ID"), data.readUInt16(prefix + i + "_B_ID"), data.has(prefix + i + "_Allow_A_Unset"), data.has(prefix + i + "_Allow_B_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.TIME_OF_DAY:
                    if (!data.has(prefix + i + "_Second"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Time of day condition ",
                            prefix,
                            i,
                            " missing _Second in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCTimeOfDayCondition(data.readInt32(prefix + i + "_Second"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.PLAYER_LIFE_HEALTH:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life health condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeHealthCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.PLAYER_LIFE_FOOD:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life food condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeFoodCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.PLAYER_LIFE_WATER:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life water condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeWaterCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.PLAYER_LIFE_VIRUS:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life virus condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeVirusCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;
                }
            }
        }
Exemple #4
0
        public static void readConditions(Data data, Local localization, string prefix, INPCCondition[] conditions)
        {
            for (int i = 0; i < conditions.Length; i++)
            {
                if (!data.has(prefix + i + "_Type"))
                {
                    throw new NotSupportedException("Missing condition type");
                }
                ENPCConditionType enpcconditionType = (ENPCConditionType)Enum.Parse(typeof(ENPCConditionType), data.readString(prefix + i + "_Type"), true);
                string            text = localization.read(prefix + i);
                text = ItemTool.filterRarityRichText(text);
                bool          newShouldReset = data.has(prefix + i + "_Reset");
                ENPCLogicType newLogicType   = ENPCLogicType.NONE;
                if (data.has(prefix + i + "_Logic"))
                {
                    newLogicType = (ENPCLogicType)Enum.Parse(typeof(ENPCLogicType), data.readString(prefix + i + "_Logic"), true);
                }
                switch (enpcconditionType)
                {
                case ENPCConditionType.EXPERIENCE:
                    conditions[i] = new NPCExperienceCondition(data.readUInt32(prefix + i + "_Value"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.REPUTATION:
                    conditions[i] = new NPCReputationCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.FLAG_BOOL:
                    conditions[i] = new NPCBoolFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readBoolean(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.FLAG_SHORT:
                    conditions[i] = new NPCShortFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.QUEST:
                    conditions[i] = new NPCQuestCondition(data.readUInt16(prefix + i + "_ID"), (ENPCQuestStatus)Enum.Parse(typeof(ENPCQuestStatus), data.readString(prefix + i + "_Status"), true), data.has(prefix + i + "_Ignore_NPC"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.SKILLSET:
                    conditions[i] = new NPCSkillsetCondition((EPlayerSkillset)Enum.Parse(typeof(EPlayerSkillset), data.readString(prefix + i + "_Value"), true), newLogicType, text);
                    break;

                case ENPCConditionType.ITEM:
                    conditions[i] = new NPCItemCondition(data.readUInt16(prefix + i + "_ID"), data.readUInt16(prefix + i + "_Amount"), text, newShouldReset);
                    break;

                case ENPCConditionType.KILLS_ZOMBIE:
                {
                    EZombieSpeciality newZombie = EZombieSpeciality.NONE;
                    if (data.has(prefix + i + "_Zombie"))
                    {
                        newZombie = (EZombieSpeciality)Enum.Parse(typeof(EZombieSpeciality), data.readString(prefix + i + "_Zombie"), true);
                    }
                    conditions[i] = new NPCZombieKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), newZombie, data.has(prefix + i + "_Spawn"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;
                }

                case ENPCConditionType.KILLS_HORDE:
                    conditions[i] = new NPCHordeKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;
                }
            }
        }