]>
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; | |
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 | { | |
c8ada07e | 57 | Player *p = source->stats; |
58 | p->forest_fights--; | |
59 | p->fight = new Monster(monsters[p->level - 1][num]); | |
85ce9d3e | 60 | notice(s_GameServ, u, "You search the forest for something to kill..."); |
c8ada07e | 61 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name); |
62 | p->fight->hp = p->fight->maxhp; | |
e282e9d2 | 63 | |
64 | p->battle = NULL; // Just to make sure | |
65 | p->master = NULL; // Just to make sure | |
85ce9d3e | 66 | display_monster(u); |
67 | } | |
68 | else if (is_fighting(u)) | |
69 | { | |
70 | notice(s_GameServ, u, "You want to fight two monsters at once?"); | |
71 | } | |
72 | } | |
73 | ||
74 | } | |
75 | ||
c8ada07e | 76 | Monster *getNewMonster(Monster *m) |
77 | { | |
78 | if (!m) | |
79 | return NULL; | |
80 | ||
81 | Monster *newguy; | |
82 | newguy = new Monster; | |
83 | ||
84 | if (m->name) | |
85 | { | |
86 | newguy->name = new char[strlen(m->name)]; | |
87 | strcpy(newguy->name, m->name); | |
88 | } | |
89 | if (m->weapon) | |
90 | { | |
91 | newguy->weapon = new char[strlen(m->weapon)]; | |
92 | strcpy(newguy->weapon, m->weapon); | |
93 | } | |
94 | if (m->death) | |
95 | { | |
96 | newguy->death = new char[strlen(m->death)]; | |
97 | strcpy(newguy->death, m->death); | |
98 | } | |
99 | ||
100 | newguy->strength = m->strength; | |
101 | newguy->gold = m->gold; | |
102 | newguy->exp = m->exp; | |
103 | newguy->hp = m->hp; | |
104 | newguy->maxhp = m->maxhp; | |
105 | return newguy; | |
106 | } |