]>
Commit | Line | Data |
---|---|---|
1 | #include "sockhelp.h" | |
2 | #include "aClient.h" | |
3 | #include "list.h" | |
4 | #include "extern.h" | |
5 | #include "flags.h" | |
6 | #include <cctype> | |
7 | ||
8 | void do_forest(char *u); | |
9 | Monster *getNewMonster(Monster *m); | |
10 | void deleteMonster(Monster *m); | |
11 | ||
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); | |
26 | } else if (stricmp(cmd, "RUN") == 0) { | |
27 | do_run(source); | |
28 | } else if (stricmp(cmd, "HEAL") == 0) { | |
29 | do_heal(source); | |
30 | } | |
31 | ||
32 | source--; | |
33 | } | |
34 | ||
35 | void do_forest(char *u) | |
36 | { | |
37 | aClient *source; | |
38 | ||
39 | int num = rand() % 12; | |
40 | ||
41 | ||
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)) | |
48 | { | |
49 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); | |
50 | return; | |
51 | } | |
52 | Player *p = source->stats; | |
53 | ||
54 | if (!isAlive(p)) | |
55 | { | |
56 | notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more."); | |
57 | return; | |
58 | } | |
59 | else | |
60 | { | |
61 | if (p->forest_fights <= 0) | |
62 | { | |
63 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ | |
64 | "till tomorrow!"); | |
65 | return; | |
66 | } | |
67 | else if (!is_fighting(u)) | |
68 | { | |
69 | int eventnum = rand() % 100; | |
70 | p->forest_fights--; | |
71 | ||
72 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
73 | ||
74 | // 88% of forest searching turns up a monster | |
75 | if (eventnum >= 12) | |
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); | |
79 | if (p->fight->hp < p->fight->maxhp) | |
80 | p->fight->hp = p->fight->maxhp; | |
81 | ||
82 | p->battle = NULL; // Just to make sure | |
83 | p->master = NULL; // Just to make sure | |
84 | display_monster(u); | |
85 | } | |
86 | else if (eventnum < 12 && eventnum >= 5) // 7% for the fountain | |
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"); | |
90 | p->hp = p->maxhp; | |
91 | } | |
92 | else if (eventnum < 5) // 5 % for the wishing well | |
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!"); | |
104 | // 2% for each wishing well chance except for forest fights | |
105 | if (eventnum < 1) // forest fights | |
106 | { | |
107 | notice(s_GameServ, u, "EXTRA FOREST FIGHTS!!"); | |
108 | p->forest_fights += (rand() % 11) + 5; | |
109 | } | |
110 | else if (eventnum < 3) | |
111 | { | |
112 | notice(s_GameServ, u, "A SACK OF GOLD!"); | |
113 | p->gold += (rand() % 1000) * (p->level + (rand() % 10)); | |
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"); | |
119 | p->exp += (rand() % 100) * (p->level + rand() % 10); | |
120 | } | |
121 | } | |
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 | ||
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 | } |