Author Topic: Ignoring the Dead  (Read 336 times)

Denes

  • Traveller
  • *
  • Posts: 32
    • View Profile
Ignoring the Dead
« on: February 25, 2014, 07:37:21 am »
   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:
Code: [Select]
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.

Bonifarzia

  • Hydlaa Notable
  • *
  • Posts: 718
    • View Profile
Re: Ignoring the Dead
« Reply #1 on: February 25, 2014, 09:49:36 am »
Nice idea, Denes - maybe it will be included in the next release?

LigH

  • Forum Legend
  • *
  • Posts: 7096
    • View Profile
Re: Ignoring the Dead
« Reply #2 on: February 25, 2014, 01:23:01 pm »
Somehow I expected a philosophical story from this title, instead... ;D

Gag Harmond
Knight and Ambassador
The Royal House of Purrty

Sajut

  • Traveller
  • *
  • Posts: 36
    • View Profile
Re: Ignoring the Dead
« Reply #3 on: February 25, 2014, 04:26:59 pm »
I like the idea. It should also be possible to target only dead targets
/target [prev|next|nearest] [alive|dead] [item|npc|player|any]."
Its sometimes hard to loot when the attacking NPC's steal your target ;)