special1.cpp
roh/src-2.44b/special1.cpp · 4.4 KB
From the archive roh-2.44b.tar.bz2
Download the archive « Back to the archive contents
/*
* special1.cpp
* Special routines.
* ____ _
* | _ \ ___ __ _| |_ __ ___ ___
* | |_) / _ \/ _` | | '_ ` _ \/ __|
* | _ < __/ (_| | | | | | | \__ \
* |_| \_\___|\__,_|_|_| |_| |_|___/
*
* Permission to use, modify and distribute is granted via the
* Creative Commons - Attribution - Non Commercial - Share Alike 3.0 License
* http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* Copyright (C) 2007-2009 Jason Mitchell, Randi Mitchell
* Contributions by Tim Callahan, Jonathan Hseu
* Based on Mordor (C) Brooke Paul, Brett J. Vickers, John P. Freeman
*
*/
#include "mud.h"
//*********************************************************************
/* special_obj */
//*********************************************************************
#define SP_INVENTORY 0
#define SP_EQUIPMENT 1
#define SP_ROOM 2
int special_obj(Player* player, cmd* cmnd, int special ) {
Object *object;
int n=0;
char str[80], str2[160], match=0;
unsigned int i=0;
object = findObject(player, player->first_obj, cmnd);
if(!object || !cmnd->val[1]) {
for(n=0; n<MAXWEAR; n++) {
if(!player->ready[n])
continue;
if(keyTxtEqual(player->ready[n], cmnd->str[1]))
match++;
else
continue;
if(match == cmnd->val[1] || !cmnd->val[1]) {
object = player->ready[n];
break;
}
}
}
if(!object)
object = findObject(player, player->getRoom()->first_obj, cmnd);
if(!object) {
player->print("You don't see that.\n");
return(-1);
}
if(object->getSpecial() != special)
return(-2);
switch(object->getSpecial()) {
case SP_MAPSC:
strcpy(str, object->name);
for(i=0; i<strlen(str); i++)
if(str[i] == ' ')
str[i] = '_';
sprintf(str2, "%s/%s.txt", SIGNSCROLL, str);
if(object->flagIsSet(O_LOGIN_FILE))
viewLoginFile(player->getSock(), str2);
else
viewFile(player->getSock(), str2);
return(DOPROMPT);
case SP_COMBO:
return(combo_box(player, object));
default:
player->print("Nothing.\n");
}
return(0);
}
//*********************************************************************
// special_cmd
//*********************************************************************
int special_cmd(Player* player, int special, cmd* cmnd) {
int n=0;
switch(special) {
case SP_MAPSC:
case SP_COMBO:
if(cmnd->num < 2) {
player->print("Do that to what?\n");
return(0);
}
n = special_obj(player, cmnd, special);
if(n == -1)
return(0);
if(n == -2) {
player->print("I'd like to see you try.\n");
return(0);
} else
return(n);
default:
player->print("Nothing happens.\n");
return(0);
}
}
//*********************************************************************
/* combo_box */
//*********************************************************************
int combo_box(Player* player, Object* object ) {
BaseRoom* room = player->getRoom();
xtag *xp;
char str[80];
int dmg, i;
Socket* sock = player->getSock();
str[0] = object->damage.getSides()+'0';
str[1] = 0;
if(object->damage.getNumber() == 1 || strlen(sock->tempstr[3]) > 70)
strcpy(sock->tempstr[3], str);
else
strcat(sock->tempstr[3], str);
player->print("Click.\n");
if(!strcmp(player->name, "Bane"))
player->print("Combo so far: %s\n", sock->tempstr[3]);
broadcast(sock, room, "%M presses %P.", player, object);
if(strlen(sock->tempstr[3]) >= strlen(object->use_output)) {
if(strcmp(sock->tempstr[3], object->use_output)) {
dmg = mrand(20,40 + player->getLevel());
player->hp.decrease(dmg);
player->printColor("You were zapped for %s%d^x damage!\n", player->customColorize("*CC:DAMAGE*"), dmg);
broadcast(sock, room, "%M was zapped by %P!", player, object);
sock->tempstr[3][0] = 0;
if(player->hp.getCur() < 1) {
player->print("You died.\n");
//((Creature*)player)->die((Creature*)player);
player->die(ZAPPED);
}
}
else {
for(i=1, xp = room->first_ext;
xp && i < object->damage.getPlus();
i++, xp = xp->next_tag)
;
if(!xp)
return(0);
player->statistics.combo();
player->print("You opened the %s!\n", xp->ext->name);
broadcast(player->getSock(), player->getRoom(),
"%M opened the %s!", player, xp->ext->name);
xp->ext->clearFlag(X_LOCKED);
xp->ext->clearFlag(X_CLOSED);
xp->ext->ltime.ltime = time(0);
}
}
return(0);
}