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