]>
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 | { | |
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 | } | |
1af35752 | 67 | else if (!is_fighting(u)) |
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 | ||
7d1d9eeb | 74 | // 88% of forest searching turns up a monster |
75 | if (eventnum >= 12) | |
20d5d721 | 76 | { |
77 | p->fight = new Monster(monsters[p->level - 1][num]); | |
78 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name); | |
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 | } | |
7d1d9eeb | 86 | else if (eventnum < 12 && eventnum >= 5) // 7% for the fountain |
20d5d721 | 87 | { |
88 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
89 | notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated"); | |
20d5d721 | 90 | p->hp = p->maxhp; |
91 | } | |
ee38284f | 92 | else if (eventnum < 5) // 5 % for the wishing well |
20d5d721 | 93 | { |
94 | notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well."); | |
95 | if (p->gold == 0) | |
96 | { | |
97 | notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today."); | |
98 | return; | |
99 | } | |
100 | notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke."); | |
101 | notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome."); | |
102 | notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer."); | |
103 | notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!"); | |
ee38284f | 104 | // 2% for each wishing well chance except for forest fights |
105 | if (eventnum < 1) // forest fights | |
20d5d721 | 106 | { |
107 | notice(s_GameServ, u, "EXTRA FOREST FIGHTS!!"); | |
9cda831c | 108 | p->forest_fights += (rand() % 11) + 5; |
20d5d721 | 109 | } |
ee38284f | 110 | else if (eventnum < 3) |
20d5d721 | 111 | { |
112 | notice(s_GameServ, u, "A SACK OF GOLD!"); | |
9cda831c | 113 | p->gold += (rand() % 1000) * (p->level + (rand() % 10)); |
20d5d721 | 114 | } |
115 | else | |
116 | { | |
117 | notice(s_GameServ, u, "Time seems to stand still for a moment."); | |
118 | notice(s_GameServ, u, "EXTRA EXPERIENCE POINTS"); | |
9cda831c | 119 | p->exp += (rand() % 100) * (p->level + rand() % 10); |
20d5d721 | 120 | } |
121 | } | |
85ce9d3e | 122 | } |
123 | else if (is_fighting(u)) | |
124 | { | |
125 | notice(s_GameServ, u, "You want to fight two monsters at once?"); | |
126 | } | |
127 | } | |
128 | ||
129 | } | |
130 | ||
c8ada07e | 131 | Monster *getNewMonster(Monster *m) |
132 | { | |
133 | if (!m) | |
134 | return NULL; | |
135 | ||
136 | Monster *newguy; | |
137 | newguy = new Monster; | |
138 | ||
139 | if (m->name) | |
140 | { | |
141 | newguy->name = new char[strlen(m->name)]; | |
142 | strcpy(newguy->name, m->name); | |
143 | } | |
144 | if (m->weapon) | |
145 | { | |
146 | newguy->weapon = new char[strlen(m->weapon)]; | |
147 | strcpy(newguy->weapon, m->weapon); | |
148 | } | |
149 | if (m->death) | |
150 | { | |
151 | newguy->death = new char[strlen(m->death)]; | |
152 | strcpy(newguy->death, m->death); | |
153 | } | |
154 | ||
155 | newguy->strength = m->strength; | |
156 | newguy->gold = m->gold; | |
157 | newguy->exp = m->exp; | |
158 | newguy->hp = m->hp; | |
159 | newguy->maxhp = m->maxhp; | |
160 | return newguy; | |
161 | } |