//Changelog
//---------
//08-07-03 - Wigifer - Order Chaos removed - Tested
//Jan 06 '04 - Wren - Modded the Trusted list...will add a 2n page for trusts soon...for now rearranged for better viewing
//Jan 07 '04 - Wren - Added 2nd page for Trusted list
//Aug 21 '04 - Wren - Changed door to check for auction status
// 21/11/2005 - Raist - Added stuff for bb

//
// GUILD STONES
//

[ITEMDEF 04520]
// Guild Stone
NAME=new guild
DEFNAME=i_guild_stone
ID=i_guildstone
NAME=Guildstone
TYPE=T_STONE_GUILD
VALUE=50000
CATEGORY=Provisions - Deeds
SUBSECTION=Guild and Town Stones
DESCRIPTION=Guild Stone


[FUNCTION PAY_GUILD_DUES]
LOCAL.MINUTES = <TIMER>/60
LOCAL.HOURS = <LOCAL.MINUTES>/60
LOCAL.DAYS = <LOCAL.HOURS>/24

IF ( <LOCAL.DAYS> > 21 )
   SRC.SYSMESSAGE You can only pay up to 21 days.
   RETURN 1
ENDIF

VAR.GOLD=50
SRC.consumegold_everywhere <eval <VAR.gold>>
IF ( <VAR.consumegold> > 0 )
   SRC.SYSMESSAGE You are <eval <VAR.consumegold>>gp short.
ELSE
   TIMER = <TIMER> + 86400
   SRC.SYSMESSAGe You pay 1 day's dues to the guild.
ENDIF
RETURN 1


[FUNCTION GUILD_ANNOUNCEMENT]
   if ( <strpos 1 42 <args>> > 0 )
       src.sysmessage You cannot use '*' in your announcment
   elseif ( <strpos 1 60 <args>> > 0 )
       src.sysmessage You cannot use '<' in your announcment
   elseif ( <strpos 1 62 <args>> > 0 )
       src.sysmessage You cannot use '>' in your announcment
   elseif ( <strpos 1 91 <args>> > 0 )
       src.sysmessage You cannot use '[' in your announcment
   elseif ( <strpos 1 93 <args>> > 0 )
       src.sysmessage You cannot use ']' in your announcment
   elseif ( <strpos 1 61 <args>> > 0 )
       src.sysmessage You cannot use '=' in your announcment
   elseif ( <strpos 1 92 <args>> > 0 )
       src.sysmessage You cannot use '\' in your announcment
   elseif ( <strpos 1 47 <args>> > 0 )
       src.sysmessage You cannot use '/' in your announcment
   elseif ( <strpos 1 123 <args>> > 0 )
       src.sysmessage You cannot use '{' in your announcment
   elseif ( <strpos 1 125 <args>> > 0 )
       src.sysmessage You cannot use '}' in your announcment
   elseif ( <strpos 1 124 <args>> > 0 )
       src.sysmessage You cannot use '|' in your announcment
   elseif ( <strpos 1 33 <args>> > 0 )
       src.sysmessage You cannot use '!' in your announcment
   elseif ( <strpos 1 34 <args>> > 0 )
       src.sysmessage You cannot use '"' in your announcment
   elseif ( <strpos 1 35 <args>> > 0 )
       src.sysmessage You cannot use '#' in your announcment
   elseif ( <strpos 1 36 <args>> > 0 )
       src.sysmessage You cannot use '$' in your announcment
   elseif ( <strpos 1 37 <args>> > 0 )
       src.sysmessage You cannot use '%' in your announcment
   elseif ( <strpos 1 43 <args>> > 0 )
      src.sysmessage You cannot use '+' in your announcment
   else
      MEMORYFINDTYPE.memory_guild.LINK.TAG.GUILD_MSG = <ARGS>
   ENDIF
   RETURN 1


// This is the guildmaster initial selection screen for guildstones
[MENU MENU_GUILD_MASTER]
<Name> (<MasterTitle> <Master>).
ON=0 Recruit someone into the guild
   RECRUIT
ON=0 View the current roster.
   VIEWROSTER
ON=0 View the guild's charter.
   VIEWCHARTER
ON=0 Declare your fealty. You are currently loyal to <LoyalTo>.
   DECLAREFEALTY
ON=0 Toggle showing the guild's abbreviation in your name to unguilded people. Currently <AbbreviationToggle>.
   TOGGLEABBREVIATION
ON=0 Resign from the guild.
   RESIGN
ON=0 View list of candidates who have been sponsored to the guild.
   VIEWCANDIDATES
ON=0 View list of guilds that <Name> has declared war on.
   VIEWENEMYS
ON=0 View list of guilds that have declared war on <Name>.
   VIEWTHREATS
ON=0 Pay Guildstone Dues (50gp per day).  Currently paid <EVAL (<EVAL (<EVAL (<TIMER>/60)>/60)>/24)> days.
   PAY_GUILD_DUES
ON=0 Access Guild <MasterGenderTitle> functions.
   MASTERMENU


// This is the NON-guildmaster initial selection screen for guildstones
[MENU MENU_GUILD_MEMBER]
<Name> (<MasterTitle> <Master>)
ON=0 Recruit someone into the guild
   RECRUIT
ON=0 View the current roster.
   VIEWROSTER
ON=0 View the guild's charter.
   VIEWCHARTER
ON=0 Declare your fealty. You are currently loyal to <LoyalTo>.
   DECLAREFEALTY
ON=0 Toggle showing the guild's abbreviation in your name to unguilded people. Currently <AbbreviationToggle>.
   TOGGLEABBREVIATION
ON=0 Resign from the guild.
   RESIGN
ON=0 View list of candidates who have been sponsored to the guild.
   VIEWCANDIDATES
ON=0 View list of guilds that <Name> has declared war on.
   VIEWENEMYS
ON=0 View list of guilds that have declared war on <Name>.
   VIEWTHREATS
ON=0 Pay Guildstone Dues (50gp per day).  Currently paid <EVAL (<EVAL (<EVAL (<TIMER>/60)>/60)>/24)> days.
   PAY_GUILD_DUES


// Guild master functions.
[MENU MENU_GUILD_MASTERFUNC]
<Name>, Guild <MasterGenderTitle> functions
ON=0 Set the guild name.
   SETNAME
ON=0 Set the guilds abbreviation.
   SETABBREVIATION
ON=0 Set this guild to a standard non-Order\Chaos guild (If not done stone may be removed)
   CHANGEALIGN 0
ON=0 Set the guild's charter.
   SETCHARTER
ON=0 Dismiss a member.
   DISMISSMEMBER
ON=0 Declare war.
   DECLAREWAR
ON=0 Declare peace.
   DECLAREPEACE
ON=0 Accept a candidate seeking membership.
   ACCEPTCANDIDATE
ON=0 Refuse a candidate seeking membership.
   REFUSECANDIDATE
ON=0 Set the guildmaster's title.
   SETGMTITLE
ON=0 Grant a title to another member.
   GRANTTITLE
ON=0 Set Guild Announcement
   PROMPTCONSOLE GUILD_ANNOUNCEMENT Enter the message you would like to send
ON=0 Return to main menu.
   RETURNMAINMENU


// Non-member view.
[MENU MENU_GUILD_NON]
<Name> (<MasterTitle> <Master>)
ON=0 View the guild's charter.
   VIEWCHARTER
ON=0 View list of guilds that <Name> has declared war on.
   VIEWENEMYS
ON=0 View list of guilds that have declared war on <Name>.
   VIEWTHREATS



//
// HOUSES
//

[FUNCTION house_init_tags]
  if ( 0<TAG.NUM.STRUCTS>	== 0 )
     TAG.NUM.STRUCTS	= 0
  endif
  if ( 0<TAG.TAX.STRUCTS>	== 0 )
     TAG.TAX.STRUCTS	= 0
  endif
  if ( 0<TAG.MAN.STRUCTS>	== 0 )
     TAG.MAN.STRUCTS	= 0
  endif


[FUNCTION CountTrusts]
IF (<UID.0<TAG.FRIENDS.UID>.findcont(<EVAL <args>>).uid> == 0)
   RETURN 1
ELSE
   IF (<UID.0<TAG.FRIENDS.UID>.findcont(<EVAL <args>>).MOREx> == 0)
      VAR.NUM.PTRUSTS = (<VAR.NUM.PTRUSTS> + 1)
   ELSE
      VAR.NUM.FTRUSTS = (<VAR.NUM.FTRUSTS> + 1)
   ENDIF
ENDIF
VAR.TRUSTS.COUNT = <EVAL (<argn> + 1)>
CountTrusts <VAR.TRUSTS.COUNT>


[FUNCTION house_init_costs]
  // house_init_tags
  VAR.TAX.HOUSE		= <LINK.house_tax>
  VAR.MAN.HOUSE		= <LINK.house_man>

  VAR.TAX.STRUCTS	= <LINK.structs_tax>
  VAR.MAN.STRUCTS	= <LINK.structs_man>
  VAR.NUM.STRUCTS	= <LINK.structs_num>
  
  VAR.TAX.TOTAL		= <eval (<var.tax.house> + <var.tax.structs>)>
  VAR.MAN.TOTAL		= <eval (<var.man.house> + <var.man.structs>)>

  VAR.TOTAL		= <eval (<var.man.total> + <var.tax.total>)>
  VAR.DAYS		= <eval (<TIMER>/86400)>
  VAR.HOURS		= <eval ( (3600+ (<TIMER>-(<VAR.DAYS>)*86400))/3600) )>

 
[FUNCTION structs_num]
  if !( 0<TAG.NUM.STRUCTS> )
     return 0
  endif
  return <TAG.NUM.STRUCTS>


[FUNCTION structs_tax]
  if !( 0<TAG.NUM.STRUCTS> )
     return 0
  endif

  return <eval (<TAG.TAX.STRUCTS> * <VAR.TAX> / 20)>


[FUNCTION structs_man]
  if !( 0<TAG.NUM.STRUCTS> )
     return 0
  endif

  // 40 per standard piece
  return <eval ((<TAG.MAN.STRUCTS> * 40)/100)>

  
[FUNCTION house_license]
   return <eval (( 1000 + <house_tax> + <house_man> )/2)>


[FUNCTION house_tax]
//  VAR.P	= <P>	//Commenting out...don't see it used Jan 27, 2005
  VAR.TAX	= 0
  
  LOCAL.REGION	= <LINK.REGION.NAME>
  if ( 0<LINK.REGION.TAG.TAX> )
     VAR.TAX	= <LINK.REGION.TAG.TAX>
  endif

  //Empty Trust tax vars
  VAR.NUM.PTRUSTS 	= 0
  VAR.NUM.FTRUSTS	= 0
  VAR.TAX.PTRUSTS	= 0
  VAR.TAX.FTRUSTS	= 0

  //Calculate Region Tax
  if ( 0 )
  elseif ( !strcmpi( "Minoc", "<STRSUB 0 5 <LOCAL.REGION>>" ) )
     VAR.TAX	= 25
  elseif ( !strcmpi( "Yew", "<STRSUB 0 3 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Northern Ter", "<STRSUB 0 12 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Vesper", "<STRSUB 0 6 <LOCAL.REGION>>" ) )
     VAR.TAX	= 20
  elseif ( !strcmpi( "Trinsic", "<STRSUB 0 7 <LOCAL.REGION>>" ) )
     VAR.TAX	= 20
  elseif ( !strcmpi( "Skara Brae", "<STRSUB 0 10 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Serpent's Ho", "<STRSUB 0 12 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Ocllo", "<STRSUB 0 5 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Nujel'm", "<STRSUB 0 7 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Moonglow", "<STRSUB 0 8 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Magincia", "<STRSUB 0 8 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Jhelom", "<STRSUB 0 6 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Cove", "<STRSUB 0 4 <LOCAL.REGION>>" ) )
     VAR.TAX	= 15
  elseif ( !strcmpi( "Britain", "<STRSUB 0 7 <LOCAL.REGION>>" ) )
     VAR.TAX	= 40
//     CountTrusts

//     IF !(<VAR.NUM.PTRUSTS> < 1)
//        VAR.TAX.PTRUSTS	= 0	//No charge for now on partials
//     ENDIF
//     VAR.TAX.PTRUSTS = <EVAL (<VAR.TAX.PTRUSTS>*<VAR.NUM.PTRUSTS>)>

//     IF !(<VAR.NUM.FTRUSTS> < 1)
//        VAR.TAX.FTRUSTS	= <EVAL ( 1000 - (<VALUE> / 100) )>
//        IF (0<VAR.TAX.FTRUSTS> < 25 )
//           VAR.TAX.FTRUSTS = 25
//        ENDIF
//     ENDIF
//     VAR.TAX.FTRUSTS = <EVAL (<VAR.TAX.FTRUSTS>*<VAR.NUM.FTRUSTS>)>
  else
  endif
  
  //Cap the taxes
  VAR.TAX.HOUSE = <eval (( (((((40000+<VALUE>)/2)*<VAR.TAX>)/10000)*10 )) + <VAR.TAX.PTRUSTS> + <VAR.TAX.FTRUSTS> )>
  IF (<VAR.TAX.HOUSE> > 25000)
     VAR.TAX.HOUSE = 25000
  ENDIF
  RETURN <VAR.TAX.HOUSE>
  

[FUNCTION house_man]
  VAR.MAN.HOUSE = <eval ( ((<VALUE>*15)/10000)*10 )>
  IF (<VAR.MAN.HOUSE> > 35000)
     VAR.MAN.HOUSE = 35000
  ENDIF
  RETURN <VAR.MAN.HOUSE>

[FUNCTION findhouse]
  VAR.FINDHOUSE	= 0
  FORCHARMEMORYTYPE memory_guard
     IF <LINK> = <args>
        VAR.FINDHOUSE	= <UID>
        RETURN 1
     ENDIF
  ENDFOR
  RETURN 0


[FUNCTION SRCHOUSE_friend]
  if ( (<SRC.UID> == <MORE1>) || (<SRC.ISGM>) )
     return 1
  endif

  if ( !strcmp( "<SRC.ACCOUNT>", "<SRC.UID.<MORE1>.ACCOUNT>" ) )
     return 1
  endif

  if ( <SRCFRIEND> )
     return 1
  endif
  return 0

[FUNCTION SRCHOUSE_owner]
  if ( (<SRC.UID> == <MORE1>) || (<SRC.ISGM>) )
     return 1
  endif

  if ( !strcmp( "<SRC.ACCOUNT>", "<SRC.UID.<MORE1>.ACCOUNT>" ) )
     return 1
  endif

  if ( <SRCOWNER> )
     return 1
  endif
  return 0


[FUNCTION SRCFRIEND]
  FINDFRIEND <SRC.UID>
  return <VAR.FINDFRIEND>
  

[FUNCTION findfriend]
  VAR.FINDFRIEND	= 0
  IF ( 0<TAG.FRIENDS.UID> == 0 )
     return 0
  ENDIF
  
  FORCONT <TAG.FRIENDS.UID> 0
     IF ( <BASEID> != i_house_trust )
        return 0
     ENDIF
     
     IF ( <LINK> = <args> )
        VAR.FINDFRIEND	= <UID>
        RETURN 1
     ENDIF
  ENDFOR
  RETURN 0
  
  

[FUNCTION SRCOWNER]
  FINDOWNER <SRC.UID>
  return <VAR.FINDOWNER>


[FUNCTION findowner]
  VAR.findowner	= 0
  if ( 0<TAG.FRIENDS.UID> == 0 )
     return 0
  endif
  
  FORCONT <TAG.FRIENDS.UID> 0
     IF ( <BASEID> != i_house_trust )
        return 0
     ENDIF
     
     IF ( <LINK> = <args> )
        IF !( <MOREx> == 0 )
           VAR.FINDOWNER	= <UID>
           RETURN 1
        ENDIF
     ENDIF
  ENDFOR
  RETURN 0


[FUNCTION ISANAUCTIONHOUSE]
   LOCAL.REGION	= <LINK.REGION.NAME>
//   IF ( !strcmpi("Britain Territory PVP", "<STRSUB 0 21 <LOCAL.REGION>>") )
 //     RETURN 1   
 //  ELSE
  //    RETURN 0
  // ENDIF
   RETURN 0
   
   //This is used when auctions go back in place.
   IF ( 0<LINK.TAG.TOWNITEM> = 01 )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 19 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 18 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 17 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 16 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 15 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 14 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 13 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 12 8 <LOCAL.REGION>>" ) )
       RETURN 0   
   ENDIf
   RETURN 1

     
[FUNCTION ISRENTPAYABLE]
   LOCAL.REGION	= <LINK.REGION.NAME>
   IF ((<UID.<LINK.MORE1>.HOUSE_COUNT> > 4) && (!<SRC.ISGM>))
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 19 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 18 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 17 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 16 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 15 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 14 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 13 8 <LOCAL.REGION>>" ) )
       RETURN 0
   ELSEIF ( !strcmpi( "No Build", "<STRSUB 12 8 <LOCAL.REGION>>" ) )
       RETURN 0   
   ENDIf
   RETURN 1



//
//  SIGNS
//
[ITEMDEF 0bd1]
DEFNAME		= i_sign_brass
TYPE		= t_script
TDATA2		= 064
FLIP		= 1
DUPELIST	= 0bd2
CATEGORY	= Decoration - Signs
SUBSECTION	= Blank
DESCRIPTION	= Brass Blank


ON = @Create
  ATTR			= 010
  COLOR			= house_colour_init
  TIMER			= 1
  TAG.INIT_HOUSE	= 1
  TYPE			= t_sign_gump

ON = @Targon_Char
  if ( <SRC.TAG0.HOUSEACTION> == 0 )
  elseif ( <SRC.TAG.HOUSEACTION> == 45 )
    if ( <SRC.TARG.UID> == <LINK.MORE1> )
       src.sysmessage You are the owner of the structure!
       return 1
    endif
    if ( <SRC.TARG.NPC> )
       src.sysmessage NPCs can't own structures!
       return 1
    endif
    if ( <SRC.REGION.UID> == <REGION.UID> )
       src.sysmessage You must leave the structure in order to bestow ownership.
       return 1
    endif
    if ( <SRC.findtype(t_eq_trade_window).uid> )
       SRC.ACT		= <SRC.findtype(t_eq_trade_window).uid>

       if ( <SRC.ACT.LINK.CONT> == <SRC.TARG.UID> )
          SRC.ACT.LINK.CONT	= <SRC.UID>
          SRC.ACT.CONT	= <SRC.TARG.UID>
          SRC.ACT.REMOVE
       endif
    endif
    local.scompare=<STRSUB 0 21 <SRC.REGION.NAME>>
    if  strmatch("<local.scompare>","Britain Territory PVP")
      if (<COUNT_BB_HOUSES <SRC.TARG.UID>> > 0)
	 SRC.SYSMESSAGE @0108 They already own a house in this region!
         RETURN 1
      endif
    endif
    
    SRC.ACT		= <SRC.MEMORYFIND.<LINK.UID>.uid>
    SRC.ACT.CONT	= <SRC.TARG.UID>
    LINK.MORE1		= <SRC.TARG.UID>
    SRC.SYSMESSAGE <SRC.TARG.NAME> is now the owner of <LINK.NAME>.
    SRC.TARG.SYSMESSAGE You are now the owner of <LINK.NAME>.
    RETURN 1

  elseif ( <SRC.TAG.HOUSEACTION> == 50 )
    // add friend
    if ( <SRC.TARG.NPC> )
       src.sysmessage Only players can be trusted to access the structure.
       return 1
    endif
  
    if ( <SRC.TARG.UID> == <LINK.MORE1> )
       if ( <SRC.TARG.UID> == <SRC.UID> )
          src.sysmessage You are the owner of the structure!
       else
          src.sysmessage <SRC.TARG.NAME> is the owner of the structure!
       endif
       return 1
    endif
  
    LINK.FINDFRIEND <SRC.TARG.UID>
    if ( <VAR.FINDFRIEND> != 0 )
       src.sysmessage <SRC.TARG.NAME> is already a trusted person of the structure.
       return 1
    endif

    SRC.SYSMESSAGE Added <SRC.TARG.NAME> as a trusted person of the structure.
    SRC.NEWITEM	i_house_trust
    SRC.ACT.NAME	= <SRC.TARG.NAME> (by <SRC.NAME>)
    SRC.ACT.MORE2	= <SRC.UID>
    SRC.ACT.LINK	= <SRC.TARG.UID>
    SRC.ACT.CONT	= <LINK.TAG.FRIENDS.UID>
    RETURN 1

  endif
  return 1


ON = @Click
  IF (<SRC.ACCOUNT.PLEVEL> > 1)
     MESSAGE <UID.<LINK.MORE1>.ACCOUNT>'s
  ENDIF
  
  if (<LINK> == 04ffffff)
     return 0
  endif

  if ( <LINK.TAG.STATUS> != house_status_auction )
     if ( <LINK.TYPE> == t_multi )
        MESSAGE <LINK.NAME>
        return 1
     endif
     return 0
  endif

  if ( <LINK.TAG.AUCTION.BIDDER> == 0 )
     MESSAGE <NAME> (no bid)
     return 1
  endif

  MESSAGE <NAME>
  MESSAGE (<eval <LINK.TAG.AUCTION.BID>>gp by <SRC.UID.<LINK.TAG.AUCTION.BIDDER>.name>)
  MESSAGE (<eval ((<timer>+60)/60)>minutes to go)
  return 1


ON = @DCLICK
  if ( <SRC.ISDEAD> )
      SRC.SYSMESSAGE "Get a life..."
      return 0
  elseif (<LINK> == 04ffffff)
     return 0
  endif
  TYPE			= t_sign_gump

  if !( 0<TAG.INIT_HOUSE> == 0 )
     return 1
  endif

  if ( <LINK.TAG.STATUS> != house_status_auction )
     if !( <LINK.SRCHOUSE_friend> ) 
        SRC.SYSMESSAGE This structure belongs to <src.uid.<LINK.MORE1>.name>!
	return 1
     endif
  elseif !( <SRC.ISGM> )
     if ( <LINK.TAG.AUCTION.BIDDER> == <SRC.UID> )
        SRC.SYSMESSAGE You already have the best bid, at <eval <LINK.TAG.AUCTION.BID>>gp, <eval (<timer>+60)/60)>minutes to go.
	return 1
     else
        local.scompare=<STRSUB 0 21 <SRC.REGION.NAME>>
        IF strmatch("<local.scompare>","Britain Territory PVP")
           IF ( <COUNT_BB_HOUSES <SRC.UID>> > 0)
              SRC.SYSMESSAGE You already own a Brit Bridge Home, you cannot bid on another.
              RETURN 1
           ENDIF
        ENDIF
     endif

     f_mnu_house_auction
     return 1
  endif

  if ( <LINK.TAG.STATUS> == house_status_init )
     house_init_costs
     MENU mnu_house_init
     return 1
  endif
  
  house_init_costs
  VAR.TAX		= <VAR.TOTAL>
  if ( <LINK.TAG.PAID> < <VAR.TAX> )		// warn that next tax won't be paid
     COLOR			= house_colour_tax
  endif

  DIALOG_house_sign
  RETURN 1

ON=@Timer
  if ( (<LINK> == 04ffffff) | (<LINK.MORE1> == 0) )
     TIMER	= 100
     return 1
  endif

  // one time initialization
  if !( 0<TAG.INIT_HOUSE> == 0 )
     TAG.INIT_HOUSE	=
     NAME		= <LINK.NAME>
     TIMER		= house_time_init
     COLOR		= house_colour_init
     LINK.TAG.STATUS	= house_status_init
     LINK.TAG.PAID	= 0
     return 1
  endif

  if ( <LINK.TAG.STATUS> == house_status_auction )		// auctioned
    if ( <LINK.TAG.AUCTION.BIDDER> == 0 )			// no bidder, remove
       LINK.REMOVE
       REMOVE
       return 1
    endif

    // auction done, change owner and clear memory
    VAR.NEW_OWNER	= <LINK.TAG.AUCTION.BIDDER>
    VAR.PREV_OWNER	= <LINK.MORE1>
    LINK.TAG.PREV_OWNER	= <VAR.PREV_OWNER>
    LINK.MORE1		= <VAR.NEW_OWNER>
    
    LOCAL.SCOMPARE=<STRSUB 0 21 <LINK.REGION.NAME>>
    IF STRMATCH("<LOCAL.SCOMPARE>","Britain Territory PVP")
       LINK.TAG.TIMESPAID  =        
    ELSE
       LINK.TAG.TIMESPAID  =    
    ENDIF
       
    VAR.LINK		= <LINK.UID>

    LINK		= <VAR.PREV_OWNER>
    LINK.FINDHOUSE <VAR.LINK>
 
    LINK		= <VAR.FINDHOUSE>
    LINK.CONT		= <VAR.NEW_OWNER>
    LINK.CONT.SYSMESSAGE You are now the owner of a <LINK.CONT.UID.<VAR.LINK>.NAME>.

    LINK		= <VAR.LINK>    
    LINK.TAG.STATUS	= house_status_init	// so that the next IF inits the house
    // no return here on purpose
  endif

  if ( <LINK.TAG.STATUS> == house_status_init )		// becoming established
     TIMER		= house_time_normal
     COLOR		= house_colour_normal
     LINK.TAG.STATUS	= house_status_normal

     LOCAL.SCOMPARE=<STRSUB 0 21 <LINK.REGION.NAME>>
     IF STRMATCH("<LOCAL.SCOMPARE>","Britain Territory PVP")
        LINK.TAG.PAID	= <EVAL (<eval (<LINK.house_tax> + <LINK.house_man>)>)>
     ELSE
        LINK.TAG.PAID	= <eval (<LINK.house_tax> + <LINK.house_man>)>
     ENDIF

     LINK.TRIGGER @Init
     return 1
  endif

  house_init_costs
  VAR.TAX		= <VAR.TOTAL>

  if ( <VAR.TAX> <= <LINK.TAG.PAID> )
     LINK.TAG.PAID	= <eval (<LINK.TAG.PAID> - <VAR.TAX>)>
     TIMER		= house_time_normal
     if ( <LINK.TAG.PAID> < <VAR.TAX> )		// warn that next tax won't be paid
        COLOR			= house_colour_tax
     endif
     return 1
  endif

  //One time grace period - Added April 03 2006 before turning rents back on.
  IF ( <LINK.TAG0.GRACE_PERIOD>=0 )
     LINK.TAG.GRACE_PERIOD=1
     TIMER = 604800
     COLOR = house_colour_tax
     RETURN 1
  ENDIF

  IF <ISANAUCTIONHOUSE>
     // failed to pay, auction
     TIMER				= house_time_auction
     COLOR				= house_colour_auction
     LINK.TAG.STATUS		= house_status_auction
     LINK.TAG.AUCTION.BIDDER	= 0
     LINK.TAG.AUCTION.BID		= <eval ((<LINK.VALUE>/10) + (<VAR.TAX>*3))>

     SERV.ALLCLIENTS SYSMESSAGE AUCTION: A property belonging to <SRC.UID.<LINK.MORE1>.NAME> is now for sale in <LINK.REGION.NAME>.
  ELSE
     LINK.REMOVE    
  ENDIF
  return 1
 

ON = @Targon_Item
  if ( <SRC.TARG.TYPE> == t_struct_built )
    if ( <SRC.TARG.LINK.uid> != <LINK.UID> )
      SRC.SYSMESSAGE That structure does not belong here.
      return 1
    endif
  elseif ( <LINK.BASEID> == i_multi_struct )
    SRC.SYSMESSAGE That's not a structure.
    return 1
  elseif ( <SRC.TARG.REGION.UID> != <LINK.REGION.UID> )
    SRC.SYSMESSAGE That's outside boundaries.
    return 1
  elseif ( <SRC.TARG.LINK.TYPE> == t_multi )
    SRC.SYSMESSAGE <LINK.REGION.NAME>, <SRC.TARG.REGION.NAME>
    if ( <SRC.TARG.LINK.UID> != <LINK.REGION.UID> )
       SRC.SYSMESSAGE That item is locked to another house!
       return 1
    endif
  endif

  if ( 0 )
  elseif ( (<SRC.TARG.TYPE> == t_door) || (<SRC.TARG.TYPE> == t_door_locked) || (<SRC.TARG.TYPE> == t_door_open) )
     if ( 0 )
     elseif ( <SRC.TAG.HOUSEACTION> == 48 )		//Offer alternate wood colors for doors
 
        IF <SRC.TARG.LINK.UID>=<LINK.UID>
          IF (0<TAG.DOOR_WOOD>=0)
             SERV.NEWITEM M_Preview_Door_Color
             NEW.LINK=<SRC.TARG.UID>
             NEW.COLOR=<SRC.TARG.COLOR>
             NEW.CONT=<SRC.UID>
          ELSEIF !(<SRC.TARG.COLOR>=<TAG.DOOR_COLOR>)

             var.gold=<TAG.DOOR_GOLD>
             If <SRC.restest 1 <TAG.DOOR_WOOD>>
                SRC.consumegold_everywhere <eval (<var.gold>)>
                if ( <VAR.consumegold> > 0 )
                   SRC.SYSMESSAGE You are <eval <VAR.consumegold>>gp short.
                   VAR.RETURN	= 1
                   return 1
                endif
                SRC.CONSUME 10 <TAG.DOOR_WOOD>
             ENDIF
             SRC.TARG.COLOR=<TAG.DOOR_COLOR>
          ELSE
             SRC.SYSMESSAGE That door is already <TAG.DOOR_WOOD>.
          ENDIF
        ELSEIF
           SRC.SYSMESSAGE That door doesn't appear to be linked to your house.
        ENDIF
        TAG.DOOR_WOOD=
        TAG.DOOR_GOLD=
        TAG.DOOR_COLOR=
        RETURN 1

     elseif ( <SRC.TAG.HOUSEACTION> == 51 )	// lock
       
       if !( <SRC.TARG.ATTR> & attr_blessed )
          SRC.SYSMESSAGE The door is already locked. Only fully trusted people can enter.
       else
          SRC.SYSMESSAGE You lock the door. Only fully trusted people can enter.
          SRC.TARG.ATTR	= (<SRC.TARG.ATTR> &~ attr_blessed)
          return 1
       endif
     elseif ( <SRC.TAG.HOUSEACTION> == 52 )	// unlock
       //if ( <SRC.TARG.ATTR> & attr_blessed )
       //   SRC.SYSMESSAGE The door is not locked. Partially people are free to enter.
       //else
       //   SRC.SYSMESSAGE You unlock the door. Partially people are free to enter.
       //   SRC.TARG.ATTR	= (<SRC.TARG.ATTR> | attr_blessed)
       //endif
     endif
     return 1
  elseif ( <SRC.TARG.TYPE> == t_sign_gump )
  //elseif ( <SRC.TARG.TYPE> == t_container )
  //elseif ( <SRC.TARG.TYPE> == t_container_locked )
  else
     if ( 0 )
     elseif ( <SRC.TAG.HOUSEACTION> == 51 )	// lock
       IF ( ( (<SRC.MEMORYFINDTYPE(memory_fight).uid>) && ( <UID.<SRC.MEMORYFINDTYPE(memory_fight).LINK>.NPC> = 0 ) ) || ( (<SRC.MEMORYFINDTYPE(MEMORY_IAGGRESSOR).uid>) && ( <UID.<SRC.MEMORYFINDTYPE(MEMORY_IAGGRESSOR).LINK>.NPC> = 0 ) ) )
          SRC.SYSMESSAGE You are too busy fighting to do that right now.
          RETURN 1
       ENDIF

       IF ( (<SRC.MEMORYFINDTYPE(memory_harmedby).uid>) && ( <UID.<SRC.MEMORYFINDTYPE(memory_harmedby).LINK>.NPC> = 0 ) )
          SRC.SYSMESSAGE You are too busy defending yourself to do that right now.
          RETURN 1
       ENDIF
       
       if ( (<SRC.TARG.ATTR> & attr_move_never) && (<SRC.TARG.LINK.uid> == <LINK.uid>) )
          SRC.SYSMESSAGE That is already locked down.
       else
             
                IF (<SRC.TARG.CONT.TOPOBJ.UID> == 0)
                    IF (<SRC.TARG.TYPE> == t_corpse)  
                       SRC.SYSMESSAGE You can't lock that down!
                    ELSEIF (<SRC.TARG.BASEID> == i_bones)
                       SRC.SYSMESSAGE You can't lock that down!
                    ELSEIF (<SRC.TARG.TYPE> == t_forge) 
                       SRC.SYSMESSAGE You can't lock that down!
                    ELSEIF (<SRC.TARG.TYPE> == t_anvil) 
                       SRC.SYSMESSAGE You can't lock that down!
                    ELSE
                      SRC.SYSMESSAGE You lock down <SRC.TARG.NAME>.
                      SRC.TARG.ATTR	= (<SRC.TARG.ATTR> | attr_move_never )
                      SRC.TARG.LINK	= <LINK.UID>
                      SRC.TARG.NUDGEUP
                      SRC.TARG.NUDGEDOWN
                    ENDIF
                 else
                      SRC.SYSMESSAGE You cant lock items that are inside other items.
                 endif

       endif
     elseif ( <SRC.TAG.HOUSEACTION> == 52 )	// unlock
       if ( (<SRC.TARG.ATTR> & attr_move_never) && (<SRC.TARG.LINK.uid> == <LINK.uid>) )
                    IF (<SRC.TARG.TYPE> == t_forge) 
                    SRC.SYSMESSAGE You cant unlock that 
                    ELSEIF (<SRC.TARG.TYPE> == t_anvil) 
                    SRC.SYSMESSAGE You cant unlock that  
                    ELSE
                    SRC.SYSMESSAGE You unlock <SRC.TARG.NAME>         
                    SRC.TARG.ATTR	= ( <SRC.TARG.ATTR> & ~ attr_move_never )
                    SRC.TARG.LINK	= 04fffffff
                    ENDIF
       if ((<SRC.TARG.TYPE> == t_forge)||(<SRC.TARG.TYPE> == t_forge_out))
          SRC.TARG.ATTR = 010
       endif
          SRC.TARG.NUDGEUP
          SRC.TARG.NUDGEDOWN
       else
          SRC.SYSMESSAGE That is not locked down.
       endif
     elseif ( <SRC.TAG.HOUSEACTION> == 53 )	// raise
       IF ( <SRC.TARG.Z> < (<SRC.Z> + 15) )
          SRC.SYSMESSAGE You raise <SRC.TARG.NAME>.
          SRC.TARG.NUDGEUP 1
       else
          SRC.SYSMESSAGE You can't raise it any higher.
       endif
     elseif ( <SRC.TAG.HOUSEACTION> == 54 )	// lower
       if ( <SRC.TARG.Z> > <SRC.Z> )
          SRC.SYSMESSAGE You lower <SRC.TARG.NAME>.
          SRC.TARG.NUDGEDOWN 1
       else
          SRC.SYSMESSAGE You can't move it any lower.
       endif
     elseif ( <SRC.TAG.HOUSEACTION> == 55 )	// flip
       SRC.TARG.FLIP
     elseif ( <SRC.TAG.HOUSEACTION> == 56 )	// scrap
       if ( <SRC.TARG.TYPE> != t_struct_built )
          SRC.SYSMESSAGE That's not a structure.
          return 1
       endif
       SRC.TARG.TRIGGER @Scrap
     elseif ( <SRC.TAG.HOUSEACTION> == 57 )	// redeed
       if ( <SRC.TARG.TYPE> != t_struct_built )
          SRC.SYSMESSAGE That's not a structure.
          return 1
       endif
       SRC.TARG.TRIGGER @Redeed
     elseif ( <SRC.TAG.HOUSEACTION> == 58 )	// raise
       IF ( <SRC.TARG.Z> < (<SRC.Z> + 15) )
          SRC.SYSMESSAGE You raise <SRC.TARG.NAME>.
          SRC.TARG.NUDGEUP 5
       else
          SRC.SYSMESSAGE You can't raise it any higher.
       endif
     elseif ( <SRC.TAG.HOUSEACTION> == 59 )	// lower
       if ( <SRC.TARG.Z> > (<SRC.Z> + 4) )
          SRC.SYSMESSAGE You lower <SRC.TARG.NAME>.
          SRC.TARG.NUDGEDOWN 5
       else
          SRC.SYSMESSAGE You can't move it any lower.
       endif
     endif
     endif
     return 1
  endif

  SRC.SYSMESSAGE You can't do that!
  return 1


[ITEMDEF 0bd2]
//brass sign
DEFNAME=i_sign_brass_2
DUPEITEM=0bd1


[FUNCTION f_mnu_house_auction]
if ( <LINK.TAG.AUCTION.BIDDER> == 0 )
   VAR.bidder	= noone
   var.minbid	= minimum bid is <eval ((<LINK.TAG.AUCTION.BID> * 110)/100)>gp
else
   VAR.bidder	= <uid.<LINK.TAG.AUCTION.BIDDER>.name>
   var.minbid	= current bid is at <eval ((<LINK.TAG.AUCTION.BID> * 100)/100)>gp
endif
SRC.TAG.AUCTION.CURRENTBID	= <LINK.TAG.AUCTION.BID>
MENU mnu_house_auction




[MENU mnu_house_auction]
This structure is being bid on by <var.bidder>. The <var.minbid>.

ON = 0 ( <eval ((<LINK.TAG.AUCTION.BID>*110)/100)>gp )   minimum bid
  f_house_bid <eval ((<LINK.TAG.AUCTION.BID>*110)/100)>
ON = 0 ( <eval ((<LINK.TAG.AUCTION.BID>*125)/100)>gp )   25% more
  f_house_bid <eval ((<LINK.TAG.AUCTION.BID>*125)/100)>
ON = 0 ( <eval ((<LINK.TAG.AUCTION.BID>*150)/100)>gp )   50% more
  f_house_bid <eval ((<LINK.TAG.AUCTION.BID>*150)/100)>
ON = 0 ( <eval ((<LINK.TAG.AUCTION.BID>*200)/100)>gp )   double
  f_house_bid <eval ((<LINK.TAG.AUCTION.BID>*200)/100)>
ON = 0 ( <eval ((<LINK.TAG.AUCTION.BID>*300)/100)>gp )   triple
  f_house_bid <eval ((<LINK.TAG.AUCTION.BID>*300)/100)>




[FUNCTION f_house_bid]
  if ( <LINK.TAG.STATUS> != house_status_auction )
     src.sysmessage The auction is no longer in progress.
     return 1
  elseif ( <LINK.TAG.AUCTION.BID> != <SRC.TAG.AUCTION.CURRENTBID> )
    src.sysmessage While you considered, the bidding conditions have changed.
    return 1
  endif

  src.consumegold_everywhere <args>
  if ( <var.consumegold> > 0 )
     src.sysmessage You are <eval <var.consumegold>>gp short in your account for such a bid.
     return 0
  endif

  if ( <LINK.TAG.AUCTION.BIDDER> != 0 )
    VAR.PREV_ACT	= <SRC.ACT>
    SRC.ACT		= <LINK.TAG.AUCTION.BIDDER>
    SRC.ACT.NEWITEM	i_check
    SRC.ACT.ACT.MORE2	= <LINK.TAG.AUCTION.BID>
    SRC.ACT.ACT.CONT	= <SRC.ACT.findlayer(layer_bankbox).uid>
    SRC.ACT.SYSMESSAGE	A higher bid has been placed on <LINK.NAME>. A cheque has been issued to your bank.
    SRC.ACT		= <VAR.PREV_ACT>
  endif

  LINK.TAG.AUCTION.BIDDER	= <SRC.UID>
  LINK.TAG.AUCTION.BID		= <args>
  TIMER				= house_time_auction_bid

  src.sysmessage You bid <eval <args>>gp for the <LINK.NAME>.




[MENU mnu_house_init]
The structure is not established yet (<eval (<TIMER>)>seconds to go). You can either redeed it or establish it now. Once it is established, you can no longer redeed it. The total weekly cost for this structure in this place is currently <eval <var.total>>gp.

ON = 0 Redeed
  if !( (<SRC.UID> == <LINK.MORE1>) || (<SRC.ISGM>) || (<LINK.TAG.STATUS> == house_status_init) )
     src.sysmessage You can't redeed this structure.
     return 1
  endif
  
  SERV.LOG <SRC.ACCOUNT> (<SRC.NAME>) redeeded a '<LINK.NAME>' at (<LINK.P>).

  SRC.NEWITEM		i_deed
  SRC.ACT.TYPE		t_deed
  SRC.ACT.NAME		<LINK.NAME>
  SRC.ACT.MORE		<LINK.ID>
  SRC.ACT.MORE2		<LINK.MORE>
  SRC.ACT.BOUNCE
  LINK.REMOVE
  RETURN 1

ON = 0 Establish
  if !( (<SRC.UID> == <LINK.MORE1>) || (<SRC.ISGM>) || (<LINK.TAG.STATUS> == house_status_init) )
     src.sysmessage You can't establish this structure.
     return 1
  endif
  TIMER	= 1
  return 1
  

[MENU mnu_house_sell]
This will place the structure up for auction, and the money will be returned to you. If there is no bidder the structure will be demolished. Are you sure you want to proceed?

ON = 0 Continue...
   SRC.SYSMESSAGE This function is not implemented yet.
  



//
//  FIX THE KEYS
//
[FUNCTION f_key_targon_item]
   if ( <MORE1> == 0 )			// blank key
      SRC.TARG.MORE2 = <MORE2>		// copy MORE2
      return 0	// proceed as normal
   endif

   if ( (<SRC.TARG.TYPE> == t_door) || (<SRC.TARG.TYPE> == t_door_locked) )
     if ( <SRC.TARG.LINK.UID> )		// HOUSE door
       if ( 0<SRC.TARG.LINK.TAG.LAST_LOCK> == 0 )
          SRC.TARG.LINK.TAG.LAST_LOCK	= 0
       elseif ( <MORE2> != <SRC.TARG.LINK.TAG.LAST_LOCK> )
          src.sysmessage The lock on this door has been changed.
          return 1
       endif
       return 0
     endif
   endif



   
[ITEMDEF 0100e]
DEFNAME=i_key_copper
RESOURCES=3 i_ingot_iron
WEIGHT=1
TYPE=T_KEY
CATEGORY=Provisions - Miscellaneous
SUBSECTION=Keys
DESCRIPTION=Copper Key
SKILLMAKE=TINKERING 43.0,t_tinker_tools

ON=@Create
   // ATTR		= attr_invis | attr_newbie
   ATTR		= attr_newbie

ON=@Targon_item
   return	<f_key_targon_item>



//
//  DIALOG
//

[FUNCTION DIALOG_house_sign]
  // if the house has no bag of friends, create one
  SRC.ACT	= <LINK.TAG.FRIENDS.UID>
  if ( <SRC.ACT.UID> == 0 )
     SRC.NEWITEM	i_pouch
     if ( <ID> == 0bd1 )
       SRC.ACT.FLIP
     endif
     SRC.ACT.ATTR	= attr_invis | attr_move_never
     SRC.ACT.P		= <P>
     SRC.ACT.Z		= <eval (<Z> + 22)>
     SRC.ACT.COLOR	= 039b
     SRC.ACT.TIMER	= -1
     SRC.ACT.NAME	= group of friends
     SRC.ACT.LINK	= <LINK.UID>
     LINK.TAG.FRIENDS.UID	= <SRC.ACT.UID>
  endif

    
  // init costs
  house_init_costs

  if ( <LINK.TAG.PAID> < <VAR.TOTAL> )
     VAR.PAID.CLR	= 32
     if ( <VAR.DAYS> > 2 )
        VAR.PAID.CLR	= 42
     endif
  else
     VAR.PAID.CLR	= 88
  endif

  // init friends
  house_init_friend 0
  house_init_friend 1
  house_init_friend 2
  house_init_friend 3
  house_init_friend 4
  house_init_friend 5
  house_init_friend 6
  house_init_friend 7
  house_init_friend 8
  house_init_friend 9
  house_init_friend 10
  house_init_friend 11
  house_init_friend 12
  house_init_friend 13
  house_init_friend 14
  house_init_friend 15
  house_init_friend 16
  house_init_friend 17
  house_init_friend 18
  house_init_friend 19

  //init friends page 2
  house_init_friend 20
  house_init_friend 21
  house_init_friend 22
  house_init_friend 23
  house_init_friend 24
  house_init_friend 25
  house_init_friend 26
  house_init_friend 27
  house_init_friend 28
  house_init_friend 29
  house_init_friend 30
  house_init_friend 31
  house_init_friend 32
  house_init_friend 33
  house_init_friend 34
  house_init_friend 35
  house_init_friend 36
  house_init_friend 37
  house_init_friend 38
  house_init_friend 39


  if ( 0<SRC.TAG.CONSTRUCTION_LICENSE> )
     SRC.TAG.CONSTRUCTION_LICENSE	=
     VAR.PAGE6	= 1
     VAR.PAGE5	= 5
     VAR.PAGE1	= 6
  elseif ( <LINK.BASEID> == i_multi_struct )
     VAR.PAGE1	= 5
     VAR.PAGE5	= 1
     VAR.PAGE6	= 6
  else
     VAR.PAGE1	= 1
     VAR.PAGE5	= 5
     VAR.PAGE6	= 6
  endif

  HTMLDIALOG d_house_sign



[FUNCTION hr]
   SYSMESSAGE Houses resynced.

[DIALOG d_house_sign]
100,60
gumppic    0    0 <eval   0ce>		// left
gumppic    0   44 <eval   0ca>
gumppic    0  360 <eval   0cc>

gumppic  471    0 <eval   0cf>		// right
gumppic  471   44 <eval   0cb>
gumppic  471  360 <eval   0cd>

gumppic   44    0 <eval   0c9>		// middle
gumppic   44   44 <eval  0a2c>
gumppic   44  360 <eval   0e9>

gumppic  350    0 <eval   0cf>		// left 2
gumppic  350   44 <eval   0cb>
gumppic  350  360 <eval   0cd>

resizepic 48 25 5100 299 25		// title background

button   415   50 <eval 015a9> <eval 015aa> 0 1		// status
button   415  125 <eval 015c3> <eval 015c4> 0 2		// costs
button   415  205 <eval 015bd> <eval 015be> 0 3		// people
button   415  280 <eval 015bd> <eval 015be> 0 4		// people pg 2
//button   415  280 <eval 015c5> <eval 015c6> 0 4	// items

PAGE 1
   dtext 160 27 0 STRUCTURE

   dtext    40 70  0 Useful operations:

   button  70 95 <eval 0fa5> <eval 0fa7> 1 0 10
   dtext   110 95  52 Access your bank account.




   dtext    40 145  0 Structure operations:

   button  70 170 <eval 0fa5> <eval 0fa7> 1 0 44	
   dtext   110 170  0 rename:
   dtextentry 170 170  250 60 42 0 <LINK.NAME>

   button  70 190 <eval 0fa5> <eval 0fa7> 1 0 45
   dtext   110 190  26 bestow ownership

   button  70 210 <eval 0fa5> <eval 0fa7> 1 0 46
   dtext   110 210  27 demolish & scrap

   button  70 230 <eval 0fa5> <eval 0fa7> 1 0 47
   dtext   110 230  47 obtain construction license (<LINK.house_license>gp)

   button  70 250 <eval 0fa5> <eval 0fa7> 1 0 48
   dtext   110 250  47 upgrade/downgrade doors




   dtext    40 285 0 Other operations (fully trusted people only):
   
   button  20 310 <eval 0fa5> <eval 0fa7> 1 0 51   
   dtext   55 310  5 Lock

   button  20 330 <eval 0fa5> <eval 0fa7> 1 0 52
   dtext   55 330 10 Unlock

   button 110 310 <eval 0fa5> <eval 0fa7> 1 0 53
   dtext  145 310  5 Raise

   button 200 310 <eval 0fa5> <eval 0fa7> 1 0 58
   dtext  235 310  5 Raise 5

   button 110 330 <eval 0fa5> <eval 0fa7> 1 0 54
   dtext  145 330 10 Lower

   button 200 330 <eval 0fa5> <eval 0fa7> 1 0 59
   dtext  235 330 10 Lower 5

   button 300 310 <eval 0fa5> <eval 0fa7> 1 0 55
   dtext  335 310  5 Flip

   button 300 330 <eval 0fa5> <eval 0fa7> 1 0 56
   dtext  335 330 10 Scrap

PAGE 2
   dtext 160  27 0  COSTS

   dtext 110  60 85 Maintenance
   dtext 290  60 85 Tax
   
   dtext  60  90 87 base
   dtext  60 110 88 structures [ <eval <var.num.structs>> ]
   dtext  60 150 90 overall
   dtext  60 170 32 Of the tax, <EVAL <VAR.TAX.FTRUSTS>> is 'Full Trust' Tax.

   dtext 195  90 51 <eval <VAR.MAN.HOUSE>>gp
   dtext 195 110 51 <eval <VAR.MAN.STRUCTS>>gp
   dtext 195 150 53 <eval <VAR.MAN.TOTAL>>gp

   dtext 290  90 51 <eval <VAR.TAX.HOUSE>>gp
   dtext 290 110 51 <eval <VAR.TAX.STRUCTS>>gp
   dtext 290 150 53 <eval <VAR.TAX.TOTAL>>gp

   dtext  60 215 91 total weekly cost
   dtext  60 238 91 currently paid
   dtext  60 261 91 time until collect
   
   dtext 220 215 53 <eval (<VAR.MAN.TOTAL>+<VAR.TAX.TOTAL>)>gp
   dtext 220 238 <eval <VAR.PAID.CLR>> <eval <LINK.TAG.PAID>>gp ( <eval (<LINK.TAG.PAID>/(<VAR.TAX.TOTAL>+<VAR.MAN.TOTAL>))> weeks )
   dtext 220 261 67 <eval <var.days>> days, <eval <var.hours>> hours

   button 240 310 <eval 015c3> <eval 015c4> 1 0 30		// costs
   dtext  120 320 0 pay total cost
   dtext  120 337 0 for one week
   
PAGE 3

   gumppic    0  360 <eval   0cc>
   gumppic  471  360 <eval   0cd>
   gumppic   44  360 <eval   0e9>
   gumppic  350  360 <eval   0cd>

   dtext 160 27 0 PEOPLE

   text <VAR.FRIENDS.0.TEXT>
   button <VAR.FRIENDS.0.BT1>
   button <VAR.FRIENDS.0.BT2>
   text <VAR.FRIENDS.1.TEXT>
   button <VAR.FRIENDS.1.BT1>
   button <VAR.FRIENDS.1.BT2>
   text <VAR.FRIENDS.2.TEXT>
   button <VAR.FRIENDS.2.BT1>
   button <VAR.FRIENDS.2.BT2>
   text <VAR.FRIENDS.3.TEXT>
   button <VAR.FRIENDS.3.BT1>
   button <VAR.FRIENDS.3.BT2>
   text <VAR.FRIENDS.4.TEXT>
   button <VAR.FRIENDS.4.BT1>
   button <VAR.FRIENDS.4.BT2>
   text <VAR.FRIENDS.5.TEXT>
   button <VAR.FRIENDS.5.BT1>
   button <VAR.FRIENDS.5.BT2>
   text <VAR.FRIENDS.6.TEXT>
   button <VAR.FRIENDS.6.BT1>
   button <VAR.FRIENDS.6.BT2>
   text <VAR.FRIENDS.7.TEXT>
   button <VAR.FRIENDS.7.BT1>
   button <VAR.FRIENDS.7.BT2>
   text <VAR.FRIENDS.8.TEXT>
   button <VAR.FRIENDS.8.BT1>
   button <VAR.FRIENDS.8.BT2>
   text <VAR.FRIENDS.9.TEXT>
   button <VAR.FRIENDS.9.BT1>
   button <VAR.FRIENDS.9.BT2>
   text <VAR.FRIENDS.10.TEXT>
   button <VAR.FRIENDS.10.BT1>
   button <VAR.FRIENDS.10.BT2>
   text <VAR.FRIENDS.11.TEXT>
   button <VAR.FRIENDS.11.BT1>
   button <VAR.FRIENDS.11.BT2>
   text <VAR.FRIENDS.12.TEXT>
   button <VAR.FRIENDS.12.BT1>
   button <VAR.FRIENDS.12.BT2>
   text <VAR.FRIENDS.13.TEXT>
   button <VAR.FRIENDS.13.BT1>
   button <VAR.FRIENDS.13.BT2>
   text <VAR.FRIENDS.14.TEXT>
   button <VAR.FRIENDS.14.BT1>
   button <VAR.FRIENDS.14.BT2>
   text <VAR.FRIENDS.15.TEXT>
   button <VAR.FRIENDS.15.BT1>
   button <VAR.FRIENDS.15.BT2>
   text <VAR.FRIENDS.16.TEXT>
   button <VAR.FRIENDS.16.BT1>
   button <VAR.FRIENDS.16.BT2>
   text <VAR.FRIENDS.17.TEXT>
   button <VAR.FRIENDS.17.BT1>
   button <VAR.FRIENDS.17.BT2>
   text <VAR.FRIENDS.18.TEXT>
   button <VAR.FRIENDS.18.BT1>
   button <VAR.FRIENDS.18.BT2>
   text <VAR.FRIENDS.19.TEXT>
   button <VAR.FRIENDS.19.BT1>
   button <VAR.FRIENDS.19.BT2>


   button 290 60 <eval 015bd> <eval 015be> 1 0 50		
   dtext  260 120 0 Add trusted person
   dtext  270 135 0 to the structure.

PAGE 4

   gumppic    0  360 <eval   0cc>
   gumppic  471  360 <eval   0cd>
   gumppic   44  360 <eval   0e9>
   gumppic  350  360 <eval   0cd>

   dtext 160 27 0 PEOPLE

   text <VAR.FRIENDS.20.TEXT>
   button <VAR.FRIENDS.20.BT1>
   button <VAR.FRIENDS.20.BT2>
   text <VAR.FRIENDS.21.TEXT>
   button <VAR.FRIENDS.21.BT1>
   button <VAR.FRIENDS.21.BT2>
   text <VAR.FRIENDS.22.TEXT>
   button <VAR.FRIENDS.22.BT1>
   button <VAR.FRIENDS.22.BT2>
   text <VAR.FRIENDS.23.TEXT>
   button <VAR.FRIENDS.23.BT1>
   button <VAR.FRIENDS.23.BT2>
   text <VAR.FRIENDS.24.TEXT>
   button <VAR.FRIENDS.24.BT1>
   button <VAR.FRIENDS.24.BT2>
   text <VAR.FRIENDS.25.TEXT>
   button <VAR.FRIENDS.25.BT1>
   button <VAR.FRIENDS.25.BT2>
   text <VAR.FRIENDS.26.TEXT>
   button <VAR.FRIENDS.26.BT1>
   button <VAR.FRIENDS.26.BT2>
   text <VAR.FRIENDS.27.TEXT>
   button <VAR.FRIENDS.27.BT1>
   button <VAR.FRIENDS.27.BT2>
   text <VAR.FRIENDS.28.TEXT>
   button <VAR.FRIENDS.28.BT1>
   button <VAR.FRIENDS.28.BT2>
   text <VAR.FRIENDS.29.TEXT>
   button <VAR.FRIENDS.29.BT1>
   button <VAR.FRIENDS.29.BT2>
   text <VAR.FRIENDS.30.TEXT>
   button <VAR.FRIENDS.30.BT1>
   button <VAR.FRIENDS.30.BT2>
   text <VAR.FRIENDS.31.TEXT>
   button <VAR.FRIENDS.31.BT1>
   button <VAR.FRIENDS.31.BT2>
   text <VAR.FRIENDS.32.TEXT>
   button <VAR.FRIENDS.32.BT1>
   button <VAR.FRIENDS.32.BT2>
   text <VAR.FRIENDS.33.TEXT>
   button <VAR.FRIENDS.33.BT1>
   button <VAR.FRIENDS.33.BT2>
   text <VAR.FRIENDS.34.TEXT>
   button <VAR.FRIENDS.34.BT1>
   button <VAR.FRIENDS.34.BT2>
   text <VAR.FRIENDS.35.TEXT>
   button <VAR.FRIENDS.35.BT1>
   button <VAR.FRIENDS.35.BT2>
   text <VAR.FRIENDS.36.TEXT>
   button <VAR.FRIENDS.36.BT1>
   button <VAR.FRIENDS.36.BT2>
   text <VAR.FRIENDS.37.TEXT>
   button <VAR.FRIENDS.37.BT1>
   button <VAR.FRIENDS.37.BT2>
   text <VAR.FRIENDS.38.TEXT>
   button <VAR.FRIENDS.38.BT1>
   button <VAR.FRIENDS.38.BT2>
   text <VAR.FRIENDS.39.TEXT>
   button <VAR.FRIENDS.39.BT1>
   button <VAR.FRIENDS.39.BT2>


   button 290 60 <eval 015bd> <eval 015be> 1 0 50		
   dtext  260 120 0 Add trusted person
   dtext  270 135 0 to the structure.

PAGE 5
   dtext 160 27 0 OPTIONS


[DIALOG d_house_sign TEXT]
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(0).NAME>	// friend 0
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(1).NAME>	// friend 1
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(2).NAME>	// friend 2
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(3).NAME>	// friend 3
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(4).NAME>	// friend 4
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(5).NAME>	// friend 5
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(6).NAME>	// friend 6
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(7).NAME>	// friend 7
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(8).NAME>	// friend 8
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(9).NAME>	// friend 9
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(10).NAME>	// friend 10
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(11).NAME>	// friend 11
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(12).NAME>	// friend 12
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(13).NAME>	// friend 13
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(14).NAME>	// friend 14
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(15).NAME>	// friend 15
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(16).NAME>	// friend 16
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(17).NAME>	// friend 17
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(18).NAME>	// friend 18
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(19).NAME>	// friend 19
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(20).NAME>	// friend 20
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(21).NAME>	// friend 21
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(22).NAME>	// friend 22
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(23).NAME>	// friend 23
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(24).NAME>	// friend 24
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(25).NAME>	// friend 25
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(26).NAME>	// friend 26
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(27).NAME>	// friend 27
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(28).NAME>	// friend 28
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(29).NAME>	// friend 29
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(30).NAME>	// friend 30
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(31).NAME>	// friend 31
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(32).NAME>	// friend 32
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(33).NAME>	// friend 33
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(34).NAME>	// friend 34
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(35).NAME>	// friend 35
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(36).NAME>	// friend 36
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(37).NAME>	// friend 37
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(38).NAME>	// friend 38
<SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(39).NAME>	// friend 39



[ITEMDEF i_openbank]
ID	= i_memory
TYPE	= t_eq_script
LAYER	= layer_special

ON = @Timer
   if ( (<CONT.P.x> != <MOREx>) || (<CONT.P.y> != <MOREy>) )
      CONT.SYSMESSAGE You cancel the request to access the bank account.
      remove
      return 1
   endif
   CONT.BANKSELF
   CONT.SYSMESSAGE You receive access to your bank account.
   remove
   return 1


[ITEMDEF i_house_trust]
ID	= i_scroll_blank
NAME	= house trust
TYPE	= t_script
LAYER	= 0

ON = @Click
   MESSAGE <LINK.NAME>
   return 1


[DIALOG d_house_sign BUTTON]
ONBUTTON = 10
  if ( <src.findid( i_openbank ).uid> )
     if ( <src.findid( i_openbank ).timer> < 1 )
        src.findid.i_openbank.remove
     else
        src.sysmessage You already requested access to your account. Please wait.
        return 1
     endif
  endif
  if ( <DISTANCE> > 5 )
     SRC.SYSMESSAGE You are too far away.
     return 1
  endif
  src.newitem	= i_openbank
  src.act.morep	= <src.p>
  SRC.ACT.TIMER	= 5
  src.act.EQUIP
  SRC.SYSMESSAGE You requested access to your bank account. Please wait here.

ONBUTTON = 30
  LOCAL.TEMP = <UID.<LINK.MORE1>.UID>
  IF (<EVAL 0<LOCAL.TEMP>> > 0)
     IF !<UID.<LINK.MORE1>.FIND_THIS_HOUSE <LINK.UID>>
        TRY UID.<LINK.MORE1>.NEWITEM i_memory
        TRY UID.<LINK.MORE1>.ACT.NAME=<NAME>
        TRY UID.<LINK.MORE1>.ACT.COLOR=0100
        TRY UID.<LINK.MORE1>.ACT.TYPE = t_eq_memory_obj
        TRY UID.<LINK.MORE1>.ACT.LINK = <LINK.UID>
        TRY UID.<LINK.MORE1>.ACT.ATTR = 04
        TRY UID.<LINK.MORE1>.ACT.TIMER = -1
        TRY UID.<LINK.MORE1>.EQUIP = <UID.<LINK.MORE1>.ACT> 
     ENDIF
  ELSE
     SERV.LOG <NAME>[<UID>] is owned by 'O'
     SRC.SYSMESSAGE This house cannot be paid due to having no owner.
     RETURN 1
  ENDIF
  
  IF !<ISRENTPAYABLE>
     SRC.SYSMESSAGE The owner of this house has too many homes or this house is in a no build zone.  Rent cannot be paid.
     RETURN 1
  ELSEIF ( <DISTANCE> > 5 )
     SRC.SYSMESSAGE You are too far away.
     return 1
  endif
  
  
  LOCAL.SCOMPARE=<STRSUB 0 21 <LINK.REGION.NAME>>
//  IF strmatch("<LOCAL.SCOMPARE>","Britain Territory PVP")
//     IF (<LINK.TAG0.TIMESPAID> >= 6)
//        SRC.SYSMESSAGE Britain houses are limited lease houses (6 wks).  This house's rent has been extended to the maximum allowed for this region.
//        RETURN 1
 //    ENDIF
 // ENDIF

  house_init_costs
  VAR.ADJUST	= 0
  if ( <VAR.TOTAL> == 0 )
     VAR.TOTAL	= 100
  endif
  
  if ( (<LINK.TAG.PAID> / <VAR.TOTAL>) > 6 )
     src.sysmessage You can't pay over 6 weeks in advance.
     return 1
  endif

  if ( (<LINK.TAG.PAID> > 0) && (<LINK.TAG.PAID> < <VAR.TOTAL>) )
     VAR.TOTAL	= <eval (<var.total> - <LINK.TAG.PAID>)>
     VAR.ADJUST	= 1
  endif

  src.consumegold_everywhere <VAR.TOTAL>
  if ( <VAR.CONSUMEGOLD> > 0 )
     if ( <VAR.ADJUST> )
        src.sysmessage You are <eval <VAR.CONSUMEGOLD>>gp short for the adjustment of <eval <var.total>>gp.
     else
        src.sysmessage You are <eval <VAR.CONSUMEGOLD>>gp short of the <eval <var.total>>gp.
     endif
     return 1
  endif
  if ( <VAR.ADJUST> )
     src.sysmessage You pay the adjustment of <eval <VAR.TOTAL>>gp.
  else
     SERV.LOG RENT : <src.name> paid rent on <LINK.UID>
     src.sysmessage You pay the <eval <VAR.TOTAL>>gp.
     LINK.TAG.TIMESPAID = <EVAL (<LINK.TAG0.TIMESPAID>+1)>
  endif
  LINK.TAG.PAID	= <eval <LINK.TAG.PAID>+<var.total>>
  COLOR		= house_colour_normal

ONBUTTON = 44
  if !( <LINK.SRCHOUSE_owner> )
    src.sysmessage You do not have the previlege to do that.
    return 1
  elseif ( <strpos 1 42 <argtxt[0]>> > 0 )
    src.sysmessage You cannot use * in your house name
    return 1
  elseif ( <strpos 1 60 <argtxt[0]>> > 0 )
    src.sysmessage You cannot use < in your house name
    return 1
  elseif ( <strpos 1 62 <argtxt[0]>> > 0 )
    src.sysmessage You cannot use > in your house name
    return 1
  elseif ( <strpos 1 63 <argtxt[0]>> > 0 )
    src.sysmessage You cannot use ? in your house name
    return 1
  endif

  LINK.NAME = <argtxt[0]>
  SRC.SYSMESSAGE House renamed.

ONBUTTON = 45
  if !( (<SRC.UID> == <LINK.MORE1>) || (<SRC.ISGM>) )
    src.sysmessage You are not the owner of the house.
    return 1
  elseif ( <SRC.REGION.UID> == <REGION.UID> )
     src.sysmessage You must leave the house in order to bestow ownership.
     return 1
  endif

  var.scompare=<STRSUB 0 21 <uid.<var.hscompare>.region.name>>
  if ( ((!strcmpi("<var.scompare>","Britain Territory PVP"))
     IF (<SRC.ACCOUNT.PLEVEL>=1)
        SRC.SYSMESSAGE You cannot transfer this house.  If you are leaving the game please contact a gm to re-distribute the house.
        RETURN 1
     ENDIF
  endif
  
  SRC.TAG.HOUSEACTION	= 45
  SRC.SYSMESSAGE @28 WARNING: Use of this option will transfer ALL rights you have on this property to someone else.
  SRC.SYSMESSAGE (hint: if you have a secure trade window open, this will accept the trade immediatly). Who would you like to bestow ownership upon?
  TARGET

ONBUTTON = 46
  if !( (<SRC.UID> == <LINK.MORE1>) || (<SRC.ISGM>) )
    src.sysmessage You are not the owner of the house.
    return 1
  endif

  MENU mnu_house_scrap
  return 1

ONBUTTON = 47
  if !( <LINK.SRCHOUSE_owner> )
    src.sysmessage You do not have the previlege to do that.
    return 1
  endif

  if !( <SRC.ISGM> )
    src.consumegold_everywhere <house_license>
    if ( <var.consumegold> > 0 )
       src.sysmessage You are <eval <var.consumegold>>gp short in your account.
       return 0
    endif
  endif

  SRC.NEWITEM i_construction_license
  SRC.ACT.LINK	= <LINK.UID>
  SRC.ACT.BOUNCE

ONBUTTON = 48
  IF !( (<SRC.UID> == <LINK.MORE1>) || (<SRC.ISGM>) )
     SRC.SYSMESSAGE You are not the owner of the house.
     RETURN 1
  ELSEIF <SRC.FINDID.M_Preview_Door_Color.UID>
     SRC.SYSMESSAGE Please wait until the preview is complete.
     RETURN 1
  ENDIF
  
  SRC.TAG.HOUSEACTION	= 48
  MENU mnu_house_door
  TAG.DOOR_WOOD=
  TAG.DOOR_GOLD=
  TAG.DOOR_COLOR=


ONBUTTON = 50
  if ( !<SRC.ISGM> && (<SRC.UID> != <LINK.MORE1>) )
     LINK.FINDFRIEND <SRC.UID>
     if ( 0<VAR.FINDFRIEND> == 0 )
        src.sysmessage You are not trusted to do that.
        return 1
     endif
     SRC.ACT	= <VAR.FINDFRIEND>
     if ( <SRC.ACT.MOREx> == 0 )
        src.sysmessage You do not have full previleges on this house.
	return 1
     endif
  endif
  SRC.TAG.HOUSEACTION	= 50
  TARGET Who would you like to add as friend of the house?
  return 1

ONBUTTON = 51
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What item would you like to lock?
  SRC.TAG.HOUSEACTION	= 51

ONBUTTON = 52
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What item would you like to unlock?
  SRC.TAG.HOUSEACTION	= 52

ONBUTTON = 53
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What item would you like to raise?
  SRC.TAG.HOUSEACTION	= 53

ONBUTTON = 54
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What item would you like to lower?
  SRC.TAG.HOUSEACTION	= 54

ONBUTTON = 55
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif

  if ( <LINK.BASEID> == i_multi_struct )
     TARGET What item would you like to flip?
  else
     TARGET What structure would you like to flip?
  endif
  SRC.TAG.HOUSEACTION	= 55

ONBUTTON = 56
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What structure would you like to destroy?
  SRC.TAG.HOUSEACTION	= 56

ONBUTTON = 57
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What structure would you like to redeed?
  SRC.TAG.HOUSEACTION	= 57


ONBUTTON = 58
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What item would you like to raise?
  SRC.TAG.HOUSEACTION	= 58

ONBUTTON = 59
  if !( <LINK.SRCHOUSE_owner> )
     SRC.SYSMESSAGE You don't have enough previleges to do that.
     return 1
  endif
  TARGET What item would you like to lower?
  SRC.TAG.HOUSEACTION	= 59

ONBUTTON = 60 99
  house_friend_button1 <EVAL (<ARGN1>-60)>
  return 1

ONBUTTON = 100 139
  house_friend_button2 <EVAL (<ARGN1>-100)>
  return 1


[FUNCTION house_friend_button2]
  SRC.ACT	= <SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(<args>).uid>

  if ( !<SRC.ISGM> && <SRC.UID> != <LINK.MORE1> )
     src.sysmessage Only the owner of the house can grant or remove full previleges.
     return 1
  endif

  if ( <SRC.ACT.MOREx> )
     src.sysmessage Full previleges removed for <SRC.ACT.LINK.NAME>.
     SRC.ACT.MOREx	= 0
     return 1
  endif

  local.scompare=<STRSUB 0 21 <REGION.NAME>>
  IF strmatch("<local.scompare>","Britain Territory PVP")
     IF ( <COUNT_BB_TRUSTS <SRC.ACT.LINK.UID>> >= 4 )
       SRC.SYSMESSAGE <SRC.ACT.LINK.NAME> is already full-trusted on 4 Brit Bridge houses, they cannot be trusted on any more.
        SRC.ACT.LINK.SYSMESSAGE You are already full-trusted on 4 Brit Bridge houses, you cannot be trusted on any more
        RETURN 1
     ENDIF
  ENDIF

  SRC.SYSMESSAGE Full previleges added for <SRC.ACT.LINK.NAME>.
  SRC.ACT.MOREx	= 1
  SRC.ACT.NAME	= <SRC.ACT.LINK.NAME> (by <SRC.UID.<LINK.MORE1>.NAME>)
  SRC.ACT.MORE2	= <LINK.MORE1>
  
  
[FUNCTION house_friend_button1]

var.hscompare=<link.link>

  SRC.ACT	= <SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(<args>).uid>

  if ( !<SRC.ISGM> )
    if ( <SRC.ACT.LINK.UID> == <SRC.UID> )
       src.sysmessage You can't remove yourself from the list of trusted persons of the house.
       return 1
    endif

    if ( <SRC.UID> != <LINK.MORE1> )
       if ( <SRC.UID> != <SRC.ACT.MORE2> )
          if ( <SRC.ACT.MORE2> == <LINK.MORE1> )
             src.sysmessage You can't remove trust from that person, only <SRC.UID.<SRC.ACT.MORE2>.NAME> can.
	  else
	     src.sysmessage You can't remove trust from that person, only <SRC.UID.<SRC.ACT.MORE2>.NAME> or <SRC.UID.<LINK.MORE1>.NAME> can.
	  endif
          return 1
       endif
    endif
  endif
  
  SRC.TAG.HOUSE.REMOVING	= <SRC.ACT.UID>
  SRC.MENU mnu_house_friend_button1

[MENU mnu_house_friend_button1]
Are you sure you want to remove <SRC.ACT.LINK.NAME> from the list of trusted persons of this house?

ON = 0 Yes!

   SRC.ACT	= <SRC.TAG.HOUSE.REMOVING>
   if ( <SRC.ACT.BASEID> != i_house_trust )
      SRC.SYSMESSAGE Already removed!
      return 1
   endif
   SRC.SYSMESSAGE <SRC.ACT.LINK.NAME> is no longer a trusted person of the house.
   SRC.ACT.REMOVE

   var.scompare=<STRSUB 0 21 <uid.<var.hscompare>.region.name>>
   if ( ((!strcmpi("<var.scompare>","Britain Territory PVP"))
        try uid.<var.hscompare>.tag.trustcount=<eval 0<uid.<var.hscompare>.tag.trustcount>-1>
	try uid.bb_house_uid.tag.<SRC.ACT.LINK.account>=
	var.scompare=
	var.hscompare=
	return 1
   endif
   var.scompare=
   var.hscompare=

   return 1


[MENU mnu_house_scrap]
Demolishing this house and scraping its parts will generate <eval ((<LINK.VALUE>*4)/5)>gps of income. All items locked to it will be destroyed. Are you sure you want to demolish the house? (NOTE: If this is a town structure it will only generate <eval (<LINK.VALUE>/2)>gps.)

ON = 0 Yes!
   if !( (<SRC.UID> == <LINK.MORE1>) || (<SRC.ISGM>) )
     src.sysmessage You are not the owner of the house.
     return 1
   endif

var.scompare=<STRSUB 0 21 <region.name>>

 //if ( ((!strcmpi("<var.scompare>","Britain Territory PVP"))
         //src.sysmessage @0108 You cannot scrap a house in this region!
	 //var.scompare=
         //return 1
     //else
         SERV.LOG <SRC.ACCOUNT> (<SRC.NAME>) scrapped a '<LINK.NAME>' at (<LINK.P>).

   	 SRC.NEWITEM	i_check
  	 IF ( 0<LINK.TAG.TOWNITEM> = 01)
 	     SRC.ACT.MORE2	= <eval (<LINK.VALUE>/2)>
	   ELSE
 	     SRC.ACT.MORE2	= <eval ((<LINK.VALUE>*4)/5)>
	   ENDIF
	   SRC.ACT.CONT		= <SRC.findlayer(layer_bankbox).uid>
	   SRC.SYSMESSAGE A cheque worth <eval <SRC.ACT.MORE2>>gps has been issued to your bank.
	   LINK.REMOVE
	   var.scompare=
	   return 1
 //endif
   var.scompare=
   return 1


[FUNCTION house_init_friend]
   if ( <SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(<args>).uid> == 0 )
      TRY VAR.FRIENDS.<args>.TEXT		= 300 80 0 59		// out of screen
      TRY VAR.FRIENDS.<args>.BT1		= 300 80 <eval 0d8> <eval 0d8> 0 3 0
      TRY VAR.FRIENDS.<args>.BT2		= 300 80 <eval 0d8> <eval 0d8> 0 3 0
      return 0
   endif

   if (<argn>>=20)
      TRY VAR.FRIENDS.<args>.BT1		= 40 <eval (53+((<args>+-20)*16))> <eval 0146f> <eval 0d7> 1 3 <eval (60+<args>)>
      TRY VAR.FRIENDS.<args>.TEXT		= 95 <eval (50+((<args>+-20)*16))> 0 <eval <args>>

      if ( <SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(<args>).MOREx> == 0 )
         TRY VAR.FRIENDS.<args>.BT2		= 70 <eval (54+((<args>+-20)*16))> <eval 0d7> <eval 0d8> 1 3 <eval (100+<args>)>
      else
         TRY VAR.FRIENDS.<args>.BT2		= 70 <eval (54+(<args>+-20)*16))> <eval 0d8> <eval 0d7> 1 3 <eval (100+<args>)>
      endif
   else 
      TRY VAR.FRIENDS.<args>.BT1		= 40 <eval (53+(<args>*16))> <eval 0146f> <eval 0d7> 1 3 <eval (60+<args>)>
      TRY VAR.FRIENDS.<args>.TEXT		= 95 <eval (50+(<args>*16))> 0 <eval <args>>

      if ( <SRC.UID.<LINK.TAG.FRIENDS.UID>.findcont(<args>).MOREx> == 0 )
         TRY VAR.FRIENDS.<args>.BT2		= 70 <eval (54+(<args>*16))> <eval 0d7> <eval 0d8> 1 3 <eval (100+<args>)>
      else
         TRY VAR.FRIENDS.<args>.BT2		= 70 <eval (54+(<args>*16))> <eval 0d8> <eval 0d7> 1 3 <eval (100+<args>)>
      endif
   endif

//
//
//
//
//
[ItemDef M_Exit_Delay]
id=i_memory
Name=Exit Delay
type=t_eq_script

ON=@Create
   MORE2    = 0
   TIMER    = 1

ON=@Timer
   IF (<EVAL <MORE2>>=7)
      IF (<CONT.REGION.UID>=<MORE1>)
         CONT.GO <MOREP>
         CONT.SYSMESSAGE You Manage to slip out the door.
      ENDIF
      Remove 
   ELSE
      TIMER=1
      MORE2=<EVAL (<MORE2>+1)>
   ENDIF
   RETURN 1


[ITEMDEF 06a5]
DEFNAME=i_door_wood
RESOURCES=25 I_log
TYPE=T_DOOR
CATEGORY=Buildings - Doors
SUBSECTION=Wooden Door 1
DESCRIPTION=@ (n / sw)
DUPELIST=06a7,06a9,06ab,06ad,06af,06b1,06b3

ON = @SpellEffect
   return 1

ON = @DClick        
   if ( <SRC.ISDEAD> )
      SRC.SYSMESSAGE "Get a life..."
      return 0
   endif
   
   if ( <TYPE> == t_door_open )
      TIMER	= 1
      return 1
   endif

   if ( (<LINK> == 04fffffff) || (<LINK.TYPE> != t_multi) )
      return 0
   endif

   if ( <TIMER> > 0 )
      TIMER = 1
      return 1
   endif

   if ( <TYPE> == t_door )
      TYPE	= t_door_locked
   endif

   if ( <LINK.SRCHOUSE_owner> )
   elseif ( <LINK.SRCHOUSE_friend> ) 
     if !( <ATTR> & attr_blessed )
        //Partial Friend is West of Door
        IF ((<SRC.P.X> < <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06ad)||(<DISPID>=06af)) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<EVAL (<P.X>+1)>,<P.Y>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF
	   
        //Partial Friend is East of Door
        ELSEIF ((<SRC.P.X> > <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06b1)||(<DISPID>=06b3)) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<EVAL (<P.X>-1)>,<P.Y>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF

	//Partial Friend is North of Door
        ELSEIF ((<SRC.P.Y> < <P.Y>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=i_door_wood)||(<DISPID>=06a7)) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>+1)>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF

	//Partial Friend is South of Door
        ELSEIF ((<SRC.P.Y> > <P.Y>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06a9)||(<DISPID>=06ab)) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>-1)>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF
	ELSE
           SRC.SYSMESSAGE You are not trusted enough to enter.        
        ENDIF
        return 1
     endif
   else
     //Player is West of Door
     IF ((<SRC.P.X> < <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06ad)||(<DISPID>=06af)) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
    	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<EVAL (<P.X>+1)>,<P.Y>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF
   
     //Player is East of Door
     ElseIF ((<SRC.P.X> > <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06b1)||(<DISPID>=06b3)) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
    	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<EVAL (<P.X>-1)>,<P.Y>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF

     //Player is North of Door
     ELSEIF ((<SRC.P.Y> < <P.Y>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=i_door_wood)||(<DISPID>=06a7)) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>+1)>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF
     
     //Player is South of Door
     ELSEIF ((<SRC.P.Y> > <P.Y>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06a9)||(<DISPID>=06ab)) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>-1)>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF
     ELSE
        SRC.SYSMESSAGE This structure belongs to <src.uid.<LINK.MORE1>.name>, and you're not allowed to enter!
     ENDIF
     return 1
   endif

   if ( <LINK.TAG.STATUS> = house_status_auction )
         SRC.SYSMESSAGE This structure may not be entered until the auction is over.
         return 1
   endif

   TYPE	= t_door
   return 0
 
ON = @Timer
   if ( (<LINK> == 04fffffff) || (<LINK.TYPE> != t_multi) )
      return 0
   endif

   TYPE	= t_door_locked


[ITEMDEF 0866]
DEFNAME=i_gate_wood_3
RESOURCES=25 I_BOARD
TYPE=T_DOOR
CATEGORY=Buildings - Doors
SUBSECTION=Wooden Gate 2
DESCRIPTION=@ (n / sw)
DUPELIST=0867,0868,0869,086a,086b,086c,086d,086e,086f,0870,0871,0872,0873,0874,0875

ON = @SpellEffect
   return 1

ON = @DClick        
   if ( <SRC.ISDEAD> )
      SRC.SYSMESSAGE "Get a life..."
      return 0
   endif

   if ( <TYPE> == t_door_open )
      TIMER	= 1
      return 1
   endif

   if ( (<LINK> == 04fffffff) || (<LINK.TYPE> != t_multi) )
      return 0
   endif

   if ( <TIMER> > 0 )
      TIMER = 1
      return 1
   endif

   if ( <TYPE> == t_door )
      TYPE	= t_door_locked
   endif

   if ( <LINK.SRCHOUSE_owner> )
   elseif ( <LINK.SRCHOUSE_friend> ) 
     if !( <ATTR> & attr_blessed )
     
        //Partial Friend is West of Door
        IF ((<SRC.P.X> < <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06ad)||(<DISPID>=06af)) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<EVAL (<P.X>+1)>,<P.Y>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF
	
        //Partial Friend is East of Door
        ELSEIF ((<SRC.P.X> > <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06b1)||(<DISPID>=06b3)) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<EVAL (<P.X>-1)>,<P.Y>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF

	//Partial Friend is North of Door
        ELSEIF ((<SRC.P.Y> < <P.Y>) && (<SRC.P.Z> = <P.Z>) && (<DISPID>=i_door_wood) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>+1)>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF

	//Partial Friend is South of Door
        ELSEIF ((<SRC.P.Y> > <P.Y>) && (<SRC.P.Z> = <P.Z>) && (<DISPID>=06a9) && (<SRC.REGION.UID>=<MORE1>))
           IF !<SRC.FINDID.M_EXIT_DELAY.UID>
              SRC.NEWITEM M_Exit_Delay
	      SRC.ACT.MORE1=<MORE1>
	      SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>-1)>,<P.Z>
	      SRC.EQUIP <SRC.ACT>
	      SRC.EMOTE try to exit.
	   ENDIF
	ELSE
           SRC.SYSMESSAGE You are not trusted enough to enter.        
        ENDIF
        return 1
     endif
   else
     //Player is West of Door
     IF ((<SRC.P.X> < <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06ad)||(<DISPID>=06af)) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
    	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<EVAL (<P.X>+1)>,<P.Y>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF
	
     //Player is East of Door
     ElseIF ((<SRC.P.X> > <P.X>) && (<SRC.P.Z> = <P.Z>) && ((<DISPID>=06b1)||(<DISPID>=06b3)) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
    	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<EVAL (<P.X>-1)>,<P.Y>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF

     //Player is North of Door
     ELSEIF ((<SRC.P.Y> < <P.Y>) && (<SRC.P.Z> = <P.Z>) && (<DISPID>=i_door_wood) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
	   SRC.ACT.MORE1=<MORE1>
	   SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>+1)>,<P.Z>
	   SRC.EQUIP <SRC.ACT>
	   SRC.EMOTE try to exit.
	ENDIF

     //Partial Friend is South of Door
     ELSEIF ((<SRC.P.Y> > <P.Y>) && (<SRC.P.Z> = <P.Z>) && (<DISPID>=06a9) && (<SRC.REGION.UID>=<MORE1>))
        IF !<SRC.FINDID.M_EXIT_DELAY.UID>
           SRC.NEWITEM M_Exit_Delay
           SRC.ACT.MORE1=<MORE1>
           SRC.ACT.MOREP=<P.X>,<EVAL (<P.Y>-1)>,<P.Z>
           SRC.EQUIP <SRC.ACT>
           SRC.EMOTE try to exit.
        ENDIF
     ELSE
        SRC.SYSMESSAGE This structure belongs to <src.uid.<LINK.MORE1>.name>, and you're not allowed to enter!
     ENDIF
     return 1
   endif
   
   if ( <LINK.TAG.STATUS> = house_status_auction )
         SRC.SYSMESSAGE This structure may not be entered until the auction is over.
         return 1
   endif

   TYPE	= t_door
   return 0
 
ON = @Timer
   if ( (<LINK> == 04fffffff) || (<LINK.TYPE> != t_multi) )
      return 0
   endif

   TYPE	= t_door_locked



[MENU mnu_house_door]
Select the wood type you would like to change to.  After selection you will have to target the door you want to change.  Prices and Logs requirements will only change one door.

ON = 0 Pine - 10 Pine Logs
   IF !<SRC.RESTEST 10 i_log_pine>
      SRC.SYSMESSAGE You need 10 pine logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_pine
   TAG.DOOR_GOLD=0
   TAG.DOOR_COLOR=0
   return 1

ON = 1 Eucalyptus - 10 Eucalyptus Logs - 50k
   IF !<SRC.RESTEST 10 i_log_eucalyptus>
      SRC.SYSMESSAGE You need 10 eucalyptus logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_eucalyptus
   TAG.DOOR_GOLD=50000
   TAG.DOOR_COLOR=02e
   return 1

ON = 2 Rose - 10 Rose Logs - 60k
   IF !<SRC.RESTEST 10 i_log_rose>
      SRC.SYSMESSAGE You need 10 rose logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_rose
   TAG.DOOR_GOLD=60000
   TAG.DOOR_COLOR=088
   return 1

ON = 3 Holly - 10 Holly Logs - 70k
   IF !<SRC.RESTEST 10 i_log_holly>
      SRC.SYSMESSAGE You need 10 holly logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_holly
   TAG.DOOR_GOLD=70000
   TAG.DOOR_COLOR=0300
   return 1

ON = 4 Oak - 10 Oak Logs - 80k
   IF !<SRC.RESTEST 10 i_log_oak>
      SRC.SYSMESSAGE You need 10 oak logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_oak
   TAG.DOOR_GOLD=80000
   TAG.DOOR_COLOR=021e
   return 1

ON = 5 Ironwood - 10 Ironwood Logs - 90k
   IF !<SRC.RESTEST 10 i_log_ironwood>
      SRC.SYSMESSAGE You need 10 ironwood logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_ironwood
   TAG.DOOR_GOLD=90000
   TAG.DOOR_COLOR=0763
   return 1

ON = 6 Mahogany - 10 Mahogany Logs - 100k
   IF !<SRC.RESTEST 10 i_log_mahogany>
      SRC.SYSMESSAGE You need 10 mahogany logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_mahogany
   TAG.DOOR_GOLD=100000
   TAG.DOOR_COLOR=0608
   return 1

ON = 7 Cherry - 10 Cherry Logs - 110k
   IF !<SRC.RESTEST 10 i_log_cherry>
      SRC.SYSMESSAGE You need 10 cherry logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_cherry
   TAG.DOOR_GOLD=110000
   TAG.DOOR_COLOR=0151
   return 1

ON = 8 Interleaved - 10 Interleaved Logs - 120k
   IF !<SRC.RESTEST 10 i_log_interleaved>
      SRC.SYSMESSAGE You need 10 interleaved logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_interleaved
   TAG.DOOR_GOLD=120000
   TAG.DOOR_COLOR=090
   return 1

ON = 9 Composite - 10 Composite Logs - 130k
   IF !<SRC.RESTEST 10 i_log_composite>
      SRC.SYSMESSAGE You need 10 composite logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_composite
   TAG.DOOR_GOLD=130000
   TAG.DOOR_COLOR=0488
   return 1

ON = 10 Imbued Cherry - 10 Imbued Logs - 140k
   IF !<SRC.RESTEST 10 i_imbued_cherry>
      SRC.SYSMESSAGE You need 10 imbued cherry logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_imbued_cherry
   TAG.DOOR_GOLD=140000
   TAG.DOOR_COLOR=025
   return 1

ON = 11 Myst - 10 Myst Logs - 150k
   IF !<SRC.RESTEST 10 i_log_myst>
      SRC.SYSMESSAGE You need 10 myst logs to change to this wood.
      RETURN 1
   ENDIF
   TARGET Target the door you would like to change.
   TAG.DOOR_WOOD=i_log_myst
   TAG.DOOR_GOLD=150000
   TAG.DOOR_COLOR=07a0
   return 1

ON = 12 Preview colors
   TARGET Target the door you would like to preview the woods on.
   return 1


[ItemDef M_Preview_Door_Color]
id=i_memory
Name=Door Preview Timer
type=t_eq_script

ON=@Create
   TIMER=2
   MORE1=0

ON=@Timer
   IF (<MORE1>=0)
      CONT.SYSMESSAGE Pine
      LINK.COLOR = 0
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=1)
      CONT.SYSMESSAGE Eucalyptus
      LINK.COLOR = 02e
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=2)
      CONT.SYSMESSAGE Rose
      LINK.COLOR = 088
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=3)
      CONT.SYSMESSAGE Holly
      LINK.COLOR = 0300
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=4)
      CONT.SYSMESSAGE Oak
      LINK.COLOR = 021e
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=5)
      CONT.SYSMESSAGE Ironwood
      LINK.COLOR = 0763
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=6)
      CONT.SYSMESSAGE Mahogany
      LINK.COLOR = 0608
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=7)
      CONT.SYSMESSAGE Cherry
      LINK.COLOR = 0151
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=8)
      CONT.SYSMESSAGE Interleaved
      LINK.COLOR = 090
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=9)
      CONT.SYSMESSAGE Composite
      LINK.COLOR = 0488
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=10)
      CONT.SYSMESSAGE Imbued Cherry
      LINK.COLOR = 025
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=11)
      CONT.SYSMESSAGE Myst
      LINK.COLOR = 07a0
      MORE1=(<MORE1>+1)
      TIMER=2
   ELSEIF (<MORE1>=12)
      LINK.COLOR = <COLOR>
      REMOVE
   ENDIF
   RETURN 1


[FUNCTION HOUSECOUNT]
SRC.SYSMESSAGE You have <EVAL <SRC.HOUSE_COUNT>> house(s).
RETURN 1

[FUNCTION HOUSE_COUNT]
   //check if they have another house
   VAR.HOUSECOUNT = 0
   
   TRY UID.<SRC.ACCOUNT.CHAR.0.UID>.CHAR_HOUSE_COUNT
   IF (<SRC.ACCOUNT.CHARS>>1)
      TRY UID.<SRC.ACCOUNT.CHAR.1.UID>.CHAR_HOUSE_COUNT
      IF (<SRC.ACCOUNT.CHARS>>2)
         TRY UID.<SRC.ACCOUNT.CHAR.2.UID>.CHAR_HOUSE_COUNT
         IF (<SRC.ACCOUNT.CHARS>>3)
            TRY UID.<SRC.ACCOUNT.CHAR.3.UID>.CHAR_HOUSE_COUNT
            IF (<SRC.ACCOUNT.CHARS>>4)
               TRY UID.<SRC.ACCOUNT.CHAR.4.UID>.CHAR_HOUSE_COUNT
            ENDIF
         ENDIF
      ENDIF
   ENDIF

   RETURN <EVAL <VAR.HOUSECOUNT>>


[FUNCTION CHAR_HOUSE_COUNT]
   FORCHARMEMORYTYPE memory_guard
      IF <link.type> = t_multi
         IF ( 0<LINK.TAG.TOWNITEM> = 01 )
            //Skip this structure.
         ELSE
            VAR.HOUSECOUNT=<EVAL (<VAR.HOUSECOUNT>+1)>
         ENDIF
      ENDIF
   ENDFOR
   RETURN 1

[FUNCTION FIND_THIS_HOUSE]
   FORCHARMEMORYTYPE memory_guard
      IF (<LINK.UID>=<ARGN>)
         RETURN 1
      ENDIF
   ENDFOR
   RETURN 0
   
[EOF]