AGSScriptModuleTom VandepoeleBackground SpeechBackground Speech1.0.0 //=================================================================== // *** AGS MODULE SCRIPT *** // // Module: Background Speech v1.0.0* // // Author: Tom "Electroshokker" Vandepoele // // 1 Abstract // This module creates a SayInBackground function for characters WITH animations & voice. // // // 2 Revision History // 2008-10-11 v1.0.0 First Release. // // 3 License // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // // Copyright (C) 2007-2008 Tom Vandepoele //------------------------------------------------------------------- int charid = -1; Overlay* overlay; int sp_chan = 7; int sound; int default_text_width; int text_height; int text_x; int text_y; function SetBackgroundSpeechChannel(int channel){ sp_chan = channel; } function SayInBackground(this Character*, String message, int soundfile) { if (soundfile > -1){ PlaySoundEx(soundfile, sp_chan); default_text_width = system.viewport_width*4/6; text_height = GetTextHeight(message, Game.SpeechFont, default_text_width); /* The x position of the overlay is calculated by the character's sprite width and the text width */ /* The y position of the overlay is calculated by the character's sprite height and the text height */ ViewFrame* frame = Game.GetViewFrame(this.SpeechView, this.Loop, 0); text_x = this.x - Game.SpriteWidth[frame.Graphic]/2 - default_text_width/2; text_y = this.y - Game.SpriteHeight[frame.Graphic] - text_height; overlay = Overlay.CreateTextual(text_x, text_y, default_text_width, Game.SpeechFont, this.SpeechColor, message); } else{ overlay = this.SayBackground(message); } this.LockView(this.SpeechView); this.Animate(this.Loop, this.SpeechAnimationDelay, eRepeat, eNoBlock); charid = this.ID; sound = soundfile; } function repeatedly_execute() { if(overlay != null && overlay.Valid == true && sound != -1 && IsChannelPlaying (sp_chan) == 0){ overlay.Remove(); character[charid].UnlockView(); } }Ù//=================================================================== // *** AGS MODULE SCRIPT *** // // Module: Background Speech v1.0.0 // // Author: Tom "Electroshokker" Vandepoele // // 1 Abstract // This module creates a SayInBackground function for characters WITH animations & voice. // // // 2 Revision History // 2008-10-11 v1.0.0 First Release // // 3 License // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // // Copyright (C) 2007-2008 Tom Vandepoele //------------------------------------------------------------------- import function SayInBackground(this Character*, String message, int soundfile = -1); import function SetBackgroundSpeechChannel(int channel);9ç4ej÷´