1 //=============================================================================
2 //
3 // Adventure Game Studio (AGS)
4 //
5 // Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
6 // The full list of copyright holders can be found in the Copyright.txt
7 // file, which is part of this source code distribution.
8 //
9 // The AGS source code is provided under the Artistic License 2.0.
10 // A copy of this license can be found in the file License.txt and at
11 // http://www.opensource.org/licenses/artistic-license-2.0.php
12 //
13 //=============================================================================
14 
15 #ifndef __AC_CHARACTERINFO_H
16 #define __AC_CHARACTERINFO_H
17 
18 #include "ac/common_defines.h" // constants
19 
20 namespace AGS { namespace Common { class Stream; } }
21 using namespace AGS; // FIXME later
22 
23 #define MAX_INV             301
24 #define CHF_MANUALSCALING   1
25 #define CHF_FIXVIEW         2     // between SetCharView and ReleaseCharView
26 #define CHF_NOINTERACT      4
27 #define CHF_NODIAGONAL      8
28 #define CHF_ALWAYSIDLE      0x10
29 #define CHF_NOLIGHTING      0x20
30 #define CHF_NOTURNING       0x40
31 #define CHF_NOWALKBEHINDS   0x80
32 #define CHF_FLIPSPRITE      0x100  // ?? Is this used??
33 #define CHF_NOBLOCKING      0x200
34 #define CHF_SCALEMOVESPEED  0x400
35 #define CHF_NOBLINKANDTHINK 0x800
36 #define CHF_SCALEVOLUME     0x1000
37 #define CHF_HASTINT         0x2000   // engine only
38 #define CHF_BEHINDSHEPHERD  0x4000   // engine only
39 #define CHF_AWAITINGMOVE    0x8000   // engine only
40 #define CHF_MOVENOTWALK     0x10000   // engine only - do not do walk anim
41 #define CHF_ANTIGLIDE       0x20000
42 #define CHF_HASLIGHT        0x40000
43 // Speechcol is no longer part of the flags as of v2.5
44 #define OCHF_SPEECHCOL      0xff000000
45 #define OCHF_SPEECHCOLSHIFT 24
46 #define UNIFORM_WALK_SPEED  0
47 #define FOLLOW_ALWAYSONTOP  0x7ffe
48 
49 struct CharacterExtras; // forward declaration
50 // remember - if change this struct, also change AGSDEFNS.SH and
51 // plugin header file struct
52 struct CharacterInfo {
53     int   defview;
54     int   talkview;
55     int   view;
56     int   room, prevroom;
57     int   x, y, wait;
58     int   flags;
59     short following;
60     short followinfo;
61     int   idleview;           // the loop will be randomly picked
62     short idletime, idleleft; // num seconds idle before playing anim
63     short transparency;       // if character is transparent
64     short baseline;
65     int   activeinv;
66     int   talkcolor;
67     int   thinkview;
68     short blinkview, blinkinterval; // design time
69     short blinktimer, blinkframe;   // run time
70     short walkspeed_y, pic_yoffs;
71     int   z;    // z-location, for flying etc
72     int   walkwait;
73     short speech_anim_speed, reserved1;  // only 1 reserved left!!
74     short blocking_width, blocking_height;
75     int   index_id;  // used for object functions to know the id
76     short pic_xoffs, walkwaitcounter;
77     short loop, frame;
78     short walking, animating;
79     short walkspeed, animspeed;
80     short inv[MAX_INV];
81     short actx, acty;
82     char  name[40];
83     char  scrname[MAX_SCRIPT_NAME_LEN];
84     char  on;
85 
86     int get_effective_y();   // return Y - Z
87     int get_baseline();      // return baseline, or Y if not set
88     int get_blocking_top();    // return Y - BlockingHeight/2
89     int get_blocking_bottom(); // return Y + BlockingHeight/2
90 
has_explicit_lightCharacterInfo91     inline bool has_explicit_light() const { return (flags & CHF_HASLIGHT) != 0; }
has_explicit_tintCharacterInfo92     inline bool has_explicit_tint()  const { return (flags & CHF_HASTINT) != 0; }
93 
94 	// [IKM] 2012-06-28: I still have to pass char_index to some of those functions
95 	// either because they use it to set some variables with it,
96 	// or because they pass it further to other functions, that are called from various places
97 	// and it would be too much to change them all simultaneously
98     //
99     // [IKM] 2016-08-26: these methods should NOT be in CharacterInfo class,
100     // bit in distinct runtime character class!
101 	void UpdateMoveAndAnim(int &char_index, CharacterExtras *chex, int &numSheep, int *followingAsSheep);
102 	void UpdateFollowingExactlyCharacter();
103 
104 	int  update_character_walking(CharacterExtras *chex);
105 	void update_character_moving(int &char_index, CharacterExtras *chex, int &doing_nothing);
106 	int  update_character_animating(int &char_index, int &doing_nothing);
107 	void update_character_idle(CharacterExtras *chex, int &doing_nothing);
108 	void update_character_follower(int &char_index, int &numSheep, int *followingAsSheep, int &doing_nothing);
109 
110     void ReadFromFile(Common::Stream *in);
111     void WriteToFile(Common::Stream *out);
112 };
113 
114 
115 struct OldCharacterInfo {
116     int   defview;
117     int   talkview;
118     int   view;
119     int   room, prevroom;
120     int   x, y, wait;
121     int   flags;
122     short following;
123     short followinfo;
124     int   idleview;           // the loop will be randomly picked
125     short idletime, idleleft; // num seconds idle before playing anim
126     short transparency;       // if character is transparent
127     short baseline;
128     int   activeinv;          // this is an INT to support SeeR (no signed shorts)
129     short loop, frame;
130     short walking, animating;
131     short walkspeed, animspeed;
132     short inv[100];
133     short actx, acty;
134     char  name[30];
135     char  scrname[16];
136     char  on;
137 };
138 
139 #define COPY_CHAR_VAR(name) ci->name = oci->name
140 void ConvertOldCharacterToNew (OldCharacterInfo *oci, CharacterInfo *ci);
141 
142 #endif // __AC_CHARACTERINFO_H