Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.

Commit f9311cf

Browse files
GamerMan7799GamerMan7799
authored andcommitted
Merge pull request #24 from GamerMan7799/dev
Update Master to V4.0b
2 parents 763da85 + 2dcb44c commit f9311cf

File tree

4 files changed

+536
-146
lines changed

4 files changed

+536
-146
lines changed

basic.h

Lines changed: 260 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/*
55
Made By: Patrick J. Rye
66
Purpose: A header to hold functions that are pretty basic and likely won't change very often or at all.
7-
Current Revision: 2.1.3
7+
Current Revision: 2.1.4
88
Change Log---------------------------------------------------------------------------------------------------------------------------------------------------
99
Date Revision Changed By Changes
1010
------ --------- ------------ ---------------------------------------------------------------------------------------------------------------------
@@ -22,7 +22,11 @@ Date Revision Changed By Changes
2222
=============================================================================================================================================================
2323
2015/03/09 2.1.3 Patrick Rye -Moved win / opening messages here.
2424
-Moved enums here.
25-
=============================================================================================================================================================
25+
=============================================================================================================================================================
26+
2015/03/09 2.1.4 Patrick Rye -Added more effects.
27+
-Updated some other stuff.
28+
-Function to return string of start / end of status effect.
29+
=============================================================================================================================================================
2630
*/
2731

2832
/*********************************************************************************************************/
@@ -60,6 +64,9 @@ enum effects
6064
effectFrozen,
6165
effectBurned,
6266
effectWet,
67+
effectPoison,
68+
effectBleeding,
69+
effectConfused
6370
};
6471

6572
enum stats
@@ -72,6 +79,7 @@ enum stats
7279
statCurrHealth,
7380
statMaxHealth,
7481
statStatus,
82+
statStatusCounter,
7583
};
7684

7785
enum elements
@@ -84,7 +92,7 @@ enum elements
8492
elementEarth,
8593
elementWind,
8694
elementWater,
87-
elementPhysical, //Currently does nothing.
95+
elementPhysical, //Currently does nothing. (Will factor in when I make elemental weaknesses)
8896
elementNone //For spells that don't do damage.
8997
};
9098

@@ -96,9 +104,257 @@ enum spelltypes
96104
};
97105
/*********************************************************************************************************/
98106

99-
100107
using namespace std;
101108

109+
bool DodgeCheck(int LUK, int DEX)
110+
{
111+
//The way I worked out this dodge calc is that if the Dex and Luk both equal 150 (which isn't possible under the current levelling up system),
112+
//then they have a 25% chance to dodge. I also wanted Dex to factor into 75% of the chance and Luk only 25%
113+
//Can return true, that they dodged or false that they did not.
114+
double douDodgeChance = ((DEX/2)+(LUK/6)/4);
115+
if(rand() % 101 <= douDodgeChance) {return true;}
116+
else {return false;}
117+
}
118+
119+
bool RemoveStatusEffect(int TargetLuk, int CurrentEffect, int EffectTurns)
120+
{
121+
//Check if status effect should be removed based on turns and luck.
122+
if (EffectTurns >= 5) {return true;} //Get rid of effect if it has been there for more than 5 turns.
123+
if (rand() % 101 <= (TargetLuk) + (EffectTurns *2.5) - (intBattleLevel * 2)) {return true;}
124+
return false;
125+
}
126+
127+
float DamageHealthPercent(int CurrentHealth, int MaximumHealth)
128+
{
129+
/*Function that returns a percentage value that will be multiplied by the damage.
130+
The value will vary with health so that the less health something has
131+
The less damage it will do.
132+
The max value it return is about 1.01 or something similar, the min value
133+
is about 0.64 */
134+
135+
float HealthPercent = CurrentHealth / MaximumHealth;
136+
float TempValue = 0;
137+
TempValue -= 0.8981 * pow(HealthPercent, 3);
138+
TempValue += 1.297 * pow(HealthPercent, 2);
139+
TempValue -= 0.0358 * HealthPercent;
140+
TempValue += 0.64;
141+
return TempValue;
142+
}
143+
144+
string HitName()
145+
{
146+
/*Outputs a string that represents an attack,
147+
for example rather than just "hit" over and over,
148+
you could get "stabbed" "hit"*/
149+
const string HitStringArray[5] = {"hit","stabbed","cut","slashed","damaged"};
150+
string TempString;
151+
TempString = HitStringArray[rand() % 5];
152+
if (TempString != "") {return TempString;}
153+
return "hit";
154+
}
155+
156+
bool StunCheck(int intAttackerLuck, int intDefenderLuck)
157+
{
158+
if (intDefenderLuck < intAttackerLuck) {if(rand()% 101 < (intAttackerLuck - intDefenderLuck) / 3) {return true;}}
159+
return false;
160+
}
161+
162+
string StateOfBeing(int intCurrHealth, int intMaxHealth)
163+
{
164+
/*Outputs a string that gives a description of how the monster is doing
165+
Example: at full health can return "Healthy"
166+
while below 10% of max health it might return "dying" or "badly wounded"*/
167+
long flHealthPercent = (intCurrHealth * 100)/intMaxHealth;
168+
string strState;
169+
int intRandomState;
170+
171+
const string FullHealthOutput[3] = {"steady","well","healthy"};
172+
const string SeventyPHealthOutput[3] = {"wounded","damaged","hurt"};
173+
const string FiftyPHealthOutput[3] = {"injured","bleeding","very hurt"};
174+
const string TwentyFivePHealthOutput[3] = {"really hurt","in pain","badly damaged"};
175+
const string TenPHealthOutput[3] = {"badly wounded","badly hurt","close to dying"};
176+
const string FivePHealthOutput[3] = {"to be dying","heavily wounded","gravely wounded"};
177+
178+
intRandomState = rand() % 3; //0-2
179+
180+
if (flHealthPercent <= 5) {strState = FivePHealthOutput[intRandomState];}
181+
else if (flHealthPercent <= 10) {strState = TenPHealthOutput[intRandomState];}
182+
else if (flHealthPercent <= 25) {strState = TwentyFivePHealthOutput[intRandomState];}
183+
else if (flHealthPercent <= 50) {strState = FiftyPHealthOutput[intRandomState];}
184+
else if (flHealthPercent <= 70) {strState = SeventyPHealthOutput[intRandomState];}
185+
else {strState = FullHealthOutput[intRandomState];}
186+
187+
return strState;
188+
}
189+
190+
string EndOfEffectString(std::string Target, int Effect)
191+
{
192+
string TempStr = "";
193+
//Returns string describing status effect ending.
194+
if (Target == "player")
195+
{
196+
switch (Effect)
197+
{
198+
case effectBlinded :
199+
return "Your eyes begin to see again.";
200+
break;
201+
case effectFrozen :
202+
return "The ice surrounding your body melts away.";
203+
break;
204+
case effectBurned :
205+
return "You regain feeling in your burned flesh.";
206+
break;
207+
case effectWet :
208+
return "You feel dry again.";
209+
break;
210+
case effectPoison :
211+
return "Your body ejects the last of the poison.";
212+
break;
213+
case effectBleeding :
214+
return "Your bleeding wounds being to close.";
215+
break;
216+
case effectConfused :
217+
return "Your head is now clear.";
218+
break;
219+
case effectNone :
220+
default :
221+
return "ERROR";
222+
break;
223+
};
224+
}
225+
else
226+
{
227+
switch (Effect)
228+
{
229+
case effectBlinded :
230+
TempStr = "The ";
231+
TempStr += Target;
232+
TempStr += " blinks his eyes and looks right at you.";
233+
break;
234+
case effectFrozen :
235+
TempStr = "The ice around the ";
236+
TempStr += Target;
237+
TempStr += " melts away.";
238+
break;
239+
case effectBurned :
240+
TempStr = "The ";
241+
TempStr += Target;
242+
TempStr += " no longer appears bothered by its burns.";
243+
break;
244+
case effectWet :
245+
TempStr = "The water on the ";
246+
TempStr += Target;
247+
TempStr += " dries off";
248+
break;
249+
case effectPoison :
250+
TempStr = "The ";
251+
TempStr += Target;
252+
TempStr += " no longer looks sick.";
253+
break;
254+
case effectBleeding :
255+
TempStr = "The ";
256+
TempStr += Target;
257+
TempStr += " no longer appears bothered by its wounds.";
258+
break;
259+
case effectConfused :
260+
TempStr = "The ";
261+
TempStr += Target;
262+
TempStr += " managed to stop running in circles.";
263+
break;
264+
case effectNone :
265+
default :
266+
return "ERROR";
267+
break;
268+
};
269+
return TempStr;
270+
}
271+
return "ERROR";
272+
}
273+
274+
string StartOfEffectString(std::string Target, int Effect)
275+
{
276+
string TempStr = "";
277+
//Returns string describing status effect ending.
278+
if (Target == "player")
279+
{
280+
switch (Effect)
281+
{
282+
case effectBlinded :
283+
return "Your eyes begin to cloud up, preventing vision.";
284+
break;
285+
case effectFrozen :
286+
return "A block of ice encases your legs.";
287+
break;
288+
case effectBurned :
289+
return "A searing pain on your body is present.";
290+
break;
291+
case effectWet :
292+
return "You are now soaked to the bone.";
293+
break;
294+
case effectPoison :
295+
return "You feel sick to your stomach.";
296+
break;
297+
case effectBleeding :
298+
return "A wound has opened up and is bleeding badly.";
299+
break;
300+
case effectConfused :
301+
return "The world spins around you, you don't know where to go.";
302+
break;
303+
case effectNone :
304+
default :
305+
return "ERROR";
306+
break;
307+
};
308+
}
309+
else
310+
{
311+
switch (Effect)
312+
{
313+
case effectBlinded :
314+
TempStr = "The ";
315+
TempStr += Target;
316+
TempStr += " cannot see any more.";
317+
break;
318+
case effectFrozen :
319+
TempStr = "A block of ice encases the ";
320+
TempStr += Target;
321+
TempStr += "'s legs.";
322+
break;
323+
case effectBurned :
324+
TempStr = "The ";
325+
TempStr += Target;
326+
TempStr += " has painful burns on its body.";
327+
break;
328+
case effectWet :
329+
TempStr = "The ";
330+
TempStr += Target;
331+
TempStr += " is soaked with water.";
332+
break;
333+
case effectPoison :
334+
TempStr = "The ";
335+
TempStr += Target;
336+
TempStr += " looks sick.";
337+
break;
338+
case effectBleeding :
339+
TempStr = "The ";
340+
TempStr += Target;
341+
TempStr += " has a badly bleeding wound.";
342+
break;
343+
case effectConfused :
344+
TempStr = "The ";
345+
TempStr += Target;
346+
TempStr += " starts running in circles.";
347+
break;
348+
case effectNone :
349+
default :
350+
return "ERROR";
351+
break;
352+
};
353+
return TempStr;
354+
}
355+
return "ERROR";
356+
}
357+
102358
bool fileexists(const char *fileName)
103359
{
104360
std::ifstream infile(fileName);

0 commit comments

Comments
 (0)