std_update.txt - 6th January, 2016 Documenting changes, and additions to std.zh ============================== -- New Constants ( 2.50.2 ) -- ============================== const int RADIAN * Value for comparing degrees, to radians. const int MAX_CONSTANT, float MAX_VARIABLE, int MAX_INT, float MAX_FLOAT, float MIN_CONSTANT, float MIN_FLOAT, int MIN_INT const int MAX_COUNTER, int MIN_COUNTER const int MAX_LWEAPONS, int MAX_EWEAPONS, int MAX_NPCS, int MAX_ITEMS, int MAX_OBJECT_POINTERS, int MAX_SPRITES const int MAX_DRAWING const int MAX_GLOBAL_VARIABLES, int MAX_VARIABLES, int MAX_BITSPERVARIABLE const int MAX_ARRAY_POINTERS, int MAX_TILES, int MAX_COMBOS, int MAX_STRINGS const int MAX_SCRIPTDRAWINGCOMMANDS const int MAX_MESSAGES, int MAX_MESSAGELENGTH const int MAX_MAPS, int MAX_DMAPS const int MAX_DMAPNAMELENGTH, int MAX_DMAPTITLELENGTH, int MAX_DMAPINTROLENGTH const int MAX_FFC_* const int MAX_LEVEL * Information about some system constraints const int SCREEN_W, int SCREEN_H, int SUBSCREEN_BOTTOM, int SUBSCREEN_TOP * Screen dimensions. const int NPCSF_* * NPC Spawn Flags const int NPCM_* * NPC Misc. Flags const int SFR_* * Roomtype Screen Flags const int SFV_* * View Screen Flags const int SFS_* * Secrets Screen Flags const int SFW_* * Warp Screen Flags const int SFI_* * Items Screen Flags const int SFC_* * Combos Screen Flags const int SFSV_* * Save Screen Flags const int SFF_* * FFC Screen Flags const int SFWH_* * Whistle Screen Flags const int SFM__* * Misc. Screen Flags const int CSET_* * Values for the first colour in each CSet const int SPRITE_* * Values for all default sprites const int CB_* * Controller input buttons const int AT_* * Aim types for use with AimEWeapon() const int FLIP_* const int ROT_* * Sprite flipping, and rotation for use with ->Flip const int TILEWARP_* const int SIDEWARP_* * Tilewarp and sidewarp IDs for use with SetTileWarp() and SetSideWarp(), and corresponding Get functions. const int EXT_* * Added extend types for Link, and system information on these. -- New Functions ( 2.50.2 ) -- ============================== int GetLayerComboI(int layer, int pos) * A shorthand way to get a combo inherent flag on the specified layer. * Layer 0 is the screen itself. void SetLayerComboI(int layer, int pos, int flag) * A shorthand way to set a combo inherent flag on the specified layer. * Layer 0 is the screen itself. int GetLayerComboC(int layer, int pos) * A shorthand way to get a combo's CSet on the specified layer. * Layer 0 is the screen itself. void SetLayerComboC(int layer, int pos, int cset) * A shorthand way to set a combo's CSet on the specified layer. * Layer 0 is the screen itself. bool ChooseB(bool a, bool b) bool ChooseB(bool a, bool b, bool c) bool ChooseB(bool a, bool b, bool c, bool d) bool ChooseB(bool a, bool b, bool c, bool d, bool e) bool ChooseB(bool a, bool b, bool c, bool d, bool e, bool f) * Fairly chooses between two or more boolean values. Overloaded for up to six options. bool ChooseB() * Randomly returns true, or false with a 50/50% chance.. bool RandB() * Randomly returns true, or false with a 50/50% chance. bool RandB(int percentTrue) * Randomly returns true, or false. uses the input of percentTrue to determine chance. * Example: RandB(40) sets a 40% chance of the return being true, and a 60% chance of it being false. float SafeSqrt(int n, int spec) * Returns the square root of n, and returns a specified value 'spec' if n is a negative number. * Returns 0 on a failure. float SafeSqrt(int n) * Returns the square root of n, and returns -32768 is the value of n is a negative number. * Returns 0 on a failure. void SetLinkItem(int itm) * Safely sets an item 'itm' true, if it is false, or false if it is true. * Will not slow down ZC. void SetLinkItem(int itm, bool state) * Safely sets an item 'itm' to the value of 'state'. * Will not slow down ZC. void TraceA(int arr) void TraceA(int arr, bool verbose) * Shorthand form of TraceArray(). * Set 'verbose' true if you wish to enable verbose logging mode. * Traces the contents of an array 'arr' to allegro.log. * Warning: This may slow ZC down, particulalry if called in a loop!. void TraceA(bool arr, int size) void TraceA(bool arr, int size, bool verbose) * Shorthand form of TraceArrayB(). * You must specify the array size. * Set 'verbose' true if you wish to enable verbose logging mode. * Traces the contents of an array 'arr' to allegro.log. * Warning: This may slow ZC down, particulalry if called in a loop!. void TraceArray(int arr) * Traces the contents of an array 'arr' to allegro.log. * Warning: This may slow ZC down, particulalry if called in a loop!. void TraceArray(int arr, bool verbose) * Traces the contents of an array 'arr' to allegro.log. * Uses verbose reporting if selected.. * Warning: This may slow ZC down, particulalry if called in a loop!. void TraceArrayB(int arr) * Traces the contents of an boolean 'arr' to allegro.log. * You must specify the size of the array. * Warning: This may slow ZC down, particulalry if called in a loop!. void TraceArrayB(bool arr, int size, bool verbose) * Traces the contents of an boolean 'arr' to allegro.log. * You must specify the size of the array. * Uses verbose Logging if selected. * Warning: This may slow ZC down, particulalry if called in a loop!. void EndFFC(int ffc_ID) * Terminates an ffc specified by 'ffc_id' and sets all of its values to 0. bool InputMiddleClick() * Returns true if the middle mouse button is pressed. * Note that not all mice have a middle button. float BoolToFloat(bool input) * Converts variable 'input' to a floating point 1/0 value. ** Modified from submission by BlueTopHat int BoolToInt(bool input) * Converts variable 'input' to a integer (0 or 1). void ScreenToLayer(int sourceMap, int sourceScreen, int layerMin, int layerMax, int drawOpacity, int destLayer){ * Draws a screen specified by 'sourceMap and sourceScreen;, from layers specified by 'layerMin and layerMax', * at a desired opacity, to the layer specified by 'destLayer' of the current screen. ** Originally DrawScreenToLayer() - ZoriaRPG int GetLowFloat(int n) * Accepts a float as input, and returns the decimal portion as int. ** Originally GetLowArgument() - Successor, or grayswandir? int GetHighFloat(int n) * Accepts a float as input, and returns the integer portion as int. ** Originally GetHighArgument() - Successor, or grayswandir? int GetDigitValue(int n, int place) * Extracts a single digit from n at the place specified. * -4 is the ten-thousandTHs place, 0 is the ones spot, and 4 is the ten-thousanDs spot. ** Originally GetDigit() - Gleeok int GetPartialValue(int n, int place, int num) * Extracts an integer using specific places of any value 'n', from position 'place' plus a number of places 'num'. ** Originally GetDigit() - Gleeok, or Saffith? int DecimalToInt(int v) * Converts floating point value 'v', after the decimal, to an integer. ** Originally GetRemainderAsInt() - Gleeok bool Xor(bool valA, bool valB) * Xor comparison of two boolean values. * Returns true if values *do not match*, otherwise false. bool Collision(npc n) bool Collision(ffc f) bool Collision(item i) bool Collision(lweapon l) bool Collision(eweapon e) * Shorthand way of doing LinkCollision() and prophylactic against erroneous usage. float Distance(int x1, int y1, int x2, int y2, int specify_negative_value) * Returns the distance between two sets of coordinates using Pythagoras' Theorem * Use specify_negative_value to specify a number to return, if an attempt is made to resolve the square root of a negative number. void NoInput(bool analogue_stick) * Kill inputs, but not from analogue stock, unless value 'analogue_stick' is set 'true'. int DirX(int dir) * Returns factor for X-direction (1, 0, or -1), to use with lweapon/eweapon placement and/or step. int DirY(int dir) * Returns factor for Y-direction (1, 0, or -1), to use with lweapon/eweapon placement and/or step. bool MatchLWeaponType(int list, lweapon l) * Compare given lweapon 'l' to array 'list' and returns if its ID matches any index value. bool MatchEWeaponType(int list, eweapon e) * Compare given eweapon 'e' to array 'list' and returns if its ID matches any index value. bool MatchNPC(int list, npc n) * Compare given npc 'n' to array 'list' and returns if its ID matches any index value. bool MatchNPCT(int list, npc n) * Compare given npc 'n' to array 'list' and returns if its Type matches any index value. bool MatchItem(int list, item i) * Compare given item 'i' to array 'list' and returns if its ID matches any index value. bool MatchAction(int list) * Compares the present Link->Action to values in indices of array 'list' * and returns if there is a match. bool MatchComboD(int list, int cmb) * Compares the Combo Data at location 'cmb' to values in indices of array 'list' * and returns if there is a match. bool MatchComboT(int list, int cmb) * Compares the Combo Type at location 'cmb' to values in indices of array 'list' * and returns if there is a match. bool MatchComboC(int list, int cmb) * Compares the Combo CSet at location 'cmb' to values in indices of array 'list' * and returns if there is a match. bool MatchComboF(int list, int cmb) * Compares the Combo Flag at location 'cmb' to values in indices of array 'list' * and returns if there is a match. bool MatchComboI(int list, int cmb) * Compares the Combo Inherent Flag at location 'cmb' to values in indices of * array 'list' and returns if there is a match. bool MatchComboS(int list, int cmb) * Compares the Combo Solidity at location 'cmb' to values in indices of * array 'list' and returns if there is a match. bool MatchLayerComboD(int list, int layer, int cmb) * Compares the Combo Data at location 'cmb' on layer 'layer' to values in indices of * array 'list' and returns if there is a match. bool MatchLayerComboT(int list, int layer, int cmb) * Compares the Combo Type at location 'cmb' on layer 'layer' to values in indices of * array 'list' and returns if there is a match. bool MatchLayerComboC(int list, int layer, int cmb) * Compares the Combo CSet at location 'cmb' on layer 'layer' to values in indices of * array 'list' and returns if there is a match. bool MatchLayerComboF(int list, int layer, int cmb) * Compares the Combo Flag at location 'cmb' on layer 'layer' to values in indices of * array 'list' and returns if there is a match. bool MatchLayerComboI(int list, int layer, int cmb) * Compares the Combo Inherent flag. at location 'cmb' on layer 'layer' to values in indices of * array 'list' and returns if there is a match. bool MatchLayerComboS(int list, int layer, int cmb) * Compares the Combo Solidity. at location 'cmb' on layer 'layer' to values in indices of * array 'list' and returns if there is a match. int HasTriforce(int level) * Returns true if Link has the Triforce piece for the level 'level'. int HasCompass(int level) * Returns true if Link has the compass for the level 'level'. int HasMap(int level) * Returns true if Link has the dungeon map for the level 'level'. int HasBossKey(int level) * Returns true if Link has the boss key for the level 'level'. int DefeatedLevelBoss(int level) * Returns true if Link has defeated te boss of level 'level'. int NumTriforcePieces(int maxlevel) * Returns the total number of Triforce pieces collected. * Specify the highest level in your quest that has a Triforce piece, as arg 'maxlevel'. void SetCombo(int pos, int data, int type, int flag, int inh_flag, int cset, int solid) * Sets the values for combo at position 'pos' to those specified. * Pass -1 to leave a value unchanged. void SetLayerComboValues(int layer, int data, int type, int flag, int inh_flag, int cset, int solid) * Sets the values for a combo on layer 'layer', at position 'pos' to the values specified. * Pass -1 to any value to leave it unchanged. void CloneCombo(int pos_a, int pos_b) * Clones combo from position 'pos_a' to position 'pos_b' void CloneLayerCombo(int layer, int pos_a, int pos_b) * Clones combo on layer 'layer' posigtion 'pos_a' to the same layer at position 'pos_b' void CloneLayerCombo(int layer_a, int layer_b, int pos_a, int pos_b) * Clones a combo on layer 'layer_a' at position 'pos_a', to layer 'layer_b" at position 'pos_b'. ================================= -- Function Changes ( 2.50.2 ) -- ================================= Distance() now uses SafeSqrt() to avoid errors when parsing negative values, or values too large for ZC to use to perform a square root operation. SetLayerComboS() now refuses to set solidity for combos on layers 2 and above. Note that this is to prevent ZC crashes on 2.50.0, 2.50.1, and 2.50.2. This bug is fixed as of 2.50.3, and the changes to this function will automatically account for this in 2.50.3 during compilation; but this will not prevent earlier versions of ZC running code compile din 2.50.3 from potentially crashing. ================================================ -- string.zh Changes and Additions ( 2.50.2 ) -- ================================================ As of this version, string.zh is a base include with std.zh. You no longer need to call it separately, as it is imported directly from the main std.zh file. If this poses a problem for you, you may comment out that import directive instruction. //Constants for string.zh const int CHAR_* * ASCII CHaratcers 0 to 255 //New Functions for string.zh bool isSpace(int chr) * Returns true if 'chr' is a space. bool isVowel(int chr) * Returns true if 'chr' is a vowel (a, e, i, o , u, A, E, I, O, U) bool ContainsChar(int chr, int buffer) * Returns true is string 'buffewr' contains the character 'chr'. int ContainsCharPos(int chr, int buffer) * Returns the index position of the first occurrence of charcter 'chr' in string 'buffer'. * Returns -1 if the char was not present. ============================= -- New Includes ( 2.50.2 ) -- ============================= std.zh now includes some new files, that you will want to review. THe outline, scope, and purpose of the new expansions is outlined below. /*********************/ * LOCALISATION * /*********************/ std.zh now includes some basic local support. These files are in */locale/std_std_'language'.zh, and contain constants, and functions in other laguages. The base included locale file at this time is 'UK/International English', with more to follow. /*************************/ * GENERAL-USE ARRAY * /*************************/ float stdArray[1024] * A base, general-purpose array with a size of 1024, and a float type. std.zh now includes ONE BASE ARRAy with a float type. This is to allow users who are not versed in ZScript from avoiding a pitfall of either running out of global vars, by allowing you easy use of one global array and getter/setter functions to modify it. Furthermore, it prevents being unable to modify a quest, after releasing it, by ensuring that there is a general use array for expansion. The array is in std_vars.zh, and if you wish to, you may comment out this import directive instruction in std.zh to prevent loading the general use array, and the functions associated with it. The following functions are in the std_vars.zh file, for use with the general-use array: float GetV(int index) * Returns the value of the Nth 'index' of the general use array stdArray[]; void SetV(int index, int value) * Sets the value of stdArray['index'] to 'value'. void IncV(int index) * Increases an index value: Equivalent to doing stdArray['index']++ void IncV(int index, int value) * Increases the value of stdArray['index'] by 'value'. void DecV(int index) * Decreases an index value: Equivalent to doing stdArray['index']-- void DecV(int index, int value) * Decreases the value of stdArray['index'] by 'value'. /*************************/ * SHORTCUTS & MACROS * /*************************/ The file std_shortcuts.zh includes many useful, time-saving shortcut functions that are equivalent to calling normal ZScript functions, except that the user need not worry about the left-of-the-arrow operator. For example, Screen->Rectangle() can now be called simply as Rectangle() using this include. Please review this file, and the documentation for it (std_shortcuts.txt) for more information on its use, and on the functions contained therein. /********************/ * Jan 2016 Additions * /********************/ int DirRev(int dir) * Returns the reverse of direction 'dir' int DirAngle(int dir) * Converts a direction to an angle in degrees. int DirRad(int dir) * Converts a direction into radians. int SpeedRev(int speed, int reduceinertia) * Inverts the speed of a moving object, and alters it by value of reverseinertia int ImpactVelocity(int mass1, int velocity1, int mass2, int velociy2 ) * Returns the momentum change (acceleration) of two objects. int ImpactVelocityA(int massA, int velocityA, int massB, int velociyB ) * Accepts values for object A' and object 'B' then returns the acceleration change for object 'A'. int ImpactVelocityB(int massA, int velocityA, int massB, int velociyB ) * Accepts values for object A' and object 'B' then returns the acceleration change for object 'B'. void ImpactVelocity(lweapon a, eweapon b, int massA, int velocityA, int massB, int velociyB ) * Accepts the mass, and velocity if two weapons. Determins the acceleration on impact. * Changes the Step of both to reflect their mass on collision. void ImpactVelocityF(){} * FFC version that will change the direction, and speed of moving ffcs on collision. int CenterX(lweapon anLWeapon, bool trueoffset) int CenterX(eweapon anEWeapon, bool trueoffset) int CenterX(npc n, bool trueoffset) int CenterX(item i, bool trueoffset) int CenterX(lweapon anLWeapon, bool trueoffset, bool drawoffset) int CenterX(eweapon anEWeapon, bool trueoffset, bool drawoffset) int CenterX(npc n, bool trueoffset, bool drawoffset) int CenterX(item i, bool trueoffset, bool drawoffset) * Returns the centre X position of an object. * Set trueoffset to return the value after caqlculating its HitXOffset * Set drawoffset to return the value after calculating its DrawXOffset int CenterY(lweapon anLWeapon, bool trueoffset) int CenterY(eweapon anEWeapon, bool trueoffset) int CenterY(npc n, bool trueoffset) int CenterY(item i, bool trueoffset) int CenterY(lweapon anLWeapon, bool trueoffset, bool drawoffset) int CenterY(eweapon anEWeapon, bool trueoffset, bool drawoffset) int CenterY(npc n, bool trueoffset, bool drawoffset) int CenterY(item i, bool trueoffset, bool drawoffset) * Returns the centre Y position of an object. * Set trueoffset to return the value after caqlculating its HitXOffset * Set drawoffset to return the value after calculating its DrawXOffset int CenterLinkX(bool hitoffset) int CenterLinkX(bool hitoffset, bool drawoffset) * Returns the centre X position of Link. * Set trueoffset to return the value after caqlculating his HitXOffset * Set drawoffset to return the value after calculating his DrawXOffset * Note: HitXOffset and DrawXOffset for Link must be set by script, and do not directly affect * his hitbox or sprite. See 'Class Link' in zscript.txt for more information. int CenterLinkY(bool hitoffset) int CenterLinkY(bool hitoffset, bool drawoffset) * Returns the centre Y position of Link. * Set trueoffset to return the value after caqlculating his HitXOffset * Set drawoffset to return the value after calculating his DrawXOffset * Note: HitXOffset and DrawXOffset for Link must be set by script, and do not directly affect * his hitbox or sprite. See 'Class Link' in zscript.txt for more information. int CenterComboX(int loc) * Returns the centre X position of combo at location 'loc' similar to CenterX() int CenterComboY(int loc) * Returns the centre Y position of combo at location 'loc' similar to CenterX() float Angle(int x, int y) { * Simplified form of Angle(int x1, int x2, int y1, int y2) * Returns the direction of the vector from (0, 0) to point, in degrees from -180 to 180. (0 = right) bool Collision(int cmb, ffc f) bool Collision(ffc f, int cmb) bool Collision(int cmb, lweapon l) bool Collision(lweapon l, int cmb) bool Collision(lweapon l, int cmb, bool checkcoldetection) bool Collision(int cmb, lweapon l, bool checkcoldetection) bool Collision(int cmb, eweapon e) bool Collision(eweapon e, int cmb) bool Collision(eweapon e, int cmb, bool checkcoldetection) bool Collision(int cmb, eweapon e, bool checkcoldetection) bool Collision(int cmb, npc n) bool Collision(npc n, int cmb) bool Collision(npc n, int cmb, bool checkcoldetection) bool Collision(int cmb, npc n, bool checkcoldetection) bool Collision(int cmb, item i) bool Collision(item i, int cmb) * Check for collision between an object (ffc, *weapon, npc, item) and a combo at location 'cmb' * Set 'checkcoldetection' to true if you wish to ignore objects with CollDetection disabled (excludes item types). bool Collision(int cmb) bool Collision(int cmb, bool checkcoldetection) * Check for collision between Link and a combo at location 'loc' * Set checkcoldetection' to true if you wish to ignore collision when Link->CollDetection is false.