ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
character.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
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. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGS_ENGINE_AC_CHARACTER_H
23 #define AGS_ENGINE_AC_CHARACTER_H
24 
25 #include "ags/shared/ac/character_info.h"
26 #include "ags/engine/ac/character_extras.h"
27 #include "ags/engine/ac/dynobj/script_object.h"
28 #include "ags/engine/ac/dynobj/script_inv_item.h"
29 #include "ags/engine/ac/dynobj/script_overlay.h"
30 #include "ags/engine/game/viewport.h"
31 #include "ags/shared/util/geometry.h"
32 
33 namespace AGS3 {
34 
35 // **** CHARACTER: FUNCTIONS ****
36 
37 bool is_valid_character(int char_id);
38 // Asserts the character ID is valid,
39 // if not then prints a warning to the log; returns assertion result
40 bool AssertCharacter(const char *apiname, int char_id);
41 
42 void Character_AddInventory(CharacterInfo *chaa, ScriptInvItem *invi, int addIndex);
43 void Character_AddWaypoint(CharacterInfo *chaa, int x, int y);
44 void Character_Animate(CharacterInfo *chaa, int loop, int delay, int repeat, int blocking, int direction, int sframe = 0, int volume = 100);
45 void Character_Animate5(CharacterInfo *chaa, int loop, int delay, int repeat, int blocking, int direction);
46 void Character_ChangeRoomAutoPosition(CharacterInfo *chaa, int room, int newPos);
47 void Character_ChangeRoom(CharacterInfo *chaa, int room, int x, int y);
48 void Character_ChangeRoomSetLoop(CharacterInfo *chaa, int room, int x, int y, int direction);
49 void Character_ChangeView(CharacterInfo *chap, int vii);
50 void Character_FaceDirection(CharacterInfo *char1, int direction, int blockingStyle);
51 void Character_FaceCharacter(CharacterInfo *char1, CharacterInfo *char2, int blockingStyle);
52 void Character_FaceLocation(CharacterInfo *char1, int xx, int yy, int blockingStyle);
53 void Character_FaceObject(CharacterInfo *char1, ScriptObject *obj, int blockingStyle);
54 void Character_FollowCharacter(CharacterInfo *chaa, CharacterInfo *tofollow, int distaway, int eagerness);
55 int Character_IsCollidingWithChar(CharacterInfo *char1, CharacterInfo *char2);
56 int Character_IsCollidingWithObject(CharacterInfo *chin, ScriptObject *objid);
57 bool Character_IsInteractionAvailable(CharacterInfo *cchar, int mood);
58 void Character_LockView(CharacterInfo *chap, int vii);
59 void Character_LockViewEx(CharacterInfo *chap, int vii, int stopMoving);
60 void Character_LockViewAligned(CharacterInfo *chap, int vii, int loop, int align);
61 void Character_LockViewAligned_Old(CharacterInfo *chap, int vii, int loop, int align);
62 void Character_LockViewAlignedEx(CharacterInfo *chap, int vii, int loop, int align, int stopMoving);
63 void Character_LockViewAlignedEx_Old(CharacterInfo *chap, int vii, int loop, int align, int stopMoving);
64 void Character_LockViewFrame(CharacterInfo *chaa, int view, int loop, int frame);
65 void Character_LockViewFrameEx(CharacterInfo *chaa, int view, int loop, int frame, int stopMoving);
66 void Character_LockViewOffset(CharacterInfo *chap, int vii, int xoffs, int yoffs);
67 void Character_LockViewOffsetEx(CharacterInfo *chap, int vii, int xoffs, int yoffs, int stopMoving);
68 void Character_LoseInventory(CharacterInfo *chap, ScriptInvItem *invi);
69 void Character_PlaceOnWalkableArea(CharacterInfo *chap);
70 void Character_RemoveTint(CharacterInfo *chaa);
71 int Character_GetHasExplicitTint(CharacterInfo *chaa);
72 int Character_GetHasExplicitTint_Old(CharacterInfo *ch);
73 void Character_Say(CharacterInfo *chaa, const char *text);
74 void Character_SayAt(CharacterInfo *chaa, int x, int y, int width, const char *texx);
75 ScriptOverlay *Character_SayBackground(CharacterInfo *chaa, const char *texx);
76 void Character_SetAsPlayer(CharacterInfo *chaa);
77 void Character_SetIdleView(CharacterInfo *chaa, int iview, int itime);
78 void Character_SetOption(CharacterInfo *chaa, int flag, int yesorno);
79 bool Character_SetProperty(CharacterInfo *chaa, const char *property, int value);
80 bool Character_SetTextProperty(CharacterInfo *chaa, const char *property, const char *value);
81 void Character_SetSpeed(CharacterInfo *chaa, int xspeed, int yspeed);
82 void Character_StopMoving(CharacterInfo *charp);
83 void Character_Tint(CharacterInfo *chaa, int red, int green, int blue, int opacity, int luminance);
84 void Character_Think(CharacterInfo *chaa, const char *text);
85 void Character_UnlockView(CharacterInfo *chaa);
86 void Character_UnlockViewEx(CharacterInfo *chaa, int stopMoving);
87 void Character_Walk(CharacterInfo *chaa, int x, int y, int blocking, int direct);
88 void Character_Move(CharacterInfo *chaa, int x, int y, int blocking, int direct);
89 void Character_WalkStraight(CharacterInfo *chaa, int xx, int yy, int blocking);
90 
91 void Character_RunInteraction(CharacterInfo *chaa, int mood);
92 
93 // **** CHARACTER: PROPERTIES ****
94 
95 int Character_GetProperty(CharacterInfo *chaa, const char *property);
96 void Character_GetPropertyText(CharacterInfo *chaa, const char *property, char *bufer);
97 const char *Character_GetTextProperty(CharacterInfo *chaa, const char *property);
98 
99 ScriptInvItem *Character_GetActiveInventory(CharacterInfo *chaa);
100 void Character_SetActiveInventory(CharacterInfo *chaa, ScriptInvItem *iit);
101 int Character_GetAnimating(CharacterInfo *chaa);
102 int Character_GetAnimationSpeed(CharacterInfo *chaa);
103 void Character_SetAnimationSpeed(CharacterInfo *chaa, int newval);
104 int Character_GetBaseline(CharacterInfo *chaa);
105 void Character_SetBaseline(CharacterInfo *chaa, int basel);
106 int Character_GetBlinkInterval(CharacterInfo *chaa);
107 void Character_SetBlinkInterval(CharacterInfo *chaa, int interval);
108 int Character_GetBlinkView(CharacterInfo *chaa);
109 void Character_SetBlinkView(CharacterInfo *chaa, int vii);
110 int Character_GetBlinkWhileThinking(CharacterInfo *chaa);
111 void Character_SetBlinkWhileThinking(CharacterInfo *chaa, int yesOrNo);
112 int Character_GetBlockingHeight(CharacterInfo *chaa);
113 void Character_SetBlockingHeight(CharacterInfo *chaa, int hit);
114 int Character_GetBlockingWidth(CharacterInfo *chaa);
115 void Character_SetBlockingWidth(CharacterInfo *chaa, int wid);
116 int Character_GetDiagonalWalking(CharacterInfo *chaa);
117 void Character_SetDiagonalWalking(CharacterInfo *chaa, int yesorno);
118 int Character_GetClickable(CharacterInfo *chaa);
119 void Character_SetClickable(CharacterInfo *chaa, int clik);
120 int Character_GetDestinationX(CharacterInfo *chaa);
121 int Character_GetDestinationY(CharacterInfo *chaa);
122 int Character_GetID(CharacterInfo *chaa);
123 int Character_GetFrame(CharacterInfo *chaa);
124 void Character_SetFrame(CharacterInfo *chaa, int newval);
125 int Character_GetIdleView(CharacterInfo *chaa);
126 int Character_GetIInventoryQuantity(CharacterInfo *chaa, int index);
127 int Character_HasInventory(CharacterInfo *chaa, ScriptInvItem *invi);
128 void Character_SetIInventoryQuantity(CharacterInfo *chaa, int index, int quant);
129 int Character_GetIgnoreLighting(CharacterInfo *chaa);
130 void Character_SetIgnoreLighting(CharacterInfo *chaa, int yesorno);
131 int Character_GetIgnoreScaling(CharacterInfo *chaa);
132 void Character_SetIgnoreScaling(CharacterInfo *chaa, int yesorno);
133 void Character_SetManualScaling(CharacterInfo *chaa, int yesorno);
134 int Character_GetIgnoreWalkbehinds(CharacterInfo *chaa);
135 void Character_SetIgnoreWalkbehinds(CharacterInfo *chaa, int yesorno);
136 int Character_GetMovementLinkedToAnimation(CharacterInfo *chaa);
137 void Character_SetMovementLinkedToAnimation(CharacterInfo *chaa, int yesorno);
138 int Character_GetLoop(CharacterInfo *chaa);
139 void Character_SetLoop(CharacterInfo *chaa, int newval);
140 int Character_GetMoving(CharacterInfo *chaa);
141 const char *Character_GetName(CharacterInfo *chaa);
142 void Character_SetName(CharacterInfo *chaa, const char *newName);
143 int Character_GetNormalView(CharacterInfo *chaa);
144 int Character_GetPreviousRoom(CharacterInfo *chaa);
145 int Character_GetRoom(CharacterInfo *chaa);
146 int Character_GetScaleMoveSpeed(CharacterInfo *chaa);
147 void Character_SetScaleMoveSpeed(CharacterInfo *chaa, int yesorno);
148 int Character_GetScaleVolume(CharacterInfo *chaa);
149 void Character_SetScaleVolume(CharacterInfo *chaa, int yesorno);
150 int Character_GetScaling(CharacterInfo *chaa);
151 void Character_SetScaling(CharacterInfo *chaa, int zoomlevel);
152 int Character_GetSolid(CharacterInfo *chaa);
153 void Character_SetSolid(CharacterInfo *chaa, int yesorno);
154 int Character_GetSpeaking(CharacterInfo *chaa);
155 int Character_GetSpeechColor(CharacterInfo *chaa);
156 void Character_SetSpeechColor(CharacterInfo *chaa, int ncol);
157 void Character_SetSpeechAnimationDelay(CharacterInfo *chaa, int newDelay);
158 int Character_GetSpeechView(CharacterInfo *chaa);
159 void Character_SetSpeechView(CharacterInfo *chaa, int vii);
160 int Character_GetThinkView(CharacterInfo *chaa);
161 void Character_SetThinkView(CharacterInfo *chaa, int vii);
162 int Character_GetTransparency(CharacterInfo *chaa);
163 void Character_SetTransparency(CharacterInfo *chaa, int trans);
164 int Character_GetTurnBeforeWalking(CharacterInfo *chaa);
165 void Character_SetTurnBeforeWalking(CharacterInfo *chaa, int yesorno);
166 int Character_GetView(CharacterInfo *chaa);
167 int Character_GetWalkSpeedX(CharacterInfo *chaa);
168 int Character_GetWalkSpeedY(CharacterInfo *chaa);
169 int Character_GetX(CharacterInfo *chaa);
170 void Character_SetX(CharacterInfo *chaa, int newval);
171 int Character_GetY(CharacterInfo *chaa);
172 void Character_SetY(CharacterInfo *chaa, int newval);
173 int Character_GetZ(CharacterInfo *chaa);
174 void Character_SetZ(CharacterInfo *chaa, int newval);
175 int Character_GetSpeakingFrame(CharacterInfo *chaa);
176 
177 //=============================================================================
178 
179 struct MoveList;
180 namespace AGS {
181 namespace Shared {
182 class Bitmap;
183 }
184 }
185 using namespace AGS; // FIXME later
186 
187 // Configures and starts character animation.
188 void animate_character(CharacterInfo *chap, int loopn, int sppd, int rept, int direction = 0, int sframe = 0, int volume = 100);
189 // Clears up animation parameters
190 void stop_character_anim(CharacterInfo *chap);
191 void walk_character(int chac, int tox, int toy, int ignwal, bool autoWalkAnims);
192 int find_looporder_index(int curloop);
193 // returns 0 to use diagonal, 1 to not
194 int useDiagonal(CharacterInfo *char1);
195 // returns 1 normally, or 0 if they only have horizontal animations
196 int hasUpDownLoops(CharacterInfo *char1);
197 void start_character_turning(CharacterInfo *chinf, int useloop, int no_diagonal);
198 void fix_player_sprite(MoveList *cmls, CharacterInfo *chinf);
199 // Check whether two characters have walked into each other
200 int has_hit_another_character(int sourceChar);
201 int doNextCharMoveStep(CharacterInfo *chi, int &char_index, CharacterExtras *chex);
202 // Tells if character is currently moving, in eWalkableAreas mode
203 bool is_char_walking_ndirect(CharacterInfo *chi);
204 int find_nearest_walkable_area_within(int *xx, int *yy, int range, int step);
205 void find_nearest_walkable_area(int *xx, int *yy);
206 void FindReasonableLoopForCharacter(CharacterInfo *chap);
207 void walk_or_move_character(CharacterInfo *chaa, int x, int y, int blocking, int direct, bool isWalk);
208 int wantMoveNow(CharacterInfo *chi, CharacterExtras *chex);
209 void setup_player_character(int charid);
210 int GetCharacterFrameVolume(CharacterInfo *chi);
211 Shared::Bitmap *GetCharacterImage(int charid, bool *is_original = nullptr);
212 CharacterInfo *GetCharacterAtScreen(int xx, int yy);
213 // Deduces room object's scale, accounting for both manual scaling and the room region effects;
214 // calculates resulting sprite size.
215 void update_character_scale(int charid);
216 CharacterInfo *GetCharacterAtRoom(int x, int y);
217 // Get character ID at the given room coordinates
218 int is_pos_on_character(int xx, int yy);
219 void get_char_blocking_rect(int charid, int *x1, int *y1, int *width, int *y2);
220 // Check whether the source char has walked onto character ww
221 int is_char_on_another(int sourceChar, int ww, int *fromxptr, int *cwidptr);
222 int my_getpixel(Shared::Bitmap *blk, int x, int y);
223 // X and Y co-ordinates must be in 320x200 format
224 int check_click_on_character(int xx, int yy, int mood);
225 void _DisplaySpeechCore(int chid, const char *displbuf);
226 void _DisplayThoughtCore(int chid, const char *displbuf);
227 void _displayspeech(const char *texx, int aschar, int xx, int yy, int widd, int isThought);
228 int get_character_currently_talking();
229 void DisplaySpeech(const char *texx, int aschar);
230 int update_lip_sync(int talkview, int talkloop, int *talkframeptr);
231 
232 // Recalculate dynamic character properties, e.g. after restoring a game save
233 void restore_characters();
234 
235 // Calculates character's bounding box in room coordinates (takes only in-room transform into account)
236 // use_frame_0 optionally tells to use frame 0 of current loop instead of current frame.
237 Rect GetCharacterRoomBBox(int charid, bool use_frame_0 = false);
238 // Find a closest viewport given character is to. Checks viewports in their order in game's array,
239 // and returns either first viewport character's bounding box intersects with (or rather with its camera),
240 // or the one that is least far away from its camera; calculated as a perpendicular distance between two AABBs.
241 PViewport FindNearestViewport(int charid);
242 
243 // order of loops to turn character in circle from down to down
244 extern int turnlooporder[8];
245 
246 } // namespace AGS3
247 
248 #endif
Definition: achievements_tables.h:27
Definition: ags.h:40