Sirenix
Member
I'm trying to figure out how to make this work. So far I'm stumped. This same but of code works in my PM script, but doesnt seem to want to compile in the spell i've created. What it's supposed to do is, when a creature is cloned, if its night time, make them a werewolf instead of a human, otherwise make them their default body type. Heres the bit of code giving me the issue:
Heres the error: Which are all on line 76 in the above codeblock
and heres the whole spell script. With the exception of the time morph above it all compiles and works (with my highly modified PM)
Just a final thought, this was part of an old sicknesses system by GoldenDraco13 that I've torn inside out several times over the past 10 years. I'd be very thankful for any help. Thanks!
Code:
protected override void OnTick()
{
if ( m_Attacker.HarmfulCheck( m_Defender ) )
{
Mobile targ = (Mobile)m_Defender;
VampireCloneMage dg = new VampireCloneMage();
if (targ.Skills[SkillName.Magery].Base >= 50.0)
{
dg.AI = AIType.AI_Mage;
}
else if (targ.Skills[SkillName.Archery].Base >= 50.0)
{
dg.AI = AIType.AI_Archer;
}
else if (targ.Skills[SkillName.Necromancy].Base >= 50.0)
{
dg.AI = AIType.AI_Necro;
}
else if (targ.Skills[SkillName.Chivalry].Base >= 50.0)
{
dg.AI = AIType.AI_Paladin;
}
dg.Name = targ.Name;
dg.SpeechHue=targ.SpeechHue;
dg.Fame=targ.Fame;
dg.Karma=(0-targ.Karma);
dg.EmoteHue=targ.EmoteHue;
dg.Title="the Lycan";
dg.Criminal=(targ.Criminal);
dg.Str=targ.Str;
dg.Int=targ.Int;
dg.Hits=targ.Hits;
dg.Dex=targ.Dex;
dg.Mana=targ.Mana;
dg.Stam=targ.Stam;
dg.Female=targ.Female;
dg.TithingPoints=targ.TithingPoints;
dg.AccessLevel=targ.AccessLevel;
dg.VirtualArmor=(targ.VirtualArmor);
dg.SetSkill( SkillName.Wrestling, targ.Skills[SkillName.Wrestling].Value );
dg.SetSkill( SkillName.Tactics, targ.Skills[SkillName.Tactics].Value );
dg.SetSkill( SkillName.Anatomy, targ.Skills[SkillName.Anatomy].Value );
dg.SetSkill( SkillName.Magery, targ.Skills[SkillName.Magery].Value );
dg.SetSkill( SkillName.MagicResist, targ.Skills[SkillName.MagicResist].Value );
dg.SetSkill( SkillName.Meditation, targ.Skills[SkillName.Meditation].Value );
dg.SetSkill( SkillName.EvalInt, targ.Skills[SkillName.EvalInt].Value );
dg.SetSkill( SkillName.Archery, targ.Skills[SkillName.Archery].Value );
dg.SetSkill( SkillName.Macing, targ.Skills[SkillName.Macing].Value );
dg.SetSkill( SkillName.Swords, targ.Skills[SkillName.Swords].Value );
dg.SetSkill( SkillName.Fencing, targ.Skills[SkillName.Fencing].Value );
dg.SetSkill( SkillName.Lumberjacking, targ.Skills[SkillName.Lumberjacking].Value );
dg.SetSkill( SkillName.Alchemy, targ.Skills[SkillName.Alchemy].Value );
dg.SetSkill( SkillName.Parry, targ.Skills[SkillName.Parry].Value );
dg.SetSkill( SkillName.Focus, targ.Skills[SkillName.Focus].Value );
dg.SetSkill( SkillName.Necromancy, targ.Skills[SkillName.Necromancy].Value );
dg.SetSkill( SkillName.Chivalry, targ.Skills[SkillName.Chivalry].Value );
dg.SetSkill( SkillName.ArmsLore, targ.Skills[SkillName.ArmsLore].Value );
dg.SetSkill( SkillName.Poisoning, targ.Skills[SkillName.Poisoning].Value );
dg.SetSkill( SkillName.SpiritSpeak, targ.Skills[SkillName.SpiritSpeak].Value );
dg.SetSkill( SkillName.Stealing, targ.Skills[SkillName.Stealing].Value );
dg.SetSkill( SkillName.Inscribe, targ.Skills[SkillName.Inscribe].Value );
dg.Kills=(targ.Kills);
dg.ControlSlots=2;
SpellHelper.Summon( dg, m_Attacker, 0x215, TimeSpan.FromSeconds( 180.0 ), false, false );
//m_Attacker.Hunger = 20 ;
//m_Attacker.Thirst = 20 ;
targ.Damage( Utility.Random( 500, 500 ) );
m_Attacker.SendMessage( 0x35, "You taste Blood!" );
int hours, minutes;
Server.Items.Clock.GetTime( Caster.Map, Caster.X, Caster.Y, out hours, out minutes );
if ( hours <= 5 || hours >= 18 )
{
dg.Body = Utility.RandomList( 42, 719, 1070 );
dg.Hue = targ.HairHue;
if ( targ.HairHue == 0 )
{
dg.Hue = 1140;
}
}
if ( hours >= 6 && hours <= 17 )
{
dg.Body = targ.Body;
dg.Hue = targ.Hue;
}
}
}
Heres the error: Which are all on line 76 in the above codeblock
Code:
Errors:
+ My Customs/Systems/Custom Spells/Spells/Lycan/LycanTurn.cs:
CS0038: Line 405: Cannot access a non-static member of outer type 'Server.Spells.Spell' via nested type 'Server.Spells.Lycan.L
ycanTurn.InternalTimer'
CS0038: Line 405: Cannot access a non-static member of outer type 'Server.Spells.Spell' via nested type 'Server.Spells.Lycan.L
ycanTurn.InternalTimer'
CS0038: Line 405: Cannot access a non-static member of outer type 'Server.Spells.Spell' via nested type 'Server.Spells.Lycan.L
ycanTurn.InternalTimer'
and heres the whole spell script. With the exception of the time morph above it all compiles and works (with my highly modified PM)
Code:
using System;
using Server.Targeting;
using Server.Network;
using Server.Mobiles;
using Server.Items;
using System.Reflection;
namespace Server.Spells.Lycan
{
public class LycanTurn : LycanAbility
{
private static SpellInfo m_Info = new SpellInfo(
"Turn", "*Bares Teeth*",
230,
9022
);
public override TimeSpan CastDelayBase { get { return TimeSpan.FromSeconds( 1.0 ); } }
public override double RequiredSkill{ get{ return 0.0; } }
public override int RequiredMana{ get{ return 30; } }
//public override int RequiredHealth{ get{ return 40; } }
public LycanTurn( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
{
}
public override void OnCast()
{
PlayerMobile mplayer = Caster as PlayerMobile;
int hours, minutes;
Server.Items.Clock.GetTime( mplayer.Map, mplayer.X, mplayer.Y, out hours, out minutes );
if ( /*( hours <= 5 || hours >= 18 ) && */( mplayer.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.Lycan || mplayer.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanElf ||
mplayer.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanDrow || mplayer.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanOrc ))
{
if (mplayer.Blood <= 40 )
{
Caster.SendMessage( "You are too low on blood, using this would surely kill you." );
}
if ( mplayer.WerebeastType == LycanType.WereWolf || mplayer.WerebeastType == LycanType.ChampLycan )
Caster.Target = new InternalTarget( this );
else
{
Caster.SendMessage( "You are not powerful enough to use this ability yet." );
}
}
else
{
Caster.SendMessage( "You can not use this ability." );
}
}
public override bool DelayedDamage{ get{ return true; } }
public void Target( Mobile m )
{
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( CheckHSequence( m ) )
{
Mobile source = Caster;
SpellHelper.Turn( Caster, m );
if ( m is Mobile )
{
Mobile targ = (Mobile)m;
PlayerMobile caster = Caster as PlayerMobile;
if (targ is PlayerMobile)
{
PlayerMobile playertarg = targ as PlayerMobile;
if( playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.Lycan || playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanElf ||
playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanDrow || playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanOrc )
{
Caster.SendMessage( 0x35, "You can not turn one of your own kind." );
return;
}
else if(playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.Lycan || playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanElf ||
playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanDrow || playertarg.m_PlayerRaceType == Server.Mobiles.PlayerRaceType.LycanOrc)
{
if ( caster.WerebeastType == LycanType.WereWolf )
{
Caster.SendMessage( 0x35, "The vampire blood burns you." );
Caster.FixedParticles( 0x3735, 1, 30, 9503, EffectLayer.Waist );
Effects.SendLocationEffect(Caster.Location, Caster.Map,0x371C, 20);
Caster.PlaySound( Caster.Female ? 814 : 1088 );
Caster.Say( "*ahhhh!*" );
Caster.Damage( Utility.Random( 40, 75 ) );
targ.Damage( Utility.Random( 10, 15 ) );
targ.Stam -= 10; //tick away some stamina
Caster.DoHarmful( targ );
caster.Blood -= 40;
return;
}
else
{
if (playertarg.VampireType == VampType.Ancient)
{
Caster.SendMessage( 0x35, "The vampire blood burns you." );
Caster.FixedParticles( 0x3735, 1, 30, 9503, EffectLayer.Waist );
Effects.SendLocationEffect(Caster.Location, Caster.Map,0x371C, 20);
Caster.PlaySound( Caster.Female ? 814 : 1088 );
Caster.Say( "*ahhhh!*" );
Caster.Damage( Utility.Random( 20, 30 ) );
targ.Damage( Utility.Random( 20, 30 ) );
Caster.DoHarmful( targ );
targ.Stam -= 10; //tick away some stamina
targ.SendMessage( "You begin to feel dizzy from the loss of blood." );
caster.Blood -= 40;
}
else
{
Caster.SendMessage( 0x35, "The vampire blood burns you." );
Caster.FixedParticles( 0x3735, 1, 30, 9503, EffectLayer.Waist );
Effects.SendLocationEffect(Caster.Location, Caster.Map,0x371C, 20);
Caster.PlaySound( Caster.Female ? 814 : 1088 );
Caster.Say( "*ahhhh!*" );
Caster.Damage( Utility.Random( 10, 20 ) );
targ.Damage( Utility.Random( 15, 25 ) );
Caster.DoHarmful( targ );
playertarg.Sickness = SickFlag.LycanInfection;
targ.Stam -= 10; //tick away some stamina
targ.SendMessage( "You begin to feel dizzy from the loss of blood." );
caster.Blood -= 40;
}
}
}
else
{
playertarg.Damage( Utility.Random( 10, 25 ) );
Caster.Hunger = 20 ;
Caster.Thirst = 20 ;
caster.Blood -= 40;
Caster.DoHarmful( targ );
//targ.Hits -= 3; //tick away some health
targ.Stam -= 10; //tick away some stamina
targ.SendMessage( "You begin to feel dizzy from the loss of blood." );
if (playertarg.SImmune == false)
{
playertarg.Sickness = SickFlag.LycanInfection;
Caster.SendMessage( 0x35, "You taste Blood." );
}
if (playertarg.SImmune == true)
{
Caster.SendMessage( 0x35, "You bite them and drink their blood but they seem to be immune to your venom." );
}
}
}
if ( !targ.InRange( Caster, 2 ))
{
Caster.SendMessage( 0x35, "You must be closer to bite them." );
return;
}
if ( targ is BaseVendor )
{
Caster.SendMessage( 0x35, "You can't turn vendors." );
return;
}
if ( targ is BaseSABosses || targ is BaseRenowned || targ is BaseChampion || targ is MinaxBoss || targ is AuraOfMinax ||
targ is JakeSewer )
{
Caster.SendMessage( 0x35, "They are are immune to the lycan infection." );
return;
}
if ( targ is BaseCreature )
{
BaseCreature creature = (BaseCreature)targ;
if (creature.IsParagon)
{
Caster.SendMessage( 0x35, "They are are immune to the lycan infection." );
return;
}
else
{
if (targ.Body == 400 || targ.Body == 401 || targ.Body == 605 || targ.Body == 606 ||
targ.Body == 184 || targ.Body == 183 || targ.Body == 125 || targ.Body == 126 ||
targ.Body == 124 || targ.Body == 767 || targ.Body == 768 )
{
if (Caster.Followers>=3)
{
Caster.SendMessage("You couldn't control that if you did turn it.");
}
else
{
if ( targ.Spell != null )
targ.Spell.OnCasterHurt();
targ.Paralyzed = false;
targ.Animate( 32, 5, 1, true, false, 0 );
targ.ApplyPoison( targ, Poison.Regular );
InternalTimer t = new InternalTimer( this, caster, targ, m );
t.Start();
caster.Blood -= 40;
}
}
else
{
targ.Damage( Utility.Random( 5, 10 ) );
if ( caster.Blood >= 95 )
{
caster.Blood = 100;
}
else
{
caster.Blood += 5;
}
//Caster.Hunger = 20 ;
//Caster.Thirst = 20 ;
targ.Damage( Utility.Random( 5, 10 ) );
Caster.SendMessage( 0x35, "You can not turn them so you decide to feed instead." );
}
}
}
}
else
{
Caster.SendMessage( 0x35, "You can't turn that" );
}
}
FinishSequence();
}
public void CopyFromLayer( Mobile from, Mobile mimic, Layer layer )
{
if (from.FindItemOnLayer(layer) != null)
{
Item copy = (Item)from.FindItemOnLayer(layer);
Type t = copy.GetType();
ConstructorInfo[] info = t.GetConstructors();
foreach ( ConstructorInfo c in info )
{
//if ( !c.IsDefined( typeof( ConstructableAttribute ), false ) ) continue;
ParameterInfo[] paramInfo = c.GetParameters();
if ( paramInfo.Length == 0 )
{
object[] objParams = new object[0];
try
{
Item newItem=null;
object o = c.Invoke( objParams );
if ( o != null && o is Item )
{
newItem = (Item)o;
CopyProperties( newItem, copy );//copy.Dupe( item, copy.Amount );
newItem.Parent = null;
mimic.EquipItem(newItem);
}
if ( newItem!=null)
{
if ( newItem is BaseWeapon&& o is BaseWeapon)
{
BaseWeapon weapon=newItem as BaseWeapon;
BaseWeapon oweapon=o as BaseWeapon;
weapon.Attributes=oweapon.Attributes;
weapon.WeaponAttributes=oweapon.WeaponAttributes;
}
if ( newItem is BaseArmor&& o is BaseArmor)
{
BaseArmor armor=newItem as BaseArmor;
BaseArmor oarmor=o as BaseArmor;
armor.Attributes=oarmor.Attributes;
armor.ArmorAttributes=oarmor.ArmorAttributes;
armor.SkillBonuses=oarmor.SkillBonuses;
}
mimic.EquipItem(newItem);
}
}
catch
{
from.Say( "Error!" );
return;
}
}
}
}
if (mimic.FindItemOnLayer(layer) != null && mimic.FindItemOnLayer(layer).LootType != LootType.Blessed)
mimic.FindItemOnLayer(layer).LootType = LootType.Newbied;
}
public void DupeFromLayer( Mobile from, Mobile mimic, Layer layer )
{
//if (from.FindItemOnLayer(layer) != null)
// mimic.AddItem(from.FindItemOnLayer(layer).Dupe(1));
if (mimic.FindItemOnLayer(layer) != null && mimic.FindItemOnLayer(layer).LootType != LootType.Blessed)
mimic.FindItemOnLayer(layer).LootType = LootType.Newbied;
}
public static void CopyProperties ( Item dest, Item src )
{
PropertyInfo[] props = src.GetType().GetProperties();
for ( int i = 0; i < props.Length; i++ )
{
try
{
if ( props[i].CanRead && props[i].CanWrite )
{
//Console.WriteLine( "Setting {0} = {1}", props[i].Name, props[i].GetValue( src, null ) );
props[i].SetValue( dest, props[i].GetValue( src, null ), null );
}
}
catch
{
//Console.WriteLine( "Denied" );
}
}
}
public void DeleteFromLayer( Mobile from, Layer layer )
{
if (from.FindItemOnLayer(layer) != null)
from.RemoveItem(from.FindItemOnLayer(layer));
}
public void RemoveFromAllLayers(Mobile from)
{
DeleteFromLayer(from, Layer.FirstValid);
DeleteFromLayer(from, Layer.TwoHanded);
DeleteFromLayer(from, Layer.Shoes);
DeleteFromLayer(from, Layer.Pants);
DeleteFromLayer(from, Layer.Shirt);
DeleteFromLayer(from, Layer.Helm);
DeleteFromLayer(from, Layer.Gloves);
DeleteFromLayer(from, Layer.Ring);
DeleteFromLayer(from, Layer.Talisman);
DeleteFromLayer(from, Layer.Neck);
DeleteFromLayer(from, Layer.Hair);
DeleteFromLayer(from, Layer.Waist);
DeleteFromLayer(from, Layer.InnerTorso);
DeleteFromLayer(from, Layer.Bracelet);
DeleteFromLayer(from, Layer.Unused_xF);
DeleteFromLayer(from, Layer.FacialHair);
DeleteFromLayer(from, Layer.MiddleTorso);
DeleteFromLayer(from, Layer.Earrings);
DeleteFromLayer(from, Layer.Arms);
DeleteFromLayer(from, Layer.Cloak);
DeleteFromLayer(from, Layer.OuterTorso);
DeleteFromLayer(from, Layer.OuterLegs);
DeleteFromLayer(from, Layer.LastUserValid);
DeleteFromLayer(from, Layer.Mount);
}
private class InternalTimer : Timer
{
private Spell m_Spell;
private Mobile m_Target;
private Mobile m_Attacker, m_Defender;
public InternalTimer( Spell spell, Mobile attacker, Mobile defender, Mobile target ) : base( TimeSpan.FromSeconds( Core.AOS ? 10.0 : 10.0 ) )
{
m_Spell = spell;
m_Attacker = attacker;
m_Defender = defender;
m_Target = target;
Priority = TimerPriority.FiftyMS;
}
protected override void OnTick()
{
if ( m_Attacker.HarmfulCheck( m_Defender ) )
{
Mobile targ = (Mobile)m_Defender;
VampireCloneMage dg = new VampireCloneMage();
if (targ.Skills[SkillName.Magery].Base >= 50.0)
{
dg.AI = AIType.AI_Mage;
}
else if (targ.Skills[SkillName.Archery].Base >= 50.0)
{
dg.AI = AIType.AI_Archer;
}
else if (targ.Skills[SkillName.Necromancy].Base >= 50.0)
{
dg.AI = AIType.AI_Necro;
}
else if (targ.Skills[SkillName.Chivalry].Base >= 50.0)
{
dg.AI = AIType.AI_Paladin;
}
dg.Name = targ.Name;
dg.SpeechHue=targ.SpeechHue;
dg.Fame=targ.Fame;
dg.Karma=(0-targ.Karma);
dg.EmoteHue=targ.EmoteHue;
dg.Title="the Lycan";
dg.Criminal=(targ.Criminal);
dg.Str=targ.Str;
dg.Int=targ.Int;
dg.Hits=targ.Hits;
dg.Dex=targ.Dex;
dg.Mana=targ.Mana;
dg.Stam=targ.Stam;
dg.Female=targ.Female;
dg.TithingPoints=targ.TithingPoints;
dg.AccessLevel=targ.AccessLevel;
dg.VirtualArmor=(targ.VirtualArmor);
dg.SetSkill( SkillName.Wrestling, targ.Skills[SkillName.Wrestling].Value );
dg.SetSkill( SkillName.Tactics, targ.Skills[SkillName.Tactics].Value );
dg.SetSkill( SkillName.Anatomy, targ.Skills[SkillName.Anatomy].Value );
dg.SetSkill( SkillName.Magery, targ.Skills[SkillName.Magery].Value );
dg.SetSkill( SkillName.MagicResist, targ.Skills[SkillName.MagicResist].Value );
dg.SetSkill( SkillName.Meditation, targ.Skills[SkillName.Meditation].Value );
dg.SetSkill( SkillName.EvalInt, targ.Skills[SkillName.EvalInt].Value );
dg.SetSkill( SkillName.Archery, targ.Skills[SkillName.Archery].Value );
dg.SetSkill( SkillName.Macing, targ.Skills[SkillName.Macing].Value );
dg.SetSkill( SkillName.Swords, targ.Skills[SkillName.Swords].Value );
dg.SetSkill( SkillName.Fencing, targ.Skills[SkillName.Fencing].Value );
dg.SetSkill( SkillName.Lumberjacking, targ.Skills[SkillName.Lumberjacking].Value );
dg.SetSkill( SkillName.Alchemy, targ.Skills[SkillName.Alchemy].Value );
dg.SetSkill( SkillName.Parry, targ.Skills[SkillName.Parry].Value );
dg.SetSkill( SkillName.Focus, targ.Skills[SkillName.Focus].Value );
dg.SetSkill( SkillName.Necromancy, targ.Skills[SkillName.Necromancy].Value );
dg.SetSkill( SkillName.Chivalry, targ.Skills[SkillName.Chivalry].Value );
dg.SetSkill( SkillName.ArmsLore, targ.Skills[SkillName.ArmsLore].Value );
dg.SetSkill( SkillName.Poisoning, targ.Skills[SkillName.Poisoning].Value );
dg.SetSkill( SkillName.SpiritSpeak, targ.Skills[SkillName.SpiritSpeak].Value );
dg.SetSkill( SkillName.Stealing, targ.Skills[SkillName.Stealing].Value );
dg.SetSkill( SkillName.Inscribe, targ.Skills[SkillName.Inscribe].Value );
dg.Kills=(targ.Kills);
dg.ControlSlots=2;
SpellHelper.Summon( dg, m_Attacker, 0x215, TimeSpan.FromSeconds( 180.0 ), false, false );
//m_Attacker.Hunger = 20 ;
//m_Attacker.Thirst = 20 ;
targ.Damage( Utility.Random( 500, 500 ) );
m_Attacker.SendMessage( 0x35, "You taste Blood!" );
int hours, minutes;
Server.Items.Clock.GetTime( Caster.Map, Caster.X, Caster.Y, out hours, out minutes );
if ( hours <= 5 || hours >= 18 )
{
dg.Body = Utility.RandomList( 42, 719, 1070 );
dg.Hue = targ.HairHue;
if ( targ.HairHue == 0 )
{
dg.Hue = 1140;
}
}
if ( hours >= 6 && hours <= 17 )
{
dg.Body = targ.Body;
dg.Hue = targ.Hue;
}
}
}
}
private class InternalTarget : Target
{
private LycanTurn m_Owner;
public InternalTarget( LycanTurn owner ) : base( 12, false, TargetFlags.Harmful )
{
m_Owner = owner;
}
protected override void OnTarget( Mobile from, object o )
{
if ( o is Mobile )
m_Owner.Target( (Mobile)o );
}
protected override void OnTargetFinish( Mobile from )
{
m_Owner.FinishSequence();
}
}
}
}
Just a final thought, this was part of an old sicknesses system by GoldenDraco13 that I've torn inside out several times over the past 10 years. I'd be very thankful for any help. Thanks!
Last edited: