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