]>
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" |
8022c441 | 6 | #include "pouch.h" |
7 | #include "sockhelp.h" | |
85ce9d3e | 8 | |
9 | void do_forest(char *u); | |
c8ada07e | 10 | Monster *getNewMonster(Monster *m); |
11 | void deleteMonster(Monster *m); | |
9d057db5 | 12 | |
85ce9d3e | 13 | void forest(char *source, char *buf) |
14 | { | |
15 | char *cmd = strtok(buf, " "); | |
16 | ||
17 | if (cmd[0] == ':') | |
18 | cmd++; | |
19 | if (source[0] == ':') | |
20 | source++; | |
21 | ||
22 | if (stricmp(cmd, "SEARCH") == 0) | |
23 | { | |
24 | do_forest(source); | |
25 | } else if (stricmp(cmd, "ATTACK") == 0) { | |
26 | do_attack(source); | |
c8ada07e | 27 | } else if (stricmp(cmd, "RUN") == 0) { |
28 | do_run(source); | |
ad7dfaa0 | 29 | } else if (stricmp(cmd, "HEAL") == 0) { |
30 | do_heal(source); | |
85ce9d3e | 31 | } |
32 | ||
33 | source--; | |
34 | } | |
35 | ||
36 | void do_forest(char *u) | |
37 | { | |
fbb87959 | 38 | aClient *source; |
39 | ||
40 | if (!(source = find(u))) | |
ee38284f | 41 | { |
fbb87959 | 42 | notice(s_GameServ, u, "Fatal Error in do_forest. Contact a %S admin for help."); |
43 | return; | |
ee38284f | 44 | } |
fbb87959 | 45 | else if (!is_playing(source)) |
85ce9d3e | 46 | { |
fbb87959 | 47 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); |
48 | return; | |
1af35752 | 49 | } |
fbb87959 | 50 | Player *p = source->stats; |
51 | ||
52 | if (!isAlive(p)) | |
1af35752 | 53 | { |
fbb87959 | 54 | notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more."); |
55 | return; | |
85ce9d3e | 56 | } |
fbb87959 | 57 | else |
85ce9d3e | 58 | { |
fbb87959 | 59 | updateTS(source->stats); |
60 | if (p->getForestFights() <= 0) | |
85ce9d3e | 61 | { |
fbb87959 | 62 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ |
63 | "till tomorrow!"); | |
64 | return; | |
85ce9d3e | 65 | } |
fbb87959 | 66 | else if (!is_fighting(source)) |
85ce9d3e | 67 | { |
fbb87959 | 68 | int eventnum = rand() % 100; |
69 | p->subtractForestFights(1); | |
70 | ||
71 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
72 | ||
73 | // 90% of forest searching turns up a monster | |
74 | if (eventnum >= 10) | |
75 | { | |
5de7a0b0 | 76 | p->setMonster(levels[p->getLevel() - 1].randomMonster()); |
77 | ||
fbb87959 | 78 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->getMonster()->name.c_str()); |
79 | if (p->getMonster()->hp < p->getMonster()->maxhp) | |
80 | p->getMonster()->hp = p->getMonster()->maxhp; | |
81 | ||
82 | p->delBattle(); // Just to make sure | |
83 | p->delMaster(); // Just to make sure | |
84 | display_monster(u); | |
85 | } | |
86 | else if (eventnum < 10 && eventnum >= 9) // 1% for finding potions | |
87 | { | |
88 | list<tavernItem>::iterator temp_tavernitem; | |
89 | ||
90 | notice(s_GameServ, u, "Fortune smiles upon thee!"); | |
91 | ||
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()); | |
100 | } | |
101 | else if (eventnum < 9 && eventnum >= 4) // 5% for the fountain | |
102 | { | |
103 | if (p->getHP() < p->getMaxHP()) | |
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->healall(); | |
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->addForestFights(1); | |
114 | } | |
115 | } | |
116 | else if (eventnum < 4) // 4 % for the wishing well | |
117 | { | |
118 | notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well."); | |
119 | if (p->getGold() == 0) | |
120 | { | |
121 | notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today."); | |
122 | p->addForestFights(1); | |
123 | return; | |
124 | } | |
125 | long newstats; | |
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!"); | |
130 | // 2% for each wishing well chance except for forest fights | |
131 | if (eventnum < 1) // forest fights | |
132 | { | |
133 | newstats = (rand() % 11) + 5; | |
134 | notice(s_GameServ, u, "%ld EXTRA FOREST FIGHTS!!", | |
135 | newstats); | |
136 | p->addForestFights(newstats); | |
137 | } | |
138 | else if (eventnum < 3) | |
139 | { | |
140 | newstats = levels[p->getLevel() - 1].getGold().random(); | |
141 | notice(s_GameServ, u, "A SACK WITH %ld GOLD!", newstats); | |
142 | p->addGold(newstats); | |
143 | } | |
144 | else | |
145 | { | |
146 | newstats = levels[p->getLevel() - 1].getExp().random(); | |
147 | notice(s_GameServ, u, "Time seems to stand still for a moment."); | |
148 | notice(s_GameServ, u, " %ld EXTRA EXPERIENCE POINTS", newstats); | |
149 | p->addExp(newstats); | |
150 | } | |
151 | } | |
85ce9d3e | 152 | } |
fbb87959 | 153 | else if (is_fighting(u)) |
85ce9d3e | 154 | { |
fbb87959 | 155 | notice(s_GameServ, u, "You want to fight two monsters at once?"); |
85ce9d3e | 156 | } |
fbb87959 | 157 | } |
85ce9d3e | 158 | } |
159 | ||
c8ada07e | 160 | Monster *getNewMonster(Monster *m) |
161 | { | |
162 | if (!m) | |
163 | return NULL; | |
164 | ||
165 | Monster *newguy; | |
166 | newguy = new Monster; | |
ddef84f1 | 167 | newguy->name = m->name; |
168 | newguy->weapon = m->weapon; | |
169 | newguy->death = m->death; | |
c8ada07e | 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 | } |