Dedication to Action and fun.
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 More than one hostile PC perceived

View previous topic View next topic Go down 
AuthorMessage
lolthatguy

avatar

Posts : 243
Join date : 2013-05-05
Age : 23
Location : larry town

PostSubject: More than one hostile PC perceived   Sat Feb 20, 2016 1:26 pm

I'm trying to make it so if more than one hostile PC is seen by an NPC it'll use a contingency and shoot out helpers to aid it; I don't want the thing to get ganked unfairly and have super inflation due to a much easier kill.

Is there a way to do this?
Back to top Go down
View user profile
Highv Priest
Admin
avatar

Posts : 561
Join date : 2012-09-13

PostSubject: Re: More than one hostile PC perceived   Sun Feb 21, 2016 1:58 am

There is multiple ways for the NPC to go about this. Easiest(and least resource intensive) method would be:
object oTarget = PUT WHATEVER STARTING TARGET THE NPC OBTAINS WHEN DETERMINING INFORMATION.
object oPC;
if(GetIsPC(oTarget))
{
if(GetObjectSeen(oTarget))
{
object oPC = GetFirstFactionMember(oTarget);
while(oPC != OBJECT_INVALID)
{
oPC = GetNextFactionMember(oTarget);
if(GetObjectSeen(oPC) && oPC != oTarget)
{
DO YOUR CALL FOR HELP THING HERE
break;
}
}
}
}





Alternative resource cheap method(not as cheap as the first one, but prevents players from outsmarting the AI by just not being in parties) is to simply use a sphere loop as though you were casting a spell at a location.
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 27.0, GetLocation(OBJECT_SELF), TRUE);
int i = 0;
while(oTarget != OBJECT_INVALID)
{
if(GetIsPC(oTarget))
{
if(GetObjectSeen(oTarget) && i != 1)
{
i++;
}
else if(GetObjectSeen(oTarget))
{
DO CALL FOR HELP THING HERE
break;
}
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 27.0, GetLocation(OBJECT_SELF), TRUE);
}


That's the resource cheap methods. The expensive method is to simply go with:

object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 2, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if(oPC != OBJECT_INVALID)
{
DO YOUR CALL FOR HELP THING HERE

}


Both options would work, but the first option would use up maybe.... 0.000001 seconds of server processing time. Whereas the second option would use up 0.000009 seconds. It sounds like trolling to consider it this way, but that's being generous. GetNearestCreature is the most CPU intensive function in nwn. The more creatures on a map the more insane it's resource use is.
Back to top Go down
View user profile http://badlandsaction.forumotion.com
lolthatguy

avatar

Posts : 243
Join date : 2013-05-05
Age : 23
Location : larry town

PostSubject: Re: More than one hostile PC perceived   Sun Feb 21, 2016 12:03 pm

this is awesome, thanks.
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: More than one hostile PC perceived   

Back to top Go down
 
More than one hostile PC perceived
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Your most hated hostile enemy in Fallout.
» Supposed Hostile Enemies Not Attacking BUG
» Fallout 4: Your worst blunder
» Need help with hostile danse

Permissions in this forum:You cannot reply to topics in this forum
Badlands Action :: Talking about nwn :: Q&A-
Jump to: