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