]>
Commit | Line | Data |
---|---|---|
1 | #include "sockhelp.h" | |
2 | #include "aClient.h" | |
3 | #include "list.h" | |
4 | #include "extern.h" | |
5 | #include <cctype> | |
6 | ||
7 | void do_forest(char *u); | |
8 | Monster *getNewMonster(Monster *m); | |
9 | void deleteMonster(Monster *m); | |
10 | ||
11 | void forest(char *source, char *buf) | |
12 | { | |
13 | char *cmd = strtok(buf, " "); | |
14 | ||
15 | if (cmd[0] == ':') | |
16 | cmd++; | |
17 | if (source[0] == ':') | |
18 | source++; | |
19 | ||
20 | if (stricmp(cmd, "SEARCH") == 0) | |
21 | { | |
22 | do_forest(source); | |
23 | } else if (stricmp(cmd, "ATTACK") == 0) { | |
24 | do_attack(source); | |
25 | } else if (stricmp(cmd, "RUN") == 0) { | |
26 | do_run(source); | |
27 | } else if (stricmp(cmd, "HEAL") == 0) { | |
28 | do_heal(source); | |
29 | } | |
30 | ||
31 | source--; | |
32 | } | |
33 | ||
34 | void do_forest(char *u) | |
35 | { | |
36 | aClient *source; | |
37 | char *cmd; | |
38 | ||
39 | int num = rand() % 12; | |
40 | ||
41 | source = find(u); | |
42 | ||
43 | if (!is_playing(u)) | |
44 | { | |
45 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); | |
46 | } | |
47 | else | |
48 | { | |
49 | if (source->stats->forest_fights <= 0) | |
50 | { | |
51 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ | |
52 | "till tomorrow!"); | |
53 | return; | |
54 | } | |
55 | else if (isnt_fighting(u)) | |
56 | { | |
57 | Player *p = source->stats; | |
58 | p->forest_fights--; | |
59 | p->fight = new Monster(monsters[p->level - 1][num]); | |
60 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
61 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name); | |
62 | p->fight->hp = p->fight->maxhp; | |
63 | p->battle = NULL; | |
64 | display_monster(u); | |
65 | } | |
66 | else if (is_fighting(u)) | |
67 | { | |
68 | notice(s_GameServ, u, "You want to fight two monsters at once?"); | |
69 | } | |
70 | } | |
71 | ||
72 | } | |
73 | ||
74 | Monster *getNewMonster(Monster *m) | |
75 | { | |
76 | if (!m) | |
77 | return NULL; | |
78 | ||
79 | Monster *newguy; | |
80 | newguy = new Monster; | |
81 | ||
82 | if (m->name) | |
83 | { | |
84 | newguy->name = new char[strlen(m->name)]; | |
85 | strcpy(newguy->name, m->name); | |
86 | } | |
87 | if (m->weapon) | |
88 | { | |
89 | newguy->weapon = new char[strlen(m->weapon)]; | |
90 | strcpy(newguy->weapon, m->weapon); | |
91 | } | |
92 | if (m->death) | |
93 | { | |
94 | newguy->death = new char[strlen(m->death)]; | |
95 | strcpy(newguy->death, m->death); | |
96 | } | |
97 | ||
98 | newguy->strength = m->strength; | |
99 | newguy->gold = m->gold; | |
100 | newguy->exp = m->exp; | |
101 | newguy->hp = m->hp; | |
102 | newguy->maxhp = m->maxhp; | |
103 | return newguy; | |
104 | } |