Adding Loot in a single monster
First, let us open IceSerpent.cs (found in '\Scripts\Mobiles\Animals\Reptiles') and find Line 1 - 63, they look like this:
Code:
using System;
using Server.Items;
using Server.Mobiles;
namespace Server.Mobiles
{
[CorpseName( "an ice serpent corpse" )]
[TypeAlias( "Server.Mobiles.Iceserpant" )]
public class IceSerpent : BaseCreature
{
[Constructable]
public IceSerpent() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
{
Name = "a giant ice serpent";
Body = 89;
BaseSoundID = 219;
SetStr( 216, 245 );
SetDex( 26, 50 );
SetInt( 66, 85 );
SetHits( 130, 147 );
SetMana( 0 );
SetDamage( 7, 17 );
SetDamageType( ResistanceType.Physical, 10 );
SetDamageType( ResistanceType.Cold, 90 );
SetResistance( ResistanceType.Physical, 30, 35 );
SetResistance( ResistanceType.Cold, 80, 90 );
SetResistance( ResistanceType.Poison, 15, 25 );
SetResistance( ResistanceType.Energy, 10, 20 );
SetSkill( SkillName.Anatomy, 27.5, 50.0 );
SetSkill( SkillName.MagicResist, 25.1, 40.0 );
SetSkill( SkillName.Tactics, 75.1, 80.0 );
SetSkill( SkillName.Wrestling, 60.1, 80.0 );
Fame = 3500;
Karma = -3500;
VirtualArmor = 32;
PackItem( Loot.RandomArmorOrShieldOrWeapon() );
switch ( Utility.Random( 10 ))
{
case 0: PackItem( new LeftArm() ); break;
case 1: PackItem( new RightArm() ); break;
case 2: PackItem( new Torso() ); break;
case 3: PackItem( new Bone() ); break;
case 4: PackItem( new RibCage() ); break;
case 5: PackItem( new RibCage() ); break;
case 6: PackItem( new BonePile() ); break;
case 7: PackItem( new BonePile() ); break;
case 8: PackItem( new BonePile() ); break;
case 9: PackItem( new BonePile() ); break;
}
if ( 0.025 > Utility.RandomDouble() )
PackItem( new GlacialStaff() );
}
Notice the three colors, Green, Blue and Orange. They each mark a method for adding loot, each method is usable in different situations. Let's break em down.
The Green section
This line of code use a utility, a utility defined in LootPack.cs, but let's keep things simple, the line could be changed from "PackItem( Loot.RandomArmorOrShieldOrWeapon() );" to "PackItem( new Spear() );"
This would add, instead of a random Armor, shield or weapon, a Spear to the mob backpack (the mob will carry it in its backpack, not only "drop" it). You can replace "Spear()" with any item.
The Blue section
This is a nifty bit of code, the first line is a randomizer, it will pick a number from 0 to 9.
The lines after the first line define what happens if that particular number would be chosen.
For example, if the randomizer choose the number 5 then this code will execute: "case 5: PackItem( new RibCage() ); break;", meaning a Rib Cage will be placed will be placed in the mobiles' backpack.
The Orange section
This is my favorite method, it is a randomizer aswell, but this time it's a so-called Double, instead of a whole-number.
The randomizer will pic a number from 0.00001 to 0.999, or in simpler terms (by moving the decimal two places to the right):
It will choose a number from 0.01% to 99.99%.
So the first line of the Orange section tells us:
"if ( 0.025 > Utility.RandomDouble() )"
If the randomizer choose a number lower then 0.025 (2.5%), then the code on the next line "PackItem( new GlacialStaff() );" will be executed.
If the randomizer choose, let's say 0.03 (3%), the code won't be executed and the Glacial Staff won't drop.
If you would want a Glacial staff to drop 50% of the time, you would write:
if ( 0.5 > Utility.RandomDouble() )
99%
"if ( 0.99 > Utility.RandomDouble() )"
75%
"if ( 0.75 > Utility.RandomDouble() )"
1%
"if ( 0.01 > Utility.RandomDouble() )"
0.1%
"if ( 0.001 > Utility.RandomDouble() )"