Advertisement
ywkls

Tango.zh

Nov 17th, 2019
121
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // tango.zh
  2. // Version 1.0.0
  3.  
  4. // Screen Freezing
  5.  
  6. const int FFC_FREEZE_1 = 31;
  7. const int FFC_FREEZE_2 = 32;
  8. const int SCREEN_FREEZE_COMBO_1 = 151;
  9. const int SCREEN_FREEZE_COMBO_2 = 151;
  10. const int MENU_FREEZE_ALL = 151;
  11.  
  12. // Standard settings -----------------------------------------------------------
  13.  
  14. // How fast messages scroll
  15. const int __TANGO_SCROLL_SPEED = 4;
  16.  
  17. // How much holding A speeds up text
  18. const int __TANGO_SPEEDUP_FACTOR = 5;
  19.  
  20. // Whether holding A or B speeds up scrolling to the next message
  21. const int __TANGO_SCROLL_SPEEDUP = 1;
  22.  
  23. // Whether a sound is played when a space is printed
  24. const int __TANGO_SFX_ON_SPACE = 0;
  25.  
  26. // Whether there's a delay before a space, as with printable characters
  27. const int __TANGO_DELAY_ON_SPACE = 1;
  28.  
  29. // Strings that advance automatically will wait this long before doing so
  30. const int __TANGO_AUTO_ADVANCE_TIME = 90;
  31.  
  32. // Layer to draw on
  33. const int __TANGO_DRAWING_LAYER = 6;
  34.  
  35. // Offscreen bitmap to use for text rendering
  36. const int __TANGO_BITMAP = 6;
  37.  
  38. // String codes are marked by this character
  39. // 64 is @
  40. const int __TANGO_CODE_DELIMITER = 64;
  41.  
  42. // Whether the current string scrolls up before displaying the next one
  43. // rather than just disappearing
  44. const int __TANGO_SCROLL_TO_NEXT = 1;
  45.  
  46. // The maximum length of a string handled by @string.
  47. // Increasing this will make the function take more space in the buffer.
  48. // It's not necessary to account for the null terminator.
  49. const int __TANGO_MAX_STRING_FUNC_LENGTH = 16;
  50.  
  51. // End standard settings -------------------------------------------------------
  52.  
  53.  
  54.  
  55. // Advanced settings -----------------------------------------------------------
  56.  
  57. // Custom variables
  58. float Tango_D[8]; // Access as @d0 to @d8; can be safely removed
  59. int talkCount;
  60. float a2;
  61.  
  62. const float VAR_TANGO_D0 = 0.0055;
  63. const float VAR_TANGO_D7 = 0.0062;
  64. const int VAR_TALKCOUNT = 11772.9723;
  65. const int IDX_TALKCOUNT = 10;
  66.  
  67. const float VAR_A2 = 0.0036; //arbitrary argument for @a2
  68.  
  69. float Tango_GetCustomVar(int var)
  70. {
  71. if(var>=VAR_TANGO_D0 && var<=VAR_TANGO_D7)
  72. return Tango_D[(var-VAR_TANGO_D0)*10000];
  73.  
  74. else if(var==VAR_TALKCOUNT)
  75. {
  76. ffc f=GetCurrentFFC();
  77. return f->Misc[IDX_TALKCOUNT];
  78. }
  79.  
  80. else if (var==VAR_A2)
  81. {
  82. return a2;
  83. }
  84.  
  85. else
  86. {
  87. Tango_LogUndefinedVariable(var);
  88. return 0;
  89. }
  90. }
  91.  
  92. void Tango_SetCustomVar(int var, float value)
  93. {
  94. if(var>=VAR_TANGO_D0 && var<=VAR_TANGO_D7)
  95. Tango_D[(var-VAR_TANGO_D0)*10000]=value;
  96.  
  97. else if(var==VAR_TALKCOUNT)
  98. {
  99. ffc f=GetCurrentFFC();
  100. f->Misc[IDX_TALKCOUNT]=value;
  101. }
  102.  
  103. else if (var==VAR_A2)
  104. {
  105. a2=value;
  106. }
  107.  
  108. else
  109. Tango_LogUndefinedVariable(var);
  110. }
  111.  
  112. int Func_Name(int string){
  113. return Tango_ConvertFunctionName(string);
  114. }
  115.  
  116. // Custom functions
  117. const float FUNC_WARPLINK = 1940.4746; // @warplink()
  118. const float FUNC_GIVEITEM = 720.9516; // @giveitem()
  119. const float FUNC_BOMBDEATH = 2545.7314; //@bombdeath()
  120. const float FUNC_INCREASE = 915.4514; //@counter()
  121. const float FUNC_TAKEMONEY = 11753.4841; //@takmoney()
  122. const float FUNC_HASITEM = 100.7733; //@hasitem()
  123. const float FUNC_LEARNSLASH = 51629.3737; //@learnslash()
  124.  
  125. float __Tango_RunCustomFunction(float function, float args)
  126. {
  127. if(function==FUNC_WARPLINK){
  128. Link->Warp(args[0], args[1]); // Use args[0] and args[1] if you want it to take arguments
  129. }
  130. else if(function==FUNC_INCREASE){
  131. int cr_type = args[0];
  132. int num = args[1];
  133. if(Game->Counter[cr_type] >= 0
  134. && (Game->Counter[cr_type]+num)<=Game->MCounter[cr_type]){
  135. Game->Counter[cr_type] += num;
  136. return 1;
  137. }
  138. else if(Game->Counter[cr_type] >= 0
  139. && (Game->Counter[cr_type]+num)>Game->MCounter[cr_type]){
  140. Game->Counter[cr_type] = Game->MCounter[cr_type];
  141. return 1;
  142. }
  143. else
  144. return 0;
  145. }
  146. else if(function==FUNC_GIVEITEM){
  147. int it=args[0];
  148. item the_item;
  149. the_item = Screen->CreateItem(it);
  150. the_item->X= Link->X;
  151. the_item->Y= Link->Y;
  152. }
  153. else if(function==FUNC_BOMBDEATH){
  154. eweapon Superbomb = Screen->CreateEWeapon(EW_SBOMBBLAST);
  155. Superbomb->X=Link->X;
  156. Superbomb->Y=Link->Y-16;
  157. Superbomb->Damage=96;
  158. }
  159. else if(function==FUNC_TAKEMONEY){
  160. int amount=args[0];
  161. if (Game->Counter[CR_RUPEES] >= amount){
  162. Game->DCounter[CR_RUPEES] -= amount;
  163. return 1;
  164. }
  165. else{
  166. return 0;
  167. }
  168. }
  169. else if(function==FUNC_HASITEM){
  170. int it=args[0];
  171. if (Link->Item[it]){
  172. return 1;
  173. }
  174. else{
  175. return 0;
  176. }
  177. }
  178. else if(function==FUNC_LEARNSLASH){
  179. Game->Generic[GEN_CANSLASH] = 1;
  180. }
  181. else{
  182. Tango_LogUndefinedFunction(function);
  183. }
  184.  
  185. return 0;
  186. }
  187.  
  188. // Menu data
  189. const int __TANGO_MAX_MENU_ITEMS = 6;
  190. float __Tango_Data[42]; // 24+3*__TANGO_MAX_MENU_ITEMS
  191.  
  192. // Style data
  193. const int __TANGO_NUM_STYLES = 10;
  194. int __Tango_Styles[260]; // 26 * __TANGO_NUM_STYLES
  195.  
  196. // Text buffer and slots
  197. int __Tango_Buffer[1216]; // Arbitrary size
  198.  
  199. const int __TANGO_NUM_SLOTS = 4;
  200. int __Tango_SlotData[80]; // 20 * __TANGO_NUM_SLOTS
  201.  
  202. // Slot types and definitions
  203. const int TANGO_SLOT_NAVI = 0;
  204. const int TANGO_SLOT_POPUP = 1;
  205. const int TANGO_SLOT_NORMAL = 2;
  206. const int WINDOW_SLOT_1 = 3;
  207. const int WINDOW_SLOT_2 = 4;
  208.  
  209.  
  210. int __Tango_SlotDefs[] = {
  211. // 0
  212. TANGO_SLOT_NAVI,
  213. 0, // Starting index in __Tango_StringBuffer
  214. 64, // Maximum length after processing
  215. 256, 0, // X, Y on offscreen bitmap
  216. 128, 64, // Width, height on offscreen bitmap
  217.  
  218. // 1
  219. TANGO_SLOT_POPUP,
  220. 64,
  221. 128,
  222. 256, 64,
  223. 128, 64,
  224.  
  225. // 2
  226. TANGO_SLOT_NORMAL,
  227. 192,
  228. 512,
  229. 0, 0,
  230. 256, 256,
  231.  
  232. // 3
  233. TANGO_SLOT_NORMAL,
  234. 704,
  235. 512,
  236. 0, 256,
  237. 256, 256
  238. };
  239.  
  240.  
  241. // These must be implemented in order for TANGO_FLAG_FREEZE_SCREEN to work.
  242. // These must be implemented in order for TANGO_FLAG_FREEZE_SCREEN to work.
  243. // These are used by TANGO_FLAG_FREEZE_SCREEN.
  244. void __Tango_FreezeScreen(){
  245. ffc freezer=Screen->LoadFFC(31);
  246. freezer->Data=MENU_FREEZE_ALL; //2252
  247. freezer=Screen->LoadFFC(FFC_FREEZE_2);
  248. freezer->Data=0;
  249. SuspendGhostZHScripts();
  250. }
  251.  
  252. void __Tango_UnfreezeScreen(){
  253. ffc freezer=Screen->LoadFFC(31);
  254. freezer->Data=0;
  255. freezer=Screen->LoadFFC(FFC_FREEZE_2);
  256. freezer->Data=0;
  257. ResumeGhostZHScripts();
  258. }
  259.  
  260. // Edit these functions to change which buttons are used.
  261.  
  262. // Return Link->Press* for advance/end string button
  263. bool __Tango_PressAdvance()
  264. {
  265. return Link->PressA;
  266. }
  267.  
  268. // Return Link->Input* for advance/end string button
  269. bool __Tango_InputAdvance()
  270. {
  271. return Link->InputA;
  272. }
  273.  
  274. // Unset Link->Input* and Link->Press* for advance/end string button
  275. void __Tango_UnpressAdvance()
  276. {
  277. Link->InputA=false;
  278. Link->PressA=false;
  279. }
  280.  
  281. // Return Link->Press* for speedup button
  282. bool __Tango_PressSpeedup()
  283. {
  284. return Link->PressA;
  285. }
  286.  
  287. // Return Link->Input* for speedup button
  288. bool __Tango_InputSpeedup()
  289. {
  290. return Link->InputA;
  291. }
  292.  
  293. // Unset Link->Input* and Link->Press* for speedup button
  294. void __Tango_UnpressSpeedup()
  295. {
  296. Link->InputA=false;
  297. Link->PressA=false;
  298. }
  299.  
  300. // Return Link->Press* for super speed button
  301. bool __Tango_PressSuperSpeed()
  302. {
  303. return Link->PressB;
  304. }
  305.  
  306. // Return Link->Input* for super speed button
  307. bool __Tango_InputSuperSpeed()
  308. {
  309. return Link->InputB;
  310. }
  311.  
  312. // Unset Link->Input* and Link->Press* for super speed button
  313. void __Tango_UnpressSuperSpeed()
  314. {
  315. Link->InputB=false;
  316. Link->PressB=false;
  317. }
  318.  
  319. // Return Link->Press* for menu select button
  320. bool __Tango_PressMenuSelect()
  321. {
  322. return Link->PressA;
  323. }
  324.  
  325. // Return Link->Press* for menu cancel button
  326. bool __Tango_PressMenuCancel()
  327. {
  328. return Link->PressB;
  329. }
  330.  
  331. // Return Link->Input* for both menu select and cancel buttons
  332. bool __Tango_InputMenu()
  333. {
  334. return Link->InputA || Link->InputB;
  335. }
  336.  
  337. // Unset Link->Input* and Link->Press* for menu select and cancel buttons
  338. void __Tango_UnpressMenu()
  339. {
  340. Link->InputA=false;
  341. Link->PressA=false;
  342. Link->InputB=false;
  343. Link->PressB=false;
  344. }
  345.  
  346.  
  347. // Import stringControlCode.zh instead of stringControlCodeDisabled.zh
  348. // to enable string control codes.
  349. //import "tango/1.0/stringControlCodeDisabled.zh"
  350. import "tango/1.3/stringControlCode.zh"
  351.  
  352.  
  353. // Import loggingFull.zh instead of loggingMinimal.zh for more useful
  354. // error messages. This will bloat scripts, so it should only be used
  355. // for debugging.
  356. //import "tango/1.0/loggingMinimal.zh"
  357. import "tango/1.3/loggingFull.zh"
  358.  
  359. // End advanced settings -------------------------------------------------------
  360.  
  361. //--------------Common Functions Here--------------------------------------------
  362.  
  363. // Uses Tango to display a ZC message (Quest > Strings). Returns the number of
  364. // the text slot used or TANGO_INVALID if the message could not be displayed.
  365.  
  366. int ShowMessage(int message, int type, int style, float x, float y){
  367. int slot=Tango_GetFreeSlot(type);
  368. if(slot==TANGO_INVALID)
  369. return TANGO_INVALID;
  370.  
  371. Tango_ClearSlot(slot);
  372. Tango_LoadMessage(slot, message, '%');
  373. Tango_SetSlotStyle(slot, style);
  374. Tango_SetSlotPosition(slot, x, y);
  375. Tango_ActivateSlot(slot);
  376.  
  377. return slot;
  378. }
  379.  
  380. void ShowMessage(int message, int type, int style, int size, float x, float y){
  381. int slot=Tango_GetFreeSlot(type);
  382. if(slot==TANGO_INVALID)
  383. return;
  384. Tango_ClearSlot(slot);
  385. Tango_LoadMessage(slot, message, '%');
  386. Tango_SetSlotStyle(slot, style);
  387. Tango_SetSlotPosition(slot, x, y);
  388. SetStyleSize(style,size);
  389. Tango_ActivateSlot(slot);
  390. }
  391.  
  392.  
  393.  
  394. import "tango/1.3/access.zh"
  395. import "tango/1.3/common.zh"
  396. import "tango/1.3/drawing.zh"
  397. import "tango/1.3/font.zh"
  398. import "tango/1.3/functions.zh"
  399. import "tango/1.3/loading.zh"
  400. import "tango/1.3/menu.zh"
  401. import "tango/1.3/messages.zh"
  402. import "tango/1.3/metrics.zh"
  403. import "tango/1.3/processing.zh"
  404. import "tango/1.3/style.zh"
  405. import "tango/1.3/user.zh"
  406. import "tango/1.3/validation.zh"
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement