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
NWScript: void Mimic_Attacks(int myAttack, int opposingAC, object target, float delay=0.0);
void main()
{
int IAmAngry = GetLocalInt( OBJECT_SELF, "HowMad" );
object oPC = GetLastUsedBy();
object oNPC = OBJECT_SELF;
int MyAttack = 15;
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);
Mimic_Attacks(15, GetAC(oPC), oPC,3.0);
SetLocalInt( OBJECT_SELF, "HowMad", --IAmAngry);
}
}
void Mimic_Attacks(int myAttack, int opposingAC, object target, float delay)
{
if ( (myAttack + d20()) >= opposingAC) {
DelayCommand(delay, ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectDamage( d8(), 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 {
DelayCommand(delay, ActionPlayAnimation(ANIMATION_PLACEABLE_CLOSE));
DelayCommand(1.0, ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN));
}
}
In onUsed:
NWScript: void main()
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectDamage( d6() ),
GetLastUsedBy());
SetLocalInt( OBJECT_SELF, "HowMad", 1);
}
In onDamaged, onPhysicalAttack, and onSpellCastAt:
NWScript: void main()
{
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.
NWScript: #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.
|