]>
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 | |
39 | int num = rand() % 12; | |
40 | ||
85ce9d3e | 41 | |
ee38284f | 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)) | |
85ce9d3e | 48 | { |
49 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); | |
1af35752 | 50 | return; |
51 | } | |
ee38284f | 52 | Player *p = source->stats; |
53 | ||
54 | if (!isAlive(p)) | |
1af35752 | 55 | { |
56 | notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more."); | |
57 | return; | |
85ce9d3e | 58 | } |
59 | else | |
60 | { | |
0b6098d5 | 61 | updateTS(source->stats); |
ee38284f | 62 | if (p->forest_fights <= 0) |
85ce9d3e | 63 | { |
64 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ | |
65 | "till tomorrow!"); | |
66 | return; | |
67 | } | |
b410b364 | 68 | else if (!is_fighting(source)) |
85ce9d3e | 69 | { |
20d5d721 | 70 | int eventnum = rand() % 100; |
20d5d721 | 71 | p->forest_fights--; |
72 | ||
73 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
74 | ||
7d1d9eeb | 75 | // 88% of forest searching turns up a monster |
76 | if (eventnum >= 12) | |
20d5d721 | 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); | |
83cf716f | 80 | if (p->fight->hp < p->fight->maxhp) |
81 | p->fight->hp = p->fight->maxhp; | |
20d5d721 | 82 | |
83 | p->battle = NULL; // Just to make sure | |
84 | p->master = NULL; // Just to make sure | |
85 | display_monster(u); | |
86 | } | |
7d1d9eeb | 87 | else if (eventnum < 12 && eventnum >= 5) // 7% for the fountain |
20d5d721 | 88 | { |
b478c0df | 89 | if (p->hp < p->maxhp) |
90 | { | |
91 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
92 | notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated"); | |
93 | p->hp = p->maxhp; | |
94 | } | |
95 | else | |
96 | { | |
97 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
98 | notice(s_GameServ, u, "You are not thirsty, though, and you don't need healing. Best to leave this for the next warrior"); | |
99 | p->forest_fights++; | |
100 | } | |
20d5d721 | 101 | } |
ee38284f | 102 | else if (eventnum < 5) // 5 % for the wishing well |
20d5d721 | 103 | { |
104 | notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well."); | |
105 | if (p->gold == 0) | |
106 | { | |
107 | notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today."); | |
108 | return; | |
109 | } | |
7df8f136 | 110 | long newstats; |
20d5d721 | 111 | notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke."); |
112 | notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome."); | |
113 | notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer."); | |
114 | notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!"); | |
ee38284f | 115 | // 2% for each wishing well chance except for forest fights |
116 | if (eventnum < 1) // forest fights | |
20d5d721 | 117 | { |
7df8f136 | 118 | newstats = (rand() % 11) + 5; |
119 | notice(s_GameServ, u, "%ld EXTRA FOREST FIGHTS!!", | |
120 | newstats); | |
121 | p->forest_fights += newstats; | |
20d5d721 | 122 | } |
ee38284f | 123 | else if (eventnum < 3) |
20d5d721 | 124 | { |
7df8f136 | 125 | newstats = (rand() % 1000) * (p->level + (rand() % 10)); |
126 | notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats); | |
127 | p->gold += newstats; | |
20d5d721 | 128 | } |
129 | else | |
130 | { | |
7df8f136 | 131 | newstats = (rand() % 100) * (p->level + rand() % 10); |
20d5d721 | 132 | notice(s_GameServ, u, "Time seems to stand still for a moment."); |
7df8f136 | 133 | notice(s_GameServ, u, " %ld EXTRA EXPERIENCE POINTS", newstats); |
134 | p->exp += newstats; | |
20d5d721 | 135 | } |
136 | } | |
85ce9d3e | 137 | } |
138 | else if (is_fighting(u)) | |
139 | { | |
140 | notice(s_GameServ, u, "You want to fight two monsters at once?"); | |
141 | } | |
142 | } | |
143 | ||
144 | } | |
145 | ||
c8ada07e | 146 | Monster *getNewMonster(Monster *m) |
147 | { | |
148 | if (!m) | |
149 | return NULL; | |
150 | ||
151 | Monster *newguy; | |
152 | newguy = new Monster; | |
153 | ||
154 | if (m->name) | |
155 | { | |
156 | newguy->name = new char[strlen(m->name)]; | |
157 | strcpy(newguy->name, m->name); | |
158 | } | |
159 | if (m->weapon) | |
160 | { | |
161 | newguy->weapon = new char[strlen(m->weapon)]; | |
162 | strcpy(newguy->weapon, m->weapon); | |
163 | } | |
164 | if (m->death) | |
165 | { | |
166 | newguy->death = new char[strlen(m->death)]; | |
167 | strcpy(newguy->death, m->death); | |
168 | } | |
169 | ||
170 | newguy->strength = m->strength; | |
171 | newguy->gold = m->gold; | |
172 | newguy->exp = m->exp; | |
173 | newguy->hp = m->hp; | |
174 | newguy->maxhp = m->maxhp; | |
175 | return newguy; | |
176 | } |