View Full Version: Gump de création de PJ

RunUO.FR Support > Probleme de script > Gump de création de PJ


Title: Gump de création de PJ
Description: À l'aide :D


Vortal - September 26, 2004 04:05 AM (GMT)
Bon, alors voilà, j'ai de nombreux petits problèmes avec ce script. Je vous met les deux sources, puis je vous dit quels sont les problèmes.

Scripts\Custom\CharCreation.cs
CODE
using System;
using Server;
using Server.Gumps;
using Server.Targeting;
using Server.Mobiles;
using Server.Network;
using Server.Scripts.Commands;
using Server.Items;

namespace Server.Scripts.Commands
{
public class CharCreationCommand
{
 public static void Initialize()
 {
  Server.Commands.Register( "CharCreation", AccessLevel.GameMaster, new CommandEventHandler(CharCreation_OnCommand ) );
 }

 [Usage( "CharCreation" )]
 [Description( "Permet de choisir sa race et sa classe" )]
 public static void CharCreation_OnCommand( CommandEventArgs e )
 {
  Mobile from = e.Mobile;
  from.SendGump( new CharCreationGump ( from ) );
 }
}
}

namespace Server.Gumps
{
public class CharCreationGump : Gump
{
 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public CharCreationGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );
  AddLabel( 20, 15, 1149, "Races" );
  AddLabel( 20, 45, 255, string.Format( "Il vous faut choisir une race pour votre personnage." ));

  AddLabel( 40, 65, 255, string.Format( "Humain" ));
  AddLabel( 40, 85, 255, string.Format( "Elfe" ));
  AddLabel( 40, 105, 255, string.Format( "Nain" ));

  AddButton( 20, 67, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 20, 87, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
  AddButton( 20, 107, 0x2623, 0x2622, 3, GumpButtonType.Reply, 0 );

  AddLabel( 20, 145, 1149, string.Format( "Notez bien que chaque race possède ses propres avantages" ));
  AddLabel( 20, 160, 1149, string.Format( "et inconvénients. Ceux-ci sont énumérés dans les pages" ));
  AddLabel( 20, 175, 1149, string.Format( "suivantes avec une courte description." ));
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new HumainGump( from ) );
    break;
   }
   case 2:
   {
    m.SendGump( new ElfeGump( from ) );
    break;
   }
   case 3:
   {
    m.SendGump( new NainGump( from ) );
    break;
   }
  }
 }
}

public class HumainGump : Gump
{
 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public HumainGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Humain" );
  AddLabel( 20, 45, 255, string.Format( "La race humaine est la plus répandue et ne possède aucune" ));
  AddLabel( 20, 60, 255, string.Format( "limitation dans les classes. Ils sont en bons termes tant" ));
  AddLabel( 20, 75, 255, string.Format( "avec les elfes qu'avec les nains." ));

  AddLabel( 20, 105, 1149, string.Format( "Attributs de départ" ));
  AddLabel( 20, 135, 255, string.Format( "Force : {0}", "30" ));
  AddLabel( 20, 150, 255, string.Format( "Dextérité : {0}", "30" ));
  AddLabel( 20, 165, 255, string.Format( "Intelligence : {0}", "30" ));

  AddLabel( 40, 195, 255, string.Format( "Retour en arrière" ));
  AddLabel( 210, 195, 255, string.Format( "Je serai un(e) humain(e)" ));

  AddButton( 20, 195, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 190, 195, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 2:
   {
    m.Race = (Race) 1; // HUMAIN
    m.Str = 30;
    m.Dex = 30;
    m.Int = 30;
    m.Mana = 30;
    m.SendGump( new ClasseGump( from ) );
    break;
   }
  }
 }
}

public class ElfeGump : Gump
{
 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public ElfeGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Elfe" );
  AddLabel( 20, 45, 255, string.Format( "La race elfique est proche de la nature et ils sont aussi" ));
  AddLabel( 20, 60, 255, string.Format( "sauvage et sans pitié qu'elle. Il la protège farouchement et" ));
  AddLabel( 20, 75, 255, string.Format( "s'entendent très mal avec les nains." ));

  AddLabel( 20, 105, 1149, string.Format( "Attributs de départ" ));
  AddLabel( 20, 135, 255, string.Format( "Force : {0}", "20" ));
  AddLabel( 20, 150, 255, string.Format( "Dextérité : {0}", "20" ));
  AddLabel( 20, 165, 255, string.Format( "Intelligence : {0}", "50" ));

  AddLabel( 40, 195, 255, string.Format( "Retour en arrière" ));
  AddLabel( 210, 195, 255, string.Format( "Je serai un(e) elfe" ));

  AddButton( 20, 195, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 190, 195, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 2:
   {
    m.Race = (Race) 2; // ELFE
    m.Str = 20;
    m.Dex = 20;
    m.Int = 50;
    m.Mana = 50;
    m.SendGump( new ClasseGump( from ) );
    break;
   }
  }
 }
}

public class NainGump : Gump
{
 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public NainGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Nain" );
  AddLabel( 20, 45, 255, string.Format( "La race naine est cupide mais travaillante et courageuse." ));
  AddLabel( 20, 60, 255, string.Format( "Les nains sont des personnes orgeuilleuses et fières. Ils" ));
  AddLabel( 20, 75, 255, string.Format( "s'entendent très mal avec les elfes." ));

  AddLabel( 20, 105, 1149, string.Format( "Attributs de départ" ));
  AddLabel( 20, 135, 255, string.Format( "Force : {0}", "50" ));
  AddLabel( 20, 150, 255, string.Format( "Dextérité : {0}", "20" ));
  AddLabel( 20, 165, 255, string.Format( "Intelligence : {0}", "20" ));

  AddLabel( 40, 195, 255, string.Format( "Retour en arrière" ));
  AddLabel( 210, 195, 255, string.Format( "Je serai un(e) nain(e)" ));

  AddButton( 20, 195, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 190, 195, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new CharCreationGump( from ) );
    break;
   }
   case 2:
   {
    m.Race = (Race) 3; // NAIN
    m.Str = 50;
    m.Dex = 20;
    m.Int = 20;
    m.Mana = 20;
    m.SendGump( new ClasseGump( from ) );
    break;
   }
  }
 }
}

public class ClasseGump : Gump
{
 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public ClasseGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Classes" );
  AddLabel( 20, 45, 255, string.Format( "Il vous faut choisir une classe pour votre personnage." ));

  AddLabel( 40, 65, 255, string.Format( "Guerrier" ));
  AddLabel( 40, 85, 255, string.Format( "Artisan" ));
  AddLabel( 40, 105, 255, string.Format( "Mage" ));

  AddButton( 20, 67, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 20, 87, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
  AddButton( 20, 107, 0x2623, 0x2622, 3, GumpButtonType.Reply, 0 );

  AddLabel( 20, 145, 1149, string.Format( "Notez bien que chaque classe possède ses propres avantages" ));
  AddLabel( 20, 160, 1149, string.Format( "et inconvénients. Ceux-ci sont énumérés dans les pages" ));
  AddLabel( 20, 175, 1149, string.Format( "suivantes avec une courte description." ));
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new GuerrierGump( from ) );
    break;
   }
   case 2:
   {
    m.SendGump( new ArtisanGump( from ) );
    break;
   }
   case 3:
   {
    m.SendGump( new MageGump( from ) );
    break;
   }
  }
 }
}

public class GuerrierGump : Gump
{
 public void PackItem( Item item, Mobile m )
 {
  Container pack = m.Backpack;
  if ( pack != null )
   pack.DropItem( item );
  else
   item.Delete();
 }

 public void EquipItem( Item item, Mobile m )
 {
  EquipItem( item, false, m );
 }

 public void EquipItem( Item item, bool mustEquip, Mobile m )
 {
  Container pack = m.Backpack;

  if ( !mustEquip && pack != null )
   pack.DropItem( item );
  else
   item.Delete();
 }

 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public GuerrierGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Guerrier" );
  AddLabel( 20, 45, 255, string.Format( "Les guerriers maîtrisent les armes et portent de lourdes" ));
  AddLabel( 20, 60, 255, string.Format( "armures. On les voit souvent à dos de cheval et sont" ));
  AddLabel( 20, 75, 255, string.Format( "craints pour leurs habiletés au combat." ));

  AddLabel( 20, 105, 1149, string.Format( "Attributs de départ" ));
  AddLabel( 20, 135, 255, string.Format( "Force : {0}", "20" ));
  AddLabel( 20, 150, 255, string.Format( "Dextérité : {0}", "20" ));
  AddLabel( 20, 165, 255, string.Format( "Intelligence : {0}", "50" ));

  AddLabel( 40, 195, 255, string.Format( "Retour en arrière" ));
  AddLabel( 210, 195, 255, string.Format( "Je serai un(e) guerrier(e)" ));

  AddButton( 20, 195, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 190, 195, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 2:
   {
    m.Classe = (Classe) 1; // GUERRIER
    m.Title = "Guerrier";
    for (int i = 0; i < m.Skills.Length; i++)
    {
     if ( m.Skills[i].Name != "Archery" && m.Skills[i].Name != "Fencing" && m.Skills[i].Name != "Macing" && m.Skills[i].Name != "Parry" && m.Skills[i].Name != "Swords" && m.Skills[i].Name != "Tactics" && m.Skills[i].Name != "Wrestling" )
     {
      m.Skills[i].Base = 0.0;
      m.Skills[i].Cap = 100.0;
     }
    }
    m.Skills[SkillName.Archery].Base = 30.0;
    m.Skills[SkillName.Archery].Cap = 150.0;
    m.Skills[SkillName.Fencing].Base = 30.0;
    m.Skills[SkillName.Fencing].Cap = 150.0;
    m.Skills[SkillName.Macing].Base = 30.0;
    m.Skills[SkillName.Macing].Cap = 150.0;
    m.Skills[SkillName.Parry].Base = 30.0;
    m.Skills[SkillName.Parry].Cap = 150.0;
    m.Skills[SkillName.Swords].Base = 30.0;
    m.Skills[SkillName.Swords].Cap = 150.0;
    m.Skills[SkillName.Tactics].Base = 30.0;
    m.Skills[SkillName.Tactics].Cap = 150.0;
    m.Skills[SkillName.Wrestling].Base = 30.0;
    m.Skills[SkillName.Wrestling].Cap = 150.0;

    if ( m.Female )
     EquipItem( new FemaleLeatherChest(), true, m );
    else
     EquipItem( new LeatherChest(), true, m );
    EquipItem( new LeatherArms(), true, m );
    EquipItem( new LeatherGloves(), true, m );
    EquipItem( new LeatherGorget(), true, m );
    EquipItem( new WoodenShield(), true, m );
    EquipItem( new LeatherLegs(), true, m );
    EquipItem( new Broadsword(), true, m );
    EquipItem( new WoodenShield(), true, m );
    break;
   }
  }
 }
}

public class ArtisanGump : Gump
{
 public void PackItem( Item item, Mobile m )
 {
  Container pack = m.Backpack;
  if ( pack != null )
   pack.DropItem( item );
  else
   item.Delete();
 }

 public void EquipItem( Item item, Mobile m )
 {
  EquipItem( item, false, m );
 }

 public void EquipItem( Item item, bool mustEquip, Mobile m )
 {
  Container pack = m.Backpack;

  if ( !mustEquip && pack != null )
   pack.DropItem( item );
  else
   item.Delete();
 }

 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public ArtisanGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Artisan" );
  AddLabel( 20, 45, 255, string.Format( "Les artisans peuvent fabriquer différentes choses telles des" ));
  AddLabel( 20, 60, 255, string.Format( "armes ou des armures, des meubles, des vêtements, etc." ));
  AddLabel( 20, 75, 255, string.Format( "Ils sont généralement les personnages les plus riches." ));

  AddLabel( 20, 105, 1149, string.Format( "Attributs de départ" ));
  AddLabel( 20, 135, 255, string.Format( "Force : {0}", "20" ));
  AddLabel( 20, 150, 255, string.Format( "Dextérité : {0}", "20" ));
  AddLabel( 20, 165, 255, string.Format( "Intelligence : {0}", "50" ));

  AddLabel( 40, 195, 255, string.Format( "Retour en arrière" ));
  AddLabel( 210, 195, 255, string.Format( "Je serai un(e) artisan(e)" ));

  AddButton( 20, 195, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 190, 195, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 2:
   {
    m.Classe = (Classe) 2; // ARTISAN
    m.Title = "Artisan";
    for (int i = 0; i < m.Skills.Length; i++)
    {
     if ( m.Skills[i].Name != "Blacksmithy" && m.Skills[i].Name != "Fletching" && m.Skills[i].Name != "Carpentry" && m.Skills[i].Name != "Tailoring" && m.Skills[i].Name != "Tinkering" && m.Skills[i].Name != "ItemID" && m.Skills[i].Name != "Armslore"  && m.Skills[i].Name != "Mining"  && m.Skills[i].Name != "Lumberjacking"  && m.Skills[i].Name != "Fishing"  && m.Skills[i].Name != "Cooking" )
     {
      m.Skills[i].Base = 0.0;
      m.Skills[i].Cap = 100.0;
     }
    }
    m.Skills[SkillName.Mining].Base = 0.0;
    m.Skills[SkillName.Mining].Cap = 150.0;
    m.Skills[SkillName.Lumberjacking].Base = 0.0;
    m.Skills[SkillName.Lumberjacking].Cap = 150.0;
    m.Skills[SkillName.Fishing].Base = 0.0;
    m.Skills[SkillName.Fishing].Cap = 150.0;
    m.Skills[SkillName.Cooking].Base = 0.0;
    m.Skills[SkillName.Cooking].Cap = 150.0;

    m.Skills[SkillName.Blacksmith].Base = 30.0;
    m.Skills[SkillName.Blacksmith].Cap = 150.0;
    m.Skills[SkillName.Fletching].Base = 30.0;
    m.Skills[SkillName.Fletching].Cap = 150.0;
    m.Skills[SkillName.Carpentry].Base = 30.0;
    m.Skills[SkillName.Carpentry].Cap = 150.0;
    m.Skills[SkillName.Tailoring].Base = 30.0;
    m.Skills[SkillName.Tailoring].Cap = 150.0;
    m.Skills[SkillName.Tinkering].Base = 30.0;
    m.Skills[SkillName.Tinkering].Cap = 150.0;
    m.Skills[SkillName.ItemID].Base = 30.0;
    m.Skills[SkillName.ItemID].Cap = 150.0;
    m.Skills[SkillName.ArmsLore].Base = 30.0;
    m.Skills[SkillName.ArmsLore].Cap = 150.0;

    PackItem( new TinkerTools(), m );
    PackItem( new DovetailSaw(), m );
    PackItem( new Scissors(), m );
    PackItem( new SmithHammer(), m );
    PackItem( new Pickaxe(), m );
    PackItem( new FletcherTools(), m );
    PackItem( new SewingKit(), m );
    PackItem( new Hatchet(), m );
    EquipItem( new HalfApron( Utility.RandomYellowHue()), true, m );
    break;
   }
  }
 }
}

public class MageGump : Gump
{
 public void PackItem( Item item, Mobile m )
 {
  Container pack = m.Backpack;
  if ( pack != null )
   pack.DropItem( item );
  else
   item.Delete();
 }

 public void EquipItem( Item item, Mobile m )
 {
  EquipItem( item, false, m );
 }

 public void EquipItem( Item item, bool mustEquip, Mobile m )
 {
  Container pack = m.Backpack;

  if ( !mustEquip && pack != null )
   pack.DropItem( item );
  else
   item.Delete();
 }

 public void AddBlueBack( int width, int height )
 {
  AddBackground(0, 0, width, height, 9270);
  Closable=true;
  Disposable=true;
  Dragable=true;
  Resizable=false;
 }

 public MageGump( Mobile m ) : base ( 0, 0 )
 {
  PlayerMobile from = ( PlayerMobile ) m;
  AddBlueBack( 400, 250 );

  AddLabel( 20, 15, 1149, "Mage" );
  AddLabel( 20, 45, 255, string.Format( "Les mages lancent des sorts, écrivent des parchemins" ));
  AddLabel( 20, 60, 255, string.Format( "magiques et enchantent les objets. Ils sont généralement" ));
  AddLabel( 20, 75, 255, string.Format( "peu bavards mais forment des ennemis redoutables." ));

  AddLabel( 20, 105, 1149, string.Format( "Attributs de départ" ));
  AddLabel( 20, 135, 255, string.Format( "Force : {0}", "20" ));
  AddLabel( 20, 150, 255, string.Format( "Dextérité : {0}", "20" ));
  AddLabel( 20, 165, 255, string.Format( "Intelligence : {0}", "50" ));

  AddLabel( 40, 195, 255, string.Format( "Retour en arrière" ));
  AddLabel( 210, 195, 255, string.Format( "Je serai un(e) mage" ));

  AddButton( 20, 195, 0x2623, 0x2622, 1, GumpButtonType.Reply, 0 );
  AddButton( 190, 195, 0x2623, 0x2622, 2, GumpButtonType.Reply, 0 );
 }

 public override void OnResponse( NetState state, RelayInfo info )
 {
  Mobile from = state.Mobile;
  PlayerMobile m = ( PlayerMobile ) from;
  int val = info.ButtonID;

  switch(val)
  {
   case 0:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 1:
   {
    m.SendGump( new ClasseGump( from ) );
    break;
   }
   case 2:
   {
    m.Classe = (Classe) 3; // MAGE
    m.Title = "Mage";
    for (int i = 0; i < m.Skills.Length; i++)
    {
     if ( m.Skills[i].Name != "Alchemy" && m.Skills[i].Name != "Inscribe" && m.Skills[i].Name != "Magery" && m.Skills[i].Name != "Meditation" && m.Skills[i].Name != "MagicResist" && m.Skills[i].Name != "SpiritSpeak" && m.Skills[i].Name != "EvalInt" && m.Skills[i].Name != "Necromancy" )
     {
      m.Skills[i].Base = 0.0;
      m.Skills[i].Cap = 100.0;
     }
    }
    m.Skills[SkillName.Necromancy].Base = 0.0;
    m.Skills[SkillName.Necromancy].Cap = 150.0;

    m.Skills[SkillName.Alchemy].Base = 30.0;
    m.Skills[SkillName.Alchemy].Cap = 150.0;
    m.Skills[SkillName.Inscribe].Base = 30.0;
    m.Skills[SkillName.Inscribe].Cap = 150.0;
    m.Skills[SkillName.Magery].Base = 30.0;
    m.Skills[SkillName.Magery].Cap = 150.0;
    m.Skills[SkillName.Meditation].Base = 30.0;
    m.Skills[SkillName.Meditation].Cap = 150.0;
    m.Skills[SkillName.MagicResist].Base = 30.0;
    m.Skills[SkillName.MagicResist].Cap = 150.0;
    m.Skills[SkillName.SpiritSpeak].Base = 30.0;
    m.Skills[SkillName.SpiritSpeak].Cap = 150.0;
    m.Skills[SkillName.EvalInt].Base = 30.0;
    m.Skills[SkillName.EvalInt].Cap = 150.0;

    PackItem( new Bottle(), m );
    PackItem( new MortarPestle(), m );

    for (int i = 0; i < 2; i++)
    {
     switch ( ( Utility.Random( 8 ) * Utility.Random( 3 ) ) - 1 )
     {
      case  0: PackItem( new ClumsyScroll(), m ); break;
      case  1: PackItem( new CreateFoodScroll(), m ); break;
      case  2: PackItem( new FeeblemindScroll(), m ); break;
      case  3: PackItem( new HealScroll(), m ); break;
      case  4: PackItem( new MagicArrowScroll(), m ); break;
      case  5: PackItem( new NightSightScroll(), m ); break;
      case  6: PackItem( new ReactiveArmorScroll(), m ); break;
      case  7: PackItem( new WeakenScroll(), m ); break;
      case  8: PackItem( new AgilityScroll(), m ); break;
      case  9: PackItem( new CunningScroll(), m ); break;
      case 10: PackItem( new CureScroll(), m ); break;
      case 11: PackItem( new HarmScroll(), m ); break;
      case 12: PackItem( new MagicTrapScroll(), m ); break;
      case 13: PackItem( new MagicUnTrapScroll(), m ); break;
      case 14: PackItem( new ProtectionScroll(), m ); break;
      case 15: PackItem( new StrengthScroll(), m ); break;
      case 16: PackItem( new BlessScroll(), m ); break;
      case 17: PackItem( new FireballScroll(), m ); break;
      case 18: PackItem( new MagicLockScroll(), m ); break;
      case 19: PackItem( new PoisonScroll(), m ); break;
      case 20: PackItem( new TelekinisisScroll(), m ); break;
      case 21: PackItem( new TeleportScroll(), m ); break;
      case 22: PackItem( new UnlockScroll(), m ); break;
      case 23: PackItem( new WallOfStoneScroll(), m ); break;
     }
    }
//     EquipItem( new Robe( Utility.RandomBlueHue(), m ) );
//     EquipItem( new WizardsHat(), m );

//     Spellbook book = new Spellbook( (ulong)0x382A8C38 );
//     EquipItem( book, m );

//     BagOfReagents regs = new BagOfReagents( 30 );
    break;
   }
  }
 }
}
}


Scripts\Misc\CharacterCreation.cs
CODE
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Accounting;
using Server.Custom;
using Server.Scripts.Commands;
using Server.Gumps;
using Server.Targeting;

.......

 private static void EventSink_CharacterCreated( CharacterCreatedEventArgs args )
 {
  Mobile newChar = CreateMobile( args.Account as Account );

  if ( newChar == null )
  {
   Console.WriteLine( "Login: {0}: Character creation failed, account full", args.State );
   return;
  }

  args.Mobile = newChar;
  m_Mobile = newChar;

  newChar.Player = true;
  newChar.AccessLevel = ((Account)args.Account).AccessLevel;
  newChar.Female = args.Female;
  newChar.Body = newChar.Female ? 0x191 : 0x190;
  newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000;
  newChar.Hunger = 20;

  SetName( newChar, args.Name );

  AddBackpack( newChar );

  SetStats( newChar, args.Str, args.Dex, args.Int );
  SetSkills( newChar, args.Skills, args.Profession );

  AddHair( newChar, args.HairID, Utility.ClipHairHue( args.HairHue & 0x3FFF ) );
  AddBeard( newChar, args.BeardID, Utility.ClipHairHue( args.BeardHue & 0x3FFF ) );
  AddShirt( newChar, args.ShirtHue );
  AddPants( newChar, args.PantsHue );
  AddShoes( newChar );

  //CityInfo city = args.City;
  CityInfo city = new CityInfo( "Britain", "Sweet Dreams Inn", 1496, 1628, 10 );

  newChar.MoveToWorld( city.Location, Map.Felucca );

  Console.WriteLine( "Login: {0}: New character being created (account={1})", args.State, ((Account)args.Account).Username );
  Console.WriteLine( " - Character: {0} (serial={1})", newChar.Name, newChar.Serial );
  Console.WriteLine( " - Started: {0} {1}", city.City, city.Location );

  newChar.SendGump( new CharCreationGump( newChar ) );
 }

.......



Voici mes problèmes :

1) Le gump ne s'affiche pas automatiquement à la création d'un perso
2) Les items mentionnés (sauf pour l'artisan) ne s'ajoute pas ni ne s'équipe comme demandé
3) Pas un problème mais une question, comment ferais-je pour que la fonction EquipItem et Packitem ne soit écrite qu'une seule fois mais tout de même accessible de chacun des Gumps ?


Merci !

slade15 - September 26, 2004 08:32 AM (GMT)
3) oui c'est possible il suffi de l'ecrire dans le gump de base et elle sera visible dans tout les enfant de gump, mais cela n'a pas de sense car pour quelque chose qui sera util qu'a 3 gump ici tu vas l'ajouté a tout les gump de ton jeux, donc ne te le conseille pas

2) suite 3)
dans le Mobile de base il existe deja
CODE

public void AddItem ( Item);
public bool AddToBackpack (Item);
public virtual bool EquipItem (Item);


donc il est visible dans tout les vendeur,PlayerMobile, monstre, pnj, ...

donc essaye d'utiliser ca pour le 2)

exemple :
CODE

m.EquipItem( new FemaleLeatherChest());

je pense que si tu fait un AddItem il s'equipe deja (a tester)
donc voila essaye de jongler avec ces 3 la

1) j'ai deja vu que si on etais en mobile et pas playerMobile le gump s'affichais pas essaye
CODE

PlayerMobile player = (PlayerMobile) newChar;
player.SendGump( new CharCreationGump( player) );

Vortal - September 26, 2004 07:11 PM (GMT)
Ca fonctionne bien sauf pour le point 1)

Quelqu'un aurait une autre idée ?

Vortal - September 27, 2004 05:34 AM (GMT)
Problème corrigé. Merci à tous.

Zdravo - October 9, 2004 07:26 PM (GMT)
pourrais tu expliquer comment tu as corrigé ton problème :)

Il faut penser aux autres ;) :P

Vortal - October 12, 2004 11:49 PM (GMT)
Oups, désolé ! J'avoue ne pas y avoir pensé.. hehe Je poste la réponse dès que je remet la main sur mon backup (formattage..) !

Au pire, si c'est pressant, tu peux consulter la version "complète" du script ici : http://invisionfree.com/forums/Hyel_dev/in...p?showtopic=546




* Hosted for free by InvisionFree