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