Exemple #1
0
            // Called when our rider wants to dismount
            // If it returns true, the dismounting is allowed
            // else the dismounting is prevented
            public override bool RiderDismount(bool forced, GamePlayer player)
            {
                // If the race has started and our horse is racing we
                // prevent the dismounting and print a message
                if (!forced && player != null && IsRaceStarted() && HorseState == RaceHorseState.Racing)
                {
                    player.Out.SendMessage(
                        "You can't dismount during the race! Do you want to break all your bones?",
                        eChatType.CT_System,
                        eChatLoc.CL_SystemWindow);

                    // return false -> prevent dismounting
                    return(false);
                }

                // Unregister our horse and free the startposition
                UnregisterRacingHorse(this);

                // Walk back to our grazing spot if the rider dismounts
                WalkTo(m_originalX, m_originalY, 0, 75);

                // Set our horsestate correctly
                m_horseState = RaceHorseState.WalkingToGrazing;

                // Return true -> allow the dismounting
                return(base.RiderDismount(forced, player));
            }
Exemple #2
0
            // Called when a player wants to mount our racehorse
            // if it returns true mount is allowed if it returns
            // false then the mounting is not allowed
            public override bool RiderMount(GamePlayer rider, bool forced)
            {
                bool good = base.RiderMount(rider, forced);

                if (!good)
                {
                    return(good);
                }

                // If the race has started already, we don't allow
                // the player to mount the racehorse
                if (!forced && IsRaceStarted())
                {
                    rider.Out.SendMessage(
                        "Sorry, the race has started already! Wait until it is over!",
                        eChatType.CT_System,
                        eChatLoc.CL_SystemWindow);

                    // Return false -> don't allow the mount
                    return(false);
                }

                // We print out a nice message to the other players that are
                // standing around the horse and to the player that is mounting
                foreach (GamePlayer player in GetPlayersInRadius(1500))
                {
                    if (player != rider)
                    {
                        player.Out.SendMessage(
                            player.Name + " jumps onto " + Name + "'s back and get's ready for the race!",
                            eChatType.CT_System,
                            eChatLoc.CL_SystemWindow);
                    }
                    else
                    {
                        player.Out.SendMessage(
                            "You jump onto " + Name + "'s back and get ready for the race!",
                            eChatType.CT_System,
                            eChatLoc.CL_SystemWindow);
                    }
                }

                // We register this horse in our event and get back
                // our startnumber (0-3)
                m_horseNum = RegisterRacingHorse(this);

                // Now we fetch our startposition
                int startX, startY;

                GetStartPoint(out startX, out startY);

                // Make the mob and it's rider walk to our startposition!
                WalkTo(startX, startY, 0, 250);

                // Set the horse state correctly
                HorseState = RaceHorseState.WalkingToStart;

                // Return true -> allow the mounting
                return(true);
            }
Exemple #3
0
            //This function will be called by our raceevent when
            //the race is started
            public void StartRace()
            {
                //Set our state to racing
                m_horseState = RaceHorseState.Racing;

                //We are at the first startpoint
                m_currentPathPoint = 0;

                //We fetch the next pathpoint
                int x, y;

                GetNextPoint(m_currentPathPoint, out x, out y);

                //Now our current point is 1
                m_currentPathPoint++;
                //Walk to the target spot ... our speed is 500+random 20
                Random rnd = new Random();

                WalkTo(x, y, 0, (short)(500 + rnd.Next(20)));
            }
Exemple #4
0
            //This function will be called by our raceevent when
            //the race is started
            public void StartRace()
            {
                //Set our state to racing
                m_horseState = RaceHorseState.Racing;

                //We are at the first startpoint
                m_currentPathPoint = 0;

                //We fetch the next pathpoint
                int x, y;
                GetNextPoint(m_currentPathPoint, out x, out y);

                //Now our current point is 1
                m_currentPathPoint++;
                //Walk to the target spot ... our speed is 500+random 20
                Random rnd = new Random();
                WalkTo(x, y, 0, (short)(500 + rnd.Next(20)));
            }
Exemple #5
0
            //Called when our rider wants to dismount
            //If it returns true, the dismounting is allowed
            //else the dismounting is prevented
            public override bool RiderDismount(bool forced, GamePlayer player)
            {
                //If the race has started and our horse is racing we
                //prevent the dismounting and print a message
                if (!forced && player != null && IsRaceStarted() && HorseState == RaceHorseState.Racing)
                {
                    player.Out.SendMessage(
                        "You can't dismount during the race! Do you want to break all your bones?",
                        eChatType.CT_System,
                        eChatLoc.CL_SystemWindow);
                    //return false -> prevent dismounting
                    return false;
                }

                //Unregister our horse and free the startposition
                UnregisterRacingHorse(this);

                //Walk back to our grazing spot if the rider dismounts
                WalkTo(m_originalX, m_originalY, 0, 75);
                //Set our horsestate correctly
                m_horseState = RaceHorseState.WalkingToGrazing;
                //Return true -> allow the dismounting
                return base.RiderDismount(forced, player);
            }
Exemple #6
0
            public override void Notify(DOLEvent e, object sender, EventArgs args)
            {
                base.Notify(e, sender, args);

                if (e == GameNPCEvent.ArriveAtTarget)
                {
                    if (HorseState == RaceHorseState.WalkingToStart)
                    {
                        //We are at the first pathpoint
                        m_currentPathPoint = 0;

                        //Get the next point we will be racing to
                        int x, y;
                        GetNextPoint(m_currentPathPoint, out x, out y);

                        //Turn the horse towards the next point on the path
                        TurnTo(x, y);

                        //We are waiting for the race to start now!
                        m_horseState = RaceHorseState.WaitingForRaceStart;
                    }
                    else if (HorseState == RaceHorseState.WalkingToGrazing)
                    {
                        //We set our heading to our original heading
                        Heading = m_originalHeading;
                        //We broadcast the update to the players around us
                        BroadcastUpdate();
                        //Set the horse state back to grazing
                        m_horseState = RaceHorseState.Grazing;
                    }
                }
                else if (e == GameNPCEvent.CloseToTarget)
                {
                    if (HorseState == RaceHorseState.Racing)
                    {
                        if (m_currentPathPoint >= (racePoints.Length/2))
                        {
                            //Our state is finished now
                            m_horseState = RaceHorseState.Finished;

                            //We register the finish in the raceevent
                            HorseFinished(this);
                        }
                        else
                        {
                            //We set our new speed with a small random
                            //variance up and down
                            Random rnd = new Random();
                            short speed = (short)(CurrentSpeed + rnd.Next(20) - 10);
                            CurrentSpeed = speed;

                            //If our speed drops below 500 we set it to 500
                            //if it get's higher than 550 we set it to 550
                            if (CurrentSpeed < 500)
                                CurrentSpeed = 500;
                            else if (CurrentSpeed > 550)
                                CurrentSpeed = 550;

                            //We get our next pathpoint and
                            int nextX, nextY;
                            GetNextPoint(m_currentPathPoint, out nextX, out nextY);
                            m_currentPathPoint++;

                            WalkTo(nextX, nextY, 0, CurrentSpeed);
                        }
                    }
                }
            }
Exemple #7
0
            public override void Notify(DOLEvent e, object sender, EventArgs args)
            {
                base.Notify(e, sender, args);

                if (e == GameNPCEvent.ArriveAtTarget)
                {
                    if (HorseState == RaceHorseState.WalkingToStart)
                    {
                        //We are at the first pathpoint
                        m_currentPathPoint = 0;

                        //Get the next point we will be racing to
                        int x, y;
                        GetNextPoint(m_currentPathPoint, out x, out y);

                        //Turn the horse towards the next point on the path
                        TurnTo(x, y);

                        //We are waiting for the race to start now!
                        m_horseState = RaceHorseState.WaitingForRaceStart;
                    }
                    else if (HorseState == RaceHorseState.WalkingToGrazing)
                    {
                        //We set our heading to our original heading
                        Heading = m_originalHeading;
                        //We broadcast the update to the players around us
                        BroadcastUpdate();
                        //Set the horse state back to grazing
                        m_horseState = RaceHorseState.Grazing;
                    }
                }
                else if (e == GameNPCEvent.CloseToTarget)
                {
                    if (HorseState == RaceHorseState.Racing)
                    {
                        if (m_currentPathPoint >= (racePoints.Length / 2))
                        {
                            //Our state is finished now
                            m_horseState = RaceHorseState.Finished;

                            //We register the finish in the raceevent
                            HorseFinished(this);
                        }
                        else
                        {
                            //We set our new speed with a small random
                            //variance up and down
                            Random rnd   = new Random();
                            short  speed = (short)(CurrentSpeed + rnd.Next(20) - 10);
                            CurrentSpeed = speed;

                            //If our speed drops below 500 we set it to 500
                            //if it get's higher than 550 we set it to 550
                            if (CurrentSpeed < 500)
                            {
                                CurrentSpeed = 500;
                            }
                            else if (CurrentSpeed > 550)
                            {
                                CurrentSpeed = 550;
                            }

                            //We get our next pathpoint and
                            int nextX, nextY;
                            GetNextPoint(m_currentPathPoint, out nextX, out nextY);
                            m_currentPathPoint++;

                            WalkTo(nextX, nextY, 0, CurrentSpeed);
                        }
                    }
                }
            }
Exemple #8
0
            //Called when a player wants to mount our racehorse
            //if it returns true mount is allowed if it returns
            //false then the mounting is not allowed
            public override bool RiderMount(GamePlayer rider, bool forced)
            {
                bool good = base.RiderMount(rider, forced);
                if (!good)
                    return good;

                //If the race has started already, we don't allow
                //the player to mount the racehorse
                if (!forced && IsRaceStarted())
                {
                    rider.Out.SendMessage("Sorry, the race has started already! Wait until it is over!",
                                          eChatType.CT_System,
                                          eChatLoc.CL_SystemWindow);
                    //Return false -> don't allow the mount
                    return false;
                }

                //We print out a nice message to the other players that are
                //standing around the horse and to the player that is mounting
                foreach (GamePlayer player in GetPlayersInRadius(1500))
                    if (player != rider)
                    {
                        player.Out.SendMessage(
                            player.Name + " jumps onto " + Name + "'s back and get's ready for the race!",
                            eChatType.CT_System,
                            eChatLoc.CL_SystemWindow);
                    }
                    else
                    {
                        player.Out.SendMessage(
                            "You jump onto " + Name + "'s back and get ready for the race!",
                            eChatType.CT_System,
                            eChatLoc.CL_SystemWindow);
                    }

                //We register this horse in our event and get back
                //our startnumber (0-3)
                m_horseNum = RegisterRacingHorse(this);

                //Now we fetch our startposition
                int startX, startY;
                GetStartPoint(out startX, out startY);

                //Make the mob and it's rider walk to our startposition!
                WalkTo(startX, startY, 0, 250);
                //Set the horse state correctly
                HorseState = RaceHorseState.WalkingToStart;
                //Return true -> allow the mounting
                return true;
            }