2 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
20 #include "Level/Awards.hpp"
23 #include "Objects/Person.hpp"
28 float startbonustotal;
32 const char *bonus_names[bonus_count] = {
33 #define DECLARE_BONUS(id, name, ...) name,
34 #include "Bonuses.def"
38 const char *award_names[award_count] = {
39 #define DECLARE_AWARD(id, name) name,
44 static const int bonus_values[bonus_count] = {
45 #define DECLARE_BONUS(id, name, value) value,
46 #include "Bonuses.def"
51 award_bonus(int playerid, int bonusid, int alt_value)
57 bonusvalue = alt_value ? alt_value : bonus_values[bonusid];
60 // FIXME: make these per-player
79 int award_awards(int *awards)
82 if (damagetaken == 0 && Person::players[0]->bloodloss == 0) {
83 awards[numawards] = awardflawless;
87 for (unsigned i = 1; i < Person::players.size(); i++) {
88 if (Person::players[i]->dead != 2)
92 awards[numawards] = awardalldead;
96 for (unsigned i = 1; i < Person::players.size(); i++) {
97 if (Person::players[i]->dead != 1)
101 awards[numawards] = awardnodead;
104 if (numresponded == 0 && !numthrowkill) {
105 awards[numawards] = awardstealth;
108 if (numattacks == numstaffattack && numattacks > 0) {
109 awards[numawards] = awardbojutsu;
112 if (numattacks == numswordattack && numattacks > 0) {
113 awards[numawards] = awardswordsman;
116 if (numattacks == numknifeattack && numattacks > 0) {
117 awards[numawards] = awardknifefighter;
120 if (numattacks == numunarmedattack && numthrowkill == 0 && weapons.size() > 0) {
121 awards[numawards] = awardkungfu;
124 if (numescaped > 0) {
125 awards[numawards] = awardevasion;
128 if (numflipfail == 0 && numflipped + numwallflipped * 2 > 20) {
129 awards[numawards] = awardacrobat;
132 if (numthrowkill == (int(Person::players.size()) - 1)) {
133 awards[numawards] = awardlongrange;
137 for (unsigned i = 1; i < Person::players.size(); i++) {
138 if (Person::players[i]->dead != 2)
141 if (numafterkill > 0 && alldead) {
142 awards[numawards] = awardbrutal;
145 if (numreversals > ((float)numattacks)*.8 && numreversals > 3) {
146 awards[numawards] = awardaikido;
149 if (maxalarmed == 1 && Person::players.size() > 2) {
150 awards[numawards] = awardstrategy;
153 if (numflipfail > 3) {
154 awards[numawards] = awardklutz;