// Gui Script // ================================ OPTIONS =============================================== // ============================= EDIT FROM HERE =========================================== // Setup the default Language (only affects the provided GUIs) // Unhandled events can directly be changed in the function Unhandled() // Currently supported languages: // eLangEN (English) // eLangDE (German) // eLangES (Spanish) // eLangFR (French) // eLangIT (Italian) // eLangPT (Portuguese) // eLangNL (Dutch) int lang = eLangEN; int ActionLabelColorNormal = 15219, // colour used in action bar ActionLabelColorHighlighted = 38555, // highlighted colour used in action bar invUparrowONsprite = 124, // sprite slot of the upper inv arrow / normal invUparrowOFFsprite = 154, // sprite slot of the upper inv arrow / disabled invUparrowHIsprite = 137, // sprite slot of the upper inv arrow / highlighted invDownarrowONsprite = 128, // " " " lower " " invDownarrowOFFsprite = 155, // " " " lower " " invDownarrowHIsprite = 141, // " " " lower " " walkoffscreen_offset = 30, // offset used by WalkOffScreen and exit extensions cursorspritenumber = 19, // used for semi-blockable movement blankcursorspritenumber = 29; // used for semi-blockable movement bool approachCharInteract = true; // walk to character before starting interaction bool openDoorDoubleclick = true; // doubleclick on open doors changes room instantly bool runOnDoubleClick = true; // doubleclick occured int runCursorDistance = 10; // Distance between mouse cursor and player until running begins int runSpeedupRate = 2; // multiplied to the player movement speed, while running // 1 = no speedup at all, 2 = double speed and so on bool disableDoubleclick = false; // disable doubleclick entirely bool NPC_facing_player = false; // Non playable characters are facing // the player before talk-to and give-to bool oldschool_inv_clicks = false; // turned on: right-click on inv items is lookat // turned off: right-click on inv items is use bool objHotTalk = false; // Talk to Objects and Hotspots // You can define Audioclips, which are being used in the doorscripts #ifndef USE_OBJECT_ORIENTED_AUDIO // In AGS 3.1 you have to assign a number: // openDoorSound = 15; int openDoorSound = 0, closeDoorSound = 0, unlockDoorSound = 0; #endif #ifdef USE_OBJECT_ORIENTED_AUDIO // In AGS 3.2 you do it this way: // Audioclip *openDoorSound = aDoorsound; AudioClip* openDoorSound, closeDoorSound, unlockDoorSound; #endif // ============================= EDIT UNTIL HERE =========================================== // ========================== variables (not to edit) ====================================== String madetext; // String that is shown in the action bar String numbers; // used by getInteger() to convert strings String door_strings[6]; // default messages for the door script int global_action; // containing the current clicked action int default_action; // default action (most likely walk-to) int alternative_action; // right-click action int used_action; // used_action = global_action, if not cancelled int GSagsusedmode; // on_mouse_click -> unhandled_event int GSloctype; // the result of GetLocationType int GSlocid; // on_mouse_click -> String GSlocname; // on_mouse_click -> unhandled_event String GSinvloc; // locationname>extension String SHOWNlocation; // location translated String location; // The location name underneath the cursor String location_ex; // The location name underneath the cursor bool player_frozen; // player can't move bool disabled_gui; // GUI disabled int door_state[MAX_DOORS]; // Array for the door script int action_button[A_COUNT_]; // Array containing the verb button Ids int action_button_normal[A_COUNT_]; // contains the verb button sprites int action_button_highlight[A_COUNT_]; // Contains the highlighted verb button sprites int button_action[A_COUNT_]; // Array containg the related actions like eGA_LookAt String tresult; // translated result of the action mode, eg. "Look at %s" String act_object; // action_object - object used in action String item; // inventory item to be used or given int GStopsaveitem = 0; // top savegame element of the save GUI int listBoxGap; // used in the save-game dialog to determine a list-item's height int dc_speed; // double click speed, set in the game start section int action_l_keycode[A_COUNT_]; // lower case keycodes for the verbs int action_u_keycode[A_COUNT_]; // upper case keycodes for the verbs InventoryItem*ItemGiven; // Item given to a character char key_l_yes, key_u_yes, key_l_no, key_u_no; // translated keys for yes and no bool timer_run; // is doubleclick timer running int timer_click; // double click timer int player_walk_x_speed; // Initial walking speed x coordinate int player_walk_y_speed; // Initial walking speed y coordinate int player_ani_speed; // Initial animation speed bool player_is_running; // if character is currently running // ============================= Helper functions =========================================== function set_door_state(int door_id, int value) { door_state[door_id] = value; } int get_door_state(int door_id) { return door_state[door_id]; } function init_object (int door_id, int obj){ if (get_door_state(door_id) == 1) { object[obj].Visible=true; object[obj].Clickable=false; } else { object[obj].Visible=false; object[obj].Clickable=false; } } float Distance(int x1, int y1, int x2, int y2) { int dx = x1 - x2; int dy = y1 - y2; return Maths.Sqrt(IntToFloat(dx*dx+dy*dy)); } int Absolute(int value) { if (value<0) return -value; return value; } int Offset(int point1, int point2) { return Absolute(point1 - point2); } int getButtonAction(int action) { return button_action[action]; } function disable_gui() { disabled_gui=true; gMaingui.Visible=false; gAction.Visible=false; } function enable_gui() { disabled_gui=false; gMaingui.Visible=true; gAction.Visible=true; Wait(1); } bool is_gui_disabled() { return disabled_gui; } function set_double_click_speed(int speed){ dc_speed = speed; } // ============================= verb action functions =========================================== function TranslateAction(int action, int tr_lang) { if (tr_lang == eLangDE) { if (action == eMA_WalkTo) tresult="Gehe zu %s"; else if (action == eGA_LookAt) tresult="Schau %s an"; else if (action == eGA_TalkTo) tresult="Rede mit %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Gib !s an %s"; else tresult="Gib %s"; } else if (action == eGA_PickUp) tresult="Nimm %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Benutze !s mit %s"; else tresult="Benutze %s"; } else if (action == eGA_Open) tresult="Öffne %s"; else if (action == eGA_Close) tresult="Schließe %s"; else if (action == eGA_Push) tresult="Drücke %s"; else if (action == eGA_Pull) tresult="Ziehe %s"; else tresult=" "; } else if (tr_lang == eLangES) { if (action == eMA_WalkTo) tresult="Ir a %s"; else if (action == eGA_LookAt) tresult="Mirar %s"; else if (action == eGA_TalkTo) tresult="Hablar con %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Dar !s a %s"; else tresult="Dar %s"; } else if (action == eGA_PickUp) tresult="Coger %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Usar !s con %s"; else tresult="Usar %s"; } else if (action == eGA_Open) tresult="Abrir %s"; else if (action == eGA_Close) tresult="Cerrar %s"; else if (action == eGA_Push) tresult="Empujar %s"; else if (action == eGA_Pull) tresult="Tirar de %s"; else tresult=" "; } else if (tr_lang == eLangFR) { if (action == eMA_WalkTo) tresult="Aller vers %s"; else if (action == eGA_LookAt) tresult="Regarder %s"; else if (action == eGA_TalkTo) tresult="Parler à %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Donner !s à %s"; else tresult="Donner %s"; } else if (action == eGA_PickUp) tresult="Prendre %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Utiliser !s sur %s"; else tresult="Utiliser %s"; } else if (action == eGA_Open) tresult="Ouvrir %s"; else if (action == eGA_Close) tresult="Fermer %s"; else if (action == eGA_Push) tresult="Pousser %s"; else if (action == eGA_Pull) tresult="Tirer %s"; else tresult=" "; } else if (tr_lang == eLangIT) { if (action == eMA_WalkTo) tresult="Vai a %s"; else if (action == eGA_LookAt) tresult="Esamina %s"; else if (action == eGA_TalkTo) tresult="Parla con %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Dai !s a %s"; else tresult="Dai %s"; } else if (action == eGA_PickUp) tresult="Raccogli %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Usa !s con %s"; else tresult="Usa %s"; } else if (action == eGA_Open) tresult="Apri %s"; else if (action == eGA_Close) tresult="Ferma %s"; else if (action == eGA_Push) tresult="Premi %s"; else if (action == eGA_Pull) tresult="Tira %s"; else tresult=" "; } else if (tr_lang == eLangPT) { if (action == eMA_WalkTo) tresult="Ir para %s"; else if (action == eGA_LookAt) tresult="Olhar para %s"; else if (action == eGA_TalkTo) tresult="Falar com %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Dar !s a %s"; else tresult="Dar %s"; } else if (action == eGA_PickUp) tresult="Apanhar %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Usar !s com %s"; else tresult="Usar %s"; } else if (action == eGA_Open) tresult="Abrir %s"; else if (action == eGA_Close) tresult="Fechar %s"; else if (action == eGA_Push) tresult="Empurrar %s"; else if (action == eGA_Pull) tresult="Puxar %s"; else tresult=" "; } else if (tr_lang == eLangNL) { if (action == eMA_WalkTo) tresult="Ga naar %s"; else if (action == eGA_LookAt) tresult="Bekijk %s"; else if (action == eGA_TalkTo) tresult="Praat met %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Geef !s aan %s"; else tresult="Geef %s"; } else if (action == eGA_PickUp) tresult="Pak %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Gebruik !s met %s"; else tresult="Gebruik %s"; } else if (action == eGA_Open) tresult="Open %s"; else if (action == eGA_Close) tresult="Sluit %s"; else if (action == eGA_Push) tresult="Duw %s"; else if (action == eGA_Pull) tresult="Trek %s"; else tresult=" "; } else { if (action == eMA_WalkTo) tresult="Go to %s"; else if (action == eGA_LookAt) tresult="Look at %s"; else if (action == eGA_TalkTo) tresult="Talk to %s"; else if (action == eGA_GiveTo) { if (item.Length>0) tresult="Give !s to %s"; else tresult="Give %s"; } else if (action == eGA_PickUp) tresult="Pick up %s"; else if (action == eGA_Use) { if (item.Length>0) tresult="Use !s with %s"; else tresult="Use %s"; } else if (action == eGA_Open) tresult="Open %s"; else if (action == eGA_Close) tresult="Close %s"; else if (action == eGA_Push) tresult="Push %s"; else if (action == eGA_Pull) tresult="Pull %s"; else tresult=" "; } // fill object and item into action template tresult=GetTranslation(tresult); int ip=tresult.IndexOf("!s"); if (ip>=0) { int op=tresult.Contains("%s"); tresult=tresult.ReplaceCharAt(ip, '%'); if (ip"); if (pos==-1) return 0; else if (pos+index*) of a string return ExtensionEx(1,location); } function RemoveExtension(){ //removes the extension of a string int pos = location.IndexOf(">"); if (Extension()!=0)location=location.Truncate(pos); return pos; } function AddExtension(char extension) { //adds an extension to a thing that doesn't have one int length=location.Length; if (Extension()==0) { location=location.Append(">n"); location=location.ReplaceCharAt(length+1, extension); } } function SetAlternativeAction(char extension, Action alt_action) { if (alt_action==eMA_Default) { if (Extension()==extension) alternative_action = alt_action; } else { int button=action_button[alt_action]; int normalbuttonpic=action_button_normal[alt_action]; int overbuttonpic=action_button_highlight[alt_action]; // used for setting the default action given the extension. GUIControl*gc=gMaingui.Controls[button]; Button*b=gc.AsButton; if (Extension()==extension) { b.NormalGraphic=overbuttonpic; alternative_action=alt_action; } else b.NormalGraphic=normalbuttonpic; b.MouseOverGraphic=overbuttonpic; } } // Door extension for Open/Close function OpenCloseExtension(int door_id) { if ((get_door_state(door_id)==0) || (get_door_state(door_id)==2)) AddExtension('o'); else AddExtension('c'); } function VariableExtensions() { // define here, which things will use a variable extension (>v) // by default, it's only used for doors. int r=player.Room; Object*oo=Object.GetAtScreenXY(mouse.x, mouse.y); int o=0; if (oo!=null) o=oo.ID; Hotspot*hh=Hotspot.GetAtScreenXY(mouse.x, mouse.y); int h=hh.ID; // Open/Close Extension: // Room | Hotspot |(Door_id) if (r==1 && h == 1) OpenCloseExtension (20); //else if (r==2 && h == 2) OpenCloseExtension (3); // Other possible extensions could be: Turn On/Turn Off } function CheckDefaultAction() { // you could want to change which extension activates which default action, or which button sprite // it changes. The extensions are characters, so remember to put them with single ', not ". int x=mouse.x; int y=mouse.y; location=Game.GetLocationName(x, y); location_ex = location; // Setting default modes if the thing has no extension: if (Extension() == 0 ) { if (GetLocationType(x, y) == eLocationCharacter) // if it is a character AddExtension('t'); // set default action "talk to" else if ((GetLocationType(x, y)!=eLocationNothing) || (InventoryItem.GetAtScreenXY(x, y)!=null)) // if its an inv item, a hotspot or an object AddExtension('l'); // set default action "look at" else AddExtension('n'); // set default action "none" } else if (Extension()=='v') { // if the default action depends on some events RemoveExtension(); VariableExtensions(); } if (GlobalCondition(eGlob_InvOnInv) || (objHotTalk && GlobalCondition(eGlob_GiveTalkNoChar)) || GlobalCondition(eGlob_GiveNoInv) ) //Dont send the name of the hotspt/obj/char/inv to the action bar and set default action "none" if (!GlobalCondition(eGlob_InvTalk)) location=">n"; GSinvloc=location; // Set "Look" as default action for Inv items if ((Extension()=='u') && (InventoryItem.GetAtScreenXY(x, y) != null)) { // it's an inv item RemoveExtension(); AddExtension('l'); // set default action "look at" } SetAlternativeAction('n', eMA_Default); SetAlternativeAction('g', eGA_GiveTo); SetAlternativeAction('p', eGA_PickUp); SetAlternativeAction('u', eGA_Use); SetAlternativeAction('o', eGA_Open); SetAlternativeAction('l', eGA_LookAt); SetAlternativeAction('s', eGA_Push); SetAlternativeAction('c', eGA_Close); SetAlternativeAction('t', eGA_TalkTo); SetAlternativeAction('y', eGA_Pull); RemoveExtension(); SHOWNlocation=location; } // ============================= ActionBar =========================================== function UpdateActionBar (){ // set the text in the action bar int action = global_action; act_object=SHOWNlocation; item=""; if (Mouse.Mode==eModeUseinv) { // use or give inventory item item=player.ActiveInventory.Name; location=item; RemoveExtension(); item=location; } else if (GlobalCondition (eGlob_MouseInvWalk)) { // if the mouse is in the inventory and modes Walk or pickup are selected if (oldschool_inv_clicks) action=eGA_LookAt; else { action=eGA_Use; } } TranslateAction(action, lang); madetext=tresult; // show action text ActionLine.Text=madetext; ActionLine.TextColor=ActionLabelColorNormal; } // ============================= translation =========================================== String clearToSpace(String text) { int p=0; // ignore white spaces at the beginning while (p0) { action_l_keycode[action]=bd.Chars[p]; p--; action_u_keycode[action]=bd.Chars[p]; if (action_l_keycode[action]!=' ') p=0; } button_action[action_button[action]]=action; } function AdjustLanguage() { // English if (lang == eLangEN){ // yes/no-keys key_u_yes= 'Y'; key_l_yes= 'y'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 125 138 Qq"); SetActionButtons(eGA_PickUp, "a_button_pick_up 1 126 139 Ww"); SetActionButtons(eGA_Use, "a_button_use 2 127 140 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 129 142 Aa"); SetActionButtons(eGA_LookAt, "a_button_look_at 4 134 147 Ss"); SetActionButtons(eGA_Push, "a_button_push 5 131 144 Dd"); SetActionButtons(eGA_Close, "a_button_close 6 133 146 Zz"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 7 130 143 Xx"); SetActionButtons(eGA_Pull, "a_button_pull 8 135 148 Cc"); } // German else if (lang == eLangDE) { // yes/no-keys key_u_yes= 'J'; key_l_yes= 'j'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 157 166 Qq"); SetActionButtons(eGA_Use, "a_button_use 1 158 167 Ww"); SetActionButtons(eGA_PickUp, "a_button_pick_up 2 159 168 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 160 169 Aa"); SetActionButtons(eGA_Close, "a_button_close 4 161 170 Ss"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 5 162 171 Dd"); SetActionButtons(eGA_LookAt, "a_button_look_at 6 163 172 Yy"); SetActionButtons(eGA_Push, "a_button_push 7 164 173 Xx"); SetActionButtons(eGA_Pull, "a_button_pull 8 165 156 Cc"); } // Spanish else if (lang == eLangES) { // yes/no-keys key_u_yes= 'S'; key_l_yes= 's'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 6 11 Qq"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 1 18 17 Ww"); SetActionButtons(eGA_Use, "a_button_use 2 4 145 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 5 2 Aa"); SetActionButtons(eGA_Close, "a_button_close 4 8 7 Ss"); SetActionButtons(eGA_PickUp, "a_button_pick_up 5 10 9 Dd"); SetActionButtons(eGA_LookAt, "a_button_look_at 6 122 75 Zz"); SetActionButtons(eGA_Push, "a_button_push 7 14 13 Xx"); SetActionButtons(eGA_Pull, "a_button_pull 8 16 15 Cc"); } // French else if (lang == eLangFR) { // yes/no-keys key_u_yes= 'O'; key_l_yes= 'o'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 149 184 Qq"); SetActionButtons(eGA_PickUp, "a_button_pick_up 1 176 185 Ww"); SetActionButtons(eGA_Use, "a_button_use 2 177 186 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 178 187 Aa"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 4 179 188 Xx"); SetActionButtons(eGA_Push, "a_button_push 5 180 189 Dd"); SetActionButtons(eGA_Close, "a_button_close 6 181 190 Zz"); SetActionButtons(eGA_LookAt, "a_button_look_at 7 182 191 Ss"); SetActionButtons(eGA_Pull, "a_button_pull 8 183 175 Cc"); } // Italian else if (lang == eLangIT) { // yes/no-keys key_u_yes= 'S'; key_l_yes= 's'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 193 200 Qq"); SetActionButtons(eGA_PickUp, "a_button_pick_up 1 195 203 Ww"); SetActionButtons(eGA_Use, "a_button_use 2 196 204 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 197 205 Aa"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 4 198 206 Xx"); SetActionButtons(eGA_Push, "a_button_push 5 199 207 Dd"); SetActionButtons(eGA_Close, "a_button_close 6 201 213 Zz"); SetActionButtons(eGA_LookAt, "a_button_look_at 7 202 214 Ss"); SetActionButtons(eGA_Pull, "a_button_pull 8 194 215 Cc"); } else if (lang == eLangPT) { // yes/no-keys key_u_yes= 'S'; key_l_yes= 's'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 12 224 Qq"); SetActionButtons(eGA_PickUp, "a_button_pick_up 1 216 225 Ww"); SetActionButtons(eGA_Use, "a_button_use 2 217 226 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 218 227 Aa"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 4 219 228 Xx"); SetActionButtons(eGA_Push, "a_button_push 5 223 232 Dd"); SetActionButtons(eGA_Close, "a_button_close 6 221 230 Zz"); SetActionButtons(eGA_LookAt, "a_button_look_at 7 222 231 Ss"); SetActionButtons(eGA_Pull, "a_button_pull 8 220 229 Cc"); } else if (lang == eLangNL) { // yes/no-keys key_u_yes= 'J'; key_l_yes= 'j'; key_u_no= 'N'; key_l_no= 'n'; // (eNum Name, Name, GUI Button ID, Sprite-Normal, Sprite-Highlight, Keyboard-Shortcut) SetActionButtons(eGA_GiveTo, "a_button_give 0 241 174 Qq"); SetActionButtons(eGA_Use, "a_button_use 1 243 234 Ww"); SetActionButtons(eGA_PickUp, "a_button_pick_up 2 242 233 Ee"); SetActionButtons(eGA_Open, "a_button_open 3 244 235 Aa"); SetActionButtons(eGA_Close, "a_button_close 4 247 238 Ss"); SetActionButtons(eGA_TalkTo, "a_button_talk_to 5 245 236 Dd"); SetActionButtons(eGA_LookAt, "a_button_look_at 6 248 239 Yy"); SetActionButtons(eGA_Push, "a_button_push 7 246 237 Xx"); SetActionButtons(eGA_Pull, "a_button_pull 8 249 240 Cc"); } // --- load font corresponding to language and screen width --- String font_info; if (System.ScreenWidth<640) font_info=GetTranslation("font_lowres: 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1"); else font_info=GetTranslation("font_hires: 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1"); //Game.NormalFont font_info=clearToSpace(font_info); numbers=font_info; // Setting the fonts from the string: font_info Game.SpeechFont = getInteger(); // Speech ActionLine.Font = getInteger(); // Status-Line Game.NormalFont = getInteger(); // Dialog GUI OptionsTitle.Font = getInteger(); // Options-GUI Title OptionsSave.Font = getInteger(); // Options-GUI Save Button OptionsLoad.Font = getInteger(); // Options-GUI Load Button OptionsQuit.Font = getInteger(); // Options-GUI Quit Button OptionsPlay.Font = getInteger(); // Options-GUI Play Button gPausedText.Font = getInteger(); // Game Paused Message OptionsDefault.Font = getInteger(); // Options-GUI Default Button OptionsMusic.Font = getInteger(); // Options-GUI Music Label OptionsSpeed.Font = getInteger(); // Options-GUI Gamespeed Label OptionsRestart.Font = getInteger(); // Options-GUI Restart Button RestoreTitle.Font = getInteger(); // Restore-GUI Title RestoreCancel.Font = getInteger(); // Restore-GUI Cancel Button SaveTitle.Font = getInteger(); // Save-GUI Title SaveOK.Font = getInteger(); // Save-GUI Okay Button SaveCancel.Font = getInteger(); // Save-GUI Cancel Button gConfirmexitText.Font = getInteger(); // Confirm Exit Message gRestartText.Font = getInteger(); // Restart Game Message } function AdjustGUIText() { // English if (lang == eLangEN){ // English OptionsTitle.Text = "Options"; OptionsMusic.Text = "Music Volume"; OptionsSound.Text = "Sound Effects Volume"; OptionsSpeed.Text = "Game Speed"; OptionsDefault.Text = "Default"; OptionsSave.Text = "Save"; OptionsLoad.Text = "Load"; OptionsRestart.Text = "Restart"; OptionsQuit.Text = "Quit"; OptionsPlay.Text = "Resume"; gPausedText.Text = "Game paused. Press to continue"; RestoreTitle.Text = "Please choose a game to load"; RestoreCancel.Text = "Cancel"; SaveTitle.Text = "Please enter a name"; SaveOK.Text = "Save"; } else if (lang == eLangDE) { // German OptionsTitle.Text = "Optionen"; OptionsMusic.Text = "Musik Lautstärke"; OptionsSound.Text = "Sound Effekte"; OptionsSpeed.Text = "Geschwindigkeit"; OptionsDefault.Text = "Standard"; OptionsSave.Text = "Speichern"; OptionsLoad.Text = "Laden"; OptionsRestart.Text = "Neustart"; OptionsQuit.Text = "Beenden"; OptionsPlay.Text = "Weiter"; gPausedText.Text = "Pause. Leertaste für weiter"; RestoreTitle.Text = "Wählen Sie ein Spiel zum Laden"; RestoreCancel.Text = "Abbruch"; SaveTitle.Text = "Name für das Spiel"; SaveOK.Text = "Speichern"; SaveCancel.Text = "Abbruch"; gConfirmexitText.Text = "Möchten Sie das Spiel beenden? (J/N)"; gRestartText.Text = "Möchten Sie das Spiel neu starten? (J/N)"; } else if (lang == eLangES) { // Spanish OptionsTitle.Text = "Opciones"; OptionsMusic.Text = "Volumen de la música"; OptionsSound.Text = "Efectos de sonido "; OptionsSpeed.Text = "Velocidad de juego"; OptionsDefault.Text = "Restablecer"; OptionsSave.Text = "Guardar"; OptionsLoad.Text = "Cargar"; OptionsRestart.Text = "Reiniciar"; OptionsQuit.Text = "Salir"; OptionsPlay.Text = "Volver"; gPausedText.Text = "Juego en pausa. Pulsa Espacio para continuar"; RestoreTitle.Text = "Por favor, elige el juego a cargar"; RestoreCancel.Text = "Cancelar"; SaveTitle.Text = "Por favor, introduce un nombre"; SaveOK.Text = "Guardar"; SaveCancel.Text = "Cancelar"; gConfirmexitText.Text = "¿Seguro que quieres salir? (S/N)"; gRestartText.Text = "¿Seguro que quieres reiniciar? (S/N)"; } else if (lang == eLangFR) { // French OptionsTitle.Text = "Paramètres"; OptionsMusic.Text = "Volume de la musique"; OptionsSound.Text = "Volume des sons"; OptionsSpeed.Text = "Vitesse du jeu"; OptionsDefault.Text = "Réinitialiser"; OptionsSave.Text = "Sauver"; OptionsLoad.Text = "Charger"; OptionsRestart.Text = "Redémarrer"; OptionsQuit.Text = "Quitter"; OptionsPlay.Text = "Reprendre"; gPausedText.Text = "PAUSE. Appuyez sur la barre d'espacement pour reprendre"; RestoreTitle.Text = "Choisissez une partie à charger"; RestoreCancel.Text = "Annuler"; SaveTitle.Text = "Saisissez un nom"; SaveOK.Text = "Sauver"; SaveCancel.Text = "Annuler"; gConfirmexitText.Text = "Voulez-vous vraiment quitter? (O/N)"; gRestartText.Text = "Voulez-vous vraiment redémarrer? (O/N)"; } else if (lang == eLangIT) { // Italian OptionsTitle.Text = "Opzioni"; OptionsMusic.Text = "Volume della Musica"; OptionsSound.Text = "Effetti Sonori"; OptionsSpeed.Text = "Velocita' del Gioco"; OptionsDefault.Text = "Default"; OptionsSave.Text = "Salva"; OptionsLoad.Text = "Carica"; OptionsRestart.Text = "Ricomincia"; OptionsQuit.Text = "Esci"; OptionsPlay.Text = "Continua"; gPausedText.Text = "Partita in Pausa. Premi Spazio per Continuare"; RestoreTitle.Text = "Scegli una partita da caricare"; RestoreCancel.Text = "Cancella"; SaveTitle.Text = "Inserisci un nome"; SaveOK.Text = "Salva"; SaveCancel.Text = "Cancella"; gConfirmexitText.Text = "Sei sicuro/a che vuoi uscire? (S/N)"; gRestartText.Text = "Sei sicuro/a che vuoi ricominciare? (S/N)"; } else if (lang == eLangPT) { // Italian OptionsTitle.Text = "Opções"; OptionsMusic.Text = "Volume Música"; OptionsSound.Text = "Efeitos Sonoros"; OptionsSpeed.Text = "Velocidade"; OptionsDefault.Text = "Standard"; OptionsSave.Text = "Gravar"; OptionsLoad.Text = "Restaurar"; OptionsRestart.Text = "Recomeçar"; OptionsQuit.Text = "Desistir"; OptionsPlay.Text = "Continuar"; gPausedText.Text = "Pausa. Prima Space para continuar"; RestoreTitle.Text = "Por favor escolha um jogo para restaurar"; RestoreCancel.Text = "Cancelar"; SaveTitle.Text = "Por favor insira um nome"; SaveOK.Text = "Gravar"; SaveCancel.Text = "Cancelar"; gConfirmexitText.Text = "De certeza que quer desistir ? (S/N)"; gRestartText.Text = "De certeza que quer recomeçar? (S/N)"; } else if (lang == eLangNL) { OptionsTitle.Text = "Opties"; OptionsMusic.Text = "Muziek Volume"; OptionsSound.Text = "Geluidseffecten"; OptionsSpeed.Text = "Snelheid"; OptionsDefault.Text = "Standaard"; OptionsSave.Text = "Opslaan"; OptionsLoad.Text = "Laden"; OptionsRestart.Text = "Herstarten"; OptionsQuit.Text = "Stop"; OptionsPlay.Text = "Ga door"; gPausedText.Text = "Pauze. Druk op de Spatiebalk om door te gaan"; RestoreTitle.Text = "Kies a.u.b. een spel om te laden"; RestoreCancel.Text = "Annuleren"; SaveTitle.Text = "Vul a.u.b. een naam in"; SaveOK.Text = "Opslaan"; SaveCancel.Text = "Annuleren"; gConfirmexitText.Text = "Weet u zeker dat u wilt stoppen? (J/N)"; gRestartText.Text = "Weet u zeker dat u wilt herstarten? (J/N)"; } } function InitGuiLanguage() { AdjustLanguage(); int i; GUIControl*gc; Button*b; while (i < A_COUNT_) { gc = gMaingui.Controls[action_button[i]]; b = gc.AsButton; b.NormalGraphic=action_button_normal[i]; i++; } } // ============================= Player function =========================================== function freeze_player(){player_frozen = true;} function unfreeze_player(){player_frozen = false;} #ifnver 3.4 function FaceDirection(this Character*, CharacterDirection dir) { int dx; if (dir==eDirectionLeft) dx=-1; if (dir==eDirectionRight) dx=1; int dy; if (dir==eDirectionUp) dy=-1; else if (dir==eDirectionDown) dy=1; this.FaceLocation(this.x+dx, this.y+dy); } #endif function SetPlayer(Character*ch) { //use this instead of SetPlayerCharacter function. if (player.Room==ch.Room) { // if old and new player character are in the same room then scroll room int x=GetViewportX(); int tx=ch.x-160; if (tx<0) tx = 0; else if (tx>Room.Width-320) tx=Room.Width-320; SetViewport(x, GetViewportY()); while (xtx) x=tx; SetViewport(x, GetViewportY()); Wait(1); } while (x>tx) { x -= X_SPEED; if (x xoffset || Offset(pl.y, chy) > yoffset) { if (dir == 0) { // get the nearest position if (Offset (chx, pl.x) >= Offset(chy, pl.y)) { // right or left if (pl.x >= chx) dir = eDirectionRight; else dir = eDirectionLeft; } else { if (pl.y >= chy) dir = eDirectionDown; else dir = eDirectionUp; } } // calculate target position if (dir == eDirectionUp) chy-=yoffset; else if (dir == eDirectionRight) chx+=xoffset; else if (dir == eDirectionDown) chy+=yoffset; else if (dir == eDirectionLeft) chx-=xoffset; // move character if (blocking==0) { pl.Walk(chx, chy); arrived = 0; } else if (blocking==1) { pl.Walk(chx, chy, eBlock, eWalkableAreas); arrived=1; } else if (blocking==2) arrived=MovePlayer(chx, chy); } if (arrived>0) { // characters only face each other after the moving character arrived at the target point if (NPCfacesplayer) ch.FaceCharacter(pl, eBlock); pl.FaceCharacter(ch, eBlock); } return arrived; } int NPCGoToCharacter(Character*chwhogoes, Character*chtogoto, CharacterDirection dir, bool NPCfacesplayer, int blocking) { // same as above but with default x and y offset. int defaultxoffset=35; int defaultyoffset=20; return GoToCharacterEx (chwhogoes, chtogoto, dir, defaultxoffset, defaultyoffset, NPCfacesplayer, blocking); } int GoToCharacter(Character*ch, CharacterDirection dir, bool NPCfacesplayer, int blocking) { // same as above but with default x and y offset. int defaultxoffset=35; int defaultyoffset=20; return GoToCharacterEx (player, ch, dir, defaultxoffset, defaultyoffset, NPCfacesplayer, blocking); } function GoTo(int blocking) { // Goes to whatever the player clicked on. // blocking: 0=non-blocking; 1=blocking; 2=semi-blocking int xtogo, ytogo; int locationtype=GetLocationType(mouse.x, mouse.y); Hotspot*hot_spot=Hotspot.GetAtScreenXY(mouse.x, mouse.y); int arrived=0; if (locationtype==eLocationCharacter) arrived=GoToCharacter(Character.GetAtScreenXY(mouse.x, mouse.y), 0, false, blocking); else { if (locationtype==eLocationHotspot && hot_spot.ID>0 && (hot_spot.WalkToX >0 || hot_spot.WalkToY > 0) ) { xtogo=hot_spot.WalkToX; ytogo=hot_spot.WalkToY; } else if (locationtype==eLocationObject) { Object*obj=Object.GetAtScreenXY(mouse.x, mouse.y); if (obj.Graphic > 0) xtogo=obj.X + (Game.SpriteWidth[obj.Graphic] / 2); else xtogo = obj.X; ytogo=obj.Y; } else { xtogo=mouse.x; ytogo=mouse.y; } xtogo+=GetViewportX (); ytogo+=GetViewportY (); if (blocking==0) player.Walk(xtogo, ytogo); else if (blocking==1) { player.Walk(xtogo, ytogo, eBlock); arrived=1; } else if (blocking==2) arrived=MovePlayer(xtogo, ytogo); } return arrived; } function Go() { // Go to whatever the player clicked on. You can cancel the action, and returns 1 if the player has gone to it. return GoTo(2); } function set_approaching_char(bool enable){ // If set to true, the player walks to other chars before talking or giving items. approachCharInteract = enable; } function WalkOffScreen(){ //handles the action of hotspots with exit extension ('>e'). //double click in such hotspots/objects... will make the player skip //walking to it. Look the documentation for more information on exits. // doubleclick if (UsedAction(eMA_WalkTo)) { if (timer_run == true) { timer_run=false; if (MovePlayerEx(player.x,player.y,eWalkableAreas)>0) { if (GSloctype==eLocationHotspot) hotspot[GSlocid].RunInteraction(eModeUsermode1); else if (GSloctype==eLocationObject) object[GSlocid].RunInteraction(eModeUsermode1); } } else { //doubleclick = false; if (!disableDoubleclick) timer_run = true; if (Go()){ int x=player.x,y=player.y; int offset=walkoffscreen_offset; int dir=ExtensionEx(2,GSlocname); if (dir=='u') y-=offset; else if (dir=='d') y+=offset; else if (dir=='l') x-=offset; else if (dir=='r') x+=offset; if (MovePlayerEx(x,y,eAnywhere)>0){ if (GSloctype==eLocationHotspot) hotspot[GSlocid].RunInteraction(eModeUsermode1); else if (GSloctype==eLocationObject) object[GSlocid].RunInteraction(eModeUsermode1); } } } } } // ============================= Unhandled Events =========================================== // Please check this section and replace the boring default values with your own. // If you courious, how it all works, keep on reading this comment ;-) // //Check modes with: if(UsedAction(A_???)), check types by if(type==#). types: // 1 a hotspot // 2 a character // 3 an object // 4 an inventory item. // 5 inv. item on hotspot // 6 inv. item on character // 7 inv. item on object // 8 inv. item on inv. item // // You have the string "locationname" that is the name of // what you clicked on, and the string "usedinvname" that is // the name of the item that was used on where you clicked (only for types 5,6,7,8) function Unhandled(int door_script) { InventoryItem*ii=InventoryItem.GetAtScreenXY(mouse.x, mouse.y); int type=0; if (GSloctype==eLocationHotspot) type=1; if (GSloctype==eLocationCharacter) type=2; if (GSloctype==eLocationObject) type=3; String locationname=GSlocname; String usedinvname; String translation; translation=Game.TranslationFilename; location=locationname; RemoveExtension(); locationname=location; if (ii!=null) type = 4; if (GSagsusedmode == eModeUseinv) { if (ii!=null) { usedinvname=ii.Name; location=usedinvname; RemoveExtension(); usedinvname=location; if (type>0) type+=4; } } if (GSagsusedmode!=eModeUsermode2 && type!=0) { if (type==2 || type==6) player.FaceCharacter(character[GSlocid], eBlock); // unhandled USE if (UsedAction(eGA_Use)) { // use inv on inv if (type >= 5) player.Say("That won't do any good."); // use else player.Say("I can't use that."); } // unhandled LOOK AT else if (UsedAction(eGA_LookAt)) { // look at hotspots, objects etc. if (type!=2) player.Say ("Nice %s", locationname); // look at characters else player.Say("It's %s",locationname); } // unhandled PUSH else if (UsedAction(eGA_Push)) { // push everything except characters if (type!=2) player.Say("I can't push that."); // push characters else player.Say("I can't push %s",locationname); } // unhandled PULL else if (UsedAction(eGA_Pull)){ // pull everything except characters if (type!=2) player.Say("I can't pull that."); // pull characters else player.Say("I can't pull %s",locationname); } // unhandled CLOSE else if (UsedAction(eGA_Close)){ if (door_script == 1) player.Say("It has already been closed."); else if (type == 2) player.Say("Doing that with %s is not a good idea.",locationname); else player.Say("I can't close that."); } // unhandled OPEN else if (UsedAction(eGA_Open)) { if (door_script == 1) player.Say("It is already open."); else if (type ==2) player.Say("%s would not like it.",locationname); else player.Say("I can't open that."); } // unhandled PICKUP else if (UsedAction(eGA_PickUp)) { if (type!=2) player.Say("I don't need that."); else player.Say("I don't want to pick %s up.",locationname); } // unhandled TALK TO else if (UsedAction(eGA_TalkTo)) { if (type==2) player.Say("I don't want to talk to %s", locationname); else player.Say("I have nothing to say."); } // unhandled USE INV else if (UsedAction(eGA_UseInv)) player.Say("That won't do any good."); // unhandled GIVE else if (ItemGiven != null) player.Say("I'd rather keep it."); // unhandled DEFAULT else if (type==4) player.Say("I can't do that."); } } // ============================= interaction functions =========================================== function EnterRoom(this Character*, int newRoom, int x, int y, CharacterDirection dir) { this.ChangeRoom(newRoom, x, y); this.FaceDirection(dir); } function any_click_move (int x, int y, CharacterDirection dir) { int result=MovePlayer(x, y); if (result) { #ifver 3.4 player.FaceDirection(dir, eBlock); #endif #ifnver 3.4 player.FaceDirection(dir); Wait(1); #endif } return result; } function any_click_walk(int x, int y, CharacterDirection dir){ int result=1; if (UsedAction(eMA_WalkTo)) any_click_move(x, y, dir); else result=0; return result; // 0 = unhandled // 1 = handled } function any_click_walk_look(int x, int y, CharacterDirection dir, String lookat){ int result=any_click_walk(x, y, dir); //if (result==0 && UsedAction(eGA_LookAt) && lookat.Length>0) { if (result==0 && lookat.Length>0) { result=1; if (any_click_move(x, y, dir)) { player.Say(lookat); } } return result; // 0 = unhandled // 1 = handled } function any_click_use_inv(InventoryItem*iitem, int x, int y, CharacterDirection dir) { int result=0; if (UsedAction(eGA_UseInv)) { if (player.ActiveInventory == iitem) { if (any_click_move (x, y, dir)) result = 2; else result = 1; } } return result; // 0 = unhandled // 1 = handled, but canceled // 2 = use this item } #ifdef USE_OBJECT_ORIENTED_AUDIO function any_click_walk_look_pick(int x, int y, CharacterDirection dir, String lookat, int obj, InventoryItem*iitem, AudioClip *sound) { AudioChannel *chan; int result=MovePlayer(x, y); if (result>0 && UsedAction(eGA_PickUp)) { if (any_click_move (x, y, dir)) { if (lookat.Length>0) player.Say(lookat); if (sound != null)chan = sound.Play(); if (obj>=0) object[obj].Visible=false; if (iitem!=null) player.AddInventory(iitem); result=2; } } return result; // 0 = unhandled // 1 = handled, but canceled // 2 = picked up } #endif #ifndef USE_OBJECT_ORIENTED_AUDIO function any_click_walk_look_pick(int x, int y, CharacterDirection dir, String lookat, int obj, InventoryItem*iitem, int sound) { int result=MovePlayer(x, y); if (result>0 && UsedAction(eGA_PickUp)) { if (any_click_move (x, y, dir)) { if (lookat.Length>0) player.Say(lookat); if (sound != 0)PlaySound(sound); if (obj>=0) object[obj].Visible=false; if (iitem!=null) player.AddInventory(iitem); result=2; } } return result; // 0 = unhandled // 1 = handled, but canceled // 2 = picked up } #endif // ============================= Door functions ========================================== function set_door_strings(String lookat, String islocked, String wrongitem, String closefirst, String unlock, String relock) { if (!String.IsNullOrEmpty(lookat)) door_strings[0]=lookat; if (!String.IsNullOrEmpty(islocked)) door_strings[1]=islocked; if (!String.IsNullOrEmpty(wrongitem)) door_strings[2]=wrongitem; if (!String.IsNullOrEmpty(closefirst)) door_strings[3]=closefirst; if (!String.IsNullOrEmpty(unlock)) door_strings[4]=unlock; if (!String.IsNullOrEmpty(relock)) door_strings[5]=relock; } String get_door_strings(String what_type) { String ret_value; if (what_type == "lookat") ret_value= door_strings[0]; else if (what_type == "islocked") ret_value= door_strings[1]; else if (what_type == "wrongitem") ret_value= door_strings[2]; else if (what_type == "closefirst") ret_value= door_strings[3]; else if (what_type == "unlock") ret_value= door_strings[4]; else if (what_type == "relock") ret_value= door_strings[5]; else ret_value= "INVALID STRING"; if (String.IsNullOrEmpty(ret_value)) return ""; else return ret_value; } #ifdef USE_OBJECT_ORIENTED_AUDIO function any_click_on_door_special(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, AudioClip *opensound, AudioClip *closesound, int key, int closevalue) { // key = -1: masterkey - even locked doors will be opened // key = -2: door can't be unlocked (like rusted) AudioChannel *chan; int result=1; if (UsedAction(eGA_Close)) { if (get_door_state(door_id)==0 || get_door_state(door_id)==2) Unhandled(1); else if (get_door_state(door_id)==1) { if (any_click_move (x, y, dir)) { if (closesound != null) chan = closesound.Play(); // Play default sound else if (closeDoorSound != null) chan = closeDoorSound.Play(); object[obj].Visible=false; set_door_state(door_id, closevalue); } } } else if (UsedAction(eGA_Open)) { if (get_door_state(door_id)==0 || (get_door_state(door_id)==2 && key==-1)) { if (any_click_move (x, y, dir)) { if (opensound != null) chan = opensound.Play(); // Play default sound else if (openDoorSound != null) chan = openDoorSound.Play(); object[obj].Visible=true; set_door_state(door_id, 1); } } else if (get_door_state(door_id)==1) Unhandled(1); else if (get_door_state(door_id)==2) { if (any_click_move (x, y, dir)) if (!String.IsNullOrEmpty(get_door_strings("islocked"))) player.Say(get_door_strings("islocked")); } } else if (UsedAction(eMA_WalkTo)) { if (get_door_state(door_id)==1) { if (timer_run == true && openDoorDoubleclick==true) { timer_run = false; if (MovePlayerEx(player.x,player.y,eWalkableAreas)>0) player.EnterRoom(nr_room, nr_x, nr_y, nr_dir); result = 2; } else { //doubleclick = false; if (openDoorDoubleclick && !disableDoubleclick) timer_run = true; if (Go()){ player.EnterRoom(nr_room, nr_x, nr_y, nr_dir); result=2; } } }else any_click_move(x, y, dir); } else if (UsedAction (eGA_LookAt) && !String.IsNullOrEmpty(get_door_strings("lookat"))) { if (any_click_move (x, y, dir)) if (!String.IsNullOrEmpty(get_door_strings("lookat")))player.Say(get_door_strings("lookat")); } else if (UsedAction(eGA_UseInv) && key>=0) { if (any_click_move (x, y, dir)) { if (player.ActiveInventory==inventory[key]) { if (get_door_state(door_id)==1) { if (!String.IsNullOrEmpty(get_door_strings("closefirst"))) player.Say(get_door_strings("closefirst")); } else if (get_door_state(door_id)==2) { if (unlockDoorSound != null) chan = unlockDoorSound.Play(); if (!String.IsNullOrEmpty(get_door_strings("unlock"))) player.Say(get_door_strings("unlock")); set_door_state(door_id, closevalue); } else if (get_door_state(door_id)==0) { object[obj].Visible=false; set_door_state(door_id, 2); if (!String.IsNullOrEmpty(get_door_strings("relock"))) player.Say(get_door_strings("relock")); } } else if (!String.IsNullOrEmpty(get_door_strings("wrongitem"))) player.Say(get_door_strings("wrongitem")); } } else result=0; return result; // 0 = unhandled // 1 = handled // 2 = NewRoom } #endif #ifnver 3.2 function any_click_on_door_special(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, int opensound, int closesound, int key, int closevalue) { // key = -1: masterkey - even locked doors will be opened // key = -2: door can't be unlocked (like rusted) int result=1; if (UsedAction(eGA_Close)) { if (get_door_state(door_id)==0 || get_door_state(door_id)==2) Unhandled(1); else if (get_door_state(door_id)==1) { if (any_click_move (x, y, dir)) { if (closesound != 0) PlaySound(closesound); // Play default sound else if (closeDoorSound != 0) PlaySound(closeDoorSound); object[obj].Visible=false; set_door_state(door_id, closevalue); } } } else if (UsedAction(eGA_Open)) { if (get_door_state(door_id)==0 || (get_door_state(door_id)==2 && key==-1)) { if (any_click_move (x, y, dir)) { if (opensound != 0) PlaySound(opensound); // Play default sound else if (openDoorSound != 0) PlaySound(openDoorSound); object[obj].Visible=true; set_door_state(door_id, 1); } } else if (get_door_state(door_id)==1) Unhandled(1); else if (get_door_state(door_id)==2) { if (any_click_move (x, y, dir)) if (!String.IsNullOrEmpty(get_door_strings("islocked"))) player.Say(get_door_strings("islocked")); } } else if (UsedAction(eMA_WalkTo)) { if (get_door_state(door_id)==1) { if (timer_run == true && openDoorDoubleclick==true) { timer_run = false; if (MovePlayerEx(player.x,player.y,eWalkableAreas)>0) player.EnterRoom(nr_room, nr_x, nr_y, nr_dir, true); result = 2; } else { //doubleclick = false; if (openDoorDoubleclick && !disableDoubleclick)timer_run = true; if (Go()){ player.EnterRoom(nr_room, nr_x, nr_y, nr_dir, true); result=2; } } }else any_click_move(x, y, dir); } else if (UsedAction (eGA_LookAt) && !String.IsNullOrEmpty(get_door_strings("lookat"))) { if (any_click_move (x, y, dir)) if (!String.IsNullOrEmpty(get_door_strings("lookat")))player.Say(get_door_strings("lookat")); } else if (UsedAction(eGA_UseInv) && key>=0) { if (any_click_move (x, y, dir)) { if (player.ActiveInventory==inventory[key]) { if (get_door_state(door_id)==1) { if (!String.IsNullOrEmpty(get_door_strings("closefirst"))) player.Say(get_door_strings("closefirst")); } else if (get_door_state(door_id)==2) { if (unlockDoorSound != 0) PlaySound(unlockDoorSound); if (!String.IsNullOrEmpty(get_door_strings("unlock"))) player.Say(get_door_strings("unlock")); set_door_state(door_id, closevalue); } else if (get_door_state(door_id)==0) { object[obj].Visible=false; set_door_state(door_id, 2); if (!String.IsNullOrEmpty(get_door_strings("relock"))) player.Say(get_door_strings("relock")); } } else if (!String.IsNullOrEmpty(get_door_strings("wrongitem"))) player.Say(get_door_strings("wrongitem")); } } else result=0; return result; // 0 = unhandled // 1 = handled // 2 = NewRoom } #endif function any_click_on_door(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir) { #ifdef USE_OBJECT_ORIENTED_AUDIO return any_click_on_door_special (door_id, obj, x, y, dir, nr_room, nr_x, nr_y, nr_dir, null, null, 0, 0); #endif #ifndef USE_OBJECT_ORIENTED_AUDIO return any_click_on_door_special (door_id, obj, x, y, dir, nr_room, nr_x, nr_y, nr_dir, 0, 0, 0, 0); #endif } // ============================= AGS internal functions ========================================== function game_start() { player_ani_speed = player.AnimationSpeed; player_walk_x_speed = player.WalkSpeedX; player_walk_y_speed = player.WalkSpeedY; if (runSpeedupRate <=0) runSpeedupRate = 1; } function on_mouse_click(MouseButton button) { if (!is_gui_disabled()) { int x=mouse.x; int y=mouse.y; // get location under mouse cursor GSloctype=GetLocationType(x, y); GSlocname=Game.GetLocationName(x, y); GSagsusedmode=Mouse.Mode; used_action=global_action; InventoryItem*ii = InventoryItem.GetAtScreenXY(x, y); if (GSloctype==eLocationHotspot) { Hotspot*h=Hotspot.GetAtScreenXY(x, y); GSlocid=h.ID; } else if (GSloctype==eLocationCharacter) { Character*c=Character.GetAtScreenXY(x, y); GSlocid=c.ID; } else if (GSloctype==eLocationObject) { Object*o=Object.GetAtScreenXY(x, y); GSlocid=o.ID; } else if (ii!=null) GSlocid=ii.ID; //dont allow endless running if (player_is_running) { player_is_running = false; timer_run = false; timer_click = 0; player.StopMoving(); player.SetWalkSpeed(player_walk_x_speed, player_walk_y_speed); player.AnimationSpeed = player_ani_speed; } if (IsGamePaused()) { // Game is paused, so do nothing (ie. don't allow mouse click) } // Mousebutton Left else if (button==eMouseLeft) { if (GlobalCondition(eGlob_InvOnInv) || GlobalCondition(eGlob_GiveTalkNoChar) || GlobalCondition(eGlob_GiveNoInv)) { // Do nothing, if: // the mode is useinv and the mouse is over the active inv (like "use knife on knife") // or the mode is talk, or "Give", and the mouse isnt over a character // or its GIVE and the mouse isnt over a inv.item } else if (ExtensionEx(1, GSlocname)=='e') { UpdateActionBar(); ActionLine.TextColor=ActionLabelColorHighlighted; WalkOffScreen(); } // walk to else if (GSagsusedmode==eModeUsermode2) { ActionLine.TextColor=ActionLabelColorHighlighted; // Run on doubleclick if (timer_run == true && runOnDoubleClick) { if (GSloctype == eLocationNothing) { player_is_running = true; timer_run = false; timer_click = 0; if (player_ani_speed < runSpeedupRate) player.AnimationSpeed = 0; else player.AnimationSpeed = player_ani_speed / runSpeedupRate; player.StopMoving(); player.SetWalkSpeed(player_walk_x_speed * runSpeedupRate, player_walk_y_speed * runSpeedupRate); } } #ifnver 3.4 if (IsInteractionAvailable(x, y, GSagsusedmode)) ProcessClick (x, y, GSagsusedmode); else ProcessClick(x, y, eModeWalkto); #endif #ifver 3.4 if (IsInteractionAvailable(x, y, GSagsusedmode)) Room.ProcessClick (x, y, GSagsusedmode); else Room.ProcessClick(x, y, eModeWalkto); #endif if (!disableDoubleclick && runOnDoubleClick && GSloctype == eLocationNothing ){ timer_run = true; } } // talkto else if (GSagsusedmode==eModeTalkto && IsInteractionAvailable(x, y, GSagsusedmode) && GSloctype==eLocationCharacter) { ActionLine.TextColor=ActionLabelColorHighlighted; if (approachCharInteract == false) character[GSlocid].RunInteraction(GSagsusedmode); else { if (GoToCharacter(character[GSlocid], 0, NPC_facing_player, 2)) character[GSlocid].RunInteraction(GSagsusedmode); } SetAction(eMA_Default); } // Giveto else if ((GSagsusedmode == eModeUseinv) && GSloctype==eLocationCharacter && isAction(eGA_GiveTo)) { ActionLine.TextColor=ActionLabelColorHighlighted; ItemGiven=player.ActiveInventory; if (approachCharInteract == false) { if (IsInteractionAvailable (x, y, eModeUseinv) == 1) { character[GSlocid].RunInteraction(eModeUseinv); } } else { if (GoToCharacter(character[GSlocid], 0, NPC_facing_player, 2)) { if (IsInteractionAvailable (x, y, eModeUseinv) == 1) { character[GSlocid].RunInteraction(eModeUseinv); } } } SetAction (eMA_Default); } else { UpdateActionBar(); ActionLine.TextColor=ActionLabelColorHighlighted; #ifnver 3.4 ProcessClick(x, y, GSagsusedmode); #endif #ifver 3.4 Room.ProcessClick(x, y, GSagsusedmode); #endif SetAction(eMA_Default); ItemGiven=null; } } // Mousebutton Right else if (button==eMouseRight) { if (alternative_action==eMA_Default) { SetAction(eMA_Default); ActionLine.TextColor=ActionLabelColorHighlighted; if (Mouse.Mode==eModeUsermode2) { if (ExtensionEx(1, GSlocname)=='e') { UpdateActionBar(); ActionLine.TextColor=ActionLabelColorHighlighted; WalkOffScreen(); } else { #ifnver 3.4 ProcessClick(x, y, eModeWalkto); #endif #ifver 3.4 Room.ProcessClick(x, y, eModeWalkto); #endif } } else { #ifnver 3.4 ProcessClick(x, y, Mouse.Mode); #endif #ifver 3.4 Room.ProcessClick(x, y, Mouse.Mode); #endif } } else { SetAction(alternative_action); used_action=global_action; UpdateActionBar(); ActionLine.TextColor=ActionLabelColorHighlighted; GSagsusedmode=Mouse.Mode; if (GSagsusedmode==eModeTalkto && IsInteractionAvailable(x, y, GSagsusedmode) && GSloctype==eLocationCharacter) { if (approachCharInteract == false) { character[GSlocid].RunInteraction(GSagsusedmode); } else { if (GoToCharacter(character[GSlocid], 0, NPC_facing_player,2 )) character[GSlocid].RunInteraction(GSagsusedmode); } } else { #ifnver 3.4 ProcessClick(x, y, GSagsusedmode); #endif #ifver 3.4 Room.ProcessClick(x, y, GSagsusedmode); #endif } SetAction(eMA_Default); } } //left click in inventory else if (button==eMouseLeftInv) { if (!isAction(eGA_GiveTo))ItemGiven= null; if (GlobalCondition (eGlob_MouseInvWalk)) { // if the mouse is in the inventory and modes Walk is selected SetAction (eGA_Use); location=GSinvloc; if (Extension()=='u' && ii.IsInteractionAvailable(eModeInteract)) { // use it immediately (not with anything else) used_action=global_action; ii.RunInteraction(eModeInteract); SetAction(eMA_Default); } else { if (oldschool_inv_clicks) { SetAction (eGA_LookAt); used_action=global_action; ii.RunInteraction(eModeLookat); SetAction(eMA_Default); } else player.ActiveInventory=ii; } } else if (GlobalCondition(eGlob_InvOnInv)) { // if the mode is useinv and the mouse is over the active inv (like "use knife on knife") // so do nothing again } else { used_action=global_action; if (Mouse.Mode==eModeInteract && ii != null) { if (isAction(eGA_Use) && ii.IsInteractionAvailable(eModeInteract)) { ActionLine.TextColor=ActionLabelColorHighlighted; ii.RunInteraction(eModeInteract); SetAction(eMA_Default); } else player.ActiveInventory=ii; } else { if ( (Mouse.Mode >0 && Mouse.Mode <10 )&& ii != null) { GSagsusedmode=Mouse.Mode; ActionLine.TextColor=ActionLabelColorHighlighted; ii.RunInteraction(Mouse.Mode); SetAction(eMA_Default); } } } } //right click in inventory else if (button==eMouseRightInv) { if (alternative_action==eMA_Default) { SetAction(eMA_Default); } else { SetAction(alternative_action); used_action=global_action; GSagsusedmode=Mouse.Mode; if (Mouse.Mode==eModeInteract && ii != null) { if (isAction(eGA_Use) && ii.IsInteractionAvailable(eModeInteract)) { UpdateActionBar(); ActionLine.TextColor=ActionLabelColorHighlighted; ii.RunInteraction(eModeInteract); SetAction(eMA_Default); } else player.ActiveInventory=ii; } else { UpdateActionBar(); ActionLine.TextColor=ActionLabelColorHighlighted; inventory[game.inv_activated].RunInteraction(Mouse.Mode); SetAction(eMA_Default); } } } } else { #ifnver 3.4 ProcessClick(mouse.x, mouse.y, Mouse.Mode); #endif #ifver 3.4 Room.ProcessClick(mouse.x, mouse.y, Mouse.Mode); #endif } } function repeatedly_execute_always() { // Doubleclick Timer if (!IsGamePaused() && !is_gui_disabled()) { if (timer_run == true) { if (disableDoubleclick) { timer_run = false; } else { timer_click++; if (timer_click >= dc_speed){ timer_click = 0; timer_run = false; } } } } } function repeatedly_execute() { if (!IsGamePaused() && !is_gui_disabled()) { // Keep running, if mouse is pressed if (player_is_running && mouse.IsButtonDown(eMouseLeft)) { int mx = mouse.x + GetViewportX(); int my = mouse.y + GetViewportY(); int px = player.x; int py = player.y; int dist = FloatToInt(Distance(mx, my, px, py), eRoundDown); if (!player.Moving) { // Running on an exit or door if (dist <= runCursorDistance && (ExtensionEx(1, location_ex)=='e' || ExtensionEx(1, location_ex)=='v')) { player_is_running = false; player.StopMoving(); player.SetWalkSpeed(player_walk_x_speed, player_walk_y_speed); player.AnimationSpeed = player_ani_speed; UpdateActionBar(); ActionLine.TextColor = ActionLabelColorHighlighted; Room.ProcessClick(mouse.x, mouse.y, eModeUsermode1); } // else keep running while left mouse button pressed else if (dist > runCursorDistance ) { player.Walk(mx, my, eNoBlock); } } } // turn off running if player stops walkging else if (player_is_running && !player.Moving && !mouse.IsButtonDown(eMouseLeft)) { player_is_running = false; timer_run = false; timer_click = 0; player.StopMoving(); player.SetWalkSpeed(player_walk_x_speed, player_walk_y_speed); player.AnimationSpeed = player_ani_speed; } CheckDefaultAction(); UpdateActionBar(); } // change the arrows in the inventory to show if you // can scroll the inventory: if (MainInv.TopItem>0) { // if inventory can scroll up InvUp.NormalGraphic=invUparrowONsprite; InvUp.MouseOverGraphic=invUparrowHIsprite; if (InventoryItem.GetAtScreenXY(gMaingui.X+MainInv.X+1, gMaingui.Y+MainInv.Y+1)==null) MainInv.TopItem-=MainInv.ItemsPerRow; } else { InvUp.NormalGraphic=invUparrowOFFsprite; InvUp.MouseOverGraphic=invUparrowOFFsprite; } //if inv can scroll down if (MainInv.TopItem