So, instead of shuffling through mobs to look for a new target with ‘/target next npc’, it is possible to filter the fallen out. Something like ‘/target next alive npc’ can be implemented. Here is how it works for me:
Index: client/cmdusers.cpp
===================================================================
--- client/cmdusers.cpp (revision 9296)
+++ client/cmdusers.cpp (working copy)
@@ -650,46 +650,54 @@
else if (words[0] == "/target")
{
if (words[1].IsEmpty()) {
- return "You can use /target [self|clear] or /target [prev|next|nearest] [item|npc|player|any].";
+ return "You can use /target [self|clear] or /target [prev|next|nearest] [alive] [item|npc|player|any].";
} else if (words[1] == "self")
psengine->GetCharManager()->SetTarget(psengine->GetCelClient()->GetMainPlayer(),"select");
else
{
SearchDirection dir;
- csString tail;
+ char tailn;
if(words[1] == "next")
{
dir = SEARCH_FORWARD;
- tail = words.GetTail(2);
+ tailn=2;
}
else if(words[1] == "prev")
{
dir = SEARCH_BACK;
- tail = words.GetTail(2);
+ tailn=2;
}
else if(words[1] == "nearest")
{
dir = SEARCH_NONE;
- tail = words.GetTail(2);
+ tailn=2;
}
else
{
dir = SEARCH_NONE;
- tail = words.GetTail(1);
+ tailn=1;
}
+ bool onlyAlive=false;
+ if (words[tailn] == "alive")
+ {
+ onlyAlive=true;
+ tailn++;
+ }
+ csString tail=words.GetTail(tailn);
+
if (tail == "item")
UpdateTarget(dir, PSENTITYTYPE_ITEM, NULL);
else if (tail == "npc")
- UpdateTarget(dir, PSENTITYTYPE_NON_PLAYER_CHARACTER, NULL);
+ UpdateTarget(dir, PSENTITYTYPE_NON_PLAYER_CHARACTER, NULL, onlyAlive);
else if (tail == "player" || tail == "pc")
- UpdateTarget(dir, PSENTITYTYPE_PLAYER_CHARACTER, NULL);
+ UpdateTarget(dir, PSENTITYTYPE_PLAYER_CHARACTER, NULL, onlyAlive);
else if (tail == "any")
- UpdateTarget(dir, PSENTITYTYPE_NO_TARGET, NULL);
+ UpdateTarget(dir, PSENTITYTYPE_NO_TARGET, NULL, onlyAlive);
else if (tail == "clear")
psengine->GetCharManager()->SetTarget(NULL, "select");
else
- UpdateTarget(dir, PSENTITYTYPE_NAME, tail);
+ UpdateTarget(dir, PSENTITYTYPE_NAME, tail, onlyAlive);
}
}
@@ -1364,7 +1372,8 @@
// around to the nearest or furthest entity respectively.
void psUserCommands::UpdateTarget(SearchDirection searchDirection,
EntityTypes entityType,
- const char *name)
+ const char *name,
+ bool onlyAlive)
{
GEMClientObject* startingEntity = psengine->GetCharManager()->GetTarget();
psCelClient* cel = psengine->GetCelClient();
@@ -1428,6 +1437,11 @@
|| (entityType == PSENTITYTYPE_NAME &&
!csString(object->GetName()).StartsWith(name, true)))
continue;
+
+ if ((onlyAlive) && (!object->IsAlive()))
+ {
+ continue;
+ }
csVector3 pos = object->GetPosition();
Index: client/cmdusers.h
===================================================================
--- client/cmdusers.h (revision 9296)
+++ client/cmdusers.h (working copy)
@@ -96,7 +96,8 @@
void UpdateTarget(SearchDirection searchDirection,
EntityTypes entityType,
- const char* name);
+ const char* name,
+ bool onlyAlive=false);
/// Struct to hold our emote data.