public TrafficSpawner(string source, string timeframe, string area, TerrainType terrain, int freq, int prob)
        {
            SourceVehicle = source.ToLowerInvariant();
            if (freq < 0)
            {
                freq = 0;
            }
            CooldownTime = (freq * 1000 * 60) + (LivelyWorld.RandomInt(1, 30) * 1000);


            Prob     = prob;
            Cooldown = Game.GameTime + CooldownTime;

            Terrain = terrain;
            if (Terrain == TerrainType.Air || Terrain == TerrainType.Water)
            {
                despawnRange = 500f;
            }
            if (area.Length > 0)
            {
                AreaOrZone = area.ToLowerInvariant();
            }
            if (timeframe.Length > 0)
            {
                Time = timeframe;
            }
            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - added TrafficSpawner (" + source + ", in " + area + ")");
            }
            if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
            {
                UI.Notify(SourceVehicle + " spawner, timer:" + (Cooldown - Game.GameTime) * 0.001f + "s");
            }
        }
Example #2
0
        public void Clear()
        {
            if (LivelyWorld.CanWeUse(HunterPed))
            {
                HunterPed.RelationshipGroup = Game.GenerateHash("CIVMALE");

                if (HunterPed.CurrentBlip.Exists())
                {
                    HunterPed.CurrentBlip.Color = BlipColor.White;
                }
                Function.Call(Hash.RESET_PED_MOVEMENT_CLIPSET, HunterPed, 0.0f);
                Function.Call(Hash.RESET_PED_STRAFE_CLIPSET, HunterPed);
                HunterPed.IsPersistent = false;

                if (LivelyWorld.CanWeUse(HunterCar))
                {
                    LivelyWorld.TemporalPersistence.Add(HunterCar);
                    TaskSequence seq = new TaskSequence();
                    Function.Call(Hash.TASK_PAUSE, 0, LivelyWorld.RandomInt(2, 4) * 1000);

                    Function.Call(Hash.TASK_ENTER_VEHICLE, 0, HunterCar, 20000, -1, 1f, 1, 0);
                    Function.Call(Hash.TASK_PAUSE, 0, LivelyWorld.RandomInt(2, 4) * 1000);
                    Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, 0, HunterCar, 30f, 1 + 2 + 4 + 8 + 16 + 32);
                    seq.Close();
                    HunterPed.Task.PerformSequence(seq);
                    seq.Dispose();
                    HunterCar.IsPersistent = false;
                }
            }
            if (LivelyWorld.CanWeUse(HunterDog))
            {
                HunterDog.IsPersistent = false;
            }
        }
Example #3
0
 public void Clear()
 {
     if (LivelyWorld.CanWeUse(Dealer))
     {
         if (Dealer.CurrentBlip.Exists())
         {
             Dealer.CurrentBlip.Color = BlipColor.White;
         }
         Dealer.IsPersistent = false;
     }
     if (LivelyWorld.CanWeUse(Buyer))
     {
         Buyer.IsPersistent = false;
     }
     foreach (Ped ped in Goons)
     {
         if (LivelyWorld.CanWeUse(ped))
         {
             ped.IsPersistent = false;
         }
     }
     if (LivelyWorld.CanWeUse(car))
     {
         car.IsPersistent = false;
     }
 }
Example #4
0
        public bool Process()
        {
            if (VehiclesReplaced > 2)
            {
                if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
                {
                    UI.Notify("~o~" + TargetVehicle + " replacement entered cooldown");
                }
                Cooldown         = Game.GameTime + 60000;
                VehiclesReplaced = 0;
                return(false);
            }
            if (Cooldown < Game.GameTime)
            {
                //if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify(SourceVehicle + " - " + TargetVehicle + " - " + AreaOrZone + " - " + Time + " turn");
                Vector3 PlayerPos = Game.Player.Character.Position;

                //UI.Notify(World.GetZoneName(PlayerPos).ToLowerInvariant()+"-" + AreaOrZone);
                if (AreaOrZone == "all" || LivelyWorld.IsInNamedArea(Game.Player.Character, AreaOrZone))
                {
                    //if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify(SourceVehicle + " - "+AreaOrZone);

                    if (Time == "all" || (LivelyWorld.IsNightTime() && Time == "night") || (!LivelyWorld.IsNightTime() && Time == "day"))
                    {
                        //if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("~g~ correct timeframe");


                        //if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("~g~" + TargetVehicle + " - getting all vehicles");

                        foreach (Vehicle v in LivelyWorld.AllVehicles)
                        {//
                            if (LivelyWorld.CanWeUse(v) && !v.IsPersistent && (!v.IsOnScreen || !LivelyWorld.WouldPlayerNoticeChangesHere(v.Position)) && !LivelyWorld.BlacklistedVehicles.Contains(v) && !Game.Player.Character.IsInRangeOf(v.Position, 10f) && !LivelyWorld.LastDriverIsPed(v, Game.Player.Character))
                            {
                                //if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("Got a "+v.FriendlyName);
                                if (v.ClassType == (VehicleClass)Function.Call <int>(Hash.GET_VEHICLE_CLASS_FROM_NAME, Game.GenerateHash(TargetVehicle)) && (SourceVehicle == "all" || v.Model == Game.GenerateHash(SourceVehicle) || v.FriendlyName.ToString().ToLowerInvariant() == SourceVehicle.ToLowerInvariant()))
                                {
                                    if (LivelyWorld.DebugOutput)
                                    {
                                        File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - replacing " + SourceVehicle + " with a " + TargetVehicle + "");
                                    }
                                    if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
                                    {
                                        UI.Notify("~g~" + SourceVehicle + " replaced with " + TargetVehicle);
                                    }
                                    LivelyWorld.ReplaceVehicle(v, TargetVehicle, ShouldBeTuned);
                                    VehiclesReplaced++;
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            else if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
            {
                UI.Notify("~o~" + SourceVehicle + " - " + TargetVehicle + " - " + AreaOrZone + " - " + Time + " is on cooldown");
            }
            return(false);
        }
 public void Clear()
 {
     if (LivelyWorld.CanWeUse(veh))
     {
         veh.IsPersistent = false;
     }
     if (LivelyWorld.CanWeUse(ped))
     {
         ped.IsPersistent = false;
     }
 }
Example #6
0
 public void HelpHunter()
 {
     TimesTold++;
     if (TimesTold < 5)
     {
         Vector3 pos = World.GetSafeCoordForPed(Game.Player.Character.Position + (Game.Player.Character.ForwardVector * 40), false);
         HunterPed.Task.RunTo(pos);
     }
     else
     {
         TimesTold = 0;
         LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~You're not very good as a Spotter.");
     }
 }
        public void AmbientDrive()
        {
            //if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("Tasked " + veh.FriendlyName + " to drive, speed " + veh.Speed);
            if (!LivelyWorld.CanWeUse(ped) || ped.IsInCombat)
            {
                return;
            }
            if (veh.Model.IsHelicopter || veh.Model.Hash == Game.GenerateHash("osprey"))
            {
                Vector3 pos = veh.Position + (veh.ForwardVector * 5000) + (veh.RightVector * LivelyWorld.RandomInt(-50, 50));

                float speed = 20f;
                if (veh.Model.Hash == Game.GenerateHash("osprey"))
                {
                    speed = 40f;
                }

                Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, ped.Handle, veh.Handle, pos.X, pos.Y, pos.Z, speed, 0, veh.Model, 6, 60, 10.0);

                //veh.SetHeliYawPitchRollMult(0.2f);
            }
            else if (veh.Model.IsPlane)
            {
                Vector3 pos = LivelyWorld.LerpByDistance(veh.Position, Game.Player.Character.Position, 5000);//veh.Position + (veh.ForwardVector * 300);

                Function.Call(Hash.TASK_PLANE_MISSION, ped, veh, 0, 0, pos.X, pos.Y, pos.Z, 4, 100f, 0f, 90f, 0, 200f);
            }
            else if (veh.Model.IsBoat)
            {
                //Function.Call(Hash.TASK_HELI_MISSION, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, 0, 0, safepos.X, safepos.Y, safepos.Z, 20, 40f, 1f, 36f, 15, 15, -1f, 1);
                Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, ped, veh, 10f, 1 + 2 + 8 + 16 + 32 + 128 + 256);
            }
            else
            {
                int   drivingstyle = 1 + 2 + 8 + 16 + 32 + 128 + 256;
                float speed        = 20f;
                if (veh.HasSiren && LivelyWorld.CurrentlyAllowedEvents.Contains(EventType.EmergencyRushing) && !LivelyWorld.BobCatSecurity.Contains(veh.Model) && veh.Model != "coroner")
                {
                    drivingstyle    = 4 + 8 + 16 + 32;
                    speed           = 25f;
                    veh.SirenActive = true;
                }
                else if (Terrain == TerrainType.Offroad && LivelyWorld.RandomInt(0, 10) <= 5)
                {
                    drivingstyle = 4 + 8 + 16 + 32 + 128;
                    speed        = 40f;
                }
                Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, ped, veh, speed, drivingstyle);
            }
        }
Example #8
0
        //public Ped target=null;
        public Hunter(Vector3 place)
        {
            Function.Call(Hash.REQUEST_MISSION_AUDIO_BANK, "SCRIPT\\HUNTING_2_ELK_CALLS", 0, -1);

            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Called for Hunter Event");
            }

            /*
             * if( place == Vector3.Zero)
             * {
             *  for (int i = 0; i < 50; i++)
             *  {
             *      if (place == Vector3.Zero)
             *      {
             *          place = LivelyWorld.GenerateSpawnPos(fix, LivelyWorld.Nodetype.Offroad, false);// World.GetSafeCoordForPed(Game.Player.Character.Position.Around(100), false);
             *      }
             *  }
             * }*/



            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Found suitable place, spawning Hunter");
            }
            HunterPed = World.CreatePed(PedHash.Hunter, place);
            Vector3 pos = HunterPed.Position;


            if (LivelyWorld.DebugBlips)
            {
                HunterPed.AddBlip();
                HunterPed.CurrentBlip.Sprite       = BlipSprite.Hunting;
                HunterPed.CurrentBlip.Color        = BlipColor.Yellow;
                HunterPed.CurrentBlip.IsShortRange = true;
                HunterPed.CurrentBlip.Name         = "Hunter";
            }
            HunterPed.AlwaysKeepTask = true;
            HunterPed.Accuracy       = 100;
            //if(Game.Player.Character.Position.DistanceTo(place)>50F) DespawnRange = Game.Player.Character.Position.DistanceTo(place)*1.5f;
            //HunterPed.FiringPattern = FiringPattern.SingleShot;
            HunterPed.Weapons.Give(WeaponHash.SniperRifle, 999, true, true);
            HunterPed.Weapons.Current.SetComponent(WeaponComponent.AtArSupp02, true);

            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Set up");
            }
            World.SetRelationshipBetweenGroups(Relationship.Respect, HunterRLGroup, Game.GenerateHash("CIVMALE"));
            World.SetRelationshipBetweenGroups(Relationship.Respect, Game.GenerateHash("CIVMALE"), HunterRLGroup);

            World.SetRelationshipBetweenGroups(Relationship.Respect, Game.GenerateHash("CIVFEMALE"), HunterRLGroup);
            World.SetRelationshipBetweenGroups(Relationship.Respect, HunterRLGroup, Game.GenerateHash("CIVFEMALE"));

            World.SetRelationshipBetweenGroups(Relationship.Respect, Game.GenerateHash("COP"), HunterRLGroup);
            World.SetRelationshipBetweenGroups(Relationship.Respect, HunterRLGroup, Game.GenerateHash("COP"));


            World.SetRelationshipBetweenGroups(Relationship.Hate, HunterRLGroup, Game.GenerateHash("WILD_ANIMAL"));
            //World.SetRelationshipBetweenGroups(Relationship.Hate, Game.GenerateHash("WILD_ANIMAL"), HunterRLGroup);
            //World.SetRelationshipBetweenGroups(Relationship.Hate, Game.GenerateHash("DEER"), HunterRLGroup);
            World.SetRelationshipBetweenGroups(Relationship.Hate, HunterRLGroup, Game.GenerateHash("DEER"));
            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - animal relationships set");
            }
            //World.SetRelationshipBetweenGroups(Relationship.Hate, HunterRLGroup, Game.GenerateHash("PLAYER"));
            //World.SetRelationshipBetweenGroups(Relationship.Hate, Game.GenerateHash("PLAYER"), HunterRLGroup);

            //Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, HunterPed, 1,0);
            //Function.Call(Hash.SET_PED_TARGET_LOSS_RESPONSE, HunterPed, 3);

            if (LivelyWorld.RandomInt(0, 10) <= 5)
            {
                HunterCar = World.CreateVehicle(LivelyWorld.HuntingTrucks[LivelyWorld.RandomInt(0, LivelyWorld.HuntingTrucks.Count - 1)], HunterPed.Position + (HunterPed.ForwardVector * -8)); //World.GetNextPositionOnStreet(HunterPed.Position)
                //LivelyWorld.MoveEntitytoNearestRoad(HunterCar,false,true);
                HunterCar.Position = HunterCar.Position + (HunterCar.RightVector * 3);


                if (LivelyWorld.DebugBlips)
                {
                    HunterCar.AddBlip();
                    HunterCar.CurrentBlip.Sprite       = BlipSprite.PersonalVehicleCar;
                    HunterCar.CurrentBlip.Color        = BlipColor.Yellow;
                    HunterCar.CurrentBlip.IsShortRange = true;
                    HunterCar.CurrentBlip.Name         = "Hunter's car";
                }
            }
            else
            {
                HunterDog = World.CreatePed(PedHash.Retriever, HunterPed.Position.Around(0));
                HunterDog.RelationshipGroup    = HunterRLGroup;
                HunterDog.AlwaysKeepTask       = true;
                HunterDog.BlockPermanentEvents = true;
            }



            HunterPed.RelationshipGroup = HunterRLGroup;
            int patience = 0;

            while (patience < 500 && (!Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, "move_ped_crouched") || !Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, "move_ped_crouched_strafing")))
            {
                patience++;
                Function.Call(Hash.REQUEST_ANIM_SET, "move_ped_crouched");
                Function.Call(Hash.REQUEST_ANIM_SET, "move_ped_crouched_strafing");
            }
            Script.Wait(300);
            Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, HunterPed, "move_ped_crouched", 1048576000);
            Function.Call(Hash.SET_PED_STRAFE_CLIPSET, HunterPed, "move_ped_crouched_strafing");

            Function.Call(Hash.SET_PED_SEEING_RANGE, HunterPed, 150f);
            Function.Call(Hash.SET_PED_VISUAL_FIELD_MIN_ELEVATION_ANGLE, HunterPed, -40f);
            Function.Call(Hash.SET_PED_VISUAL_FIELD_MAX_ELEVATION_ANGLE, HunterPed, 5f);
            Function.Call(Hash.SET_PED_SHOOT_RATE, HunterPed, 50);
            Function.Call(Hash.SET_PED_COMBAT_MOVEMENT, HunterPed, 0);
            Function.Call(Hash.SET_PED_TARGET_LOSS_RESPONSE, HunterPed, 0);

            Function.Call(Hash.TASK_WANDER_IN_AREA, HunterPed, pos.X, pos.Y, pos.Z, 100f, 2f, 3f);
            //Function.Call(Hash.TASK_WANDER_STANDARD, HunterPed, 20f,0);
            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - spawn finished");
            }
        }
Example #9
0
        public void Process()
        {
            if ((!Game.Player.Character.IsInRangeOf(HunterPed.Position, DespawnRange) || !HunterPed.IsAlive) && !Finished)
            {
                Finished = true;
            }
            if (LivelyWorld.CanWeUse(HunterDog) && !HunterDog.IsInRangeOf(HunterPed.Position, 5f) && HunterDog.IsStopped)
            {
                Function.Call(Hash.TASK_GO_TO_ENTITY, HunterDog, HunterPed, -1, 2f, 1f, 0f, 0);
            }

            if (!Notified && Game.Player.Character.IsStopped && Game.Player.Character.IsInRangeOf(HunterPed.Position, 8f))
            {
                Notified = true;
                LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: Hey man wandering alone in the woods, why don't you give me a hand here. If you spot any animal, tell me, ok?");
                LivelyWorld.AddQueuedHelpText("If you spot prey, press ~INPUT_CONTEXT~ to tell the ~b~Hunter~w~.");
                World.SetRelationshipBetweenGroups(Relationship.Like, HunterRLGroup, Game.GenerateHash("PLAYER"));
                World.SetRelationshipBetweenGroups(Relationship.Like, Game.GenerateHash("PLAYER"), HunterRLGroup);
            }
            if (!HunterPed.IsInCombat && HunterPed.IsStopped)
            {
                patience++;
                if (!PlayedCall && LivelyWorld.RandomInt(0, 10) <= 5)
                {
                    Function.Call(Hash.PLAY_SOUND_FROM_ENTITY, -1, "PLAYER_CALLS_ELK_MASTER", HunterPed, 0, 0, 0);
                    PlayedCall = true;
                }
            }
            else if (PlayedCall)
            {
                PlayedCall = false;
            }
            if (HunterPed.IsInCombat)
            {
                foreach (Ped ped in World.GetAllPeds())
                {
                    if (ped.HeightAboveGround < 3f && !ped.IsHuman && !ped.IsAlive && HunterPed.IsInCombatAgainst(ped))
                    {
                        Function.Call(Hash._0x0DC7CABAB1E9B67E, ped, true); //Load Collision

                        //target = ped;
                        TaskSequence seq = new TaskSequence();

                        //Function.Call(Hash._PLAY_AMBIENT_SPEECH1, 0, "KILLED_ALL", "SPEECH_PARAMS_FORCE");
                        Function.Call(Hash.TASK_GO_TO_ENTITY, 0, ped, -1, 1f, 3f, 0f, 0);
                        Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, 0, false);

                        seq.Close();
                        HunterPed.Task.PerformSequence(seq);
                        seq.Dispose();
                        if (TimesTold > 0)
                        {
                            LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: Thanks, man.~n~~g~$10~w~ for your help.");
                            Game.Player.Money += 10;
                            TimesTold          = 0;
                        }
                        break;
                    }
                }
            }
            else
            {
                if (patience > 5)
                {
                    //HunterPed.RelationshipGroup = HunterRLGroup;
                    foreach (Ped ped in World.GetNearbyPeds(HunterPed, 5f))
                    {
                        if (ped.IsDead)
                        {
                            if (Game.Player.Character.IsInRangeOf(HunterPed.Position, 20f))
                            {
                                Kills++;

                                LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: That's one for the pot!");
                                if (Kills > 4 && LivelyWorld.CanWeUse(HunterCar))
                                {
                                    LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~:That's enough for today."); Finished = true;
                                }
                                else if (Kills > 1)
                                {
                                    LivelyWorld.AddQueuedConversation("~b~[Hunter]~w~: " + Kills + " already!");
                                }
                            }
                            if (LivelyWorld.CanWeUse(HunterCar))
                            {
                                Function.Call(GTA.Native.Hash.SET_ENTITY_LOAD_COLLISION_FLAG, ped, true); //Load Collision

                                Function.Call(Hash.SET_ENTITY_RECORDS_COLLISIONS, ped, true);             //Load Collision

                                ped.IsPersistent = true;
                                LivelyWorld.TemporalPersistence.Add(ped);
                                ped.Position = HunterCar.Position + (HunterCar.ForwardVector * -2) + (HunterCar.UpVector * 2);
                                Function.Call(Hash.SET_PED_TO_RAGDOLL, ped, 2000, 2000, 3, true, true, false);
                                Function.Call(Hash.CREATE_NM_MESSAGE, 1151);
                                Function.Call(Hash.GIVE_PED_NM_MESSAGE, ped, true);
                            }
                            else
                            {
                                ped.Delete();
                            }
                            break;
                        }
                    }
                    HunterPed.BlockPermanentEvents = false;
                    Vector3 pos = HunterPed.Position;
                    Function.Call(Hash.TASK_WANDER_IN_AREA, HunterPed, pos.X, pos.Y, pos.Z, 100f, 2f, 3f);
                    patience  = 0;
                    TimesTold = 0;
                }
            }
        }
Example #10
0
        public void Process()
        {
            if (hitch.IsInCombat)
            {
                Finished = true;
                return;
            }
            if (LivelyWorld.CanWeUse(Taxi) && LivelyWorld.CanWeUse(hitch) && LivelyWorld.CanWeUse(Driver) && Taxi.IsInRangeOf(Game.Player.Character.Position, Range))
            {
                if (DropOff)
                {
                    if (Status == 0)
                    {
                        Status++;
                        Vector3 pos = World.GetSafeCoordForPed(Taxi.Position + (Taxi.ForwardVector * 50f));

                        Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 10f, 1, Taxi.Model, 1 + 2 + 8 + 16 + 32 + 128 + 256, 5.0, 30.0);
                    }
                    else
                    {
                        if (Taxi.IsStopped)
                        {
                            hitch.Task.LeaveVehicle();
                            Finished = true;
                        }
                    }
                }
                else
                {
                    switch (Status)
                    {
                    case 0:
                    {
                        if (Taxi.IsInRangeOf(hitch.Position, 20f))
                        {
                            Status++;
                            Vector3 pos = Taxi.Position + (Taxi.ForwardVector * 10f) + (Taxi.RightVector * 2);
                            Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 3f, 1, Taxi.Model, 4 + 8 + 16 + 32, 3.0, 50.0);
                        }
                        else if (Taxi.IsStopped)
                        {
                            Vector3 pos = hitch.Position;
                            Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 10f, 1, Taxi.Model, 1 + 2 + 8 + 16 + 32 + 128 + 256, 15.0, 1.0);
                            //Driver.Task.DriveTo(Taxi, hitch.Position, 10f, 10f, 1 + 2  + 16 + 32+ 128 + 256);
                        }
                        break;
                    }

                    case 1:
                    {
                        if (hitch.IsInVehicle(Taxi))
                        {
                            Status++;
                            Range = 50;
                        }
                        else if (!hitch.IsGettingIntoAVehicle)
                        {
                            hitch.Task.EnterVehicle(Taxi, VehicleSeat.RightRear, -1, 1f);
                        }
                        break;
                    }

                    case 2:
                    {
                        if (Taxi.IsStopped)
                        {
                            Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, Driver, Taxi, 20f, 1 + 2 + 4 + 8 + 16 + 32 + 128 + 256);
                        }
                        break;
                    }
                    }
                }
            }
            else if (!Finished)
            {
                Finished = true;
            }
        }
        public bool Process()
        {
            ExistingVehicles = 0;
            foreach (Vehicle v in LivelyWorld.AllVehicles)
            {
                if (v.Model == SourceVehicle)
                {
                    ExistingVehicles++;
                }
            }

            if (ExistingVehicles > 4)
            {
                if (LivelyWorld.DebugOutput)
                {
                    File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Too many vehicles of " + SourceVehicle + " already exist, spawn attempt aborted");
                }
                return(false);
            }
            if (Terrain == TerrainType.Water && !LivelyWorld.IsPlayerNearWater(200f))
            {
                return(false);
            }
            if (!LivelyWorld.CanWeUse(veh))
            {
                if (Cooldown < Game.GameTime)
                {
                    Vector3 PlayerPos = Game.Player.Character.Position;
                    if (AreaOrZone == "all" || LivelyWorld.IsInNamedArea(Game.Player.Character, AreaOrZone))
                    {
                        if (Time == "all" || (LivelyWorld.IsNightTime() && Time == "night") || (!LivelyWorld.IsNightTime() && Time == "day"))
                        {
                            if (LivelyWorld.RandomInt(0, 100) > Prob)
                            {
                                Cooldown = Game.GameTime + CooldownTime;
                                if (LivelyWorld.DebugOutput)
                                {
                                    File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Probability check for " + SourceVehicle + " too low, resetting cooldown without spawning.");
                                }
                                return(false);
                            }
                            else
                            {
                                if (LivelyWorld.DebugOutput)
                                {
                                    File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Spawning a " + SourceVehicle + "");
                                }
                            }

                            Vector3 spawnpos = Vector3.Zero;
                            int     patience = 0;
                            if (patience < 3) //  while (Game.GameTime > patience+3000 && (spawnpos==Vector3.Zero || LivelyWorld.WouldPlayerNoticeChangesHere(spawnpos))) //WOULD_ENTITY_BE_OCCLUDED(Hash entityModelHash, float x, float y, float z, BOOL p4)
                            {
                                patience++;
                                switch (Terrain)
                                {
                                case TerrainType.Road:
                                {
                                    int p = 1;

                                    spawnpos = Vector3.Zero;

                                    while (p < 50 && (spawnpos == Vector3.Zero || LivelyWorld.WouldPlayerNoticeChangesHere(spawnpos)))
                                    {
                                        p++;
                                        spawnpos = LivelyWorld.GenerateSpawnPos(Game.Player.Character.Position.Around(100 + (p * 10)), LivelyWorld.Nodetype.Road, false);
                                        Script.Yield();
                                    }
                                    break;
                                }

                                case TerrainType.Offroad:
                                {
                                    int p = 1;

                                    while (p < 50 && (spawnpos == Vector3.Zero || LivelyWorld.WouldPlayerNoticeChangesHere(spawnpos)))
                                    {
                                        p++;
                                        spawnpos = LivelyWorld.GenerateSpawnPos(Game.Player.Character.Position.Around(100 + (p * 10)), LivelyWorld.Nodetype.Offroad, false);
                                        Script.Yield();
                                    }
                                    break;
                                }

                                case TerrainType.Air:
                                {
                                    int traffic = 0;
                                    foreach (Vehicle v in LivelyWorld.AllVehicles)
                                    {
                                        if (v.HeightAboveGround > 20 && (v.Model.IsHelicopter || v.Model.IsPlane))
                                        {
                                            traffic++;
                                        }
                                    }
                                    if (traffic > 10)
                                    {
                                        if (LivelyWorld.DebugOutput)
                                        {
                                            File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - too much air traffic (>5) to spawn more.");
                                        }
                                        return(false);
                                    }
                                    if (new Model(SourceVehicle).IsHelicopter)
                                    {
                                        spawnpos = Game.Player.Character.Position.Around(LivelyWorld.RandomInt(300, 600));
                                    }
                                    else
                                    {
                                        spawnpos = Game.Player.Character.Position.Around(LivelyWorld.RandomInt(500, 800));
                                    }
                                    spawnpos = spawnpos + new Vector3(0, 0, LivelyWorld.RandomInt(50, 100));
                                    break;
                                }

                                case TerrainType.Water:
                                {
                                    int traffic = 0;
                                    foreach (Vehicle v in LivelyWorld.AllVehicles)
                                    {
                                        if (v.Model.IsBoat)
                                        {
                                            traffic++;
                                        }
                                    }
                                    if (traffic > 10)
                                    {
                                        if (LivelyWorld.DebugOutput)
                                        {
                                            File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - too much boat traffic (> 5) to spawn more.");
                                        }
                                        return(false);
                                    }
                                    if (World.GetZoneNameLabel(Game.Player.Character.Position) == "OCEANA")
                                    {
                                        foreach (Vector3 v in LivelyWorld.OceanSpawns)
                                        {
                                            if (Game.Player.Character.IsInRangeOf(v, despawnRange - 100f) && !LivelyWorld.AnyVehicleNear(v, 100f) && !LivelyWorld.WouldPlayerNoticeChangesHere(v))
                                            {
                                                spawnpos = v;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        spawnpos = LivelyWorld.GenerateSpawnPos(Game.Player.Character.Position.Around(200), LivelyWorld.Nodetype.Water, false);
                                    }
                                    break;
                                }
                                }
                            }

                            if (spawnpos == Vector3.Zero)
                            {
                                if (LivelyWorld.DebugOutput)
                                {
                                    File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - adequate spawn position not found, aborting traffic spawn.");
                                }
                                return(false);
                            }

                            float angle = LivelyWorld.AngleBetweenVectors(Game.Player.Character.Position, spawnpos);
                            if (Terrain != TerrainType.Road)
                            {
                                angle = +LivelyWorld.RandomInt(-90, 90);
                            }
                            veh = World.CreateVehicle(SourceVehicle, spawnpos, angle);
                            if (LivelyWorld.CanWeUse(veh))
                            {
                                veh.Position = veh.Position + (veh.RightVector * 2); //Make sure it spawns on the right side of the road, not the left (oncoming)
                                string model = null;
                                if (model == null || new Model(model).IsValid == false)
                                {
                                    ped = veh.CreateRandomPedOnSeat(VehicleSeat.Driver);
                                }
                                else
                                {
                                    ped = World.CreatePed(model, veh.Position.Around(5));
                                    ped.SetIntoVehicle(veh, VehicleSeat.Driver);
                                }

                                if (veh.Model.IsHelicopter || veh.Model.Hash == Game.GenerateHash("osprey"))
                                {
                                    veh.Position = veh.Position + new Vector3(0, 0, LivelyWorld.RandomInt(50, 100));

                                    foreach (Vector3 takeoff in LivelyWorld.AmbientHeliLanding)
                                    {
                                        if (Game.Player.Character.IsInRangeOf(takeoff, 1000f))
                                        {
                                            veh.Position = takeoff;
                                            break;
                                        }
                                    }
                                    Function.Call(Hash.SET_HELI_BLADES_FULL_SPEED, veh);
                                    Function.Call(Hash.SET_VEHICLE_FORWARD_SPEED, veh, 30f);
                                    veh.LandingGear = VehicleLandingGear.Retracted;
                                }
                                else if (veh.Model.IsPlane)
                                {
                                    veh.Position = LivelyWorld.LerpByDistance(Game.Player.Character.Position, veh.Position, 500);
                                    if (veh.Model.GetDimensions().Y > 20f)
                                    {
                                        veh.Position = veh.Position + new Vector3(0, 0, 200);
                                    }
                                    if (veh.Model.GetDimensions().Y > 40f)
                                    {
                                        veh.Position = veh.Position + new Vector3(0, 0, 200);
                                        despawnRange = 2000f;
                                    }
                                    veh.LandingGear = VehicleLandingGear.Retracted;

                                    Function.Call(Hash.SET_VEHICLE_FORWARD_SPEED, veh, 30f);
                                }
                                else if (!veh.Model.IsBoat)
                                {
                                    LivelyWorld.MoveEntitytoNearestRoad(veh, true, true);
                                }



                                if (LivelyWorld.DebugBlips)
                                {
                                    veh.AddBlip();

                                    if (veh.Model.IsPlane)
                                    {
                                        veh.CurrentBlip.Sprite = BlipSprite.Plane;
                                    }
                                    if (veh.Model.IsBike)
                                    {
                                        veh.CurrentBlip.Sprite = BlipSprite.PersonalVehicleBike;
                                    }
                                    if (veh.Model.IsBoat)
                                    {
                                        veh.CurrentBlip.Sprite = BlipSprite.Boat;
                                    }
                                    if (veh.Model.IsCar)
                                    {
                                        veh.CurrentBlip.Sprite = BlipSprite.PersonalVehicleCar;
                                    }
                                    if (veh.Model.IsHelicopter)
                                    {
                                        veh.CurrentBlip.Sprite = BlipSprite.Helicopter;
                                    }

                                    veh.CurrentBlip.Color        = BlipColor.White;
                                    veh.CurrentBlip.IsShortRange = true;
                                    veh.CurrentBlip.Name         = veh.FriendlyName;
                                }
                                AmbientDrive();
                                veh.Alpha        = 0;
                                veh.Driver.Alpha = 0;
                                LivelyWorld.FadeIn.Add(veh);
                                LivelyWorld.FadeIn.Add(veh.Driver);
                                if (LivelyWorld.CarrierVehicles.Contains(veh.Model))
                                {
                                    Model   vehicle = LivelyWorld.RandomNormalVehicle();
                                    Vehicle cargo   = World.CreateVehicle(vehicle, veh.Position + (veh.UpVector * 5f));

                                    if (LivelyWorld.CanWeUse(cargo))
                                    {
                                        LivelyWorld.Attach(veh, cargo);
                                    }
                                    LivelyWorld.TemporalPersistence.Add(cargo);
                                }
                                if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
                                {
                                    UI.Notify("~o~" + SourceVehicle + " spawned (and entered cooldown)");                                                    // if(LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
                                }
                                if (!veh.SirenActive)
                                {
                                    veh.Driver.IsPersistent = false;
                                    veh.IsPersistent        = false;
                                }
                            }
                            else
                            {
                                return(false);
                            }

                            return(true);
                        }
                    }
                }
                //else if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("~o~Spawner - " + SourceVehicle + " - " + AreaOrZone + " - " + Time + " is on cooldown");
            }
            else if (LivelyWorld.CanWeUse(veh))
            {
                if (!veh.IsInRangeOf(Game.Player.Character.Position, despawnRange) && !LivelyWorld.WouldPlayerNoticeChangesHere(veh.Position))
                {
                    if (veh.CurrentBlip.Exists())
                    {
                        veh.CurrentBlip.Color = BlipColor.White;
                    }
                    veh.MarkAsNoLongerNeeded();
                    veh = null;
                    if (LivelyWorld.CanWeUse(ped))
                    {
                        ped.MarkAsNoLongerNeeded();
                        ped = null;
                    }
                    if (Cooldown < Game.GameTime)
                    {
                        Cooldown = Game.GameTime + CooldownTime;
                    }
                }
                else
                {
                    if (veh.Speed < 3f && LivelyWorld.CanWeUse(ped))
                    {
                        //  AmbientDrive();
                    }
                }
                if (Cooldown < Game.GameTime)
                {
                    Cooldown = Game.GameTime + 40000;
                }
            }
            return(false);
        }
Example #12
0
        public DrugDeal(Vector3 place, bool gangs)
        {
            if (LivelyWorld.DebugOutput)
            {
                File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Called for DrugDeal Event");
            }
            center = place;

            TimeAlive = Game.GameTime + 60000;
            //Distance = place.DistanceTo(Game.Player.Character.Position);
            GangDeal = gangs;
            if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
            {
                UI.Notify("~b~Deal spawned");
            }
            //LivelyWorld.BlacklistedImportantEvents.Add(EventType.Deal);
            Vector3 carpos = World.GetSafeCoordForPed(center, false);

            float          Heading = LivelyWorld.AngleBetweenVectors(place, carpos);
            OutputArgument outArgA = new OutputArgument();
            OutputArgument outArgB = new OutputArgument();

            if (Function.Call <bool>(Hash.GET_CLOSEST_VEHICLE_NODE_WITH_HEADING, place.X, place.Y, place.Z, outArgA, outArgB, 0, 1077936128, 0))
            {
                Heading = outArgB.GetResult <float>();
            }
            if (gangs)
            {
                car = World.CreateVehicle("gburrito", carpos, Heading + LivelyWorld.RandomInt(-20, 20));// LivelyWorld.AngleBetweenVectors(place, carpos));
                if (!LivelyWorld.CanWeUse(car))
                {
                    Finished = true;
                    return;
                }
                if (!LivelyWorld.CarCanSeePos(car, car.Position + (car.ForwardVector * -10), 0))
                {
                    car.Position = car.Position + (car.ForwardVector * 3);
                }

                //Dealer
                Ped newped = World.CreatePed("G_M_Y_Lost_01", car.Position + (car.ForwardVector * -4));
                if (!LivelyWorld.CanWeUse(newped))
                {
                    Finished = true;
                    return;
                }
                newped.RelationshipGroup = LivelyWorld.NeutralRLGroup;
                newped.Weapons.Give(WeaponHash.Pistol, 30, false, true);

                newped.AlwaysKeepTask = true;
                Function.Call(Hash.TASK_START_SCENARIO_IN_PLACE, newped, "WORLD_HUMAN_STAND_IMPATIENT", 1000, true);
                newped.Heading = car.Heading + 180f;//LivelyWorld.AngleBetweenVectors(carpos, place);
                Dealer         = newped;


                //Goons
                newped = World.CreatePed("G_M_Y_Lost_01", car.Position + (car.ForwardVector * -3) + (car.RightVector * -2));
                if (!LivelyWorld.CanWeUse(newped))
                {
                    Finished = true;
                    return;
                }
                newped.RelationshipGroup = LivelyWorld.NeutralRLGroup;
                newped.Weapons.Give(WeaponHash.AssaultRifle, 30, true, true);
                newped.AlwaysKeepTask = true;
                newped.Heading        = LivelyWorld.AngleBetweenVectors(carpos, place);

                //Function.Call(Hash.TASK_START_SCENARIO_IN_PLACE, newped, "PROP_HUMAN_STAND_IMPATIENT", 5000, true);
                Goons.Add(newped);

                newped = World.CreatePed("G_M_Y_Lost_01", car.Position + (car.ForwardVector * -3) + (car.RightVector * 2));
                if (!LivelyWorld.CanWeUse(newped))
                {
                    Finished = true;
                    return;
                }
                newped.RelationshipGroup = LivelyWorld.NeutralRLGroup;
                newped.Weapons.Give(WeaponHash.AssaultRifle, 30, true, true);
                newped.AlwaysKeepTask = true;
                newped.Heading        = LivelyWorld.AngleBetweenVectors(carpos, place);
                //Function.Call(Hash.TASK_START_SCENARIO_IN_PLACE, newped, "WORLD_HUMAN_SMOKING", 5000, true);
                Goons.Add(newped);


                //Buyer
                newped = null;
                newped = World.CreateRandomPed(car.Position + (car.ForwardVector * -7));
                if (!LivelyWorld.CanWeUse(newped))
                {
                    Finished = true;
                    return;
                }
                newped.RelationshipGroup = LivelyWorld.NeutralRLGroup;
                //newped.SetConfigFlag(17, true);
                newped.AlwaysKeepTask = true;

                Function.Call(Hash.TASK_START_SCENARIO_IN_PLACE, newped, "CODE_HUMAN_CROSS_ROAD_WAIT", 1000, true);
                newped.Heading = car.Heading;//LivelyWorld.AngleBetweenVectors(place, carpos);

                car.OpenDoor(VehicleDoor.Trunk, false, false);
                Buyer = newped;
                //PedsInvolved.Add(newped);
            }
            else
            {
                center = place;

                Model model = LivelyWorld.DrugCars[LivelyWorld.RandomInt(0, LivelyWorld.DrugCars.Count - 1)];
                while (!model.IsVehicle)
                {
                    model = LivelyWorld.DrugCars[LivelyWorld.RandomInt(0, LivelyWorld.DrugCars.Count - 1)];
                }

                car = World.CreateVehicle(model, carpos, LivelyWorld.AngleBetweenVectors(place, carpos));
                if (!LivelyWorld.CanWeUse(car))
                {
                    Finished = true;
                    return;
                }
                if (!LivelyWorld.CarCanSeePos(car, car.Position + (car.ForwardVector * -10), 0))
                {
                    car.Position = car.Position + (car.ForwardVector * 3);
                }

                Ped newped = World.CreatePed("s_m_y_dealer_01", car.Position + (car.ForwardVector * -4));
                if (!LivelyWorld.CanWeUse(newped))
                {
                    Finished = true;
                    return;
                }
                newped.RelationshipGroup = LivelyWorld.NeutralRLGroup;
                newped.Weapons.Give(WeaponHash.Pistol, 30, false, true);
                newped.AlwaysKeepTask = true;
                //newped.Task.StartScenario("WORLD_HUMAN_SMOKING", newped.Position);
                newped.Heading = car.Heading + 180f; //LivelyWorld.AngleBetweenVectors(carpos, place);
                Dealer         = newped;             // PedsInvolved.Add(newped);


                newped = null;
                newped = World.CreateRandomPed(car.Position + (car.ForwardVector * -7));
                if (!LivelyWorld.CanWeUse(newped))
                {
                    Finished = true;
                    return;
                }
                newped.RelationshipGroup = LivelyWorld.NeutralRLGroup;
                //newped.SetConfigFlag(17, true);
                newped.AlwaysKeepTask = true;
                //newped.Task.StartScenario("WORLD_HUMAN_SMOKING", newped.Position);
                newped.Heading = car.Heading;//LivelyWorld.AngleBetweenVectors(place, carpos);
                Buyer          = newped;

                car.OpenDoor(VehicleDoor.Trunk, false, false);
                // PedsInvolved.Add(newped);
            }

            Dealer.RelationshipGroup = DealerRLGroup;
            foreach (Ped ped in Goons)
            {
                ped.RelationshipGroup = DealerRLGroup;
            }

            if (LivelyWorld.DebugBlips)
            {
                Dealer.AddBlip();
                Dealer.CurrentBlip.Scale        = 0.7f;
                Dealer.CurrentBlip.IsShortRange = true;
                Dealer.CurrentBlip.Name         = "Deal";
            }
            if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios)
            {
                UI.Notify("~b~Spawned Deal");
            }
        }
Example #13
0
        public void Process()
        {
            if (!StoleCar && Game.Player.Character.IsInVehicle(car))
            {
                StoleCar = true;

                if (GangDeal)
                {
                    Game.Player.Character.Weapons.Give(WeaponHash.SawnOffShotgun, 50, false, true);
                    Game.Player.Character.Weapons.Give(WeaponHash.AssaultRifle, 250, false, true);
                    Game.Player.Character.Weapons.Give(WeaponHash.Molotov, 8, false, true);

                    LivelyWorld.DisplayHelpTextThisFrame("You found some weapons inside the van.");
                }
                else
                {
                    int money = LivelyWorld.RandomInt(200, 1000);
                    Game.Player.Money += money;

                    LivelyWorld.DisplayHelpTextThisFrame("You found some money in the glove compartment.");
                }
            }

            if (!Ruined)
            {
                if (TimeAlive < Game.GameTime)
                {
                    TaskSequence seq = new TaskSequence();

                    Function.Call(Hash.TASK_ENTER_VEHICLE, 0, car, 20000, -1, 1f, 1, 0);

                    Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, 0, car, 15f, 1 + 2 + 8 + 32 + 128 + 256);
                    seq.Close();
                    Dealer.Task.PerformSequence(seq);
                    seq.Dispose();
                    if (LivelyWorld.CanWeUse(car))
                    {
                        car.CloseDoor(VehicleDoor.Trunk, false);
                    }
                    Finished = true;
                }
                if (LivelyWorld.isCopInRange(Dealer.Position, 40) || LivelyWorld.isCopVehicleRange(Dealer.Position, 40))
                {
                    Dealer.Task.FightAgainst(Game.Player.Character);
                }
                if (Game.Player.Character.IsInRangeOf(Dealer.Position, 40f) && Dealer.IsOnScreen && World.GetRelationshipBetweenGroups(DealerRLGroup, Game.Player.Character.RelationshipGroup) != Relationship.Hate)
                {
                    World.SetRelationshipBetweenGroups(Relationship.Hate, DealerRLGroup, Function.Call <int>(GTA.Native.Hash.GET_HASH_KEY, "PLAYER"));
                    World.SetRelationshipBetweenGroups(Relationship.Hate, Function.Call <int>(GTA.Native.Hash.GET_HASH_KEY, "PLAYER"), DealerRLGroup);
                }
                if (Dealer.IsInCombat)
                {
                    if (!Buyer.IsFleeing)
                    {
                        Buyer.Task.ReactAndFlee(Dealer);
                    }
                    Ruined = true;
                    if (Goons.Count > 0 && LivelyWorld.CanWeUse(car))
                    {
                        TaskSequence seq = new TaskSequence();
                        Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, 0, car, 30f, 4 + 8 + 16 + 32);
                        seq.Close();
                        Dealer.Task.PerformSequence(seq);
                        seq.Dispose();
                    }
                }
                if (!Game.Player.Character.IsInRangeOf(car.Position, Distance * 1.5f) || (!car.IsAlive || StoleCar))
                {
                    Finished = true;
                }
            }
            else if (!Game.Player.Character.IsInRangeOf(car.Position, 100f) || (!car.IsAlive || StoleCar))
            {
                Finished = true;
            }
        }