public static void Fortitude(CharData ch, string[] str) { if( ch == null ) return; string arg = String.Empty; int amount; if (ch.IsNPC() || ((PC)ch).SkillAptitude["fortitude"] == 0) { ch.SendText("Try all you will, but you're still your plain self.\r\n"); return; } if (!MUDString.StringsNotEqual(arg, "off")) { if (ch.HasAffect( Affect.AffectType.skill, "fortitude")) { //strip the affect ch.AffectStrip( Affect.AffectType.skill, "fortitude"); } else { ch.SendText("You are not using fortitude.\r\n"); } return; } if (((PC)ch).SkillAptitude["fortitude"] >= 95) amount = 15; else if (((PC)ch).SkillAptitude["fortitude"] >= 60) amount = 10; else amount = 5; Affect af = new Affect(Affect.AffectType.skill, "fortitude", 5 * ch.Level, Affect.Apply.constitution, amount, Affect.AFFECT_NONE); ch.AddAffect(af); ch.SendText("You feel more fortified.\r\n"); }
public static void Charm(CharData ch, string[] str) { if( ch == null ) return; string arg = String.Empty; int amount; if (!ch.HasSkill("charm of the otter")) { ch.SendText("Try all you will, but you're still your plain self.\r\n"); return; } if (!MUDString.StringsNotEqual(arg, "off")) { if (ch.HasAffect( Affect.AffectType.skill, "charm of the otter")) { //strip the affect ch.AffectStrip( Affect.AffectType.skill, "charm of the otter"); } else { ch.SendText("You are not using charm of the otter.\r\n"); } return; } if (((PC)ch).SkillAptitude["charm of the otter"] >= 95) amount = 15; else if (((PC)ch).SkillAptitude["charm of the otter"] >= 60) amount = 10; else amount = 5; Affect af = new Affect(Affect.AffectType.skill, "charm of the otter", 5 * ch.Level, Affect.Apply.charisma, amount, Affect.AFFECT_NONE); ch.AddAffect(af); ch.SendText("You feel more charasmatic!\r\n"); }
public static void Endurance(CharData ch, string[] str) { if( ch == null ) return; string arg = String.Empty; int amount; if (ch.IsNPC() || ((PC)ch).SkillAptitude["endurance"] == 0) { ch.SendText("Try all you will, but you're still your plain self.\r\n"); return; } if (!MUDString.StringsNotEqual(arg, "off")) { if (ch.HasAffect( Affect.AffectType.skill, "endurance")) { //strip the affect ch.AffectStrip( Affect.AffectType.skill, "endurance"); } else { ch.SendText("You are not using endurance.\r\n"); } return; } if (((PC)ch).SkillAptitude["endurance"] >= 95) amount = 15; else if (((PC)ch).SkillAptitude["endurance"] >= 60) amount = 10; else amount = 5; Affect af = new Affect(Affect.AffectType.skill, "endurance", 5 * ch.Level, Affect.Apply.move, amount, Affect.AFFECT_MOVEMENT_INCREASED); ch.AddAffect(af); ch.SendText("You feel the endurance of the mountains in your muscles!\r\n"); }
public static void Savvy(CharData ch, string[] str) { if( ch == null ) return; string arg = String.Empty; int amount; if (ch.IsNPC() || ((PC)ch).SkillAptitude["savvy"] == 0) { ch.SendText("Try all you will, but you're still your plain self.\r\n"); return; } if (!MUDString.StringsNotEqual(arg, "off")) { if (ch.HasAffect( Affect.AffectType.skill, "savvy")) { //strip the affect ch.AffectStrip( Affect.AffectType.skill, "savvy"); } else { ch.SendText("You are not using savvy.\r\n"); } return; } if (((PC)ch).SkillAptitude["savvy"] >= 95) amount = 15; else if (((PC)ch).SkillAptitude["savvy"] >= 60) amount = 10; else amount = 5; Affect af = new Affect(Affect.AffectType.skill, "savvy", 5 * ch.Level, Affect.Apply.strength, amount, Affect.AFFECT_STRENGTH_INCREASED); ch.AddAffect(af); ch.SendText("You feel more savvy.\r\n"); }
public static void Shadow(CharData ch, string[] str) { if( ch == null ) return; Affect af = new Affect(); if (!ch.IsNPC() && !ch.HasSkill("shadow form")) { ch.SendText("You don't know how to take shadow form.\r\n"); return; } ch.SendText("You attempt to move in the shadows.\r\n"); ch.AffectStrip( Affect.AffectType.skill, "shadow form"); if (ch.CheckSkill("shadow form")) { af.Value = "shadow form"; af.Type = Affect.AffectType.skill; af.Duration = ch.Level; af.SetBitvector(Affect.AFFECT_SNEAK); ch.AddAffect(af); } ch.WaitState(10); return; }
/// <summary> /// Inflicts damage from a spell, based on the weapon damage() function, but customized for spells. /// /// Needs to be cleaned up because it's just too big (600+ lines). /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> /// <param name="dam"></param> /// <param name="spell"></param> /// <param name="damType"></param> /// <returns></returns> public static bool InflictSpellDamage( CharData ch, CharData victim, int dam, Spell spell, AttackType.DamageType damType ) { if( ch == null || victim == null || victim.CurrentPosition == Position.dead ) return true; // Remove memorization and meditation bits. // And invis. ch.BreakInvisibility(); victim.BreakMeditate(); victim.BreakMemorization(); if( CheckShrug( ch, victim ) ) return false; if( victim.CurrentPosition == Position.sleeping && !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) { SocketConnection.Act( "$n&n has a rude awakening!", victim, null, null, SocketConnection.MessageTarget.room ); victim.CurrentPosition = Position.resting; if( ch.InRoom == victim.InRoom && ch.FlightLevel == victim.FlightLevel ) SetFighting( victim, ch ); } // Check for globe spells. See also FinishSpell under TargetType.singleCharacterOffensive // This check here is just to prevent area effect spells from // doing damage if too low level. The check for direct spells is in // Magic.cs if (victim.IsAffected( Affect.AFFECT_MAJOR_GLOBE) && (spell.SpellCircle[(int)ch.CharacterClass.ClassNumber] <= 6 || spell.Name == "fireshield" || spell.Name == "shockshield" || spell.Name == "soulshield" || spell.Name == "coldshield" ) ) { SocketConnection.Act( "&+RThe globe around $N&+R's body bears the brunt of your assault!&n", ch, null, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "&+RYour globe deflects $n&+R's attack!&n", ch, null, victim, SocketConnection.MessageTarget.victim ); SocketConnection.Act( "&+R$N&+R's globe deflects $n&+R's attack!&n", ch, null, victim, SocketConnection.MessageTarget.room_vict ); return false; } if (victim.IsAffected( Affect.AFFECT_GREATER_SPIRIT_WARD) && spell.SpellCircle[(int)ch.CharacterClass.ClassNumber] <= 5) { SocketConnection.Act( "&+WThe aura around $N&+W's body bears the brunt of your assault!&n", ch, null, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "&+WYour globe absorbs $n&+W's attack!&n", ch, null, victim, SocketConnection.MessageTarget.victim ); SocketConnection.Act( "&+W$N&+W's aura absorbs $n&+W's attack!&n", ch, null, victim, SocketConnection.MessageTarget.room_vict ); return false; } if (victim.IsAffected( Affect.AFFECT_MINOR_GLOBE) && spell.SpellCircle[(int)ch.CharacterClass.ClassNumber] <= 4) { SocketConnection.Act( "&+RThe globe around $N&+R's body bears the brunt of your assault!&n", ch, null, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "&+RYour globe deflects $n&+R's attack!&n", ch, null, victim, SocketConnection.MessageTarget.victim ); SocketConnection.Act( "&+R$N&+R's globe deflects $n&+R's attack!&n", ch, null, victim, SocketConnection.MessageTarget.room_vict ); return false; } if (victim.IsAffected( Affect.AFFECT_SPIRIT_WARD) && spell.SpellCircle[(int)ch.CharacterClass.ClassNumber] <= 3) { SocketConnection.Act( "&+WThe aura around $N&+W's body bears the brunt of your assault!&n", ch, null, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "&+WYour globe absorbs $n&+W's attack!&n", ch, null, victim, SocketConnection.MessageTarget.victim ); SocketConnection.Act( "&+W$N&+W's aura absorbs $n&+W's attack!&n", ch, null, victim, SocketConnection.MessageTarget.victim ); return false; } /* * Stop up any residual loopholes. */ // 1275 is average damage from Akiaurn's Power Word // I changed this to reflect that. if( ( dam > 1275 ) && ch.Level < Limits.LEVEL_AVATAR && ch.GetRace() != Race.RACE_DRAGON ) { string buf3; if( ch.IsNPC() && ch.Socket ) buf3 = String.Format( "Spell_Damage: {0} from {1} by {2}: > 1275 points with {3} spell!", dam, ch.Name, ch.Socket.Original.Name, spell.Name ); else buf3 = String.Format( "Spell_Damage: {0} from {1}: > 1275 points with {2} spell!", dam, ch.IsNPC() ? ch.ShortDescription : ch.Name, spell.Name ); Log.Error( buf3, 0 ); dam = 1275; } if (victim.IsAffected( Affect.AFFECT_MINOR_PARA) && !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) { SocketConnection.Act( "$n&n disrupts the magic preventing $N&n from moving.", ch, null, victim, SocketConnection.MessageTarget.room_vict ); SocketConnection.Act( "You disrupt the magic preventing $N&n from moving.", ch, null, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "&+YYou can move again.&n", ch, null, victim, SocketConnection.MessageTarget.victim ); victim.RemoveAffect( Affect.AFFECT_MINOR_PARA ); victim.AffectStrip( Affect.AffectType.spell, "earthen grasp" ); victim.AffectStrip( Affect.AffectType.spell, "greater earthen grasp"); } bool immune = false; if( victim != ch ) { /* * Certain attacks are forbidden. * Most other attacks are returned. */ if( IsSafe( ch, victim ) ) return false; // is_safe could wipe out victim, as it calls procs if a boss // check and see that victim is still valid if( !victim ) return true; Crime.CheckAttemptedMurder( ch, victim ); if( victim.CurrentPosition > Position.stunned && !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) { // Offensive spells engage victim if not fighting, and // caster only if neither are fighting. if( !victim.Fighting && victim.InRoom == ch.InRoom && victim.FlightLevel == ch.FlightLevel ) { SetFighting( victim, ch ); if( !ch.Fighting ) SetFighting( ch, victim ); // Can't have prone people automaticaly stand. if( victim.CurrentPosition == Position.standing ) victim.CurrentPosition = Position.fighting; } /* * If NPC victim is following, ch might attack victim's master. * No charm check here because charm would be dispelled from * tanking mobile when combat ensues thus ensuring PC charmer is * not harmed. * Check for is_same_group wont work as following mobile is not * always grouped with PC charmer */ if( ch.IsNPC() && victim.IsNPC() && victim.Master && victim.Master.InRoom == ch.InRoom && MUDMath.NumberBits( 2 ) == 0 ) { StopFighting( ch, false ); SetFighting( ch, victim.Master ); return false; } } /* * More charm stuff. */ if( victim.Master == ch && !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) StopFighting( victim, true ); /* * Hunting stuff... */ if( dam != 0 && victim.IsNPC() && !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) { StartGrudge( victim, ch, false ); } /* * Damage modifiers. */ if (victim.IsAffected( Affect.AFFECT_SANCTUARY)) dam /= 2; if ((victim.IsAffected( Affect.AFFECT_PROTECT_EVIL)) && ch.IsEvil()) dam -= dam / 8; else if ((victim.IsAffected( Affect.AFFECT_PROTECT_GOOD)) && ch.IsGood()) dam -= dam / 8; if( dam < 0 ) dam = 0; } switch( victim.CheckRIS( damType ) ) { case Race.ResistanceType.resistant: dam -= dam / 3; break; case Race.ResistanceType.immune: immune = true; dam = 0; break; case Race.ResistanceType.susceptible: dam += dam / 2; break; case Race.ResistanceType.vulnerable: dam *= 2; break; } if( ( damType == AttackType.DamageType.wind || damType == AttackType.DamageType.gas || damType == AttackType.DamageType.asphyxiation ) && victim.IsAffected( Affect.AFFECT_DENY_AIR)) { if( MUDMath.NumberPercent() < 50 ) { victim.SendText( "&+CYou deny the damage.&n\r\n" ); immune = true; dam = 0; } else dam -= dam / 5; } if (damType == AttackType.DamageType.fire && victim.IsAffected( Affect.AFFECT_DENY_FIRE)) { if( MUDMath.NumberPercent() < 50 ) { victim.SendText( "&+rYou deny the damage.&n\r\n" ); immune = true; dam = 0; } else dam -= dam / 5; } if( ( damType == AttackType.DamageType.earth || damType == AttackType.DamageType.crushing ) && victim.IsAffected(Affect.AFFECT_DENY_EARTH)) { if( MUDMath.NumberPercent() < 50 ) { victim.SendText( "&+yYou deny the damage.&n\r\n" ); immune = true; dam = 0; } else dam -= dam / 5; } if( ( damType == AttackType.DamageType.water || damType == AttackType.DamageType.acid || damType == AttackType.DamageType.drowning ) && victim.IsAffected(Affect.AFFECT_DENY_WATER)) { if( MUDMath.NumberPercent() < 50 ) { victim.SendText( "&+bYou deny the damage.&n\r\n" ); immune = true; dam = 0; } else dam -= dam / 5; } // Check for protection spells that give 25% damage reduction - Xangis if (damType == AttackType.DamageType.fire && victim.IsAffected( Affect.AFFECT_PROTECT_FIRE)) dam = ( dam * 3 ) / 4; else if (damType == AttackType.DamageType.cold && victim.IsAffected( Affect.AFFECT_PROTECT_COLD)) dam = ( dam * 3 ) / 4; else if (damType == AttackType.DamageType.acid && victim.IsAffected( Affect.AFFECT_PROTECT_ACID)) dam = ( dam * 3 ) / 4; else if (damType == AttackType.DamageType.gas && victim.IsAffected( Affect.AFFECT_PROTECT_GAS)) dam = ( dam * 3 ) / 4; else if (damType == AttackType.DamageType.electricity && victim.IsAffected( Affect.AFFECT_PROTECT_LIGHTNING)) dam = ( dam * 3 ) / 4; /* * We moved DamageMessage out of the victim != ch if above * so self damage would show. Other valid type_undefined * damage is ok to avoid like mortally wounded damage */ if( spell != Spell.SpellList["reserved"] && !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) SendSpellDamageMessage( ch, victim, dam, spell, immune ); /* PC to PC damage quartered. * NPC to PC damage divided by 3. */ if( dam > 0 && !victim.IsNPC() && victim != ch ) { if( !ch.IsNPC() ) dam /= 4; else dam /= 3; } /* * Hurt the victim. * Inform the victim of his new state. */ if( !( victim.GetRace() == Race.RACE_FIRE_ELE && damType == AttackType.DamageType.fire ) && !( victim.GetRace() == Race.RACE_WATER_ELE && damType == AttackType.DamageType.water ) && !( victim.GetRace() == Race.RACE_EARTH_ELE && damType == AttackType.DamageType.earth ) && !( victim.GetRace() == Race.RACE_AIR_ELE && damType == AttackType.DamageType.wind ) ) { /* Added damage exp! */ // chance added because people level faster and faster as they get higher level... // you can now only get damage exp on mobs that con easy or better // and there's only a 25% chance per hit of you evern being eligible for damage exp. if( MUDMath.NumberPercent() < 25 && victim.Level >= ( ch.Level - 3 ) ) ch.GainExperience( Math.Max( 1, dam / 20 ) ); victim.Hitpoints -= dam; } else { string attack; if( spell != null && spell != Spell.SpellList["none"] ) attack = spell.Name; else attack = "it"; SocketConnection.Act( "$N&n absorbs your $t!", ch, attack, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "You absorb $n&n's $t!", ch, attack, victim, SocketConnection.MessageTarget.victim ); SocketConnection.Act( "$N&n absorbs $n&n's $t", ch, attack, victim, SocketConnection.MessageTarget.room_vict ); if( ch.IsImmortal() ) { string buf4 = String.Format( "You healed {0} damage.", victim.GetMaxHit() >= dam + victim.Hitpoints ? dam : victim.GetMaxHit() - victim.Hitpoints ); ch.SendText( buf4 ); } victim.Hitpoints = Math.Min( victim.GetMaxHit(), victim.Hitpoints + dam ); return false; } if( !victim.IsNPC() && victim.Level >= Limits.LEVEL_AVATAR && victim.Hitpoints < 1 ) victim.Hitpoints = 1; if (victim.IsAffected(Affect.AFFECT_BERZERK) && victim.CurrentPosition <= Position.stunned ) victim.RemoveAffect(Affect.AFFECT_BERZERK); victim.UpdatePosition(); switch( victim.CurrentPosition ) { case Position.mortally_wounded: victim.SendText( "&+LYou are &+Rmo&n&+rr&+Rt&n&+ral&+Rl&n&+ry&+L wounded, and will die soon, if not aided.&n\r\n" ); SocketConnection.Act( "$n&+L is &+Rmo&n&+rr&+Rt&n&+ral&+Rl&n&+ry&+L wounded, and will die soon, if not aided.&n", victim, null, null, SocketConnection.MessageTarget.room, true ); StopNotVicious( victim ); break; case Position.incapacitated: victim.SendText( "&+LYou are incapacitated and will slowly &n&+rbl&+Re&n&+re&+Rd&+L to death, if not aided.\r\n" ); SocketConnection.Act( "$n&+L is incapacitated and will slowly &n&+rbl&+Re&n&+re&+Rd&+L to death, if not aided.&n", victim, null, null, SocketConnection.MessageTarget.room, true ); StopNotVicious( victim ); break; case Position.stunned: victim.SendText( "&+LYou are stunned, but will probably recover.&n\r\n" ); SocketConnection.Act( "$n&+L is stunned, but will probably recover.&n", victim, null, null, SocketConnection.MessageTarget.room, true ); break; case Position.dead: SocketConnection.Act( spell.MessageKill, ch, null, victim, SocketConnection.MessageTarget.room_vict ); SocketConnection.Act( spell.MessageKill, ch, null, victim, SocketConnection.MessageTarget.character ); if( victim == ch ) { victim.SendText( "&+LYou have been &+Rsl&n&+ra&+Ri&n&+rn&+L!&n\r\n\r\n" ); } else { string buf = String.Format( "&+LYou have been &+Rsl&n&+ra&+Ri&n&+rn&+L by&n {0}&+L!&n\r\n\r\n", ch.ShowNameTo( victim, false ) ); victim.SendText( buf ); } StopFighting( victim, true ); SocketConnection.Act( "$n&+L is &n&+rdead&+L!&n", victim, null, null, SocketConnection.MessageTarget.room, true ); break; default: if( dam > victim.GetMaxHit() / 5 ) victim.SendText( "That really did &+RHURT&n!\r\n" ); if( victim.Hitpoints < victim.GetMaxHit() / 10 ) victim.SendText( "You sure are &n&+rBL&+RE&n&+rE&+RDI&n&+rN&+RG&n!\r\n" ); break; } /* * Sleep spells and extremely wounded folks. */ if( !victim.IsAwake() ) /* lets make NPC's not slaughter PC's */ { if( victim.Fighting && victim.Fighting.Hunting && victim.Fighting.Hunting.Who == victim ) StopHunting( victim.Fighting ); if( victim.Fighting && !victim.IsNPC() && ch.IsNPC() ) StopFighting( victim, true ); else StopFighting( victim, false ); } /* * Payoff for killing things. */ if( victim.CurrentPosition == Position.dead ) { StopFighting( ch, false ); if( !victim.HasActionBit(MobTemplate.ACT_NOEXP ) || !victim.IsNPC() ) GroupExperienceGain( ch, victim ); if( !victim.IsNPC() ) { if( ch.IsNPC() ) { ( (PC)victim ).MobDeaths++; if( victim.IsGuild() ) { ( (PC)victim ).GuildMembership.MonsterDeaths++; ( (PC)victim ).GuildMembership.Score += CalculateDeathScore( ch, victim ); } ( (PC)victim ).Score += CalculateDeathScore( ch, victim ); } else { ( (PC)ch ).PlayerKills++; ( (PC)victim ).PlayerDeaths++; ( (PC)victim ).Score += CalculateDeathScore( ch, victim ); ( (PC)ch ).Score += CalculateKillScore( ch, victim ); if( ch.IsGuild() && victim.IsGuild() && ( (PC)ch ).GuildMembership != ( (PC)victim ).GuildMembership ) { ( (PC)ch ).GuildMembership.PlayerKills++; ( (PC)victim ).GuildMembership.PlayerDeaths++; ( (PC)ch ).GuildMembership.Score += CalculateKillScore( ch, victim ); ( (PC)victim ).GuildMembership.Score += CalculateDeathScore( ch, victim ); } } string logBuf = String.Format( "{0}&n killed by {1}&n at {2}", victim.Name, ( ch.IsNPC() ? ch.ShortDescription : ch.Name ), victim.InRoom.IndexNumber ); Log.Trace( logBuf ); ImmortalChat.SendImmortalChat( ch, ImmortalChat.IMMTALK_DEATHS, Limits.LEVEL_AVATAR, logBuf ); /* * Dying penalty: * 1/2 way back to previous 2 levels. */ // Newbies do not lose exp from death. if( ch.Level > 5 ) victim.GainExperience( ( 0 - ( ( ( 50 + victim.Level ) * ExperienceTable.Table[ victim.Level ].LevelExperience ) / 400 ) ) ); if( victim.Level < 2 && victim.ExperiencePoints < 1 ) victim.ExperiencePoints = 1; } else { if( !ch.IsNPC() ) { ( (PC)ch ).MobKills++; if( ch.IsGuild() ) { ( (PC)ch ).GuildMembership.MonsterKills++; ( (PC)ch ).GuildMembership.Score += CalculateKillScore( ch, victim ); } ( (PC)ch ).Score += CalculateKillScore( ch, victim ); } } KillingBlow( ch, victim ); // Keep in mind after this point the character is not in the // CharList, not in any room, and is at the menu. Don't do // anything that would cause a segmentation fault. if( ch.IsGuild() && victim.IsGuild() && ( (PC)ch ).GuildMembership != ( (PC)victim ).GuildMembership ) { ( (PC)ch ).GuildMembership.Score += 20; } return true; } if( victim == ch ) { return false; } /* * Wimp out? */ if( victim.IsNPC() && dam > 0 ) { if( ( victim.HasActionBit(MobTemplate.ACT_WIMPY ) && MUDMath.NumberBits( 1 ) == 0 && victim.Hitpoints < victim.GetMaxHit() / 5 ) || (victim.IsAffected(Affect.AFFECT_CHARM) && victim.Master && victim.Master.InRoom != victim.InRoom ) ) { StartFearing( victim, ch ); StopHunting( victim ); CommandType.Interpret(victim, "flee"); } } if( !victim.IsNPC() && victim.Hitpoints > 0 && victim.Hitpoints <= victim.Wimpy ) { CommandType.Interpret(victim, "flee"); } return false; }
public static void ApplyPoison( CharData ch ) { Affect af = new Affect(); bool isSpell = false; foreach (Affect aff in ch.Affected) { if( aff.Type == Affect.AffectType.spell && aff.Value == "poison" ) { isSpell = true; } else if ((aff.Type == Affect.AffectType.skill && aff.Value == "poison weapon" || aff.Value == "poison bite") ) { foreach (AffectApplyType apply in aff.Modifiers) { if (apply.Location != Affect.Apply.none || ch.IsAffected(Affect.AFFECT_SLOW_POISON) && MUDMath.NumberBits(1) == 0) continue; Poison.Type poisonType = (Poison.Type)apply.Amount; int dam; switch (poisonType) { case Poison.Type.damage: SocketConnection.Act("$n&n goes into a brief siezure as the poison courses through $s body.", ch, null, null, SocketConnection.MessageTarget.room); ch.SendText("Your muscles twitch randomly as the poison courses through your body.\r\n"); dam = MUDMath.Dice(1, 10); if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) InflictDamage(ch, ch, dam, "poison weapon", ObjTemplate.WearLocation.none, AttackType.DamageType.poison); else InflictDamage(ch, ch, dam / 2, "poison weapon", ObjTemplate.WearLocation.none, AttackType.DamageType.poison); return; case Poison.Type.attributes: if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) { int lev = aff.Level; ch.AffectStrip(Affect.AffectType.skill, "poison weapon"); af.Type = Affect.AffectType.skill; af.Value = "poison"; af.Duration = lev / 4; af.Level = lev; af.AddModifier(Affect.Apply.strength, 0 - MUDMath.Dice(1, 20)); af.AddModifier(Affect.Apply.dexterity, 0 - MUDMath.Dice(1, 20)); af.AddModifier(Affect.Apply.agility, 0 - MUDMath.Dice(1, 20)); af.AddModifier(Affect.Apply.constitution, 0 - MUDMath.Dice(1, 20)); af.SetBitvector(Affect.AFFECT_POISON); ch.AddAffect(af); ch.SendText("You suddenly feel quite weak as the poison is distributed through your body.&n\r\n"); SocketConnection.Act("$n&n pales visibly and looks much weaker.", ch, null, null, SocketConnection.MessageTarget.room); return; } ch.SendText("You feel the poison working its way into your system.\r\n"); InflictDamage(ch, ch, 2, "poison weapon", ObjTemplate.WearLocation.none, AttackType.DamageType.poison); break; case Poison.Type.damage_major: dam = MUDMath.Dice(10, 10); SocketConnection.Act("$n&n screams in agony as the poison courses through $s body.", ch, null, null, SocketConnection.MessageTarget.room); ch.SendText("&+RYour blood is on fire!&n\r\n"); if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) InflictDamage(ch, ch, dam, "poison weapon", ObjTemplate.WearLocation.none, AttackType.DamageType.poison); else InflictDamage(ch, ch, dam / 2, "poison weapon", ObjTemplate.WearLocation.none, AttackType.DamageType.poison); return; case Poison.Type.minor_para: if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) { ch.AffectStrip(Affect.AffectType.skill, "poison_weapon"); af.Value = "poison"; af.Type = Affect.AffectType.skill; af.Duration = MUDMath.NumberRange(1, 10); af.SetBitvector(Affect.AFFECT_MINOR_PARA); ch.AddAffect(af); ch.SendText("&+YYou are paralyzed!&n\r\n"); StopFighting(ch, false); SocketConnection.Act("$n&n&+y is suddenly overcome with rigor and cannot move.&n", ch, null, null, SocketConnection.MessageTarget.room); } break; case Poison.Type.minor_para_extended: if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) { ch.AffectStrip(Affect.AffectType.skill, "poison_weapon"); af.Value = "poison"; af.Type = Affect.AffectType.skill; af.Duration = MUDMath.NumberRange(5, 30); af.SetBitvector(Affect.AFFECT_MINOR_PARA); ch.AddAffect(af); ch.SendText("&+YYou are paralyzed!&n\r\n"); StopFighting(ch, false); SocketConnection.Act("$n&n&+y is suddenly overcome with rigor and cannot move.&n", ch, null, null, SocketConnection.MessageTarget.room); } break; case Poison.Type.major_para: if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) { ch.AffectStrip(Affect.AffectType.skill, "poison_weapon"); af.Value = "poison"; af.Type = Affect.AffectType.skill; af.Duration = MUDMath.NumberRange(1, 10); af.SetBitvector(Affect.AFFECT_HOLD); ch.AddAffect(af); ch.SendText("&+YYou are paralyzed!&n\r\n"); StopFighting(ch, false); SocketConnection.Act("$n&n&+y is suddenly overcome with rigor and cannot move.&n", ch, null, null, SocketConnection.MessageTarget.room); } break; case Poison.Type.major_para_extended: if (!Magic.SpellSavingThrow(aff.Level, ch, AttackType.DamageType.poison)) { ch.AffectStrip(Affect.AffectType.skill, "poison_weapon"); af.Value = "poison"; af.Type = Affect.AffectType.skill; af.Duration = MUDMath.NumberRange(5, 30); af.SetBitvector(Affect.AFFECT_HOLD); ch.AddAffect(af); ch.SendText("&+YYou are paralyzed!&n\r\n"); StopFighting(ch, false); SocketConnection.Act("$n&n&+y is suddenly overcome with rigor and cannot move.&n", ch, null, null, SocketConnection.MessageTarget.room); } break; case Poison.Type.perm_constitution: // TODO: Implement perm constitution loss from poison. break; case Poison.Type.perm_hitpoints: // TODO: Implement perm hitpoint loss from poison. break; case Poison.Type.near_death: // TODO: Implement "near death" poison - one that drains HP very quickly but does not kill. break; default: Log.Error("Unimplemented or unknown poison type: " + poisonType.ToString()); break; } } } //end if } if( isSpell ) { //normal poison from the spell ch.SendText( "You shiver and suffer.\r\n" ); SocketConnection.Act( "$n&n shivers and suffers.", ch, null, null, SocketConnection.MessageTarget.room ); if (!ch.IsAffected(Affect.AFFECT_SLOW_POISON)) { InflictSpellDamage( ch, ch, 2, "poison", AttackType.DamageType.poison ); } else { // Slow poison gives them a 20% chance of avoiding damage // and does half damage when it does hit them, giving // them 40% as much damage overall as a non-slowed person if( MUDMath.NumberPercent() < 80 ) InflictSpellDamage( ch, ch, 1, "poison", AttackType.DamageType.poison ); } } else { //normal poison from a bite or weapon ch.SendText( "You shiver and suffer.\r\n" ); SocketConnection.Act( "$n&n shivers and suffers.", ch, null, null, SocketConnection.MessageTarget.room ); if (!ch.IsAffected(Affect.AFFECT_SLOW_POISON)) { InflictDamage( ch, ch, 2, "poison", ObjTemplate.WearLocation.none, AttackType.DamageType.poison ); } else { // Slow poison gives them a 20% chance of avoiding damage // and does half damage when it does hit them, giving // them 40% as much damage overall as a non-slowed person if( MUDMath.NumberPercent() < 80 ) InflictDamage( ch, ch, 1, "poison", ObjTemplate.WearLocation.none, AttackType.DamageType.poison ); } } }
public static void StopFollower( CharData ch ) { if( !ch ) { Log.Error("StopFollower called with no CH argument.\r\n", 0); return; } if( !ch.Master ) { Log.Error("StopFollower: null master.", 0); return; } if( ch.IsAffected( Affect.AFFECT_CHARM ) ) { ch.RemoveAffect(Affect.AFFECT_CHARM); ch.AffectStrip( Affect.AffectType.spell, "domination"); } if( ch.Master != ch && CanSee( ch.Master, ch ) && ch.Master.InRoom ) SocketConnection.Act( "$n&n stops following you.", ch, null, ch.Master, SocketConnection.MessageTarget.victim ); if( ch.InRoom ) SocketConnection.Act( "You stop following $N&n.", ch, null, ch.Master, SocketConnection.MessageTarget.character ); // Remove the follower from the list of followers foreach( CharData follower in ch.Master.Followers ) { if( follower == ch ) { ch.Master.Followers.Remove( follower ); } } ch.Master = null; return; }
/// <summary> /// The main entry point for executing commands. /// Can be recursively called from 'at', 'order', 'force'. /// </summary> /// <param name="ch"></param> /// <param name="argument"></param> public static void Interpret(CharData ch, string argument) { // Get rid of leading and trailing spaces. argument = argument.Trim(); // Strip leading spaces. argument.Trim(); if (argument.Length == 0) { return; } // Remove AFK if (!ch.IsNPC()) { ch.RemoveActionBit(PC.PLAYER_AFK); } // Implement freeze command. if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_FREEZE)) { ch.SendText("You're totally frozen!\r\n"); return; } // Grab the command word. Special parsing so ' can be a command, // also no spaces needed after punctuation. string command; Object obj; Room room; int cmd; string logline = argument; int argptr = 0; if (!Char.IsLetter(argument[0]) && !Char.IsDigit(argument[0])) { command = argument.Substring(0, 1); argptr++; while (argument.Length > argptr && Char.IsWhiteSpace(argument[argptr])) { argument = argument.Remove(0, 1); } } else { command = MUDString.OneArgument(argument, ref argument); argument.Trim(); // Clean up the remainder of the command. } // Nothing to do if command is empty. Just send them a newline and bail. if (string.IsNullOrEmpty(command) && string.IsNullOrEmpty(argument)) { ch.SendText("\r\n"); return; } // Look for an item with a teleport trigger in the room. // and check to see if the command is a teleport trigger if (ch.InRoom && (obj = ch.GetObjHere(argument))) { if (obj.ItemType == ObjTemplate.ObjectType.teleport) { if (CheckCommandTrigger(command, obj.Values[1]) && obj.Values[2] != 0) { if (obj.Values[2] != -1) { obj.Values[2]--; } room = Room.GetRoom(obj.Values[0]); if (room) { SocketConnection.Act("$n&n vanishes suddenly.", ch, null, null, SocketConnection.MessageTarget.room); string text = String.Format("You {0} $p&n.\r\n", command); SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character); Log.Trace(String.Format("{0} activated keyword and was teleported by object.", ch.Name)); ch.RemoveFromRoom(); ch.AddToRoom(room); Interpret(ch, "look auto"); SocketConnection.Act("$n&n arrives suddenly.", ch, null, null, SocketConnection.MessageTarget.room); } else { ch.SendText("BUG: The target room for this teleporter does not exist.\r\n"); Log.Error("Target room for object {0} does not exist.", obj.ObjIndexData.IndexNumber); } return; } } else if (obj.ItemType == ObjTemplate.ObjectType.switch_trigger) { Exit exit; string cbuf = String.Format("Checking {0} against command no. {1} for {2}.", command, obj.Values[0], obj.Name); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, cbuf); if (CheckCommandTrigger(command, obj.Values[0])) { ch.SendText("Click.\r\n"); room = Room.GetRoom(obj.Values[1]); if (!room) { Log.Error("Target room for switch object {0} does not exist.", obj.ObjIndexData.IndexNumber); return; } exit = room.ExitData[obj.Values[2]]; if (exit == null) { Log.Error("Target exit for switch object {0} does not exist.", obj.ObjIndexData.IndexNumber); return; } if (exit.HasFlag(Exit.ExitFlag.blocked)) { exit.RemoveFlag(Exit.ExitFlag.blocked); } return; } } } // Look for command in command table. bool found = false; int trust = ch.GetTrust(); for (cmd = 0; cmd < CommandTable.Length; cmd++) { if (CommandTable[cmd].Name.StartsWith(command, StringComparison.CurrentCultureIgnoreCase) && (CommandTable[cmd].MinLevel <= trust)) { found = true; break; } } // Command was found, respond accordingly. if (found) { // Logging and snooping. if (CommandTable[cmd].LoggingType == LogType.never) { logline = "---- Nothing to see here ----"; } if ((!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_LOG)) || fLogAll || CommandTable[cmd].LoggingType == LogType.always) { string logBuf = String.Format("Log {0}: {1}", ch.Name, logline); Log.Trace(logBuf); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SECURE, ch.GetTrust(), logBuf); } if (ch.Socket && ch.Socket.SnoopBy) { ch.Socket.SnoopBy.WriteToBuffer("% "); ch.Socket.SnoopBy.WriteToBuffer(logline); ch.Socket.SnoopBy.WriteToBuffer("\r\n"); } // Break meditate if (CommandTable[cmd].BreakMeditate) { if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEDITATING)) { ch.RemoveActionBit(PC.PLAYER_MEDITATING); ch.SendText("You stop meditating.\r\n"); } } // Break sneak, hide, and invis // Anything that will break hide OR invis will break concealment // This is DUMB! Breaks invis w/backstab on a target that's not // there: i.e. "backstab trolll"/"backstab humann" . vis and no // attack! - (Should be handled with make_vis function). if (CommandTable[cmd].BreakInvisibility) { if (ch.IsAffected(Affect.AFFECT_INVISIBLE)) { ch.RemoveAffect(Affect.AFFECT_INVISIBLE); ch.RemoveAffect(Affect.AFFECT_HIDE); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); SocketConnection.Act("$n&n snaps into visibility.", ch, null, null, SocketConnection.MessageTarget.room); ch.SendText("You snap into visibility.\r\n"); } else if (ch.IsAffected(Affect.AFFECT_MINOR_INVIS)) { ch.RemoveAffect(Affect.AFFECT_INVISIBLE); ch.RemoveAffect(Affect.AFFECT_HIDE); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); ch.SendText("You appear.\r\n"); } } if (CommandTable[cmd].BreakHide) { if (ch.IsAffected(Affect.AFFECT_MINOR_INVIS)) { ch.SendText("You appear.\r\n"); } ch.AffectStrip( Affect.AffectType.skill, "shadow form"); ch.RemoveAffect( Affect.AFFECT_HIDE ); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); } } // Command was not found, respond accordingly. else { // Look for command in socials table. if (!Database.SocialList.CheckSocial(ch, command, argument)) { if (!ch.IsNPC() && !MUDString.IsPrefixOf(command, "petition")) { string logBuf = String.Format("Log {0}: {1}", ch.Name, logline); Log.Trace(logBuf); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SECURE, ch.GetTrust(), logBuf); Command.Petition(ch, argument.Split(' ')); return; } Log.Trace("Failed to match command."); ch.SendText("Huh?\r\n"); } return; } // Character not in position for command? if (ch.CurrentPosition < CommandTable[cmd].MinPosition) { switch (ch.CurrentPosition) { case Position.dead: ch.SendText("Lie still; you are &+rDEAD&n!\r\n"); break; case Position.mortally_wounded: case Position.incapacitated: ch.SendText("You are hurt far too bad for that.\r\n"); break; case Position.stunned: ch.SendText("You are too stunned to do that.\r\n"); break; case Position.sleeping: ch.SendText("In your dreams, or what?\r\n"); break; case Position.reclining: ch.SendText("You can't do that while lying around.\r\n"); break; case Position.sitting: ch.SendText("You can't do this sitting!\r\n"); break; case Position.kneeling: ch.SendText("Get off your knees!\r\n"); break; case Position.resting: ch.SendText("Nah... You feel too relaxed...\r\n"); break; case Position.fighting: ch.SendText("No way! You are still fighting!\r\n"); break; } if (!ch.IsImmortal()) { return; } if (ch.CurrentPosition == Position.dead) ch.CurrentPosition = Position.sleeping; ch.SendText("You're not in the right position, but..\r\n"); } if (ch.IsAffected(Affect.AFFECT_MINOR_PARA) && CommandTable[cmd].Function != Command.LookCommand && CommandTable[cmd].Function != Command.Score && CommandTable[cmd].Function != Command.Attributes) { if (!ch.IsImmortal()) { ch.SendText("&+YYour mind moves, but your body doesn't.&n\r\n"); return; } ch.SendText("&+YYour immortality allows you to move!&n\r\n"); } string[] str = argument.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); // Dispatch the command. Catch any exceptions, since most exceptions will probably happen // based on user commands. try { (CommandTable[cmd].Function)(ch, str); } catch (Exception ex) { Log.Error("Exception in CommandType.Interpret: " + ex); } return; }
/// <summary> /// The main social action processing routine. Sends the social strings and any associated sounds. /// </summary> /// <param name="ch">Character acting out the social.</param> /// <param name="command">Command entered by the character.</param> /// <param name="argument">Additional modifiers to the command entered.</param> /// <returns></returns> public bool CheckSocial(CharData ch, string command, string argument) { string arg = String.Empty; Social soc = FindSocial(command); if (soc == null) { return false; } if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_NO_EMOTE)) { ch.SendText("You are anti-social!\r\n"); return true; } if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEDITATING)) { ch.RemoveActionBit(PC.PLAYER_MEDITATING); ch.SendText("You stop meditating.\r\n"); } // Performing a social action removes hide and conceal. if (ch.IsAffected(Affect.AFFECT_MINOR_INVIS)) { ch.SendText("You appear.\r\n"); } ch.AffectStrip(Affect.AffectType.skill, "shadow form"); ch.AffectStrip(Affect.AffectType.spell, "concealment"); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); ch.RemoveAffect(Affect.AFFECT_HIDE); switch (ch.CurrentPosition) { case Position.dead: ch.SendText("Lie still; you are DEAD.\r\n"); return true; case Position.incapacitated: case Position.mortally_wounded: ch.SendText("You are hurt far too badly for that.\r\n"); return true; case Position.stunned: ch.SendText("You are too stunned to do that.\r\n"); return true; case Position.sleeping: // Special exception - only social when you're using when asleep is "snore". if (!"snore".StartsWith(soc.Name, StringComparison.CurrentCultureIgnoreCase)) { break; } ch.SendText("In your dreams, or what?\r\n"); return true; } MUDString.OneArgument(argument, ref arg); CharData victim = null; if (arg.Length == 0) { SocketConnection.Act(soc.CharNoArgument, ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act(soc.OthersNoArgument, ch, null, victim, SocketConnection.MessageTarget.room); if (!String.IsNullOrEmpty(soc.AudioFile) && ch.InRoom != null) { foreach (CharData cd in ch.InRoom.People) { cd.SendSound(soc.AudioFile); } } return true; } victim = ch.GetCharWorld(arg); if (!victim || (ch.IsRacewar(victim) && ch.InRoom != victim.InRoom)) { ch.SendText("They aren't here.\r\n"); } else if (victim == ch) { SocketConnection.Act(soc.CharSelf, ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act(soc.OthersSelf, ch, null, victim, SocketConnection.MessageTarget.room); if (!String.IsNullOrEmpty(soc.AudioFile) && ch.InRoom != null) { foreach (CharData cd in ch.InRoom.People) { cd.SendSound(soc.AudioFile); } } } else if (!ch.GetCharRoom(arg) && CharData.CanSee(ch, victim) && soc.CharFound.Length > 0 && soc.VictimFound.Length > 0) { if (!ch.IsImmortal()) { ch.SendText("You don't see them here.\r\n"); return true; } if (!victim.IsNPC()) { const string ldbase = "From far away, "; if (victim.IsIgnoring(ch)) { ch.SendText("They are ignoring you.\r\n"); return false; } Room original = ch.InRoom; ch.RemoveFromRoom(); ch.AddToRoom(victim.InRoom); string ldmsg = ldbase; ldmsg += soc.CharFound; SocketConnection.Act(ldmsg, ch, null, victim, SocketConnection.MessageTarget.character); ldmsg = ldbase; ldmsg += soc.VictimFound; SocketConnection.Act(ldmsg, ch, null, victim, SocketConnection.MessageTarget.victim); if (!String.IsNullOrEmpty(soc.AudioFile) && ch.InRoom != null) { foreach (CharData cd in ch.InRoom.People) { cd.SendSound(soc.AudioFile); } } ch.RemoveFromRoom(); ch.AddToRoom(original); } else { ch.SendText("They aren't here.\r\n"); } } else { SocketConnection.Act(soc.CharFound, ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act(soc.VictimFound, ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act(soc.OthersFound, ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); if (!String.IsNullOrEmpty(soc.AudioFile) && ch.InRoom != null) { foreach (CharData cd in ch.InRoom.People) { cd.SendSound(soc.AudioFile); } } // If mobs are to respond to socials, it should be inserted here. // This might be useful for some quests, mob functions, or other things. } return true; }