]>
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 int num
= rand() % 12;
42 if (!(source
= find(u
)))
44 notice(s_GameServ
, u
, "Fatal Error in do_forest. Contact a %S admin for help.");
47 else if (!is_playing(source
))
49 notice(s_GameServ
, u
, "You must be playing the game to search the forest!");
52 Player
*p
= source
->stats
;
56 notice(s_GameServ
, u
, "You are dead. Wait until tomorrow to search the forest some more.");
61 updateTS(source
->stats
);
62 if (p
->forest_fights
<= 0)
64 notice(s_GameServ
, u
, "You are out of forest fights for the day. Wait "\
68 else if (!is_fighting(source
))
70 int eventnum
= rand() % 100;
73 notice(s_GameServ
, u
, "You search the forest for something to kill...");
75 // 88% of forest searching turns up a monster
78 p
->fight
= new Monster(monsters
[p
->level
- 1][num
]);
79 notice(s_GameServ
, u
, "You have found \ 2%s\ 2!", p
->fight
->name
);
80 if (p
->fight
->hp
< p
->fight
->maxhp
)
81 p
->fight
->hp
= p
->fight
->maxhp
;
83 p
->battle
= NULL
; // Just to make sure
84 p
->master
= NULL
; // Just to make sure
87 else if (eventnum
< 12 && eventnum
>= 10) // 2% for finding potions
89 notice(s_GameServ
, u
, "Fortune smiles upon thee!");
91 eventnum
= 1 + rand() % 4;
96 "You have found an HP Potion!");
100 notice(s_GameServ
, u
,
101 "You have found a Strength Potion!");
102 p
->inventory
.incStrength();
105 notice(s_GameServ
, u
,
106 "You have found a Defense Potion!");
107 p
->inventory
.incDefense();
110 notice(s_GameServ
, u
,
111 "You have found a Healing Potion!");
112 p
->inventory
.incHealing();
116 else if (eventnum
< 10 && eventnum
>= 5) // 5% for the fountain
118 if (p
->hp
< p
->maxhp
)
120 notice(s_GameServ
, u
, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
121 notice(s_GameServ
, u
, "You wet your lips on the cool blue waters and feel rejuvenated");
126 notice(s_GameServ
, u
, "In your path lies a beautiful fountain from which flows the crystal waters of life.");
127 notice(s_GameServ
, u
, "You are not thirsty, though, and you don't need healing. Best to leave this for the next warrior");
131 else if (eventnum
< 5) // 5 % for the wishing well
133 notice(s_GameServ
, u
, "You come upon a pure green emerald studded magic wishing well.");
136 notice(s_GameServ
, u
, "Too bad you're broke. Guess you won't be having any wishes answered today.");
140 notice(s_GameServ
, u
, "You throw one of your gold pieces into the well and it vanishes into a puff of white smoke.");
141 notice(s_GameServ
, u
, "In an instant, the puff of smoke materializes into a gnome.");
142 notice(s_GameServ
, u
, "The gnome is holding something in his hand motioning for you to come closer.");
143 notice(s_GameServ
, u
, "It is a wand! The gnome is waving it through the air towards you!");
144 // 2% for each wishing well chance except for forest fights
145 if (eventnum
< 1) // forest fights
147 newstats
= (rand() % 11) + 5;
148 notice(s_GameServ
, u
, "%ld EXTRA FOREST FIGHTS!!",
150 p
->forest_fights
+= newstats
;
152 else if (eventnum
< 3)
154 newstats
= (rand() % 1000) * (p
->level
+ (rand() % 10));
155 notice(s_GameServ
, u
, "A SACK WITH %ld GOLD!", newstats
);
160 newstats
= (rand() % 100) * (p
->level
+ rand() % 10);
161 notice(s_GameServ
, u
, "Time seems to stand still for a moment.");
162 notice(s_GameServ
, u
, " %ld EXTRA EXPERIENCE POINTS", newstats
);
167 else if (is_fighting(u
))
169 notice(s_GameServ
, u
, "You want to fight two monsters at once?");
175 Monster
*getNewMonster(Monster
*m
)
181 newguy
= new Monster
;
185 newguy
->name
= new char[strlen(m
->name
)];
186 strcpy(newguy
->name
, m
->name
);
190 newguy
->weapon
= new char[strlen(m
->weapon
)];
191 strcpy(newguy
->weapon
, m
->weapon
);
195 newguy
->death
= new char[strlen(m
->death
)];
196 strcpy(newguy
->death
, m
->death
);
199 newguy
->strength
= m
->strength
;
200 newguy
->gold
= m
->gold
;
201 newguy
->exp
= m
->exp
;
203 newguy
->maxhp
= m
->maxhp
;