69 lines
2.6 KiB
Plaintext
69 lines
2.6 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// Real Time Strategy - NWN - Bug Zapper Creation Tool
|
|
//==============================================================================
|
|
// By Deva Bryson Winblood. 03/11/2003
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "rtsh_multiplay"
|
|
|
|
object fnGetBugTarget()
|
|
{ // find nearest insect or arachnid target
|
|
object oRet=OBJECT_INVALID;
|
|
int nC=1;
|
|
object oMe=OBJECT_SELF;
|
|
object oTest=GetNearestObject(OBJECT_TYPE_CREATURE,oMe,nC);
|
|
float fDist=GetDistanceBetween(oTest,oMe);
|
|
int nType;
|
|
string sTag;
|
|
while (oTest!=OBJECT_INVALID&&fDist<10.1&&oRet==OBJECT_INVALID)
|
|
{ // check creatures within 10 meters
|
|
nType=GetRacialType(oTest);
|
|
sTag=GetTag(oTest);
|
|
if (nType==RACIAL_TYPE_VERMIN) oRet=oTest;
|
|
else if (sTag=="GiantAntQueen"||sTag=="GiantAntGuard"||sTag=="GiantAntHiveQueen"||sTag=="GiantAntLarva"||sTag=="GiantAntSoldier"||sTag=="GiantAntWorker"||sTag=="PurpleWorm"||sTag=="SPID28"||sTag=="SPID27") oRet=oTest;
|
|
nC++;
|
|
oTest=GetNearestObject(OBJECT_TYPE_CREATURE,oMe,nC);
|
|
fDist=GetDistanceBetween(oTest,oMe);
|
|
}// check creatures within 10 meters
|
|
return oRet;
|
|
} // fnGetBugTarget()
|
|
|
|
|
|
void fnBugZapper()
|
|
{ // bug zapper routine
|
|
object oMe=OBJECT_SELF;
|
|
int nCh=GetLocalInt(oMe,"nCharges");
|
|
effect eAttack=EffectBeam(VFX_BEAM_LIGHTNING,oMe,BODY_NODE_CHEST,FALSE);
|
|
effect eDmg=EffectDamage(d6(),DAMAGE_TYPE_ELECTRICAL);
|
|
object oTarget=fnGetBugTarget();
|
|
if (oTarget!=OBJECT_INVALID&&!GetIsDead(oTarget))
|
|
{ // we have a target
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eAttack,oTarget,2.0);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDmg,oTarget,1.0);
|
|
nCh=nCh-1;
|
|
SetLocalInt(oMe,"nCharges",nCh);
|
|
} // we have a target
|
|
if (nCh>0) DelayCommand(2.0,fnBugZapper());
|
|
else
|
|
DestroyObject(oMe);
|
|
} // fnBugZapper()
|
|
|
|
//////////////////////// MAIN //////////////////////////////////////////////
|
|
void main()
|
|
{
|
|
object oPC=GetItemActivator();
|
|
location lLoc=GetItemActivatedTargetLocation();
|
|
object oZapper;
|
|
int nMana=fnGetTeamMana(oPC);
|
|
if (nMana>19)
|
|
{ // have enough Mana
|
|
SendMessageToPC(oPC,"You spent 20 mana to create a Bug Zapper.");
|
|
oZapper=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag29",lLoc,TRUE);
|
|
nMana=nMana-20;
|
|
fnSetTeamMana(oPC,nMana);
|
|
DelayCommand(5.0,SetLocalInt(oZapper,"nCharges",5));
|
|
DelayCommand(5.1,AssignCommand(oZapper,fnBugZapper()));
|
|
} // have enough Mana
|
|
else
|
|
SendMessageToPC(oPC,"This device required 20 mana each usage.");
|
|
}
|