]>
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 | { | |
fbb87959 | 39 | aClient *source; |
40 | ||
41 | if (!(source = find(u))) | |
ee38284f | 42 | { |
fbb87959 | 43 | notice(s_GameServ, u, "Fatal Error in do_forest. Contact a %S admin for help."); |
44 | return; | |
ee38284f | 45 | } |
fbb87959 | 46 | else if (!is_playing(source)) |
85ce9d3e | 47 | { |
fbb87959 | 48 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); |
49 | return; | |
1af35752 | 50 | } |
fbb87959 | 51 | Player *p = source->stats; |
52 | ||
53 | if (!isAlive(p)) | |
1af35752 | 54 | { |
fbb87959 | 55 | notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more."); |
56 | return; | |
85ce9d3e | 57 | } |
fbb87959 | 58 | else |
85ce9d3e | 59 | { |
fbb87959 | 60 | updateTS(source->stats); |
61 | if (p->getForestFights() <= 0) | |
85ce9d3e | 62 | { |
fbb87959 | 63 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ |
64 | "till tomorrow!"); | |
65 | return; | |
85ce9d3e | 66 | } |
fbb87959 | 67 | else if (!is_fighting(source)) |
85ce9d3e | 68 | { |
fbb87959 | 69 | int eventnum = rand() % 100; |
70 | p->subtractForestFights(1); | |
71 | ||
72 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
73 | ||
74 | // 90% of forest searching turns up a monster | |
75 | if (eventnum >= 10) | |
76 | { | |
00e51ca8 | 77 | Monster *tempmonster; |
78 | tempmonster = new Monster(levels[p->getLevel() - 1].randomMonster()); | |
79 | p->setMonster(tempmonster); | |
80 | delete tempmonster; | |
fbb87959 | 81 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->getMonster()->name.c_str()); |
82 | if (p->getMonster()->hp < p->getMonster()->maxhp) | |
83 | p->getMonster()->hp = p->getMonster()->maxhp; | |
84 | ||
85 | p->delBattle(); // Just to make sure | |
86 | p->delMaster(); // Just to make sure | |
87 | display_monster(u); | |
88 | } | |
89 | else if (eventnum < 10 && eventnum >= 9) // 1% for finding potions | |
90 | { | |
91 | list<tavernItem>::iterator temp_tavernitem; | |
92 | ||
93 | notice(s_GameServ, u, "Fortune smiles upon thee!"); | |
94 | ||
95 | eventnum = rand() % tavern.size(); | |
96 | temp_tavernitem = tavern.begin(); | |
97 | for (int x = 0;x < eventnum;x++) | |
98 | { | |
99 | temp_tavernitem++; | |
100 | } | |
101 | notice(s_GameServ, u, "You have found a %s", (*temp_tavernitem).getItem()->getName().c_str()); | |
102 | p->inventory->addItem((*temp_tavernitem).getItem()); | |
103 | } | |
104 | else if (eventnum < 9 && eventnum >= 4) // 5% for the fountain | |
105 | { | |
106 | if (p->getHP() < p->getMaxHP()) | |
107 | { | |
108 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
109 | notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated"); | |
110 | p->healall(); | |
111 | } | |
112 | else | |
113 | { | |
114 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
115 | notice(s_GameServ, u, "You are not thirsty, though, and you don't need healing. Best to leave this for the next warrior"); | |
116 | p->addForestFights(1); | |
117 | } | |
118 | } | |
119 | else if (eventnum < 4) // 4 % for the wishing well | |
120 | { | |
121 | notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well."); | |
122 | if (p->getGold() == 0) | |
123 | { | |
124 | notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today."); | |
125 | p->addForestFights(1); | |
126 | return; | |
127 | } | |
128 | long newstats; | |
129 | notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke."); | |
130 | notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome."); | |
131 | notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer."); | |
132 | notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!"); | |
133 | // 2% for each wishing well chance except for forest fights | |
134 | if (eventnum < 1) // forest fights | |
135 | { | |
136 | newstats = (rand() % 11) + 5; | |
137 | notice(s_GameServ, u, "%ld EXTRA FOREST FIGHTS!!", | |
138 | newstats); | |
139 | p->addForestFights(newstats); | |
140 | } | |
141 | else if (eventnum < 3) | |
142 | { | |
143 | newstats = levels[p->getLevel() - 1].getGold().random(); | |
144 | notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats); | |
145 | p->addGold(newstats); | |
146 | } | |
147 | else | |
148 | { | |
149 | newstats = levels[p->getLevel() - 1].getExp().random(); | |
150 | notice(s_GameServ, u, "Time seems to stand still for a moment."); | |
151 | notice(s_GameServ, u, " %ld EXTRA EXPERIENCE POINTS", newstats); | |
152 | p->addExp(newstats); | |
153 | } | |
154 | } | |
85ce9d3e | 155 | } |
fbb87959 | 156 | else if (is_fighting(u)) |
85ce9d3e | 157 | { |
fbb87959 | 158 | notice(s_GameServ, u, "You want to fight two monsters at once?"); |
85ce9d3e | 159 | } |
fbb87959 | 160 | } |
85ce9d3e | 161 | } |
162 | ||
c8ada07e | 163 | Monster *getNewMonster(Monster *m) |
164 | { | |
165 | if (!m) | |
166 | return NULL; | |
167 | ||
168 | Monster *newguy; | |
169 | newguy = new Monster; | |
ddef84f1 | 170 | newguy->name = m->name; |
171 | newguy->weapon = m->weapon; | |
172 | newguy->death = m->death; | |
c8ada07e | 173 | newguy->strength = m->strength; |
174 | newguy->gold = m->gold; | |
175 | newguy->exp = m->exp; | |
176 | newguy->hp = m->hp; | |
177 | newguy->maxhp = m->maxhp; | |
178 | return newguy; | |
179 | } |