]>
Commit | Line | Data |
---|---|---|
85ce9d3e | 1 | #include "sockhelp.h" |
2 | #include "aClient.h" | |
3 | #include "list.h" | |
4 | #include "extern.h" | |
5 | #include <cctype> | |
6 | ||
7 | void do_forest(char *u); | |
c8ada07e | 8 | Monster *getNewMonster(Monster *m); |
9 | void deleteMonster(Monster *m); | |
9d057db5 | 10 | |
85ce9d3e | 11 | void forest(char *source, char *buf) |
12 | { | |
13 | char *cmd = strtok(buf, " "); | |
14 | ||
15 | if (cmd[0] == ':') | |
16 | cmd++; | |
17 | if (source[0] == ':') | |
18 | source++; | |
19 | ||
20 | if (stricmp(cmd, "SEARCH") == 0) | |
21 | { | |
22 | do_forest(source); | |
23 | } else if (stricmp(cmd, "ATTACK") == 0) { | |
24 | do_attack(source); | |
c8ada07e | 25 | } else if (stricmp(cmd, "RUN") == 0) { |
26 | do_run(source); | |
ad7dfaa0 | 27 | } else if (stricmp(cmd, "HEAL") == 0) { |
28 | do_heal(source); | |
85ce9d3e | 29 | } |
30 | ||
31 | source--; | |
32 | } | |
33 | ||
34 | void do_forest(char *u) | |
35 | { | |
36 | aClient *source; | |
85ce9d3e | 37 | |
38 | int num = rand() % 12; | |
39 | ||
85ce9d3e | 40 | |
1af35752 | 41 | if (!(source = find(u)) || !source->stats) |
85ce9d3e | 42 | { |
43 | notice(s_GameServ, u, "You must be playing the game to search the forest!"); | |
1af35752 | 44 | return; |
45 | } | |
46 | else if (!is_alive(source)) | |
47 | { | |
48 | notice(s_GameServ, u, "You are dead. Wait until tomorrow to search the forest some more."); | |
49 | return; | |
85ce9d3e | 50 | } |
51 | else | |
52 | { | |
53 | if (source->stats->forest_fights <= 0) | |
54 | { | |
55 | notice(s_GameServ, u, "You are out of forest fights for the day. Wait "\ | |
56 | "till tomorrow!"); | |
57 | return; | |
58 | } | |
1af35752 | 59 | else if (!is_fighting(u)) |
85ce9d3e | 60 | { |
20d5d721 | 61 | int eventnum = rand() % 100; |
62 | Player *p = source->stats; | |
63 | p->forest_fights--; | |
64 | ||
65 | notice(s_GameServ, u, "You search the forest for something to kill..."); | |
66 | ||
67 | if (eventnum >= 25) | |
68 | { | |
69 | p->fight = new Monster(monsters[p->level - 1][num]); | |
70 | notice(s_GameServ, u, "You have found \ 2%s\ 2!", p->fight->name); | |
83cf716f | 71 | if (p->fight->hp < p->fight->maxhp) |
72 | p->fight->hp = p->fight->maxhp; | |
20d5d721 | 73 | |
74 | p->battle = NULL; // Just to make sure | |
75 | p->master = NULL; // Just to make sure | |
76 | display_monster(u); | |
77 | } | |
78 | else if (eventnum < 25 && eventnum >= 15) // 10% | |
79 | { | |
80 | notice(s_GameServ, u, "In your path lies a beautiful fountain from which flows the crystal waters of life."); | |
81 | notice(s_GameServ, u, "You wet your lips on the cool blue waters and feel rejuvenated"); | |
82 | p->forest_fights += 10; | |
83 | p->hp = p->maxhp; | |
84 | } | |
85 | else if (eventnum < 15) // 15 % for the wishing well | |
86 | { | |
87 | notice(s_GameServ, u, "You come upon a pure green emerald studded magic wishing well."); | |
88 | if (p->gold == 0) | |
89 | { | |
90 | notice(s_GameServ, u, "Too bad you're broke. Guess you won't be having any wishes answered today."); | |
91 | return; | |
92 | } | |
93 | notice(s_GameServ, u, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke."); | |
94 | notice(s_GameServ, u, "In an instant, the puff of smoke materializes into a gnome."); | |
95 | notice(s_GameServ, u, "The gnome is holding something in his hand motioning for you to come closer."); | |
96 | notice(s_GameServ, u, "It is a wand! The gnome is waving it through the air towards you!"); | |
97 | // 5% for each wishing well chance | |
98 | if (eventnum < 5) // forest fights | |
99 | { | |
100 | notice(s_GameServ, u, "EXTRA FOREST FIGHTS!!"); | |
9cda831c | 101 | p->forest_fights += (rand() % 11) + 5; |
20d5d721 | 102 | } |
103 | else if (eventnum < 10) | |
104 | { | |
105 | notice(s_GameServ, u, "A SACK OF GOLD!"); | |
9cda831c | 106 | p->gold += (rand() % 1000) * (p->level + (rand() % 10)); |
20d5d721 | 107 | } |
108 | else | |
109 | { | |
110 | notice(s_GameServ, u, "Time seems to stand still for a moment."); | |
111 | notice(s_GameServ, u, "EXTRA EXPERIENCE POINTS"); | |
9cda831c | 112 | p->exp += (rand() % 100) * (p->level + rand() % 10); |
20d5d721 | 113 | } |
114 | } | |
85ce9d3e | 115 | } |
116 | else if (is_fighting(u)) | |
117 | { | |
118 | notice(s_GameServ, u, "You want to fight two monsters at once?"); | |
119 | } | |
120 | } | |
121 | ||
122 | } | |
123 | ||
c8ada07e | 124 | Monster *getNewMonster(Monster *m) |
125 | { | |
126 | if (!m) | |
127 | return NULL; | |
128 | ||
129 | Monster *newguy; | |
130 | newguy = new Monster; | |
131 | ||
132 | if (m->name) | |
133 | { | |
134 | newguy->name = new char[strlen(m->name)]; | |
135 | strcpy(newguy->name, m->name); | |
136 | } | |
137 | if (m->weapon) | |
138 | { | |
139 | newguy->weapon = new char[strlen(m->weapon)]; | |
140 | strcpy(newguy->weapon, m->weapon); | |
141 | } | |
142 | if (m->death) | |
143 | { | |
144 | newguy->death = new char[strlen(m->death)]; | |
145 | strcpy(newguy->death, m->death); | |
146 | } | |
147 | ||
148 | newguy->strength = m->strength; | |
149 | newguy->gold = m->gold; | |
150 | newguy->exp = m->exp; | |
151 | newguy->hp = m->hp; | |
152 | newguy->maxhp = m->maxhp; | |
153 | return newguy; | |
154 | } |