]>
jfr.im git - irc/gameservirc.git/blob - gameserv/c_forest.cpp
8 void do_forest(char *u
);
9 Monster
*getNewMonster(Monster
*m
);
10 void deleteMonster(Monster
*m
);
12 void forest(char *source
, char *buf
)
14 char *cmd
= strtok(buf
, " ");
21 if (stricmp(cmd
, "SEARCH") == 0)
24 } else if (stricmp(cmd
, "ATTACK") == 0) {
26 } else if (stricmp(cmd
, "RUN") == 0) {
28 } else if (stricmp(cmd
, "HEAL") == 0) {
35 void do_forest(char *u
)
39 if (!(source
= find(u
)))
41 notice(s_GameServ
, u
, "Fatal Error in do_forest. Contact a %S admin for help.");
44 else if (!is_playing(source
))
46 notice(s_GameServ
, u
, "You must be playing the game to search the forest!");
49 Player
*p
= source
->stats
;
53 notice(s_GameServ
, u
, "You are dead. Wait until tomorrow to search the forest some more.");
58 updateTS(source
->stats
);
59 if (p
->forest_fights
<= 0)
61 notice(s_GameServ
, u
, "You are out of forest fights for the day. Wait "\
65 else if (!is_fighting(source
))
67 int eventnum
= rand() % 100;
70 notice(s_GameServ
, u
, "You search the forest for something to kill...");
72 // 88% of forest searching turns up a monster
75 p
->fight
= new Monster(levels
[p
->level
- 1].randomMonster());
76 notice(s_GameServ
, u
, "You have found \ 2%s\ 2!", p
->fight
->name
);
77 if (p
->fight
->hp
< p
->fight
->maxhp
)
78 p
->fight
->hp
= p
->fight
->maxhp
;
80 p
->battle
= NULL
; // Just to make sure
81 p
->master
= NULL
; // Just to make sure
84 else if (eventnum
< 12 && eventnum
>= 10) // 2% for finding potions
86 notice(s_GameServ
, u
, "Fortune smiles upon thee!");
88 eventnum
= 1 + rand() % 4;
93 "You have found an HP Potion!");
98 "You have found a Strength Potion!");
99 p
->inventory
.incStrength();
102 notice(s_GameServ
, u
,
103 "You have found a Defense Potion!");
104 p
->inventory
.incDefense();
107 notice(s_GameServ
, u
,
108 "You have found a Healing Potion!");
109 p
->inventory
.incHealing();
113 else if (eventnum
< 10 && eventnum
>= 5) // 5% for the fountain
115 if (p
->hp
< p
->maxhp
)
117 notice(s_GameServ
, u
, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
118 notice(s_GameServ
, u
, "You wet your lips on the cool blue waters and feel rejuvenated");
123 notice(s_GameServ
, u
, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
124 notice(s_GameServ
, u
, "You are not thirsty, though, and you don't need healing. Best to leave this for the next warrior");
128 else if (eventnum
< 5) // 5 % for the wishing well
130 notice(s_GameServ
, u
, "You come upon a pure green emerald studded magic wishing well.");
133 notice(s_GameServ
, u
, "Too bad you're broke. Guess you won't be having any wishes answered today.");
138 notice(s_GameServ
, u
, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke.");
139 notice(s_GameServ
, u
, "In an instant, the puff of smoke materializes into a gnome.");
140 notice(s_GameServ
, u
, "The gnome is holding something in his hand motioning for you to come closer.");
141 notice(s_GameServ
, u
, "It is a wand! The gnome is waving it through the air towards you!");
142 // 2% for each wishing well chance except for forest fights
143 if (eventnum
< 1) // forest fights
145 newstats
= (rand() % 11) + 5;
146 notice(s_GameServ
, u
, "%ld EXTRA FOREST FIGHTS!!",
148 p
->forest_fights
+= newstats
;
150 else if (eventnum
< 3)
152 newstats
= (rand() % 1000) * (p
->level
+ (rand() % 10));
153 notice(s_GameServ
, u
, "A SACK WITH %ld GOLD!", newstats
);
158 newstats
= (rand() % 100) * (p
->level
+ rand() % 10);
159 notice(s_GameServ
, u
, "Time seems to stand still for a moment.");
160 notice(s_GameServ
, u
, " %ld EXTRA EXPERIENCE POINTS", newstats
);
165 else if (is_fighting(u
))
167 notice(s_GameServ
, u
, "You want to fight two monsters at once?");
173 Monster
*getNewMonster(Monster
*m
)
179 newguy
= new Monster
;
183 newguy
->name
= new char[strlen(m
->name
)];
184 strcpy(newguy
->name
, m
->name
);
188 newguy
->weapon
= new char[strlen(m
->weapon
)];
189 strcpy(newguy
->weapon
, m
->weapon
);
193 newguy
->death
= new char[strlen(m
->death
)];
194 strcpy(newguy
->death
, m
->death
);
197 newguy
->strength
= m
->strength
;
198 newguy
->gold
= m
->gold
;
199 newguy
->exp
= m
->exp
;
201 newguy
->maxhp
= m
->maxhp
;