#region AuthorHeader
//
// Claim System version 1.0, by Xanthos
//
//
#endregion AuthorHeader
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Misc;
using Server.Spells;
using Server.Guilds;
using Server.Mobiles;
using Server.Targeting;
using Server.Engines.PartySystem;
using Server.Commands;
namespace Xanthos.Claim
{
public class Claim
{
public static void Initialize()
{
if ( ClaimConfig.EnableClaim )
CommandSystem.Register( "Claim", AccessLevel.Player, new CommandEventHandler( Claim_OnCommand ) );
if ( ClaimConfig.EnableGrab )
CommandSystem.Register( "Grab", AccessLevel.Player, new CommandEventHandler( Grab_OnCommand ) );
}
[Usage( "Claim" )]
[Description( "Claim a corpse for Gold" )]
public static void Claim_OnCommand( CommandEventArgs e )
{
e.Mobile.Target = new ClaimCmdTarget();
e.Mobile.SendMessage( "Choose a corpse to claim for gold." );
}
public static void Reclaim( Mobile from )
{
from.Target = new ClaimCmdTarget();
from.SendMessage( "Choose another corpse to claim." );
}
[Usage( "Grab" )]
[Description( "Grab lootable items off of the ground and claim nearby corpses." )]
public static void Grab_OnCommand( CommandEventArgs e )
{
Mobile from = e.Mobile;
if ( from.Alive == false )
{
from.PlaySound( 1069 ); //hey
from.SendMessage( "You cannot do that while you are dead!" );
return;
}
else if ( 0 != ClaimConfig.CompetitiveGrabRadius && BlockingMobilesInRange( from, ClaimConfig.GrabRadius ))
{
from.PlaySound( 1069 ); //hey
from.SendMessage( "You are too close to another player to do that!" );
return;
}
ArrayList items = new ArrayList();
ArrayList corpses = new ArrayList();
foreach ( Item item in from.GetItemsInRange( ClaimConfig.GrabRadius ))
{
if ( CorpseIsLootable( from, item as Corpse ))
corpses.Add( item );
else if ( ((IList)(ClaimConfig.TypesToLoot)).Contains( item.GetType()) || ( ClaimConfig.LootArtifacts && ItemIsArtifact( item ) ))
items.Add( item );
}
foreach ( Item item in items )
{
if ( item is Gold )
DropGold( from, item as Gold );
else
from.Backpack.DropItem( item );
}
foreach ( Item item in corpses )
ClaimCorpse( from, item as Corpse );
}
public static void ClaimCorpse( Mobile from , Corpse corpse )
{
LootCorpse( from, corpse );
AwardGold( from, corpse );
corpse.Delete();
from.SendMessage( "You claim the corpse and recieve a reward." );
}
public static void AwardGold( Mobile from , Corpse corpse )
{
int amount = Math.Max(( corpse.Owner.Fame ) / ClaimConfig.FameDivisor, ClaimConfig.MinimumReward );
DropGold( from, new Gold( amount ));
}
public static void DropGold( Mobile from, Gold gold )
{
Container goldBag = from.Backpack.FindItemByType( ClaimConfig.GoldBagType ) as Container;
if ( null == goldBag )
goldBag = from.Backpack;
if ( !goldBag.TryDropItem( from, gold, false )) // Attempt to stack it
goldBag.DropItem( gold );
from.PlaySound( 0x2E6 ); // drop gold sound
}
public static void LootCorpse( Mobile from, Corpse corpse )
{
if ( null == ClaimConfig.TypesToLoot )
return;
ArrayList items = new ArrayList( corpse.Items.Count );
foreach( Item item in corpse.Items )
{
if ( ((IList)(ClaimConfig.TypesToLoot)).Contains( item.GetType()) || ( ClaimConfig.LootArtifacts && ItemIsArtifact( item ) ))
items.Add( item );
}
for( int i = 0; i < items.Count; i++ )
{
if ( items[ i ] is Gold )
DropGold( from, items[ i ] as Gold );
else
from.AddToBackpack( (Item)items[ i ] );
}
}
private static bool CorpseIsLootable( Mobile from, Corpse corpse )
{
if ( null == corpse )
return false;
bool result = false;
if ( corpse.Owner is PlayerMobile && !ClaimConfig.LootPlayers && from != corpse.Owner )
{
from.PlaySound( 1074 ); // no
from.SendMessage( "You may not loot player corpses." );
}
else
{
BaseCreature creature = corpse.Owner as BaseCreature;
if ( null != creature && creature.IsBonded )
{
from.PlaySound( 1074 ); // no
from.SendMessage( "You may not loot the corpses of bonded pets." );
}
else if ( null != creature && corpse.Owner.Fame <= ClaimConfig.FreelyLootableFame )
result = true;
else
result = corpse.CheckLoot( from ) && !( corpse.IsCriminalAction( from ) );
}
return result;
}
public static bool BlockingMobilesInRange( Mobile from, int range )
{
foreach ( Mobile mobile in from.GetMobilesInRange( range ) )
{
if ( mobile is PlayerMobile && IsBlockingMobile( from, mobile ))
return true;
}
return false;
}
public static bool IsBlockingMobile( Mobile looter, Mobile other )
{
if ( looter == other )
return false;
Guild looterGuild = SpellHelper.GetGuildFor( looter );
Guild otherGuild = SpellHelper.GetGuildFor( other );
if ( null != looterGuild && null != otherGuild && ( looterGuild == otherGuild || looterGuild.IsAlly( otherGuild )))
return false;
Party party = Party.Get( looter );
return !( null != party && party.Contains( other ) );
}
private static bool ItemIsArtifact( Item item )
{
bool result = false;
if ( item is BaseWeapon && ((BaseWeapon)item).ArtifactRarity != 0 )
result = true;
else if ( item is BaseArmor && ((BaseArmor)item).ArtifactRarity != 0 )
result = true;
else if ( item is BaseClothing && ((BaseClothing)item).ArtifactRarity != 0 )
result = true;
else if ( item is BaseJewel && ((BaseJewel)item).ArtifactRarity != 0 )
result = true;
return result;
}
private class ClaimCmdTarget : Target
{
public ClaimCmdTarget() : base( ClaimConfig.ClaimRadius, false, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object target )
{
Corpse corpse = target as Corpse;
if ( from.Alive == false )
{
from.PlaySound( 1069 ); //hey
from.SendMessage( "You cannot do that while you are dead!" );
}
else if ( 0 != ClaimConfig.CompetitiveClaimRadius && BlockingMobilesInRange( from, ClaimConfig.CompetitiveClaimRadius ))
{
from.PlaySound( 1069 ); //hey
from.SendMessage( "You are too close to another player to do that!" );
}
else if ( null == corpse )
{
from.PlaySound( 1066 ); // giggle
from.SendMessage( "That isn't a corpse!" );
}
else if ( CorpseIsLootable( from, corpse ))
{
Claim.ClaimCorpse( from, corpse );
Reclaim( from );
}
}
}
}
}
clarissa;848097 said:I added this last night. Was able to fix some but this just has me going in circles lol. Help please.Line 161 No overload method for check loot takes 1 argumentsCode:#region AuthorHeader // // Claim System version 1.0, by Xanthos // // #endregion AuthorHeader using System; using System.Collections; using Server; using Server.Items; using Server.Misc; using Server.Spells; using Server.Guilds; using Server.Mobiles; using Server.Targeting; using Server.Engines.PartySystem; using Server.Commands; namespace Xanthos.Claim { public class Claim { public static void Initialize() { if ( ClaimConfig.EnableClaim ) CommandSystem.Register( "Claim", AccessLevel.Player, new CommandEventHandler( Claim_OnCommand ) ); if ( ClaimConfig.EnableGrab ) CommandSystem.Register( "Grab", AccessLevel.Player, new CommandEventHandler( Grab_OnCommand ) ); } [Usage( "Claim" )] [Description( "Claim a corpse for Gold" )] public static void Claim_OnCommand( CommandEventArgs e ) { e.Mobile.Target = new ClaimCmdTarget(); e.Mobile.SendMessage( "Choose a corpse to claim for gold." ); } public static void Reclaim( Mobile from ) { from.Target = new ClaimCmdTarget(); from.SendMessage( "Choose another corpse to claim." ); } [Usage( "Grab" )] [Description( "Grab lootable items off of the ground and claim nearby corpses." )] public static void Grab_OnCommand( CommandEventArgs e ) { Mobile from = e.Mobile; if ( from.Alive == false ) { from.PlaySound( 1069 ); //hey from.SendMessage( "You cannot do that while you are dead!" ); return; } else if ( 0 != ClaimConfig.CompetitiveGrabRadius && BlockingMobilesInRange( from, ClaimConfig.GrabRadius )) { from.PlaySound( 1069 ); //hey from.SendMessage( "You are too close to another player to do that!" ); return; } ArrayList items = new ArrayList(); ArrayList corpses = new ArrayList(); foreach ( Item item in from.GetItemsInRange( ClaimConfig.GrabRadius )) { if ( CorpseIsLootable( from, item as Corpse )) corpses.Add( item ); else if ( ((IList)(ClaimConfig.TypesToLoot)).Contains( item.GetType()) || ( ClaimConfig.LootArtifacts && ItemIsArtifact( item ) )) items.Add( item ); } foreach ( Item item in items ) { if ( item is Gold ) DropGold( from, item as Gold ); else from.Backpack.DropItem( item ); } foreach ( Item item in corpses ) ClaimCorpse( from, item as Corpse ); } public static void ClaimCorpse( Mobile from , Corpse corpse ) { LootCorpse( from, corpse ); AwardGold( from, corpse ); corpse.Delete(); from.SendMessage( "You claim the corpse and recieve a reward." ); } public static void AwardGold( Mobile from , Corpse corpse ) { int amount = Math.Max(( corpse.Owner.Fame ) / ClaimConfig.FameDivisor, ClaimConfig.MinimumReward ); DropGold( from, new Gold( amount )); } public static void DropGold( Mobile from, Gold gold ) { Container goldBag = from.Backpack.FindItemByType( ClaimConfig.GoldBagType ) as Container; if ( null == goldBag ) goldBag = from.Backpack; if ( !goldBag.TryDropItem( from, gold, false )) // Attempt to stack it goldBag.DropItem( gold ); from.PlaySound( 0x2E6 ); // drop gold sound } public static void LootCorpse( Mobile from, Corpse corpse ) { if ( null == ClaimConfig.TypesToLoot ) return; ArrayList items = new ArrayList( corpse.Items.Count ); foreach( Item item in corpse.Items ) { if ( ((IList)(ClaimConfig.TypesToLoot)).Contains( item.GetType()) || ( ClaimConfig.LootArtifacts && ItemIsArtifact( item ) )) items.Add( item ); } for( int i = 0; i < items.Count; i++ ) { if ( items[ i ] is Gold ) DropGold( from, items[ i ] as Gold ); else from.AddToBackpack( (Item)items[ i ] ); } } private static bool CorpseIsLootable( Mobile from, Corpse corpse ) { if ( null == corpse ) return false; bool result = false; if ( corpse.Owner is PlayerMobile && !ClaimConfig.LootPlayers && from != corpse.Owner ) { from.PlaySound( 1074 ); // no from.SendMessage( "You may not loot player corpses." ); } else { BaseCreature creature = corpse.Owner as BaseCreature; if ( null != creature && creature.IsBonded ) { from.PlaySound( 1074 ); // no from.SendMessage( "You may not loot the corpses of bonded pets." ); } else if ( null != creature && corpse.Owner.Fame <= ClaimConfig.FreelyLootableFame ) result = true; else result = corpse.CheckLoot( from ) && !( corpse.IsCriminalAction( from ) ); } return result; } public static bool BlockingMobilesInRange( Mobile from, int range ) { foreach ( Mobile mobile in from.GetMobilesInRange( range ) ) { if ( mobile is PlayerMobile && IsBlockingMobile( from, mobile )) return true; } return false; } public static bool IsBlockingMobile( Mobile looter, Mobile other ) { if ( looter == other ) return false; Guild looterGuild = SpellHelper.GetGuildFor( looter ); Guild otherGuild = SpellHelper.GetGuildFor( other ); if ( null != looterGuild && null != otherGuild && ( looterGuild == otherGuild || looterGuild.IsAlly( otherGuild ))) return false; Party party = Party.Get( looter ); return !( null != party && party.Contains( other ) ); } private static bool ItemIsArtifact( Item item ) { bool result = false; if ( item is BaseWeapon && ((BaseWeapon)item).ArtifactRarity != 0 ) result = true; else if ( item is BaseArmor && ((BaseArmor)item).ArtifactRarity != 0 ) result = true; else if ( item is BaseClothing && ((BaseClothing)item).ArtifactRarity != 0 ) result = true; else if ( item is BaseJewel && ((BaseJewel)item).ArtifactRarity != 0 ) result = true; return result; } private class ClaimCmdTarget : Target { public ClaimCmdTarget() : base( ClaimConfig.ClaimRadius, false, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object target ) { Corpse corpse = target as Corpse; if ( from.Alive == false ) { from.PlaySound( 1069 ); //hey from.SendMessage( "You cannot do that while you are dead!" ); } else if ( 0 != ClaimConfig.CompetitiveClaimRadius && BlockingMobilesInRange( from, ClaimConfig.CompetitiveClaimRadius )) { from.PlaySound( 1069 ); //hey from.SendMessage( "You are too close to another player to do that!" ); } else if ( null == corpse ) { from.PlaySound( 1066 ); // giggle from.SendMessage( "That isn't a corpse!" ); } else if ( CorpseIsLootable( from, corpse )) { Claim.ClaimCorpse( from, corpse ); Reclaim( from ); } } } } }
result = corpse.CheckLoot( from ) && !( corpse.IsCriminalAction( from ) );
result = corpse.CheckLoot( from, corpse ) && !( corpse.IsCriminalAction( from ) );
//Add it here
}
}
//Mod to allow players to double click gold and add to ledger
public override void OnDoubleClick( Mobile m )
{
if ( this.Movable )
{
Item[] items = m.Backpack.FindItemsByType( typeof( GoldLedger ) );
foreach( GoldLedger ledger in items )
{
if ( ledger.Gold + this.Amount <= 2000000000 )
{
ledger.Gold = ( ledger.Gold + Amount );
this.Delete();
m.SendMessage( "You added {0} gold to your gold ledger.", Amount );
break;
}
}
}
}
public static bool Withdraw( Mobile from, int amount )
{
#region Edit to make the bank use ledger first
if ( from.Backpack != null )
{
Item item = from.Backpack.FindItemByType( typeof( GoldLedger ) );
GoldLedger ledger = item as GoldLedger;
Item[] item2 = from.Backpack.FindItemsByType( typeof( Gold ) );
int goldint = 0;
foreach ( Item item3 in item2 )
goldint += item3.Amount;
if ( from.Backpack.ConsumeTotal( typeof( Gold ), amount ) )
{
from.SendMessage(2125, "{0} gold has been withdrawn from your backpack.", amount.ToString( "#,0" ));
return true;
}
else if ( ledger != null )
{
if ( ( goldint + ledger.Gold ) >= amount )
{
ledger.Gold -= (amount - goldint);
from.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger and/or backpack.", (amount - goldint).ToString( "#,0" ));
from.Backpack.ConsumeTotal( typeof( Gold ), goldint );
return true;
}
else if ( ledger.Gold >= amount )
{
ledger.Gold -= amount;
from.SendMessage(2125, "{0} gold has been withdrawn from your gold ledger.", amount.ToString( "#,0" ));
return true;
}
}
}
#endregion
James420;866373 said:The bags come with this claim system that is included in the first download.
Pyro Man;866544 said:Really? I downloaded it and they weren't in it. I'll try it again i suppose.