1. Mimic (Monster in a box)

2. Makes a placeable object attack back.

3. This script might not be the cleanest thing around, but it does work.

Put this in onHeartbeat




void Mimic_Attacks(int myAttack, int opposingAC, object target);
void main()
{
int IAmAngry = GetLocalInt( OBJECT_SELF, "HowMad" );
object oPC = GetLastUsedBy();
object oNPC = OBJECT_SELF;
if ( GetDistanceToObject(oPC) < 5.0 && IAmAngry) {
if ( !GetIsOpen(OBJECT_SELF) )
ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN);
if ( GetLastDamager() != OBJECT_INVALID) oPC = GetLastDamager();
Mimic_Attacks(15, GetAC(oPC), oPC);
DelayCommand(3.0, Mimic_Attacks(15, GetAC(oPC), oPC));
SetLocalInt( OBJECT_SELF, "HowMad", --IAmAngry);
}
}
void Mimic_Attacks(int myAttack, int opposingAC, object target)
{
int attackRoll = d20();
int myToHit = myAttack + attackRoll;
string roll = IntToString( myAttack ) + " + " + IntToString( attackRoll )
+ " = " + IntToString( myToHit );
if ( myToHit >= opposingAC) {
string hit = "Mimic attacks you and hits: ";
hit += roll + ".";
SendMessageToPC(target, hit);
int dmgAmount = d8();
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectDamage(dmgAmount, DAMAGE_TYPE_NEGATIVE),
target);
ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectVisualEffect( VFX_COM_HIT_NEGATIVE ),
target );
DelayCommand(1.0, ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN));
}
else {
string miss = "Mimic attacks you and misses: ";
miss += roll + ".";
SendMessageToPC( target, miss );
ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE);
DelayCommand(1.0, ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN));
}
}




In onUsed:




void main()
{
//hits you if you try to use it
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectDamage( d6() ),
GetLastUsedBy());
SetLocalInt( OBJECT_SELF, "HowMad", 1);
}






In onDamaged, onPhysicalAttack, and onSpellCastAt:





void main()
{
//Stays mad while being attacked.
SetLocalInt( OBJECT_SELF, "HowMad", 3);
}





I included an explosion death for kicks using some of the code that I found on this thread. I also added some XP for killing it.

Put this in onDeath, if you just want the xp, take out everything but the include and the RewardXP function.




#include "nw_i0_tool"
void main()
{
location loc = GetLocation(OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
EffectVisualEffect( VFX_FNF_FIREBALL ),
loc);
object newTarget = GetFirstObjectInShape(SHAPE_SPHERE, 10.0, loc);
while (newTarget != OBJECT_INVALID)
{
if ( GetIsPC(newTarget) )
ApplyEffectToObject( DURATION_TYPE_INSTANT,
EffectDamage ( d6(2), DAMAGE_TYPE_FIRE ),
newTarget);
newTarget = GetNextObjectInShape(SHAPE_SPHERE, 10.0, loc);
}
RewardPartyXP(1000, GetLastAttacker());
}





It works fine for me, but if there's any problems, I'll try to fix it. Also make sure that you give the item more hit points than normal or it'll be too easy to kill.