X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/85ce9d3ecb3e6888dae590b3a8e347e0a2131bd9..5b72cf505989156218880f602e68f151c6ea3f3a:/gameserv/c_forest.cpp diff --git a/gameserv/c_forest.cpp b/gameserv/c_forest.cpp index 21e065e..87e20d0 100644 --- a/gameserv/c_forest.cpp +++ b/gameserv/c_forest.cpp @@ -5,6 +5,8 @@ #include void do_forest(char *u); +Monster *getNewMonster(Monster *m); +void deleteMonster(Monster *m); void forest(char *source, char *buf) { @@ -20,6 +22,10 @@ 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); } source--; @@ -28,7 +34,6 @@ source--; void do_forest(char *u) { aClient *source; - char *cmd; int num = rand() % 12; @@ -48,13 +53,15 @@ void do_forest(char *u) } else if (isnt_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 %s!", ni->fight->name); - ni->fight->hp = ni->fight->maxhp; - ni->battle = NULL; + notice(s_GameServ, u, "You have found %s!", 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)) @@ -65,3 +72,34 @@ void do_forest(char *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; +}