1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5 
6 This file is part of NBlood.
7 
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #pragma once
24 
25 #include "compat.h"
26 #include "common_game.h"
27 #include "actor.h"
28 #include "db.h"
29 
30 struct AISTATE {
31     int stateType; // By NoOne: current type of state. Basically required for kModernDudeTargetChanger, but can be used for something else.
32     int seqId;
33     int funcId; // seq callback
34     int stateTicks;
35     void(*enterFunc)(spritetype *, XSPRITE *);
36     void(*moveFunc)(spritetype *, XSPRITE *);
37     void(*thinkFunc)(spritetype *, XSPRITE *);
38     AISTATE *nextState;
39 };
40 extern AISTATE aiState[];
41 extern AISTATE genIdle;
42 extern AISTATE genRecoil;
43 
44 enum AI_SFX_PRIORITY {
45     AI_SFX_PRIORITY_0 = 0,
46     AI_SFX_PRIORITY_1,
47     AI_SFX_PRIORITY_2,
48 };
49 
50 
51 struct DUDEEXTRA_at6_u1
52 {
53     int at0;
54     int at4;
55     char at8;
56 };
57 
58 struct DUDEEXTRA_at6_u2
59 {
60     int at0;
61     char at4;
62 };
63 
64 struct DUDEEXTRA
65 {
66     int at0;
67     char at4;
68     AI_SFX_PRIORITY at5;
69     union
70     {
71         DUDEEXTRA_at6_u1 u1;
72         DUDEEXTRA_at6_u2 u2;
73     } at6;
74     //DUDEEXTRA_at6 at6;
75 };
76 
77 struct TARGETTRACK {
78     int at0;
79     int at4;
80     int at8; // view angle
81     int atc;
82     int at10; // Move predict
83 };
84 
85 extern int dword_138BB0[5];
86 extern DUDEEXTRA gDudeExtra[];
87 extern int gDudeSlope[];
88 extern int cumulDamage[];
89 
90 bool sub_5BDA8(spritetype *pSprite, int nSeq);
91 void aiPlay3DSound(spritetype *pSprite, int a2, AI_SFX_PRIORITY a3, int a4);
92 void aiNewState(spritetype *pSprite, XSPRITE *pXSprite, AISTATE *pAIState);
93 void aiChooseDirection(spritetype *pSprite, XSPRITE *pXSprite, int a3);
94 void aiMoveForward(spritetype *pSprite, XSPRITE *pXSprite);
95 void aiMoveTurn(spritetype *pSprite, XSPRITE *pXSprite);
96 void aiMoveDodge(spritetype *pSprite, XSPRITE *pXSprite);
97 void aiActivateDude(spritetype *pSprite, XSPRITE *pXSprite);
98 void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z);
99 void aiSetTarget(XSPRITE *pXSprite, int nTarget);
100 int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_TYPE nDmgType, int nDamage);
101 void aiThinkTarget(spritetype *pSprite, XSPRITE *pXSprite);
102 void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite);
103 void aiProcessDudes(void);
104 void aiInit(void);
105 void aiInitSprite(spritetype *pSprite);
106 bool CanMove(spritetype* pSprite, int a2, int nAngle, int nRange);
107 void RecoilDude(spritetype* pSprite, XSPRITE* pXSprite);