RunUO-FR
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
RunUO-FR

Forum de support pour RunUO en français.
 
AccueilAccueil  Dernières imagesDernières images  RechercherRechercher  S'enregistrerS'enregistrer  Connexion  
-40%
Le deal à ne pas rater :
Tefal Ingenio Emotion – Batterie de cuisine 10 pièces (induction, ...
59.99 € 99.99 €
Voir le deal

 

 Projet Commun!

Aller en bas 
2 participants
AuteurMessage
runuoforgotten




Messages : 16
Date d'inscription : 27/09/2008
Age : 54

Projet Commun! Empty
MessageSujet: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 5:56

C'est bien de revoir se forum !
Alors pourquoi pas feter sa et débuter un projet en commun.

Si vous avec des idé a proposer, pour ma part peut etre :
-Monstre spéciaux
-Base d' Arena
-Base Item speciaux
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 10:27

Salut, glad to see you Wink

En ce moment, je voudrais faire des extensions pour un système trouvé sur RunUO.com : des dragons volants

Et sinon, travailler sur les AI me brancherai bien.

Ya pas foule ici, mais c'est une bonne idée. Propose ;o)
Revenir en haut Aller en bas
runuoforgotten




Messages : 16
Date d'inscription : 27/09/2008
Age : 54

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 20:22

Ouais sa rentre dans ma premiere sugestion.
Ma regarder sa attentivement aujourd'hui.
si tu pourais poster les script ici sur le forum sa maiderais besucoup je suis a job
(pas en fichier atacher)
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 21:10

FlyingAI.cs, qui d'ailleurs n'est pas une AI, mais le "fly-engine"...

Code:

using System;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
using Server.Network;
using Server.Items;
using Server.Regions;

namespace Server.Mobiles
{
   public class FlyingAI
   {
      public static void CheckMethods( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;
      
         CheckMap( fbc );
         CheckLandTile( fbc );
         CheckStaticLandTile( fbc );
         CheckMapEdge( fbc );
         CheckStatic( fbc );
         CheckHouse( fbc );
         FlyingRange( fbc );
      }

      public static void AnimateFlying( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

            fbc.PlaySound( 0x2D0 );
         fbc.Animate( 24, 5, 1, true, false, 0 );
      }

      public static void CheckMap( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( fbc.Map == Map.Felucca )
         {
            fbc.LeftSide = 5;
            fbc.RightSide = 5100;
            fbc.TopSide = 5;
            fbc.BottomSide = 4090;
         }

         if ( fbc.Map == Map.Trammel )
         {
            fbc.LeftSide = 5;
            fbc.RightSide = 5100;
            fbc.TopSide = 5;
            fbc.BottomSide = 4090;
         }

         if ( fbc.Map == Map.Ilshenar )
         {
            fbc.IsFlying = false;
            fbc.IsTakingOff = false;
            return;
         }

         if ( fbc.Map == Map.Malas )
         {
            fbc.LeftSide = 515;
            fbc.RightSide = 2555;
            fbc.TopSide = 5;
            fbc.BottomSide = 2045;
         }

         if ( fbc.Map == Map.Tokuno )
         {
            fbc.LeftSide = 5;
            fbc.RightSide = 1445;
            fbc.TopSide = 5;
            fbc.BottomSide = 1445;
         }
      }

      public static void RunFly( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         fbc.Direction |= Direction.Running;
      }

      public static void FlyingRange( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         int hx = fbc.Home.X;
         int hy = fbc.Home.Y;
         int hz = fbc.Home.Z;

         if ( (hx + hy + hz) == 0 )
            return;

         int mx = fbc.X;
         int my = fbc.Y;
         int mz = fbc.Z;

         int range = fbc.RangeHome;
         
         if ( hx > mx )
         {
            if ( (hx - mx) >= range )
               ChangeDirection( fbc );
         }
         if ( hx < mx )
         {
            if ( (mx - hx) >= range )
               ChangeDirection( fbc );
         }
         if ( hy > my )
         {
            if ( (hy - my) >= range )
               ChangeDirection( fbc );
         }
         if ( hy < my )
         {
            if ( (my - hy) >= range )
               ChangeDirection( fbc );
         }
         if ( hz > mz )
         {
            if ( (hz - mz) >= range )
            {
               if ( fbc.FlyingDown == true )
               {
                  fbc.FlyingDown = false;
                  fbc.FlyingUp = true;
                  return;
               }
               fbc.FlyingUp = true;
               return;
            }   
         }
         if ( hz < mz )
         {
            if ( (mz - hz) >= range )
            {
               if ( fbc.FlyingUp == true )
               {
                  fbc.FlyingUp = false;
                  fbc.FlyingDown = true;
                  return;
               }
               fbc.FlyingDown = true;
               return;
            }   
         }
      }

      public static void TakeOff( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( fbc.Ground == fbc.Z )
         {
            fbc.FlyingUp = true;
            RandomChangeDirection( fbc );
            MaskedDirection( fbc );
            AnimateFlying( fbc );
            fbc.Z++; 
            return;
         }
      
         if ( fbc.Ground < fbc.Z )
            fbc.Z++; 
      
         if ( fbc.Z > (fbc.Ground + 20) )
         {
            fbc.IsTakingOff = false;   
         }
      }

      public static void Flying( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( CheckAbove( fbc ))
         {
            fbc.IsFlying = false;
            fbc.IsTakingOff = false;
            return;
         }

         Timer f_timer = new FlyingTimer( fbc );

         CheckMethods( fbc );

         if ( fbc.CanFly == false )
            return;

         if ( fbc.FlyStam <= 50 )
         {
            fbc.FlyingUp = false;
            fbc.IsLanding = true;
            fbc.FlyingDown = true;
         }

         if ( (fbc.Z + 20) >= fbc.Ceiling )
         {
            fbc.FlyingUp = false;
            fbc.FlyingDown = true;
            fbc.Z--;
         }

         if ( fbc.FlyingUp == true )
            fbc.Z++;
         if ( fbc.FlyingDown == true )
            fbc.Z--;

         CheckMethods( fbc );

         int direct = Utility.Random( 1, 20 );
         int altitude = Utility.Random( 1, 3 );

         if ( fbc.IsTakingOff == true )
         {
            TakeOff( fbc );
 
            if ( direct == 7 )
               RandomChangeDirection( fbc );
            MaskedDirection( fbc );

            CheckMethods( fbc );

                f_timer.Start();

            if ( fbc.FlyAnim == 2 )
                   AnimateFlying( fbc );

            if ( fbc.FlyStam > 10 )
               fbc.FlyStam--;
            return;
         }

         if ( fbc.IsLanding == true )
         {
            Landing( fbc );

            if ( fbc.IsLanding == false )
               return;

            if ( direct == 7 )
               RandomChangeDirection( fbc );
            MaskedDirection( fbc );

            CheckMethods( fbc );

            f_timer.Start();

            if ( fbc.FlyAnim == 2 )
                   AnimateFlying( fbc );   
            return;
         }

         if ( (fbc.Z - 20) <= fbc.Ground )
         {
            fbc.FlyingUp = true;
            fbc.FlyingDown = false;
            fbc.Z++;
         }
         
         if ( direct == 7 )
            RandomChangeDirection( fbc );
         if ( altitude == 2 )
            RandomAltitudeDirection( fbc );
         MaskedDirection( fbc );

         CheckMethods( fbc );
                       
         f_timer.Start();

         if ( fbc.FlyAnim == 2 )
                AnimateFlying( fbc );   
      }

      public static void Landing( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( fbc.Ground > (fbc.Z - 1) )
         {
            fbc.Z = fbc.Ground + 1;
            fbc.IsLanding = false;
            fbc.IsFlying = false;
            fbc.FlyingUp = false;
            fbc.FlyingDown = false;
            return;
         }
         if ( fbc.Ground == (fbc.Z - 1) )
         {
            fbc.IsLanding = false;
            fbc.IsFlying = false;
            fbc.FlyingUp = false;
            fbc.FlyingDown = false;
            CheckStaticLanding( fbc );
            return;
         }
         if ( fbc.Z > (fbc.Ground + 1) )
            fbc.Z--;
      }

      public static void CheckStatic( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         const int a = -1;
         const int b = 1;
         const int c = 0;

         int xx = 0;
         int yy = 0;

         if ( fbc.CDirection == 1 )
         {
            xx = c;
            yy = a;
         }

         if ( fbc.CDirection == 2 )
         {
            xx = b;
            yy = a;
         }

         if ( fbc.CDirection == 3 )
         {
            xx = b;
            yy = c;
         }

         if ( fbc.CDirection == 4 )
         {
            xx = b;
            yy = b;
         }

         if ( fbc.CDirection == 5 )
         {
            xx = c;
            yy = b;
         }

         if ( fbc.CDirection == 6 )
         {
            xx = a;
            yy = b;
         }

         if ( fbc.CDirection == 7 )
         {
            xx = a;
            yy = c;
         }

         if ( fbc.CDirection == 8 )
         {
            xx = a;
            yy = a;
         }

                         Tile[] tiles = fbc.Map.Tiles.GetStaticTiles( ( fbc.X + xx ), ( fbc.Y + yy ), true );

         if ( tiles == null )
            return;

         for ( int i = 0; i < tiles.Length; ++i )
              {
                   Tile tile = tiles[i];

            if ( fbc.Z <= tile.Z )
               ChangeDirection( fbc );
                    }
      }

      public static void CheckHouse( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

               if ( fbc.Region.Name == "HouseRegion" )
            ChangeDirection( fbc );
      }

      public static void CheckLandTile( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

               Tile landTile = fbc.Map.Tiles.GetLandTile( fbc.X, fbc.Y );

         fbc.Ground = landTile.Z;
      }

      public static void CheckStaticLandTile( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

                         Tile[] tiles = fbc.Map.Tiles.GetStaticTiles( ( fbc.X ), ( fbc.Y ), true );

         if ( tiles == null )
            return;

         for ( int i = 0; i < tiles.Length; ++i )
              {
                   Tile tile = tiles[i];

                             if ( tile.Z > fbc.Ground )
               fbc.Ground = tile.Z;
                    }
      }

      public static void CheckStaticLanding( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

               Tile landTile = fbc.Map.Tiles.GetLandTile( fbc.X, fbc.Y );

         fbc.Ground = landTile.Z;

                         Tile[] tiles = fbc.Map.Tiles.GetStaticTiles( ( fbc.X ), ( fbc.Y ), true );

         if ( tiles == null )
            return;

         for ( int i = 0; i < tiles.Length; ++i )
              {
                   Tile tile = tiles[i];

            if ( tile.Z <= fbc.Ground )
               return;

                             if ( tile.Z == fbc.Z )
               fbc.Z++;

                             if ( tile.Z == ( fbc.Z -1 ))
            {
               fbc.FlyStam = fbc.FlyStamMax;
            }
                    }
      }

      public static bool CheckAbove( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return true;

               Tile landTile = fbc.Map.Tiles.GetLandTile( fbc.X, fbc.Y );

         fbc.Ground = landTile.Z;

         if ( (fbc.Ground - 10) > fbc.Z )
            return true;

                         Tile[] tiles = fbc.Map.Tiles.GetStaticTiles( ( fbc.X ), ( fbc.Y ), true );

         if ( tiles == null )
            return false;

         for ( int i = 0; i < tiles.Length; ++i )
              {
                   Tile tile = tiles[i];

            if ( (tile.Z - 10) > fbc.Z )
               return true;
                    }
         return false;
      }

      public static void CheckMapEdge( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( fbc.X < fbc.LeftSide )
            ResetNoFly( fbc );
         if ( fbc.X > fbc.RightSide )
            ResetNoFly( fbc );
         if ( fbc.Y < fbc.TopSide )
            ResetNoFly( fbc );
         if ( fbc.Y > fbc.BottomSide )
            ResetNoFly( fbc );

         if ( fbc.X - 1 <= fbc.LeftSide )
            ChangeDirection( fbc );
         if ( fbc.X + 1 >= fbc.RightSide )
            ChangeDirection( fbc );
         if ( fbc.Y - 1 <= fbc.TopSide )
            ChangeDirection( fbc );
         if ( fbc.Y + 1 >= fbc.BottomSide )
            ChangeDirection( fbc );
      }
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 21:12

et la suite :
Code:
public static void ChangeDirection( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( fbc.CDirection == 1 )
         {
            fbc.Direction = Direction.South;
            fbc.CDirection = 5;
            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 2 )
         {
            fbc.Direction = Direction.Left;
            fbc.CDirection = 6;
            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 3 )
         {
            fbc.Direction = Direction.West;
            fbc.CDirection = 7;

            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 4 )
         {
            fbc.Direction = Direction.Up;
            fbc.CDirection = 8;
            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 5 )
         {
            fbc.Direction = Direction.North;
            fbc.CDirection = 1;
            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 6 )
         {
            fbc.Direction = Direction.Right;
            fbc.CDirection = 2;
            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 7 )
         {
            fbc.Direction = Direction.East;
            fbc.CDirection = 3;
            MaskedDirection( fbc );
            return;
         }
         if ( fbc.CDirection == 8 )
         {
            fbc.Direction = Direction.Down;
            fbc.CDirection = 4;
            MaskedDirection( fbc );
            return;
         }
      }

      public static void RandomChangeDirection( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         fbc.CDirection = Utility.Random( 1, 8 );

         if ( fbc.CDirection == 1 )
            fbc.Direction = Direction.North;
         if ( fbc.CDirection == 2 )
            fbc.Direction = Direction.Right;
         if ( fbc.CDirection == 3 )
            fbc.Direction = Direction.East;
         if ( fbc.CDirection == 4 )
            fbc.Direction = Direction.Down;
         if ( fbc.CDirection == 5 )
            fbc.Direction = Direction.South;
         if ( fbc.CDirection == 6 )
            fbc.Direction = Direction.Left;
         if ( fbc.CDirection == 7 )
            fbc.Direction = Direction.West;
         if ( fbc.CDirection == 8 )
            fbc.Direction = Direction.Up;

         RunFly( fbc );
      }

      public static void MaskedDirection( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         if ( fbc.CDirection == 1 )
            fbc.Direction = Direction.North;
         if ( fbc.CDirection == 2 )
            fbc.Direction = Direction.Right;
         if ( fbc.CDirection == 3 )
            fbc.Direction = Direction.East;
         if ( fbc.CDirection == 4 )
            fbc.Direction = Direction.Down;
         if ( fbc.CDirection == 5 )
            fbc.Direction = Direction.South;
         if ( fbc.CDirection == 6 )
            fbc.Direction = Direction.Left;
         if ( fbc.CDirection == 7 )
            fbc.Direction = Direction.West;
         if ( fbc.CDirection == 8 )
            fbc.Direction = Direction.Up;

         RunFly( fbc );
      }

      public static void RandomAltitudeDirection( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         int updown = Utility.Random( 1, 10 );

         if ( updown <= 1 )
         {
            if ( fbc.Ground <= fbc.Z - 21 )
               fbc.Z--;
            else fbc.Z++;
         }
         if ( updown >= 2 )
         {
            if ( fbc.Ceiling >= fbc.Z + 21 )
               fbc.Z++;
            else fbc.Z--;
         }

         if ( fbc.FlyStam > 10 )
            fbc.FlyStam--;
      }

      public static void ResetNoFly( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;
      
         if ( fbc.CanFly == true )
            fbc.CanFly = false;
      }

      public static bool NullCheck( FlyingCreature fbc )
      {
         if ( fbc == null )
            return true;
         else if ( !fbc.Alive )
                      return true;
         else if ( fbc.Deleted )
                      return true;
         else
            return false;
      }

      public static void SpawnShadow( FlyingCreature fbc )
      {
         if ( NullCheck( fbc ))
            return;

         int bld = 0;

         Map map = fbc.Map;

         if ( map == null )
            return;

         if ( fbc.CDirection == 1 )
            bld +=7425;
         if ( fbc.CDirection == 2 )
            bld +=7418;
         if ( fbc.CDirection == 3 )
            bld +=7411;
         if ( fbc.CDirection == 4 )
            bld +=7414;
         if ( fbc.CDirection == 5 )
            bld +=7416;
         if ( fbc.CDirection == 6 )
            bld +=7428;
         if ( fbc.CDirection == 7 )
            bld +=7421;
         if ( fbc.CDirection == 8 )
            bld +=7422;
         if ( bld == 0 )
            bld +=7428;

         FlyingShadow shadow = new FlyingShadow( bld );

         Point3D loc = fbc.Location;
         
         int x = fbc.X;
         int y = fbc.Y;
         int z = fbc.Ground+1;

         loc = new Point3D( x, y, z );
         
         shadow.MoveToWorld( loc, map );
      
         if ( shadow.Z > fbc.Z )
            fbc.Z = shadow.Z + 2;
      }

      #region #FlySpeed  (needs double FlySpeed in FlyingCreature)
      private static double FlySpeed(BaseCreature m)
      {
         FlyingCreature fbc = m as FlyingCreature;
         
         double speed = 0.2;
         
         if(fbc!=null)
         {
            speed = fbc.FlySpeed;
            
            if(speed <=0)speed = 0.2;
         }
         
         return speed;
      }
      #endregion
      
      public class FlyingTimer : Timer
                {
                   private Mobile m_Mobile;

                   //public FlyingTimer( BaseCreature m ) : base( TimeSpan.FromSeconds( 0.2 ) )
                   public FlyingTimer( BaseCreature m ) : base( TimeSpan.FromSeconds( FlySpeed(m) ) )//#FlySpeed
                   {
                      m_Mobile = m;
                   }

                   protected override void OnTick()
                   {   
            FlyingCreature fbc = m_Mobile as FlyingCreature;

            if ( fbc == null )
                      {
               Stop();
               return;
                      }

            if ( !fbc.Alive )
                      {
               Stop();
               return;
                      }

            if ( fbc.Deleted )
                      {
               Stop();
               return;
                      }

            if ( fbc.FlyAnim >= 2 )
                   fbc.FlyAnim = 0;
            fbc.FlyAnim++;

            if ( fbc.IsFlying == true )
            {
               if ( fbc.CDirection == 1 )
               {
                  RunFly( fbc );
                  fbc.Y--;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 2 )
               {
                  RunFly( fbc );
                  fbc.X++;
                  fbc.Y--;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 3 )
               {
                  RunFly( fbc );
                  fbc.X++;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 4 )
               {
                  RunFly( fbc );
                  fbc.X++;
                  fbc.Y++;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 5 )
               {
                  RunFly( fbc );
                  fbc.Y++;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 6 )
               {
                  RunFly( fbc );
                  fbc.X--;
                  fbc.Y++;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 7 )
               {
                  RunFly( fbc );
                  fbc.X--;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }

               if ( fbc.CDirection == 8 )
               {
                  RunFly( fbc );
                  fbc.X--;
                  fbc.Y--;

                  if ( fbc.FlyStam > 10 )
                     fbc.FlyStam--;
                  SpawnShadow( fbc );
               }
               Flying( fbc );
               Stop();
            }
            Stop();
         }
      }
   }
}
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 21:15

Apres quoi, chaque AI classique est reprise en flyingAI, comme celle ci.

Je n'ai pas encore cherché à regarder si à part voler, il y a du neuf, et si une modif de BaseAI ne suffirait pas.

L'exemple de FlyingPredatorAI :

Code:
using System;
using System.Collections;
using Server.Targeting;
using Server.Network;
using Server.Items;
using Server.Regions;


/*
 * PredatorAI, its an animal that can attack
 *   Dont flee but dont attack if not hurt or attacked
 *
 */

namespace Server.Mobiles
{
   public class FlyingPredatorAI : BaseAI
   {
      public FlyingPredatorAI(BaseCreature m) : base (m)
      {
      }

      public override bool DoActionWander()
      {
         if ( ((FlyingCreature)m_Mobile).CanFly == false )
         {
            ((FlyingCreature)m_Mobile).IsFlying = false;
         }
         if ( m_Mobile.Combatant != null )
         {
            m_Mobile.DebugSay( "I am hurt or being attacked, I kill him" );                  
            Action = ActionType.Combat;
         }
         else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, true, false, true))
         {
            m_Mobile.DebugSay( "There is something near, I go away" );
            Action = ActionType.Backoff;
         }
         else if ( ((FlyingCreature)m_Mobile).IsFlying == true )
         {
            return false;
         }
         else
         {
            base.DoActionWander();
         }

         return true;
      }

      public override bool DoActionCombat()
      {
         FlyingCreature fbc = (FlyingCreature)m_Mobile;
         
         if ( fbc.IsFlying == true )
            fbc.IsFlying = false;

         Mobile combatant = m_Mobile.Combatant;

         if ( combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map )
         {
            m_Mobile.DebugSay( "My combatant is gone, so my guard is up" );
            Action = ActionType.Wander;
            return true;
         }

         if ( WalkMobileRange( combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
         {
            m_Mobile.Direction = m_Mobile.GetDirectionTo( combatant );
         }
         else
         {
            if ( m_Mobile.GetDistanceToSqrt( combatant ) > m_Mobile.RangePerception + 1 )
            {
               m_Mobile.DebugSay( "I cannot find {0}", combatant.Name );

               Action = ActionType.Wander;
               return true;
            }
            else
            {
               m_Mobile.DebugSay( "I should be closer to {0}", combatant.Name );
            }
         }

         return true;
      }

      public override bool DoActionBackoff()
      {
         if ( ((FlyingCreature)m_Mobile).CanFly == true && ((FlyingCreature)m_Mobile).IsFlying == false )
         {
            ((FlyingCreature)m_Mobile).FlyStam = ((FlyingCreature)m_Mobile).FlyStamMax;
         }
         if ( m_Mobile.IsHurt() || m_Mobile.Combatant != null )
         {
            Action = ActionType.Combat;
         }
         else
         {
            if (AcquireFocusMob(m_Mobile.RangePerception * 2, FightMode.Closest, true, false , true))
            {
               if ( WalkMobileRange(m_Mobile.FocusMob, 1, false, m_Mobile.RangePerception, m_Mobile.RangePerception * 2) )
               {
                  m_Mobile.DebugSay( "Well, here I am safe" );
                  Action = ActionType.Wander;
               }               
            }
            else
            {
               m_Mobile.DebugSay( "I have lost my focus, lets relax" );
               Action = ActionType.Wander;
            }
         }

         return true;
      }
   }
}
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedDim 12 Oct - 21:18

Et FlyingCreature, Tiamat13, l'auteur, avait mis tout ça dans BaseCreature, j'ai tout regroupé pour que ce soit un peu plus "plug and play" :

Code:
using System;
using Server.Items;

namespace Server.Mobiles
{
   public class FlyingCreature : BaseCreature
   {
      #region #FlySpeed
      public virtual double FlySpeed { get { return 0.2;}}
      #endregion
      
      #region props
      private bool m_CanFlying = false;
      private bool m_IsFlying = false;
      private bool m_IsTakingOff = false;
      private bool m_IsLanding = false;
      private bool m_FlyingUp = false;
      private bool m_FlyingDown = false;
      private int i_Ceiling = 100;
      private int i_Ground;
      private int i_LeftSide;
      private int i_RightSide;
      private int i_TopSide;
      private int i_BottomSide;
      private int i_Direction;
      private int i_FlyStam;
      private int i_FlyStamMax;
      private int i_FlyAnim;
      private int i_FlyCnt;

      [CommandProperty( AccessLevel.GameMaster )]
      public bool CanFly
      {
         get{ return m_CanFlying; }
         set{ m_CanFlying = value; }
      }

      public bool IsFlying
      {
         get{ return m_IsFlying; }
         set{ m_IsFlying = value; }
      }
      
      public bool IsTakingOff
      {
         get{ return m_IsTakingOff; }
         set{ m_IsTakingOff = value; }
      }
      
      public bool IsLanding
      {
         get{ return m_IsLanding; }
         set{ m_IsLanding = value; }
      }
      
      public bool FlyingUp
      {
         get{ return m_FlyingUp; }
         set{ m_FlyingUp = value; }
      }
      
      public bool FlyingDown
      {
         get{ return m_FlyingDown; }
         set{ m_FlyingDown = value; }
      }
      
      public int Ceiling
      {
         get{ return i_Ceiling; }
         set{ i_Ceiling = value; }
      }
      
      public int Ground
      {
         get{ return i_Ground; }
         set{ i_Ground = value; }
      }
      
      public int LeftSide
      {
         get{ return i_LeftSide; }
         set{ i_LeftSide = value; }
      }
      
      public int RightSide
      {
         get{ return i_RightSide; }
         set{ i_RightSide = value; }
      }
      
      public int TopSide
      {
         get{ return i_TopSide; }
         set{ i_TopSide = value; }
      }
      
      public int BottomSide
      {
         get{ return i_BottomSide; }
         set{ i_BottomSide = value; }
      }
      
      public int CDirection
      {
         get{ return i_Direction; }
         set{ i_Direction = value; }
      }
      
      [CommandProperty( AccessLevel.GameMaster )]
      public int FlyStam
      {
         get{ return i_FlyStam; }
         set{ i_FlyStam = value; }
      }
      
      [CommandProperty( AccessLevel.GameMaster )]
      public int FlyStamMax
      {
         get{ return i_FlyStamMax; }
         set{ i_FlyStamMax = value; }
      }
      
      public int FlyAnim
      {
         get{ return i_FlyAnim; }
         set{ i_FlyAnim = value; }
      }
      
      public int FlyCnt
      {
         get{ return i_FlyCnt; }
         set{ i_FlyCnt = value; }
      }
      #endregion
      
      public FlyingCreature(AIType ai,FightMode mode,int iRangePerception,int iRangeFight, double dActiveSpeed,double dPassiveSpeed)
         : base( AIType.AI_FlyingAnimal, FightMode.Aggressor, iRangePerception, iRangeFight, dActiveSpeed, dPassiveSpeed )
      {
      }
      
      public override bool OnBeforeDeath()
      {
         if ( IsFlying == true )
         {
            IsFlying = false;
            Z = (Ground + 1);
            PlaySound( 0x525 );
         }
         
         return base.OnBeforeDeath();
      }
      
      public override void OnThink()
      {
         if ( CanFly == true && IsFlying == false )
         {
            if ( FlyStam >= FlyStamMax && !Controlled )
            {
               IsFlying = true;
               IsTakingOff = true;

               FlyingAI.Flying( this );
            }
            if ( FlyStam < FlyStamMax )
               FlyStam++;
         }
         
         base.OnThink();
      }
      
      public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
      {
         if(from.Weapon != null)
         {
            if(from.Weapon is BaseRanged)
               return;
            else
            {
               if((from.Z > this.Z+10)||(from.Z < this.Z-10))
               {
                  from.SendMessage("You have to be closer to attack this!");
                  damage = 0;
               }
            }
         }
      }
      
      public FlyingCreature(Serial serial) : base(serial)
      {
      }

      public override void Serialize(GenericWriter writer)
      {
         base.Serialize(writer);

         writer.Write((int) 0);
         
         writer.Write( (bool)m_CanFlying);
         writer.Write( (bool)m_IsFlying);
         writer.Write( (bool)m_IsTakingOff);
         writer.Write( (bool)m_IsLanding);
         writer.Write( (bool)m_FlyingUp);
         writer.Write( (bool)m_FlyingDown);
         writer.Write( (int)i_Ceiling);
         writer.Write( (int)i_Ground);
         writer.Write( (int)i_LeftSide);
         writer.Write( (int)i_RightSide);
         writer.Write( (int)i_TopSide);
         writer.Write( (int)i_BottomSide);
         writer.Write( (int)i_Direction);
         writer.Write( (int)i_FlyStam);
         writer.Write( (int)i_FlyStamMax);
         writer.Write( (int)i_FlyAnim);
         writer.Write( (int) i_FlyCnt );
      }

      public override void Deserialize(GenericReader reader)
      {
         base.Deserialize(reader);

         int version = reader.ReadInt();
         
         m_CanFlying = (bool)reader.ReadBool();
         m_IsFlying = (bool)reader.ReadBool();
         m_IsTakingOff = (bool)reader.ReadBool();
         m_IsLanding = (bool)reader.ReadBool();
         m_FlyingUp = (bool)reader.ReadBool();
         m_FlyingDown = (bool)reader.ReadBool();
         i_Ceiling = (int)reader.ReadInt();
         i_Ground = (int)reader.ReadInt();
         i_LeftSide = (int)reader.ReadInt();
         i_RightSide = (int)reader.ReadInt();
         i_TopSide = (int)reader.ReadInt();
         i_BottomSide = (int)reader.ReadInt();
         i_Direction = (int)reader.ReadInt();
         i_FlyStam = (int)reader.ReadInt();
         i_FlyStamMax = (int)reader.ReadInt();
         i_FlyAnim = (int)reader.ReadInt();
         i_FlyCnt = (int)reader.ReadInt();
      }
   }
}
Revenir en haut Aller en bas
runuoforgotten




Messages : 16
Date d'inscription : 27/09/2008
Age : 54

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedLun 13 Oct - 0:02

Merci jai encore 5 h pour regarder sa a job

donc pour le faire ataquer lorsquil volle
faudrais refaire
public override bool DoActionCombat()
car des qui entre en comba
if ( fbc.IsFlying == true )
fbc.IsFlying = false;


c peut etre un peut au dessu de mes moyen de jouer dans AI des monstre

quoi que si le fight range est supérieur a 5 et quil cast des fire ball sa pourais etre pas mal pour un gragon !

ta pas fait un flying vampire qui tourne au tour de sa victime sa pourais servir.
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedLun 13 Oct - 17:03

Tamiat13 avait mis un truc dans BaseWeapon, pour gérer les attaques melee/ranged&&magic...

(tout ce qui a à voir avec le bool rangeCheck)

Code:
public virtual void OnHit( Mobile attacker, Mobile defender, double damageBonus )
      {
         bool rangeCheck = false;
 
         if ( this is BaseRanged )
             rangeCheck = true;

         if ( rangeCheck == false && attacker.Z > (defender.Z + 10) )
         {
            attacker.SendMessage("You have to be closer to attack this!");
            return;
         }

         if ( rangeCheck == false && attacker.Z < (defender.Z - 10) )
         {
            attacker.SendMessage("You have to be closer to attack this!");
            return;
         }

         if ( MirrorImage.HasClone( defender ) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble() )
         {
            Clone bc;

            foreach ( Mobile m in defender.GetMobilesInRange( 4 ) )
            {
               bc = m as Clone;

               if ( bc != null && bc.Summoned && bc.SummonMaster == defender )
               {
                  attacker.SendLocalizedMessage( 1063141 ); // Your attack has been diverted to a nearby mirror image of your target!
                  defender.SendLocalizedMessage( 1063140 ); // You manage to divert the attack onto one of your nearby mirror images.

                  /*
                   * TODO: What happens if the Clone parries a blow?
                   * And what about if the attacker is using Honorable Execution
                   * and kills it?
                   */

                  defender = m;
                  break;
               }
            }
         }

Pour ma part, pour ne rien avoir à mettre dans BaseWeapon, et tout mettre dans FlyingCreature:BaseCreature, j'ai fais :
Code:
public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
      {
         if(from.Weapon != null && from.Weapon is BaseRanged)
            return;
         else
         {
            if((from.Z > this.Z+10)||(from.Z < this.Z-10))
            {
               from.SendMessage("You have to be closer to attack this!");
               damage = 0;
            }
         }
      }
C'est pas terrible...
Revenir en haut Aller en bas
runuoforgotten




Messages : 16
Date d'inscription : 27/09/2008
Age : 54

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedLun 13 Oct - 20:42

jai du mal a voir ce que tu voudrais changer ?
Revenir en haut Aller en bas
Gargouille




Messages : 97
Date d'inscription : 02/09/2008

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedLun 13 Oct - 21:19

Faudrait que je teste en situation de combat, AlterMeleeDamageFrom est la seule méthode, possédant l'argument from, que j'ai trouvé.

Mais au fait, si les AI ne t'interessent pas trop, vas y pour une autre suggestion.
Revenir en haut Aller en bas
runuoforgotten




Messages : 16
Date d'inscription : 27/09/2008
Age : 54

Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_minipostedMar 14 Oct - 3:17

public override void AlterDamageScalarFrom( Mobile caster, ref double scalar )
public override void AlterDamageScalarTo( Mobile target, ref double scalar )
public override void AlterSpellDamageFrom( Mobile from, ref int damage )
public override void AlterSpellDamageTo( Mobile to, ref int damage )
public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
public override void AlterMeleeDamageTo( Mobile to, ref int damage )

voila 2 exemple

public override void AlterMeleeDamageFrom( Mobile from, ref int damage )//le dmg qu'il reçoit
{
if ( from is BaseCreature )
{
BaseCreature bc = (BaseCreature)from;

if ( bc.Controled || bc.BardTarget == this )
damage = 0; // Immune to pets and provoked creatures
}
}

public override void AlterMeleeDamageTo( Mobile to, ref int damage ) //le dmg qu'il fait
{
if ( to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || to is LesserHiryu || to is Daemon )
damage *= 3;
}



ouin pense ma me partir un petit projet ici !

tk sa bien fait tu parle de sa sa ma guider pour cree une baseitem décoration
Revenir en haut Aller en bas
Contenu sponsorisé





Projet Commun! Empty
MessageSujet: Re: Projet Commun!   Projet Commun! Icon_miniposted

Revenir en haut Aller en bas
 
Projet Commun!
Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
RunUO-FR :: Domaine public :: Le vivier-
Sauter vers: