]>
Commit | Line | Data |
---|---|---|
85ce9d3e | 1 | #include "sockhelp.h" |
2 | #include "aClient.h" | |
3 | #include "list.h" | |
4 | #include "extern.h" | |
ee38284f | 5 | #include "flags.h" |
85ce9d3e | 6 | #include <cctype> |
7 | ||
8 | void do_forest(char *u); | |
c8ada07e | 9 | Monster *getNewMonster(Monster *m); |
10 | void deleteMonster(Monster *m); | |
9d057db5 | 11 | |
85ce9d3e | 12 | void forest(char *source, char *buf) |
13 | { | |
14 | char *cmd = strtok(buf, " "); | |
15 | ||
16 | if (cmd[0] == ':') | |
17 | cmd++; | |
18 | if (source[0] == ':') | |
19 | source++; | |
20 | ||
21 | if (stricmp(cmd, "SEARCH") == 0) | |
22 | { | |
23 | do_forest(source); | |
24 | } else if (stricmp(cmd, "ATTACK") == 0) { | |
25 | do_attack(source); | |
c8ada07e | 26 | } else if (stricmp(cmd, "RUN") == 0) { |
27 | do_run(source); | |
ad7dfaa0 | 28 | } else if (stricmp(cmd, "HEAL") == 0) { |
29 | do_heal(source); | |
85ce9d3e | 30 | } |
31 | ||
32 | source--; | |
33 | } | |
34 | ||
35 | void do_forest(char *u) | |
36 | { | |
37 | aClient *source; | |
85ce9d3e | 38 | |
ee38284f | 39 | if (!(source = find(u))) |
40 | { | |
41 | notice(s_GameServ, u, "Fatal Error in do_forest. Contact a %S admin for help."); | |
42 | return; | |
43 | } | |
44 | else if (!is_playing(source)) | |
85ce9d3e | 45 | { |
46 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); | |
1af35752 | 47 | return; |
48 | } | |
ee38284f | 49 | Player *p = source->stats; |
50 | ||
51 | if (!isAlive(p)) | |
1af35752 | 52 | { |
53 | notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more."); | |
54 | return; | |
85ce9d3e | 55 | } |
56 | else | |
57 | { | |
0b6098d5 | 58 | updateTS(source->stats); |
ee38284f | 59 | if (p->forest_fights <= 0) |
85ce9d3e | 60 | { |
61 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ | |
62 | "till tomorrow!"); | |
63 | return; | |
64 | } | |
b410b364 | 65 | else if (!is_fighting(source)) |
85ce9d3e | 66 | { |
20d5d721 | 67 | int eventnum = rand() % 100; |
20d5d721 | 68 | p->forest_fights--; |
69 | ||
70 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
71 | ||
7d1d9eeb | 72 | // 88% of forest searching turns up a monster |
73 | if (eventnum >= 12) | |
20d5d721 | 74 | { |
bf3a2ff9 | 75 | p->fight = new Monster(monsters[p->level - 1].random()); |
20d5d721 | 76 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name); |
83cf716f | 77 | if (p->fight->hp < p->fight->maxhp) |
78 | p->fight->hp = p->fight->maxhp; | |
20d5d721 | 79 | |
80 | p->battle = NULL; // Just to make sure | |
81 | p->master = NULL; // Just to make sure | |
82 | display_monster(u); | |
83 | } | |
2271327b | 84 | else if (eventnum < 12 && eventnum >= 10) // 2% for finding potions |
85 | { | |
86 | notice(s_GameServ, u, "Fortune smiles upon thee!"); | |
87 | ||
88 | eventnum = 1 + rand() % 4; | |
89 | switch(eventnum) | |
90 | { | |
91 | case 1: | |
92 | notice(s_GameServ, u, | |
93 | "You have found an HP Potion!"); | |
94 | p->inventory.incHP(); | |
95 | break; | |
96 | case 2: | |
97 | notice(s_GameServ, u, | |
98 | "You have found a Strength Potion!"); | |
99 | p->inventory.incStrength(); | |
100 | break; | |
101 | case 3: | |
102 | notice(s_GameServ, u, | |
103 | "You have found a Defense Potion!"); | |
104 | p->inventory.incDefense(); | |
105 | break; | |
106 | case 4: | |
107 | notice(s_GameServ, u, | |
108 | "You have found a Healing Potion!"); | |
109 | p->inventory.incHealing(); | |
110 | break; | |
111 | } | |
112 | } | |
113 | else if (eventnum < 10 && eventnum >= 5) // 5% for the fountain | |
20d5d721 | 114 | { |
b478c0df | 115 | if (p->hp < p->maxhp) |
116 | { | |
117 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
118 | notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated"); | |
119 | p->hp = p->maxhp; | |
120 | } | |
121 | else | |
122 | { | |
123 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
124 | notice(s_GameServ, u, "You are not thirsty, though, and you don't need healing. Best to leave this for the next warrior"); | |
125 | p->forest_fights++; | |
126 | } | |
20d5d721 | 127 | } |
ee38284f | 128 | else if (eventnum < 5) // 5 % for the wishing well |
20d5d721 | 129 | { |
130 | notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well."); | |
131 | if (p->gold == 0) | |
132 | { | |
133 | notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today."); | |
9181f3e5 | 134 | p->forest_fights++; |
20d5d721 | 135 | return; |
136 | } | |
7df8f136 | 137 | long newstats; |
20d5d721 | 138 | notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke."); |
139 | notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome."); | |
140 | notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer."); | |
141 | notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!"); | |
ee38284f | 142 | // 2% for each wishing well chance except for forest fights |
143 | if (eventnum < 1) // forest fights | |
20d5d721 | 144 | { |
7df8f136 | 145 | newstats = (rand() % 11) + 5; |
146 | notice(s_GameServ, u, "%ld EXTRA FOREST FIGHTS!!", | |
147 | newstats); | |
148 | p->forest_fights += newstats; | |
20d5d721 | 149 | } |
ee38284f | 150 | else if (eventnum < 3) |
20d5d721 | 151 | { |
7df8f136 | 152 | newstats = (rand() % 1000) * (p->level + (rand() % 10)); |
153 | notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats); | |
154 | p->gold += newstats; | |
20d5d721 | 155 | } |
156 | else | |
157 | { | |
7df8f136 | 158 | newstats = (rand() % 100) * (p->level + rand() % 10); |
20d5d721 | 159 | notice(s_GameServ, u, "Time seems to stand still for a moment."); |
7df8f136 | 160 | notice(s_GameServ, u, " %ld EXTRA EXPERIENCE POINTS", newstats); |
161 | p->exp += newstats; | |
20d5d721 | 162 | } |
163 | } | |
85ce9d3e | 164 | } |
165 | else if (is_fighting(u)) | |
166 | { | |
167 | notice(s_GameServ, u, "You want to fight two monsters at once?"); | |
168 | } | |
169 | } | |
170 | ||
171 | } | |
172 | ||
c8ada07e | 173 | Monster *getNewMonster(Monster *m) |
174 | { | |
175 | if (!m) | |
176 | return NULL; | |
177 | ||
178 | Monster *newguy; | |
179 | newguy = new Monster; | |
180 | ||
181 | if (m->name) | |
182 | { | |
183 | newguy->name = new char[strlen(m->name)]; | |
184 | strcpy(newguy->name, m->name); | |
185 | } | |
186 | if (m->weapon) | |
187 | { | |
188 | newguy->weapon = new char[strlen(m->weapon)]; | |
189 | strcpy(newguy->weapon, m->weapon); | |
190 | } | |
191 | if (m->death) | |
192 | { | |
193 | newguy->death = new char[strlen(m->death)]; | |
194 | strcpy(newguy->death, m->death); | |
195 | } | |
196 | ||
197 | newguy->strength = m->strength; | |
198 | newguy->gold = m->gold; | |
199 | newguy->exp = m->exp; | |
200 | newguy->hp = m->hp; | |
201 | newguy->maxhp = m->maxhp; | |
202 | return newguy; | |
203 | } |