Thread: #warpto
View Single Post
  #1  
Old 08-10-2010, 03:45 PM
Tabasco's Avatar
Tabasco
Discordant
 
Join Date: Sep 2009
Posts: 269
Default #warpto

I put this in as a sort of reverse summon since I typically find myself needing to travel to a player's exact location rather than the other way around.

Code:
Index: command.cpp
===================================================================
--- command.cpp (revision 1612)
+++ command.cpp (working copy)
@@ -184,6 +184,7 @@
                command_add("log","- Search character event log",80,command_log) ||
                command_add("gm","- Turn player target's or your GM flag on or off",80,command_gm) ||
                command_add("summon","[charname] - Summons your player/npc/corpse target, or charname if specified",80,command_summon) || 
+               command_add("warpto","[charname] - warps to player/npc/corpse target, or charname if specified",80,command_warpto) || 
                command_add("zone","[zonename] [x] [y] [z] - Go to specified zone (coords optional)",50,command_zone) ||
                command_add("zoneinstance","[instanceid] [x] [y] [z] - Go to specified instance zone (coords optional)",50,command_zone_instance) ||
         command_add("peqzone","[zonename] - Go to specified zone, if you have > 75% health",0,command_peqzone) ||
@@ -305,7 +306,7 @@
                command_add("nukebuffs","- Strip all buffs on you or your target",50,command_nukebuffs) ||
                command_add("freeze","- Freeze your target",80,command_freeze) ||
                command_add("unfreeze","- Unfreeze your target",80,command_unfreeze) ||
-               command_add("pvp","[on/off] - Set your or your player target's PVP status",100,command_pvp) ||
+               command_add("pvp","[on/off] - Set you or your player target's PVP status",100,command_pvp) ||
                command_add("setxp","[value] - Set your or your player target's experience",100,command_setxp) ||
                command_add("setpvppoints","[value] - Set your or your player target's PVP points",100,command_setpvppoints) ||
                command_add("setexp",NULL,0,command_setxp) ||
@@ -1406,6 +1407,59 @@
        }
 }
 
+// Adapted from command_summon
+void command_warpto(Client *c, const Seperator *sep)
+{
+       Mob *t;
+       int32 acc, zid, inst;
+       float px, py, pz;
+
+       if(sep->arg[1][0] != 0)         // arg specified
+       {
+               Client* client = entity_list.GetClientByName(sep->arg[1]);
+               if (client != 0)        // found player in zone
+                       t=client->CastToMob();
+               else 
+               {
+                       if (!worldserver.Connected())
+                               c->Message(0, "Error: World server disconnected.");
+                       else
+                       { // player is in another zone
+                               database.GetCharacterInfo(sep->arg[1], &acc, &zid, &inst, &px, &py, &pz);
+                               c->Message(0, "Warping to %s at %1.1f, %1.1f, %1.1f", sep->arg[1], px, py, pz);
+                               c->MovePC(zid, px, py, pz, 0.0f, 0);
+                       }
+                       return;
+               }
+       }
+       else if(c->GetTarget())         // have target
+               t=c->GetTarget();
+       else
+       {
+               c->Message(0, "Usage: #warpto [charname] Either target or charname is required");
+               return;
+       }
+
+       if(!t)
+               return;
+
+       if (t->IsNPC())
+       { // npc target
+               c->Message(0, "Warping to %s at %1.1f, %1.1f, %1.1f", t->GetName(), t->GetX(), t->GetY(), t->GetZ());
+               c->MovePC(zone->GetZoneID(), t->GetX(), t->GetY(), t->GetZ(), 0.0f, 0);
+       }
+       else if (t->IsCorpse())
+       { // corpse target
+               c->Message(0, "Warping to %s at %1.1f, %1.1f, %1.1f", t->GetName(), t->GetX(), t->GetY(), t->GetZ());
+               c->MovePC(zone->GetZoneID(), t->GetX(), t->GetY(), t->GetZ(), 0.0f, 0);
+       }
+       else if (t->IsClient())
+       {
+               c->Message(0, "Warping to %s at %1.1f, %1.1f, %1.1f", t->GetName(), t->GetX(), t->GetY(), t->GetZ());
+               c->MovePC(zone->GetZoneID(), t->GetX(), t->GetY(), t->GetZ(), 0.0f, 0);
+       }
+}
+
 void command_zone(Client *c, const Seperator *sep)
 {
        if(c->Admin() < commandZoneToCoords &&
Code:
Index: command.h
===================================================================
--- command.h   (revision 1612)
+++ command.h   (working copy)
@@ -91,6 +91,7 @@
 void command_log(Client *c, const Seperator *sep);
 void command_gm(Client *c, const Seperator *sep);
 void command_summon(Client *c, const Seperator *sep);
+void command_warpto(Client *c, const Seperator *sep);
 void command_zone(Client *c, const Seperator *sep);
 void command_zone_instance(Client *c, const Seperator *sep);
 void command_peqzone(Client *c, const Seperator *sep);
Reply With Quote