Full Version : Randomness
xmlspawner >>Scripting Support >>Randomness


<< Prev | Next >>

Odee- 02-12-2006
Okay, heres what I want to do, but I just dont know how I would do it.

I want the resists on an item to be totally random. Here is what the Base Resists look like on the item.

CODE


 public override int BasePhysicalResistance{ get{ return 5; } }
 public override int BaseFireResistance{ get{ return 6; } }
 public override int BaseColdResistance{ get{ return 4; } }
 public override int BasePoisonResistance{ get{ return 7; } }
 public override int BaseEnergyResistance{ get{ return 6; } }


I want the resists to go anywhere from 2-10, not exceding 10 or going below 2.

How would I go by doing this?

__________

Also, I want this

CODE

int x_Rand;
int x_Rand = Utility.Random(5)
SkillBonuses.SetValues( 0, SkillName.Chivalry, int x_Rand );


to be anywhere from +1 - 5, not exceding 5 and not going below 1. If there is any way to do this that would be totally cool. Thanks happy.gif

If you need the script, here it is.

CODE

// Created by Odee. This script is still in Beta testing. If anyone would like to use this beta script and modify it for use on his/her server, please include my name in the script. Thank you

using System;
using Server.Items;

namespace Server.Items
{
[FlipableAttribute( 0x1415, 0x1416 )]
public class AlastarsBreastplateofJustice : PlateChest
{
 public override int BasePhysicalResistance{ get{ return 5; } }
 public override int BaseFireResistance{ get{ return 6; } }
 public override int BaseColdResistance{ get{ return 4; } }
 public override int BasePoisonResistance{ get{ return 7; } }
 public override int BaseEnergyResistance{ get{ return 6; } }

 public override int InitMinHits{ get{ return 150; } }
 public override int InitMaxHits{ get{ return 150; } }

 public override int AosStrReq{ get{ return 75; } }
 public override int OldStrReq{ get{ return 60; } }

 public override ArmorMaterialType MaterialType{ get{ return ArmorMaterialType.Plate; } }

 [Constructable]
 public AlastarsBreastplateofJustice()
 
{
  Weight = 10.0;
  Name = "Alastars Breastplate of Justice";
  Hue = 0x24F; // 591
 
  int x_Rand;
  x_Rand = Utility.Random(5);
  SkillBonuses.SetValues( 0, SkillName.Chivalry, x_Rand);
 
  int x_Rand1;
  x_Rand1 = Utility.Random(7);
  SkillBonuses.SetValues( 1, SkillName.Focus, x_Rand1);
 
 
  // Attributes here

 
 
 

 
 }
 
 public override bool OnEquip( Mobile from )
 {
  from.PlaySound( 0x202 );
  from.FixedParticles( 0x376A, 1, 62, 9923, 3, 3, EffectLayer.Waist );
     from.FixedParticles( 0x3779, 1, 46, 9502, 5, 3, EffectLayer.Waist );
     from.SendMessage("The Virtue of Justice flows through your veins as you equip the Breastplate.");
     return base.OnEquip( from );
 }

 

 public AlastarsBreastplateofJustice( Serial serial ) : base( serial )
 {
 }
 
 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );
  writer.Write( (int) 0 );
 }
 
 public override void Deserialize(GenericReader reader)
 {
  base.Deserialize( reader );
  int version = reader.ReadInt();
 }
}
}


Any help is much appreciated. Thanks smile.gif

ArteGordon- 02-12-2006
you would not modify the base resists, you would change the resistance bonuses, and you pretty much had the skill bonus call correct, like

QUOTE

[Constructable]
public AlastarsBreastplateofJustice()

{
  Weight = 10.0;
  Name = "Alastars Breastplate of Justice";
  Hue = 0x24F; // 591

  int x_Rand;
  x_Rand = Utility.Random(5);
  SkillBonuses.SetValues( 0, SkillName.Chivalry, x_Rand);

  int x_Rand1;
  x_Rand1 = Utility.Random(7);
  SkillBonuses.SetValues( 1, SkillName.Focus, x_Rand1);


  // Attributes here


FireBonus = Utility.Random(5);

SkillBonuses.SetValues( 0, SkillName.Chivalry, Utility.Random(5) );



}


look at the docs or in basearmor.cs for other bonus properties.

Odee- 02-12-2006
Okay thanks. Ill try that and see what happens.

Odee- 02-12-2006
Right on. It worked. Thanks a load. Now to add attributes to it. Thanks smile.gif