View Single Post
Old 09-09-2004, 10:30 AM   #6 (permalink)
Halciet
Forum Novice
 
Halciet's Avatar
 
Join Date: Jan 2004
Location: Chapel Hill, NC
Age: 26
Posts: 165
Send a message via ICQ to Halciet Send a message via AIM to Halciet
Default

You don't need to make new bows or anything of that nature. To make every bow/crossbow capable of firing poisoned ammunition, you just need to create two scripts and alter one:

1. Open Arrow.cs; use the find and replace to find all instances of "Arrow" and replace them with with "PoisonedArrow"

In the constructor, add
Code:
Name = "poisoned arrow";
So that it looks like this:

Code:
public PoisonedArrow( int amount ) : base( 0xF3F )
{
        Name = "poisoned arrow";
	Stackable = true;
	Weight = 0.1;
	Amount = amount;
}
Save the file as "PoisonedArrow.cs"

2. Open Bolt.cs; use the find and replace to find all instances of "Bolt" and replace them with "PoisonedBolt"

In the constructor, add
Code:
 Name = "poisoned bolt";
So that it looks like this:

Code:
public PoisonedBolt( int amount ) : base( 0x1BFB )
{
        Name = "poisoned bolt";
	Stackable = true;
	Weight = 0.1;
	Amount = amount;
}
Save the file as "PoisonedBolt.cs"

3. Open BaseRanged.cs

In the constructor, add "Poison = Poison.Lesser;" so that it looks like this:

Code:
public BaseRanged( int itemID ) : base( itemID )
{
     Poison = Poison.Lesser;
}
The will make all bows automatically poisoned, but they won't fire off the poison or display the property since the charges will be set to 0. You can change the poison level to whatever you want here, but for balance sake I just left it at Lesser.

In OnFired, add this code after "Container pack = attacker.Backpack;"

Code:
if( attacker.Player && pack != null && (( AmmoType == typeof(Arrow) && pack.ConsumeTotal( typeof( PoisonArrow ), 1 ) ) || ( AmmoType == typeof(Bolt) && pack.ConsumeTotal( typeof( PoisonBolt), 1 ) ) ) )
{
	PoisonCharges = 1;
				
	attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
				
	return true;
}
In OnHit, add this code after "base.OnHit( attacker, defender );"

Code:
if ( Poison != null && PoisonCharges > 0 )
{
	--PoisonCharges;

	if ( Utility.RandomDouble() >= 0.75 ) // 25% chance to poison
		defender.ApplyPoison( attacker, Poison );
}
There. That makes all your archery weapons capable of shooting lesser poison arrows if you have one in your pack. If you have both poisoned arrows and non-poisoned arrows in your pack, it will use up the poisoned ones first. You could add a context menu entry that lets you choose whether or not you want to fire poisoned or non-poisoned, but that's a bit more in-depth. Similarly, you'd want to make it so players could craft poison arrows, but as far as making them fireable, this is all you need to do.

I went ahead and submitted this to the FAQ section too, since a lot of people ask me how to set this up.

-Hal
Halciet is offline   Reply With Quote