forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdifficulty.cpp
100 lines (85 loc) · 2.87 KB
/
difficulty.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2012 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Simple short file - only because there was nowhere else for it logically to go */
/**
* @file difficulty.c
* Handes the difficulty level effects on gameplay.
*/
/*
Changed to allow seperate modifiers for enemy and player damage.
*/
#include "lib/framework/frame.h"
#include "difficulty.h"
#include "src/multiplay.h"
// ------------------------------------------------------------------------------------
static DIFFICULTY_LEVEL presDifLevel = DL_NORMAL;
static int fDifPlayerModifier;
static int fDifEnemyModifier;
// ------------------------------------------------------------------------------------
/* Sets the game difficulty level */
void setDifficultyLevel(DIFFICULTY_LEVEL lev)
{
switch(lev)
{
case DL_EASY:
fDifPlayerModifier = 120;
fDifEnemyModifier = 100;
break;
case DL_NORMAL:
fDifPlayerModifier = 100;
fDifEnemyModifier = 100;
break;
case DL_HARD:
fDifPlayerModifier = 80;
fDifEnemyModifier = 100;
break;
case DL_KILLER:
fDifPlayerModifier = 999; // 10 times
fDifEnemyModifier = 1; // almost nothing
break;
case DL_TOUGH:
fDifPlayerModifier = 100;
fDifEnemyModifier = 50; // they do less damage!
break;
default:
debug( LOG_ERROR, "Invalid difficulty level selected - forcing NORMAL" );
fDifPlayerModifier = 100;
fDifEnemyModifier = 100;
lev = DL_NORMAL;
break;
}
presDifLevel = lev;
}
// ------------------------------------------------------------------------------------
/* Returns the difficulty level */
DIFFICULTY_LEVEL getDifficultyLevel( void )
{
return(presDifLevel);
}
// ------------------------------------------------------------------------------------
int modifyForDifficultyLevel(int basicVal, bool IsPlayer)
{
if (bMultiPlayer && presDifLevel != DL_KILLER && presDifLevel != DL_TOUGH) // ignore multiplayer or skirmish (unless using biffer baker) games
{
return basicVal;
}
if (IsPlayer)
return basicVal * fDifPlayerModifier / 100;
else
return basicVal * fDifEnemyModifier / 100;
}
// ------------------------------------------------------------------------------------