move.c
TinyMAZE/src/comm/move.c · 2.4 KB
From the archive TinyMAZEv2.5a.tar.gz
Download the archive « Back to the archive contents
#include <stdio.h>
#include "externs.h"
#include "db.h"
#include "powers.h"
void do_teleport(OBJ *player, char *arg1, char *arg2)
{
OBJ *victim;
OBJ *destination;
char *to;
if(!power(player, POW_TELEPORT))
{
notify(player, perm_denied());
return;
}
/* Get victim */
if(!*arg2)
{
victim = player;
to = arg1;
}
else
{
victim = match_object(player, arg1, TYPE_PLAYER|TYPE_THING);
if(!victim)
{
notify(player, no_match(arg1));
return;
}
to = arg2;
}
/* Get destination */
if(!string_compare(to, "home"))
{
if(!controls(player, victim, POW_TELEPORT) &&
victim->location->owner != player)
{
notify(player, perm_denied());
return;
}
destination = victim->link;
}
else if(!string_compare(to, "back"))
destination = find_object(atoi(atr_get(victim, "LASTLOC")));
else
destination = match_object(player, to, TYPE_ROOM);
if(!destination || Typeof(destination) == TYPE_EXIT)
{
notify(player, no_match(to));
return;
}
if(!controls(player, victim, POW_TELEPORT))
{
notify(player, perm_denied());
return;
}
did_it(victim, victim->location, "LEAVE", NULL, "PLEAVE");
safe_tel(victim, destination);
did_it(victim, victim->location, "ENTER", NULL, "PENTER");
}
void do_join(OBJ *player, char *arg)
{
OBJ *victim;
if(!(victim = match_object(player, arg, NOTYPE)))
if(!(victim = match_player(NULL, arg)))
{
notify(player, no_match(arg));
return;
}
if((!controls(player, victim, POW_JOIN) &&
!controls(player, victim->location, POW_JOIN)) ||
get_class(player->owner) == CLASS_CITIZEN)
{
notify(player, perm_denied());
return;
}
moveto(player, victim->location);
}
void do_summon(OBJ *player, char *arg)
{
OBJ *victim;
OBJ *dest;
dest = player->location;
if(!(victim = match_object(player, arg, TYPE_PLAYER)))
if(!(victim = match_player(NULL, arg)))
{
notify(player, no_match(arg));
return;
}
if(Typeof(player) != TYPE_PLAYER &&
get_class(player->owner) == CLASS_CITIZEN)
{
notify(player, perm_denied());
return;
}
if(!controls(player, victim, POW_SUMMON) ||
!controls(player, victim->location->owner, POW_SUMMON) ||
!controls(player, player->location->owner, POW_SUMMON))
{
notify(player, perm_denied());
return;
}
moveto(victim, dest);
}