#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];
- 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;
- display_monster(u);
+ int eventnum = rand() % 100;
+ Player *p = source->stats;
+ p->forest_fights--;
+
+ notice(s_GameServ, u, "You search the forest for something to kill...");
+
+ if (eventnum >= 25)
+ {
+ p->fight = new Monster(monsters[p->level - 1][num]);
+ notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name);
+ if (p->fight->hp < p->fight->maxhp)
+ 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 (eventnum < 25 && eventnum >= 15) // 10%
+ {
+ notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
+ notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated");
+ p->forest_fights += 10;
+ p->hp = p->maxhp;
+ }
+ else if (eventnum < 15) // 15 % for the wishing well
+ {
+ notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well.");
+ if (p->gold == 0)
+ {
+ notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today.");
+ return;
+ }
+ notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke.");
+ notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome.");
+ notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer.");
+ notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!");
+ // 5% for each wishing well chance
+ if (eventnum < 5) // forest fights
+ {
+ notice(s_GameServ, u, "EXTRA FOREST FIGHTS!!");
+ p->forest_fights += (rand() % 11) + 5;
+ }
+ else if (eventnum < 10)
+ {
+ notice(s_GameServ, u, "A SACK OF GOLD!");
+ p->gold += (rand() % 1000) * (p->level + (rand() % 10));
+ }
+ else
+ {
+ notice(s_GameServ, u, "Time seems to stand still for a moment.");
+ notice(s_GameServ, u, "EXTRA EXPERIENCE POINTS");
+ p->exp += (rand() % 100) * (p->level + rand() % 10);
+ }
+ }
}
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;
+}