Esempio n. 1
0
        //Creates a pedestrian, assigns behavior and adds a blip if necessary. Creates a cop if cop=true, criminal if false
        private void SpawnPedestrian(bool cop)
        {
            if (peds.Count >= MaxPeds)
            {
                return;
            }

            int mod = 1;

            if (!cop)
            {
                mod *= -1;
            }

            Ped ped = World.CreatePed(RandomModel(cop), Player.Character.GetOffsetPosition(new Vector3(mod * RandomNumber(spawnRadius / 2, spawnRadius), mod * RandomNumber(spawnRadius / 2, spawnRadius), 0.0f)).ToGround());

            if (Exists(ped) && ped != null)
            {
                ped.BecomeMissionCharacter(); //makes sure the pedestrian persists while player alive

                if (cop)
                {
                    ped.RelationshipGroup = RelationshipGroup.Cop;
                    ped.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Dealer, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Player, Relationship.Respect);

                    ped.MaxHealth = copHealth;
                    ped.Health    = copHealth;
                    ped.Armor     = 50;
                }
                else
                {
                    ped.RelationshipGroup = RelationshipGroup.Criminal;
                    ped.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Civillian_Male, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Civillian_Female, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Fireman, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Bum, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Medic, Relationship.Hate);
                    ped.ChangeRelationship(RelationshipGroup.Player, Relationship.Neutral);

                    ped.MaxHealth      = robberHealth;
                    ped.Health         = robberHealth;
                    ped.Armor          = 0;
                    ped.WantedByPolice = true;
                    ped.StartKillingSpree(true);
                    Blip blip = ped.AttachBlip();
                    blips.Add(ped, blip);
                }

                ped.Task.FightAgainstHatedTargets(fightRadius); //give the pedestrian their task, will repeat

                RandomWeapons(ped, cop);
                peds.Add(ped);
                totalSpawned++;
                Wait(10);
            }
        }
Esempio n. 2
0
        private void AddToGroup(Ped p)
        {
            if (!Exists(p))
            {
                return;                                                    // check if the ped is valid
            }
            p.CurrentRoom                  = Player.Character.CurrentRoom; // required, or ped won't be visible when spawned inside a building
            p.WillDoDrivebys               = true;
            p.PriorityTargetForEnemies     = true;
            p.DuckWhenAimedAtByGroupMember = false;
            p.AlwaysDiesOnLowHealth        = true;
            p.SetPathfinding(true, true, true);

            Weapon weap = Player.Character.Weapons.CurrentType;

            p.Weapons.FromType(weap).Ammo = 30000;
            p.Weapons.MP5.Ammo            = 30000;
            p.Weapons.Select(weap); // activate same weapon as the one the player carries

            p.RelationshipGroup = RelationshipGroup.Player;
            p.ChangeRelationship(RelationshipGroup.Player, Relationship.Companion);
            p.CantBeDamagedByRelationshipGroup(RelationshipGroup.Player, true);

            group.AddMember(p);
            Game.DisplayText(group.MemberCount + " members in gang");
        }
Esempio n. 3
0
        private void AnyTaxiScript_KeyDown(object sender, GTA.KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Keys.N:
                switch (state)
                {
                case eState.Off:
                    SelectedCar = World.GetClosestVehicle(Player.Character.Position, 5.0F);
                    if (!Exists(SelectedCar))
                    {
                        return;
                    }
                    SelectedDriver = SelectedCar.GetPedOnSeat(VehicleSeat.Driver);
                    if (!Exists(SelectedDriver))
                    {
                        SelectedDriver = SelectedCar.CreatePedOnSeat(VehicleSeat.Driver);
                        if (!Exists(SelectedDriver))
                        {
                            SelectedCar = null;
                            return;
                        }
                    }
                    else if (SelectedDriver == Player)
                    {
                        SelectedCar    = null;
                        SelectedDriver = null;
                        return;
                    }

                    // force the game to load all path nodes, or he wouldn't be able to find the way to distant locations
                    Game.LoadAllPathNodes = true;

                    SelectedCar.DoorLock = 0;
                    SelectedCar.MakeProofTo(false, false, false, true, false);  // make the car collision proof, or it will blow up pretty fast

                    // make sure that the driver won't die from his miserable driving skills
                    SelectedDriver.Invincible = true;
                    SelectedDriver.WillFlyThroughWindscreen = false;
                    SelectedDriver.CanBeKnockedOffBike      = false;

                    // make sure that he will focus on his task
                    SelectedDriver.BlockPermanentEvents = true;
                    SelectedDriver.ChangeRelationship(RelationshipGroup.Player, Relationship.Respect);

                    SelectedDriver.Task.ClearAll();
                    SelectedDriver.Task.AlwaysKeepTask = true;
                    SelectedDriver.Task.Wait(-1);  // wait until we clear the tasks again

                    if (Player.Group.MemberCount > 0)
                    {
                        // Group.EnterVehicle will make sure that only members closeby try to enter the vehicle
                        Player.Group.EnterVehicle(SelectedCar, true, true);
                    }
                    else
                    {
                        Player.Character.Task.EnterVehicle(SelectedCar, SelectedCar.GetFreePassengerSeat());
                    }

                    state = eState.WaitingForPlayer;
                    break;

                case eState.WaitingForPlayer:
                    TurnDriverToNormal();
                    state = eState.Off;
                    break;

                case eState.Driving:   // Change Route
                case eState.ReachedTarget:
                    if (SetDestination())
                    {
                        // give the new task to the driver
                        SelectedDriver.BlockPermanentEvents = true;
                        SelectedDriver.Task.ClearAll();
                        SelectedDriver.Task.AlwaysKeepTask = true;
                        SelectedDriver.Task.DriveTo(SelectedCar, Destination, Speed, false);

                        state = eState.Driving;
                    }
                    break;
                }
                break;

            case Keys.M:
                if (state == eState.Driving)  // Accelerate time when M is pressed while driving
                {
                    ChangedTimescale = !ChangedTimescale;
                    if (ChangedTimescale)
                    {
                        Game.TimeScale = 4.0F;
                    }
                    else
                    {
                        Game.TimeScale = 1.0F;
                    }
                }
                break;
            }
        }