Wow, awesome! I just got back from work to all these replies!
'>! I'm
gonna have to sort through these before I have an intelligent reply, but
I wanted to post and say I saw them and you guys are AWESOME.
Especially since this was an additional question from my first one.
Just to be fair and/or get it checked, here's the heartbeat on him at the moment, with my comments and debug stuff still in there. This also still uses randomly generated waypoints instead of farthest away.
#include "zep_inc_monster"
void main()
{
//defining variables
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
object oWP;
string sState = GetLocalString(OBJECT_SELF, "STATE");
effect eTransform = EffectVisualEffect(36);
//If he's already in wisp form...
if (sState == "WISP")
{
//... then don't do anything else yet.
ClearAllActions();
}
//check how close the PC is. If PC is close, then run away, unless you're a wisp.
if ((GetDistanceToObject(oPC) < 5.0) && (sState != "WISP"))
{
//randomly generate which waypoint to move to.
int iRandom = Random(7);
switch (iRandom)
{
case 0: oWP = GetWaypointByTag("WP_zcaveboss_01");
SendMessageToPC(oPC, "WP 1");
break;
case 1: oWP = GetWaypointByTag("WP_zcaveboss_02");
SendMessageToPC(oPC, "WP 2");
break;
case 2: oWP = GetWaypointByTag("WP_zcaveboss_03");
SendMessageToPC(oPC, "WP 3");
break;
case 3: oWP = GetWaypointByTag("WP_zcaveboss_04");
SendMessageToPC(oPC, "WP 4");
break;
case 4: oWP = GetWaypointByTag("WP_zcaveboss_05");
SendMessageToPC(oPC, "WP 5");
break;
case 5: oWP = GetWaypointByTag("WP_zcaveboss_06");
SendMessageToPC(oPC, "WP 6");
break;
case 6: oWP = GetWaypointByTag("WP_zcaveboss_07");
SendMessageToPC(oPC, "WP 7");
break;
}
//howl!
ActionCastSpellAtObject(SPELLABILITY_HOWL_FEAR, oPC, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
//turn to purple wisp and become invincible
ApplyEffectToObject(DURATION_TYPE_INSTANT, eTransform, OBJECT_SELF);
SetCreatureAppearanceType(OBJECT_SELF, 1996);
SetPlotFlag(OBJECT_SELF, 1);
SetLocalString(OBJECT_SELF, "STATE", "WISP");
//move to randomly generated waypoint
DelayCommand(1.0, AssignCommand(OBJECT_SELF, ActionMoveToObject(oWP)));
//wait ten seconds, then return to cerebrilith model and become vulnerable again
DelayCommand(10.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eTransform, OBJECT_SELF));
DelayCommand(10.0, AssignCommand(OBJECT_SELF, SetCreatureAppearanceType(OBJECT_SELF, 2016)));
DelayCommand(10.0, AssignCommand(OBJECT_SELF, SetPlotFlag(OBJECT_SELF, 0)));
DelayCommand(10.0, AssignCommand(OBJECT_SELF, SetLocalString(OBJECT_SELF, "STATE", "NORMAL")));
}
else SendMessageToPC(oPC, "No nearby threats!");
}
I also got some help from my roommate... she does code professionally, but has never used NWN. She suggested a for loop, which I don't quite remember how to do. Here's her psuedo-code:
object currentfurthestobject = GetWaypointByTag("WP_zcaveboss_0" + 1);
currentfurthestdistance = distanceto first way point
//make a while loop, start from second way point in list
while(theres still way points) //or foreach way point
for(int i = 2; i <= 7; i++)
{
currentwaypoint = GetWaypointByTag("WP_zcaveboss_0" + i);
distance = distance to current way point
if(distance > currentfurthestdistance)
{
currentfurthestdistance = distance
currentfurthestobject = currentwaypoint;
}
}
Okay... I'm going to see what I can get working with those resources! Thank you for all your help.
'>
Edit: I frankenstein'd a lot of this together and it seems to be working!
'> He STILL attacks as a wisp/ghost sometimes, though. I'll have to play with that. Thanks for your help, guys!
Modifié par chlorinesea, 17 mars 2011 - 07:57 .