コード例 #1
0
ファイル: Quest.cs プロジェクト: tuita520/GTARPG
        private void SetupConditions()
        {
            BlipObjects = new List <BlipObject>();

            if (CreateHandInBlip)
            {
                BlipObjects.Add(RPGBlips.QuestHandIn(Name, HandInBlipPosition));
            }

            foreach (var c in Conditions)
            {
                SetupCondition(c, true);
            }
        }
コード例 #2
0
ファイル: Quest.cs プロジェクト: tuita520/GTARPG
        public void SetupCondition(QuestCondition c, bool firstSetup)
        {
            if (c.Type == ConditionType.Kill && c.Parameters.ContainsKey("ModelHash") ||
                c.Type == ConditionType.Loot && c.Parameters.ContainsKey("ModelHash"))
            {
                int[] hashes;
                var   models  = c.Parameters["ModelHash"] as uint[];
                var   modelsA = c.Parameters["ModelHash"] as JArray;

                if (models != null)
                {
                    hashes = models.Select(m => (int)m).ToArray();
                }
                else
                {
                    hashes = modelsA.Select(jv => (uint)jv).Select(t => (int)t).ToArray();
                }


                if (SpawnTargets)
                {
                    c.Position = c.Position == Vector3.Zero ? RPGMethods.GetSpawnPoint(350) : c.Position;
                    BlipObjects.Add(RPGBlips.QuestArea(Name, c.Position));

                    EventHandler.Do(q =>
                    {
                        var pos           = c.Position;
                        var amountToSpawn = AmountToSpawn;
                        var playerGroup   = Game.Player.Character.RelationshipGroup;
                        var enemies       = World.AddRelationshipGroup("RPG_Enemies");
                        World.SetRelationshipBetweenGroups(Relationship.Neutral, playerGroup, enemies);
                        for (int i = 0; i < amountToSpawn; i++)
                        {
                            var hash = hashes[Random.Range(0, hashes.Length)];
                            var m    = new Model(hash);
                            m.Request(1000);
                            var ped = World.CreatePed(m, pos + Vector3.RandomXY() * 2, Game.Player.Character.Heading + 180);
                            ped.RelationshipGroup = enemies;
                            var b = ped.AddBlip();
                            EventHandler.Wait(100);
                            b.IsFriendly = false;
                            b.Scale      = 0.6f;
                            ped.Task.WanderAround();
                            //todo: apply some weapon damage scaling here lol
                            ped.Weapons.Give(WeaponHash.Pistol, 1000, false, true);
                            ped.CanSwitchWeapons = true;
                            RPG.WorldData.AddPed(new NpcObject("Quest_" + Name, ped));
                            RPG.WorldData.AddBlip(new BlipObject("Quest_" + Name, b));
                            HasSpawnedTargets = true;
                        }
                    });
                }
            }

            if (!c.Parameters.ContainsKey("Current"))
            {
                c.Parameters.Add("Current", 0);
            }

            if (firstSetup)
            {
                switch (c.Type)
                {
                case ConditionType.Kill:
                case ConditionType.Loot:
                case ConditionType.DestroyVehicle:
                case ConditionType.Acquire:
                    c.Parameters["Current"] = 0;
                    break;

                case ConditionType.Interact:
                case ConditionType.Escort:
                case ConditionType.Race:
                case ConditionType.EvadeCops:
                    c.Parameters["Current"] = false;
                    break;

                case ConditionType.Custom:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }