Hi all

Got a strange request/query

I want to modify the playermobile script so that one player in particular, gives off a poisonous cloud around them.
Meaning, when they get within 2 tiles of a vendor or animal, the animal/vendor is then poisoned, lol.
It's mostly for fun, I want to wind up a female friend of mine.
I thought, perhaps the code from the Pyre script could be somehow modified to work for this purpose, but was wanting some advice, as I can't get it to work.
While it compiles ok, nothing seems to happen when she is near anything.
I'm guessing it's not as simple as copying/pasting code from one script to another lol

This is the section I added to the playermobile code:

bool tick = false;
public virtual void OnThink()
{
if (this.Account.Username == "FriendsAccount")
{
tick = !tick;

if (tick)
return;

List<Mobile> targets = new List<Mobile>();

if (Map != null)
foreach (Mobile m in GetMobilesInRange(2))
if (this != m && SpellHelper.ValidIndirectTarget(this, m) && CanBeHarmful(m, false) && (!Core.AOS || InLOS(m)))
targets.Add(m);
for (int i = 0; i < targets.Count; ++i)
{
Mobile m = targets;

AOS.Damage(m, this, 5, 0, 100, 0, 0, 0);
m.Poison = Poison.Lethal;
m.Title = "Poisoned!";
}
}
}
 
I would not modify the PlayerMobile for this. If you have XML Attachments, you could probably do this with an attachment. Otherwise, you can catch movement in general, and check to see if the movement involves your friend and if so, check for other mobiles in range.
 
I am all for doing things with EventSink rather than modifying existing scripts. Makes it much cleaner. Give this a try after you add your poison or whatever:

Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Misc
{
    public class PoisonedFriend
    {

        public static void Initialize()
        {
            EventSink.Movement += new MovementEventHandler(EventSink_FriendMovementCheck);
        }
		
        private static void EventSink_FriendMovementCheck(MovementEventArgs args)
        {
            Mobile mover = args.Mobile;
			
			if (mover is PlayerMobile && ((PlayerMobile)mover).Name == "YourFriendsCharacterName")
			{
				foreach (object o in mover.GetObjectsInRange(3)) // Set the range of infection here
				{
					if (o is Vendor)
					{
						Vendor vendor = o as Vendor;
						// Here add your poison to the vendor...
					}
					else if (o is BaseCreature)
					{
						BaseCreature creature = o as BaseCreature;
						// Here add your poison to the creature...
					}
				}
			}
		}
	}
}
 
Ok, error I'm getting is.....

Code:
Errors:
 + Customs/AdamsCustoms/Carp/PoisonMovement.cs:
  CS1061: Line 27: 'object' does not contain a definition for 'Poison' and no
extension method 'Poison' accepting a first argument of type 'object' could be f
ound (are you missing a using directive or an assembly reference?)
  CS1061: Line 32: 'object' does not contain a definition for 'Poison' and no
extension method 'Poison' accepting a first argument of type 'object' could be f
ound (are you missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
 
Thanks for that, I modified it a bit and it works perfectly lol.
Added a check in so she can't poison people's pets, I think I did it right.

Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Misc
{
  public class PoisonedFriend
  {

  public static void Initialize()
  {
  EventSink.Movement += new MovementEventHandler(EventSink_FriendMovementCheck);
  }

  private static void EventSink_FriendMovementCheck(MovementEventArgs args)
  {
  Mobile mover = args.Mobile;

  if (mover is PlayerMobile && ((PlayerMobile)mover).Name == "Friend")
  {
  foreach (object o in mover.GetObjectsInRange(1)) // Set the range of infection here
  {
  if (o is BaseVendor)
  {
  BaseVendor vendor = o as BaseVendor;
  vendor.Poison = Poison.Lethal;
  vendor.Hue = 26;
  }
  if (o is Food)
  {
  Food food = o as Food;
  food.Poison = Poison.Lethal;
  food.Hue = 26;
  food.EngravedText = "<BASEFONT COLOR=#FFC0CB>Poisoned!<BASEFONT COLOR=#FFFFFF>";
  }
  else if (o is BaseCreature)
  {
  BaseCreature creature = o as BaseCreature;
  if (creature.Controlled)
  return;
  creature.Hue = 26;
  creature.Poison = Poison.Lethal;
  }
  }
  }
  }
  }
}
 
Ok, one last question, can it be set so when the poison is applied, to say vendors or a creature, she is flagged?
I thought about adding a line such as - vendor.Combatant = 0x537C "name";
But that doesn't work.
I need it so she is responsible for deaths of innocent vendors (I already have it so vendors give counts lol)
 
Back