Debian Codegraph @

src/cdogs/character.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4
5 Copyright (c) 2013-2014, 2016, 2019-2021, 2023, 2025 Cong Xu
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11 Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
13 Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 */
29 #pragma once
30
31 #include "blit.h"
32 #include "c_array.h"
33 #include "character_class.h"
34 #include "pickup_class.h"
35 #include "weapon.h"
36 #include "yajl/api/yajl_gen.h"
37
38 typedef struct
39 {
40 int probabilityToMove;
41 int probabilityToTrack;
42 int probabilityToShoot;
43 int actionDelay;
44 } CharBot;
45
46 typedef struct
47 {
48 const CharacterClass *Class;
49 char *PlayerTemplateName;
50 char *HeadParts[HEAD_PART_COUNT];
51 float speed;
52 const WeaponClass *Gun;
53 const WeaponClass *Melee;
54 int maxHealth;
55 // Max health for ExceedMax health pickups
56 int excessHealth;
57 unsigned int flags;
58 CharColors Colors;
59 const PickupClass *Drop;
60 CharBot *bot;
61 } Character;
62
63 typedef struct
64 {
65 CArray OtherChars; // of Character, both normal baddies and special chars
66
67 // IDs only (of int)
68 CArray prisonerIds;
69 CArray baddieIds;
70 CArray specialIds;
71 } CharacterStore;
72
73 void CharacterStoreInit(CharacterStore *store);
74 void CharacterStoreTerminate(CharacterStore *store);
75 void CharacterStoreCopy(
76 CharacterStore *dst, const CharacterStore *src, CArray *playerTemplates);
77 void CharacterStoreResetOthers(CharacterStore *store);
78 void CharacterLoadJSON(
79 CharacterStore *c, CArray *playerTemplates, json_t *root, int version);
80 bool CharacterStoreSave(CharacterStore *s, const char *path);
81 Character *CharacterStoreAddOther(CharacterStore *store);
82 Character *CharacterStoreInsertOther(CharacterStore *store, const size_t idx);
83 void CharacterStoreDeleteOther(CharacterStore *store, int idx);
84 void CharacterStoreAddPrisoner(CharacterStore *store, int character);
85 void CharacterStoreAddBaddie(CharacterStore *store, int character);
86 void CharacterStoreAddSpecial(CharacterStore *store, int character);
87 void CharacterStoreDeleteBaddie(CharacterStore *store, int idx);
88 void CharacterStoreDeleteSpecial(CharacterStore *store, int idx);
89 int CharacterStoreGetPrisonerId(const CharacterStore *store, const int i);
90 int CharacterStoreGetSpecialId(const CharacterStore *store, const int i);
91 int CharacterStoreGetRandomBaddieId(const CharacterStore *store);
92 int CharacterStoreGetRandomSpecialId(const CharacterStore *store);
93
94 void CharacterCopy(
95 Character *dst, const Character *src, CArray *playerTemplates);
96 bool CharacterSave(yajl_gen g, const Character *c);
97
98 bool CharacterIsPrisoner(const CharacterStore *store, const Character *c);
99
100 void CharacterSetHeadPart(Character *c, const HeadPart hp, const char *name);
101 void CharacterShuffleAppearance(Character *c);