ZVSE 
ERMS_ScriptDate=18.7(July).2004
_WARNING_#1=IMPORTANT! This file is not in a plain text format. NEVER use any editor except ERM_S for making any kind of changes!
ERMS_PoweredBy=ERM Scripter v. 2004.6.29.918
 
** Market of Time ERM Script Version 1.3.3 created by Timothy E. Pulver
** This script requires WoG Version 3.56 and ERM Version 2.5 to use. 
** WoGify Name: script09.erm 
** V1.3.3 update by Tobyn "Warfare support"
** V1.3.2 update by Overlord "extended dialogue 3 + single skill check" 
** (changes v1.3.1 - bug found: 27 skill looping correction) 
** Updated: July 18, 2004.
 
** This script sets up all Markets of Time on a map to function as locations 
** where heroes can forget skills they have learned for a cost of 2000 gold. 
** When a hero visits a Market of Time, the player is invited to choose which 
** skill he wants to forget. A hero can forget a maximum of one skill per 
** day and 500 movement points are deducted from the hero's move that turn 
** (it takes awhile to meditate). 
 
** To install this script in a map, simply copy & paste the code into a global 
** (timed) event. Copy the entire code, from ZVSE to the end. Make sure that 
** you disable ALL colours from receiving the event and/or change the event 
** day to something like 500 or later to avoid the ERM script popping up as if 
** it were a regular event message. 
 
** And of course, you'll also need to put one or more Market of Time objects 
** on your map for the heroes to visit. Have fun forgetting! :-) 
 
** Version 1.3 adds compatibility with enhanced skills that have their name 
** shown in yellow text. 
 
Flags used: 1-4, 1000 
Variables used: v50-v54, v451-v469, z1, z47-z61, z241-z248 
Functions used: 451 
Dialogs used: 14 
Macros used: @hsex@, @slevel@, @pgold@, @sicon@, @cday@, @skillnum@, @pithnum@, @skname@, @hname@, @he-she@, @man-woman@, @pithy@ 
 
 
[Check version of ERM to see if it's current enough] 
[Display warning message if it isn't] 
!#IF:V1/0; 
!#UN:V?v468/?v469; 
!#IF&v468<356:V1/1; 
!#IF&v469<250:V1/1; 
!#IF&1:M1/z109000; 

[Set up Macros] 
!#MCv452:S@hsex@; [Sex of hero] 
!#MCv453:S@slevel@; [Hero's level in skill to forget] 
!#MCv454:S@pgold@; [Player's current gold] 
!#MCv455:S@sicon@; [Icon number for skill to forget] 
!#MCv456:S@cday@; [Current day] 
!#MCv458:S@skillnum@;  [Number of skill chosen to forget] 
!#MCv4591:S@pithnum@; [Pithy message number] 
!#MCz1:S@skname@; [Name of skill chosen to forget] 
!#MCz242:S@hname@; [Name of hero] 
!#MCz245:S@he-she@; ["he" or "she"] 
!#MCz246:S@man-woman@; ["man" or "woman"] 
!#MCz247:S@pithy@; [Pithy message] 

[Check if script is enabled in WoG Options: v1]
!#UN:P109/?v1;
 
[Initialize variables v460-v467 to zero] 
!#VRv460&v1=1:C-1/-1/-1/-1/-1/-1/-1/-1; 
 
[Set hint for Market of Time] 
!#VRz241&v1=1:Sz109001; 
!#HT63/51&v1=1:T241; 
 
[Activate if any Market of Time is visited by a human player] 
!?OB63/51&1000; 

[Check if script is enabled in WoG Options: y-1]
!!UN:P109/?y-1;

[Exit trigger if script isn't enabled]
!!FU&y-1=0:E;
 
[Get colour, name and sex of hero visiting Market] 
!!HE-1:O?v451 B0/?$hname$ R2/?$hsex$; 
!!VRv451:+460; [Store hero visiting index number (for v460..v467) in v451]
 
[Display this message the first time each player visits the Market on a given map] 
!!IF&vv451=-1:M1/z109002; 
 
[Set variable (v460..v467) to show that a player has visited before] 
!!VRvv451:S1; 
 
!!VRz49:Sz109003; [Set variable to "Which skills do you wish to forget, %$hname$?": z49]
 
[Check all heroes' secondary skills with a Loop FU451] 
[Set Flag 3 to True if hero has no secondary skills] 
!!DO451/0/27/1:P0/1;  [Loop through all skills 0..27, x1=0, x2=1] 
!!IF:V3/0;            [Inialize Flag 3 to False]
!!IF&v51=50:V3/1;     [If v51=50, set Flag 3 to True]
!!IF&3:M1/z109004;    [Display message if hero has no skills ("you must have at least one skill if you wish to forget skills", etc.)]

!!FU&3:E; [Exit trigger if hero has no secondary skills]
 
[New Method - Extended Dialogue 3 if v51>51] 
[Radio buttons, store choice in v54, initial state of buttons=button 1 selected]
[z49=window header, z50-z61=skills the hero knows (up to 12)]
!!IF&v51>51:G1/54/1/z49/z50/z51/z52/z53/z54/z55/z56/z57/z58/z59/z60/z61; 
 
[Call Function 451 in a loop to find the skill chosen] 
[and assigns its number to $skillnum$ if it does] 
!!DO451/0/27/1&v51>51:P0/v54; [Loop through all skills, 0..27, x1=0, x2=v54 (choice made)]

 [Ask if player wishes to forget skill chosen, result in Flag 4] 
!!IF:Q4/20/$sicon$/36/2000/2/z109005; 
!!FU&-4:E; [End script if player doesn't wish to forget a skill after all]
 
[Check if hero has already forgotten a skill today] 
[Set flag 2 to true if he/she has] 
!!IF:V2/0; 
!!IF:W-1; 
!!VR$cday$:Sc0;
!!IF&w45=$cday$:V2/1; 
!!IF&2:M1/z109006; [Display message if hero has already forgotten a skill today]

!!FU&2:E; [End script if hero has already forgotten a skill today]
 
[Checks if player has enough money to afford this service] 
!!OW:R-1/6/?$pgold$; 
!!IF&$pgold$<2000:Q1/6/2000/1/z109007; [Display message if player doesn't have enough gold]
!!FU&$pgold$<2000:E; [End script if player doesn't have enough gold]
 
[Reduces player's gold by 2000 to pay for service] 
!!OW:R-1/6/d-2000; 
 
[Generate random pithy message] 
!!VR$he-she$&$hsex$=0:Sz109008; 
!!VR$man-woman$&$hsex$=0:Sz109009; 
!!VR$he-she$&$hsex$=1:Sz109010; 
!!VR$man-woman$&$hsex$=1:Sz109011; 
!!VR$pithnum$:S1 R11; 
!!VR$pithy$&$pithnum$=1:Sz109012; 
!!VR$pithy$&$pithnum$=2:Sz109013; 
!!VR$pithy$&$pithnum$=3:Sz109014; 
!!VR$pithy$&$pithnum$=4:Sz109015; 
!!VR$pithy$&$pithnum$=5:Sz109016; 
!!VR$pithy$&$pithnum$=6:Sz109017; 
!!VR$pithy$&$pithnum$=7:Sz109018; 
!!VR$pithy$&$pithnum$=8:Sz109019; 
!!VR$pithy$&$pithnum$=9:Sz109020; 
!!VR$pithy$&$pithnum$=10:Sz109021; 
!!VR$pithy$&$pithnum$=11:Sz109022; 
!!VR$pithy$&$pithnum$=12:Sz109023; 
 
[Show skill that's being forgotten along with message] 
!!IF:Q1/20/$sicon$/1/z109024; 
 
[Remove hero's skill] 
;                                                  [TOBYN ADDED: support for unlearning Warfare]
!!UN:P193/?y-2;                                       check if Warfare enabled
!!VRy-3|$skillnum$=10/$skillnum$=20/$skillnum$=27:S1; set y-3=1 if one of the Warfare skills
!!HE-1&y-2=1/y-3=1:S10/0 S20/0 S27/0;                 unlearn all three Warfare skills
!!HE-1:S$skillnum$/0;
 
[Reduce hero's movement by 500] 
!!HE-1:Wd-500; 
 
[Set hero's w45 variable to current day] 
!!VRw45:Sc0; 
 
[The new loop method] 
[Look up skill number/level/icon & name. assign it to..] 
[$skillnum$,$slevel$,$sicon$ & $skname$] 
!?FU451; 
!!VRv51&x1=0:S50; !!VRv52&x1=0:S50; !!VRv53&x1=0:S1; 
!!HE-1:Sx1/?v50;                [Check secondary skill number, store hero's level in v50]
!!VRzv52&v52<=61:S^^;           [Inialize z50..z61 to null]
!!UN&v50>0:N4/z47/x1;           [Store skill name in z47]
!!VR$skname$&v53=x2:S^{%Z47}^;  [Store {skill name} in z1 ($skname) if x2=1 and v53 is still 1]
 
!!VRzv51&v50=1/v51<=61:Sz109025+z47; [Store Basic+skill name in z50..z61 if hero has basic skill]
!!VRzv51&v50=2/v51<=61:Sz109026+z47; [Store Advanced+skill name in z50..z61 if hero has advanced skill] 
!!VRzv51&v50=3/v51<=61:Sz109027+z47; [Store Expert+skill name in z50..z61 if hero has expert skill]
 
!!VR$skillnum$&v53=x2:Sx1; 
!!VR$slevel$&v53=x2:Sv50; 
!!VR$sicon$&v53=x2:S$skillnum$ *3 +2 +$slevel$; 
 
!!VRv51&v50>0:+1; !!VRv52:+1; !!VRx1:+1; !!VRv53&v50>0:*2;

