75 lines
2.7 KiB
Plaintext
75 lines
2.7 KiB
Plaintext
/////////////////////////////////////////////////////////////////////////////////
|
|
// Real Time Strategy - NWN - Sludge Factory Creation and Operation
|
|
//==============================================================================
|
|
// By Deva Bryson Winblood. 3/11/2003
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
#include "rtsh_multiplay"
|
|
|
|
void fnFactoryOperation()
|
|
{ // everything the factory does
|
|
object oMe=OBJECT_SELF;
|
|
object oCr;
|
|
int nC=1;
|
|
float fDist;
|
|
object oPC=GetLocalObject(oMe,"oOwner");
|
|
int nMana=fnGetTeamMana(oPC);
|
|
int nOn=GetLocalInt(oMe,"nOn");
|
|
effect ePuff=EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_ACID);
|
|
if (nOn==TRUE)
|
|
{ // it is on
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,ePuff,oMe,1.0);
|
|
ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE,1.0,9.0);
|
|
oCr=GetNearestObject(OBJECT_TYPE_CREATURE,oMe,nC);
|
|
fDist=GetDistanceBetween(oCr,oMe);
|
|
while(oCr!=OBJECT_INVALID&&fDist<15.1&&nMana>8)
|
|
{ // while still valid
|
|
if(GetLocalString(oCr,"sTeamID")=="UNC")
|
|
{ // unclean unit
|
|
if (!GetHasSpellEffect(SPELL_BULLS_STRENGTH,oCr))
|
|
{ // needs the spell
|
|
nMana=nMana-9;
|
|
fnSetTeamMana(oPC,nMana);
|
|
SendMessageToPC(oPC,"The sludge factory used 9 mana to give some food to "+GetName(oCr));
|
|
AssignCommand(oMe,ActionCastSpellAtObject(SPELL_BULLS_STRENGTH,oCr,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE));
|
|
} // needs the spell
|
|
} // unclean unit
|
|
nC++;
|
|
oCr=GetNearestObject(OBJECT_TYPE_CREATURE,oMe,nC);
|
|
fDist=GetDistanceBetween(oCr,oMe);
|
|
} // while still valid
|
|
} // it is on
|
|
else
|
|
{ // it is off
|
|
ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE,1.0,9.0);
|
|
} // it is off
|
|
DelayCommand(10.0,fnFactoryOperation());
|
|
} // fnFactoryOperation()
|
|
|
|
|
|
|
|
void main()
|
|
{
|
|
object oPC=GetItemActivator();
|
|
object oItem=GetItemActivated();
|
|
location lLoc=GetItemActivatedTargetLocation();
|
|
int nMana=fnGetTeamMana(oPC);
|
|
string sID=GetLocalString(oPC,"sTeamID");
|
|
object oFactory;
|
|
if (sID=="UNC")
|
|
{ // Unclean
|
|
if (nMana>49)
|
|
{ // enough mana
|
|
nMana=nMana-50;
|
|
fnSetTeamMana(oPC,nMana);
|
|
SendMessageToPC(oPC,"You use 50 mana to create a sludge factory. Now your units will get strong eating yummy sludge!");
|
|
oFactory=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_pl_mag26",lLoc,TRUE);
|
|
DelayCommand(3.0,SetLocalObject(oFactory,"oOwner",oPC));
|
|
DelayCommand(5.0,AssignCommand(oFactory,fnFactoryOperation()));
|
|
} // enough mana
|
|
else
|
|
SendMessageToPC(oPC,"This device requires 50 mana to use.");
|
|
} // Unclean
|
|
else
|
|
SendMessageToPC(oPC,"You do not have the first idea what this is for. It smells really bad though.");
|
|
}
|