#include <cctype>
void do_forest(char *u);
-
+Monster *getNewMonster(Monster *m);
+void deleteMonster(Monster *m);
void forest(char *source, char *buf)
{
do_forest(source);
} else if (stricmp(cmd, "ATTACK") == 0) {
do_attack(source);
+ } else if (stricmp(cmd, "RUN") == 0) {
+ do_run(source);
} else if (stricmp(cmd, "HEAL") == 0) {
do_heal(source);
}
void do_forest(char *u)
{
aClient *source;
- char *cmd;
int num = rand() % 12;
- source = find(u);
- if (!is_playing(u))
+ if (!(source = find(u)) || !source->stats)
{
notice(s_GameServ, u, "You must be playing the game to search the forest!");
+ return;
+ }
+ else if (!is_alive(source))
+ {
+ notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more.");
+ return;
}
else
{
"till tomorrow!");
return;
}
- else if (isnt_fighting(u))
+ else if (!is_fighting(u))
{
- Player *ni = source->stats;
- ni->forest_fights--;
- ni->fight = &monsters[ni->level - 1][num];
+ Player *p = source->stats;
+ p->forest_fights--;
+ p->fight = new Monster(monsters[p->level - 1][num]);
notice(s_GameServ, u, "You search the forest for something to kill...");
- notice(s_GameServ, u, "You have found \ 2%s\ 2!", ni->fight->name);
- ni->fight->hp = ni->fight->maxhp;
- ni->battle = NULL;
+ notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name);
+ p->fight->hp = p->fight->maxhp;
+
+ p->battle = NULL; // Just to make sure
+ p->master = NULL; // Just to make sure
display_monster(u);
}
else if (is_fighting(u))
}
+Monster *getNewMonster(Monster *m)
+{
+ if (!m)
+ return NULL;
+
+ Monster *newguy;
+ newguy = new Monster;
+
+ if (m->name)
+ {
+ newguy->name = new char[strlen(m->name)];
+ strcpy(newguy->name, m->name);
+ }
+ if (m->weapon)
+ {
+ newguy->weapon = new char[strlen(m->weapon)];
+ strcpy(newguy->weapon, m->weapon);
+ }
+ if (m->death)
+ {
+ newguy->death = new char[strlen(m->death)];
+ strcpy(newguy->death, m->death);
+ }
+
+ newguy->strength = m->strength;
+ newguy->gold = m->gold;
+ newguy->exp = m->exp;
+ newguy->hp = m->hp;
+ newguy->maxhp = m->maxhp;
+ return newguy;
+}