PDA

View Full Version : Quest::Summon();


JrFaust
01-25-2007, 05:26 PM
This is just an idea and a cut and paste job from the source code with minor edits. I think this would work to implement Perl quest summoning. But I've yet to master compiling so if any one has time and a strong heart and willing. Would you be so kind as to try this out?

I know that there are a few of us that would like to be able to summon via quests, and if we could get this in as custom or even offical code that would be great.
If by looking at the code you know it won't/can't work just let me know.


For questmgr.h
void Summon(int entity_id);

For questmgr.ccp
void QuestManager::Summon(int target_id) {
Mob *t;

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
// @merth: Taking this command out until we test the factor of 8 in ServerOP_ZonePlayer
c->Message(0, "Summoning player from another zone not yet implemented.");
return;

ServerPacket* pack = new ServerPacket(ServerOP_ZonePlayer, sizeof(ServerZonePlayer_Struct));
ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer;
strcpy(szp->adminname, c->GetName());
szp->adminrank = c->Admin();
szp->ignorerestrictions = 2;
strcpy(szp->name, sep->arg[1]);
strcpy(szp->zone, zone->GetShortName());
szp->x_pos = c->GetX(); // @merth: May need to add a factor of 8 in here..
szp->y_pos = c->GetY();
szp->z_pos = c->GetZ();
worldserver.SendPacket(pack);
safe_delete(pack);
}
return;
}
}
else if(c->GetTarget()) // have target
t=c->GetTarget();
else
{
if(c->Admin() < 150)
c->Message(0, "You need a NPC/corpse target for this command");
else
c->Message(0, "Usage: #summon [charname] Either target or charname is required");
return;
}

if (t->IsNPC())
{ // npc target
c->Message(0, "Summoning NPC %s to %1.1f, %1.1f, %1.1f", t->GetName(), c->GetX(), c->GetY(), c->GetZ());
t->CastToNPC()->GMMove(c->GetX(), c->GetY(), c->GetZ(), c->GetHeading());
t->CastToNPC()->SaveGuardSpot(true);
}
else if (t->IsCorpse())
{ // corpse target
c->Message(0, "Summoning corpse %s to %1.1f, %1.1f, %1.1f", t->GetName(), c->GetX(), c->GetY(), c->GetZ());
t->CastToCorpse()->GMMove(c->GetX(), c->GetY(), c->GetZ(), c->GetHeading());
}
else if (t->IsClient())
{
if(c->Admin() < 150)
{
c->Message(0, "You may not summon a player.");
return;
}
c->Message(0, "Summoning player %s to %1.1f, %1.1f, %1.1f", t->GetName(), c->GetX(), c->GetY(), c->GetZ());
t->CastToClient()->MovePC(zone->GetZoneID(), c->GetX(), c->GetY(), c->GetZ(), 2, true);
}
}