本文整理汇总了C#中MUDEngine.CharData.HasSpell方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.HasSpell方法的具体用法?C# CharData.HasSpell怎么用?C# CharData.HasSpell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUDEngine.CharData
的用法示例。
在下文中一共展示了CharData.HasSpell方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckSpellup
// This _function should prevent a mob from spamming
// spellups on itself if it is already affected by the spell.
// in the Spellup() _function, checks for Affect.AFFECT_WHATEVER
// still need to be done. - Xangis
static bool CheckSpellup( CharData ch, string name, int percent )
{
if (ch == null) return false;
if (String.IsNullOrEmpty(name))
return false;
Spell spell = Spell.SpellList[name];
if (spell == null)
{
return false;
}
// Keep mobs from casting spells they are affected by
if( ch.HasAffect( Affect.AffectType.spell, spell ) )
return false;
if( ( ch.HasSpell( name ) )
&& ( MUDMath.NumberPercent() < percent ) )
{
if (spell.ValidTargets != TargetType.singleCharacterDefensive &&
spell.ValidTargets != TargetType.self)
Log.Error( "CheckSpellup: Mob casting spell {0} which is neither TargetType.self nor TargetType.defensive.", spell );
SocketConnection.Act( "$n&n starts casting...", ch, null, null, SocketConnection.MessageTarget.room );
ch.SetAffectBit( Affect.AFFECT_CASTING );
CastData caster = new CastData();
caster.Who = ch;
caster.Eventdata = Event.CreateEvent(Event.EventType.spell_cast, spell.CastingTime, ch, ch, spell);
Database.CastList.Add( caster );
return true;
}
return false;
}
示例2: SummonIfHating
/*
* If a spell casting mob is hating someone, try to summon them.
*
* Xangis - Need to add code to also gate to the person if they can't be summoned
*/
static void SummonIfHating( CharData ch )
{
string name = String.Empty;
string buf = String.Empty;
if( ch.Fighting || ch.Fearing || ch.Hating.Count == 0 || ch.InRoom.HasFlag( RoomTemplate.ROOM_SAFE ) )
return;
/* If summoner is busy hunting someone aleady, don't summon. */
if( ch.Hunting )
return;
CharData victim = ch.GetRandomHateTarget( false );
// Pretty stupid to summon someone who's in the same room.
if( !victim || ch.InRoom == victim.InRoom )
return;
if( ( ch.HasSpell( "relocate" ) ))
{
if( !victim.IsNPC() )
buf += "relocate 0." + name;
else
buf += "relocate " + name;
}
else if( ch.HasSpell( "summon" ) )
{
if( !victim.IsNPC() )
buf += "summon 0." + name;
else
buf += "summon " + name;
}
else if ((ch.Level * 4 - 3) >= Spell.SpellList["spirit jump"].SpellCircle[(int)ch.CharacterClass.ClassNumber])
{
if( !victim.IsNPC() )
buf += "'spirit jump' 0." + name;
else
buf += "'spirit jump' " + name;
}
CommandType.Interpret(ch, "cast " + buf);
return;
}
示例3: CheckOffensive
/// <summary>
/// Check for use of Direct targeted spells (TargetType.singleCharacterOffensive)
/// </summary>
/// <param name="ch"></param>
/// <param name="victim"></param>
/// <param name="spell"></param>
/// <param name="percent"></param>
/// <returns></returns>
public static bool CheckOffensive( CharData ch, CharData victim, Spell spell, int percent )
{
if (ch == null) return false;
string buf = String.Format("CheckOffensive: spell ({0})'{1}'", spell, spell.Name);
Log.Trace( buf );
if( spell == null )
return false;
if( ch.HasSpell(spell) && ( MUDMath.NumberPercent() < percent ) )
{
if (spell.ValidTargets != TargetType.singleCharacterOffensive &&
spell.ValidTargets != TargetType.none &&
spell.ValidTargets != TargetType.singleCharacterRanged)
Log.Error( "Check_spellup: Mob casting spell {0} which is neither _targetType offensive nor ignore.a", spell );
SocketConnection.Act( "$n&n starts casting...", ch, null, null, SocketConnection.MessageTarget.room );
ch.SetAffectBit( Affect.AFFECT_CASTING );
CastData caster = new CastData();
caster.Who = ch;
caster.Eventdata = Event.CreateEvent(Event.EventType.spell_cast, spell.CastingTime, ch, victim, spell);
Database.CastList.Add( caster );
return true;
}
return false;
}
示例4: Memorize
/// <summary>
/// This is called by Command.Memorize and Commandpray. This was originally
/// attached to each function, but it's silly to have two large blocks
/// of the same code
/// </summary>
/// <param name="ch"></param>
/// <param name="argument"></param>
/// <param name="pray"></param>
public static void Memorize( CharData ch, string argument, bool pray )
{
string text;
Dictionary<String, Int32> memmed = new Dictionary<String, Int32>();
int[] circle = new int[ Limits.MAX_CIRCLE ];
int[] circfree = new int[ Limits.MAX_CIRCLE ];
// with an argument they want to start memorizing a new spell.
if( !String.IsNullOrEmpty(argument) )
{
// Must be in the proper position
if( ch.CurrentPosition != Position.resting )
{
if( pray )
ch.SendText( "You can only pray for spells while resting.\r\n" );
else
ch.SendText( "You can memorize spells only when resting.\r\n" );
return;
}
// Find the spell they want
Spell spell = StringLookup.SpellLookup( argument );
if( spell == null )
{
ch.SendText( "Never heard of that spell...\r\n" );
return;
}
// Check to see that they can memorize another spell
// Immortals have no limits
if( !ch.IsImmortal() )
{
if( ( (PC)ch ).Hunger <= 0 || ( (PC)ch ).Thirst <= 0 )
{
ch.SendText( "You can't seem to concentrate on anything but your appetite.\r\n" );
}
if( !ch.HasSpell( argument ) )
{
ch.SendText( "That spell is beyond you.\r\n" );
return;
}
if (!pray && ((PC)ch).SpellAptitude[spell.Name] < 1)
{
ch.SendText( "You have not yet learned that spell. Find a place to scribe it.\r\n" );
return;
}
int lvltotal = 0;
foreach( MemorizeData mem in ((PC)ch).Memorized )
{
if (mem.Circle == spell.SpellCircle[(int)ch.CharacterClass.ClassNumber])
lvltotal += 1;
}
int numMemmable = 0;
if (ch.CharacterClass.MemType == CharClass.MemorizationType.Lesser)
{
numMemmable = LesserMemchart[(ch.Level - 1), (spell.SpellCircle[(int)ch.CharacterClass.ClassNumber] - 1)];
}
else
{
numMemmable = Memchart[(ch.Level - 1), (spell.SpellCircle[(int)ch.CharacterClass.ClassNumber] - 1)];
}
if (lvltotal >= numMemmable )
{
if( pray )
ch.SendText( "You can pray for no more spells of that level.\r\n" );
else
ch.SendText( "You can memorize no more spells of that circle.\r\n" );
return;
}
}
// If we know what they want and they can have it, let's create it.
MemorizeData memm = CreateMemorizeData( ch, spell );
if( !memm )
{
Log.Error( "Unable to create memorization (spell {0})", spell );
return;
}
// If they're not already memorizing, they are now.
ch.SetActionBit(PC.PLAYER_MEMORIZING );
if( pray )
text = String.Format( "You start praying for {0} which will take about {1} seconds.\r\n",
spell.Name, ( memm.Memtime / Event.TICK_PER_SECOND ) );
else
text = String.Format( "You start memorizing {0} which will take about {1} seconds.\r\n",
spell.Name, ( memm.Memtime / Event.TICK_PER_SECOND ) );
ch.SendText( text );
//.........这里部分代码省略.........
示例5: FinishSpell
//.........这里部分代码省略.........
|| ch.InRoom.ExitData[ dir ].HasFlag( Exit.ExitFlag.closed )
|| ch.InRoom.ExitData[ dir ].HasFlag( Exit.ExitFlag.blocked )
|| ch.InRoom.ExitData[dir].HasFlag(Exit.ExitFlag.walled))
continue;
if( ch.InRoom.ExitData[ dir ].TargetRoom == victim.InRoom )
{
targetInRange = true;
break;
}
// for fireball we check two rooms away
if( ch.InRoom.ExitData[ dir ].TargetRoom &&
ch.InRoom.ExitData[ dir ].TargetRoom.ExitData[ dir ]
&& ch.InRoom.ExitData[ dir ].TargetRoom.ExitData[ dir ].TargetRoom == victim.InRoom )
{
targetInRange = true;
break;
}
}
if( !targetInRange )
{
ch.SendText( "They are no longer in range!\r\n" );
return;
}
break;
}
// No wait state - we already made them wait.
ch.PracticeSpell( spell );
if (ch.IsNPC())
{
chance = 85;
}
else if (ch.HasSpell(spell.Name))
{
chance = ((PC)ch).SpellAptitude[spell.Name];
}
if( !ch.IsImmortal() && ( MUDMath.NumberPercent() > chance ) )
{
ch.SendText( "You lost your concentration.\r\n" );
SocketConnection.Act( "&+r$n&n&+r stops chanting abruptly.&n", ch, null, null, SocketConnection.MessageTarget.room );
}
else
{
// TODO: Figure out whether this should be re-enabled.
//if( song )
//{
// ch.SendText( "You complete a verse of the song...\r\n" );
// ch.GainExperience( 1 );
// SaySong( ch, spell );
//}
//else
{
if (!ch.IsClass(CharClass.Names.psionicist))
{
ch.SendText( "You complete your spell...\r\n" );
if( MUDString.StringsNotEqual( spell.Name, "ventriloquate" ) )
SaySpell( ch, spell );
}
ch.GainExperience( 1 );
}
if( !ch.IsNPC() )
{
string buf = String.Format( "Spell ({0}) being cast by {1}", spell.Name, ch.Name );
Log.Trace( buf );
示例6: Cast
/// <summary>
/// Handles all spellcasting, whether it be willing, singing, or casting
/// If they got here as a bard, they're using the SING command word,
/// if they got here as a psionicist, they're using the WILL command word,
/// and if they got here as anything else, they're using CAST.
///
/// These are just cheesy details handled by CommandType.cs... we don't care.
/// What we do care about is that we *know* it's safe to base all our
/// messages/decisions on the character's class.
///
/// This function is also *mob-safe*, meaning that mobs can cast spells
/// too. However, this is not the preferred method (as far as I can tell)
///
/// Shaman totems are checked for in this function.
/// </summary>
/// <param name="ch"></param>
/// <param name="argument"></param>
public static void Cast( CharData ch, string argument )
{
// No casting while berzerked... Nor singing! Hah!
if (ch.IsAffected(Affect.AFFECT_BERZERK))
{
ch.SendText( "Not while you're in a &+RBl&n&+ro&+Ro&n&+rd&+L Rage&n!\r\n" );
return;
}
// No casting while thirsty... Nor singing! Hah!
if (ch.IsAffected(Affect.AFFECT_THIRST) && ( ch.IsNPC() || ( (PC)ch ).Thirst < 10 ) )
{
ch.SendText( "&+BNo&+Ct w&+chi&+ble &+cyo&+Bu'&+cre &+Bso p&+carc&+Bhed&n!\r\n" );
return;
}
String[] pieces = argument.Split( new Char[] {'\''}, StringSplitOptions.RemoveEmptyEntries);
if (pieces.Length < 1)
{
ch.SendText("Spell names must always be in single quotes, such as: cast 'magic missile' troll.\r\n");
return;
}
if (pieces.Length > 1)
{
pieces[1] = pieces[1].Trim();
}
Spell spell;
if (((spell = StringLookup.SpellLookup(pieces[0])) == null) || ((!ch.HasSpell(pieces[0])) && !ch.IsImmortal()))
{
ch.SendText( "You can't do that.\r\n" );
return;
}
if( !CheckTotem( ch, spell ))
return;
if( !ch.CheckConcentration( spell ) )
return;
if (!ch.CheckMemorized(spell))
return;
if( ( !ch.CanSpeak() || ch.HasInnate(Race.RACE_MUTE)) && !ch.IsClass(CharClass.Names.psionicist))
{
ch.SendText( "Your lips move but no sound comes out.\r\n" );
return;
}
if( !ch.InRoom.CheckCastable( ch, ch.IsClass( CharClass.Names.bard ), true) )
return;
if( ch.InRoom.CheckStarshell( ch ) )
return;
int manaUsed = 0;
// TODO: Rather than hard-code psionicist as a mana class, let that be set in the class files.
if (ch.IsClass(CharClass.Names.psionicist))
{
manaUsed = Macros.ManaCost(ch, spell);
}
else if (ch.IsClass(CharClass.Names.bard))
{
manaUsed = spell.MinimumMana;
}
// Locate targets.
if( ch.IsNPC() )
{
ImmortalChat.SendImmortalChat( null, ImmortalChat.IMMTALK_SPAM, 0, "Magic.Cast: Attempting to find _targetType for " + ch.ShortDescription + "&n." );
}
if (pieces.Length > 1)
{
ProcessSpellTargets(ch, spell, pieces[1]);
}
else
{
ProcessSpellTargets(ch, spell, null);
}
}