//////////////////////////////////////////////////////////////////////////////////////////////
///////       Fishing - net & lobster traps
///////     By: Capes last modified - 2018-04-17 0.56d
//////////////////////////////////////////////////////////////////////////////////////////////
[TEMPLATE random_fish]
ITEM={i_fish_big_1 1 i_fish_big_2 1 i_fish_big_3 1 i_fish_big_4 1 i_fish_small 1 0dd7 1 0dd8 1 0dd9 1 random_cannibalized_fish 1 random_special_fish 1 0dba 1 0dbb 1}
[TEMPLATE random_special_fish]
ITEM={i_fish_makoto_courtesan_fish 1 i_fish_minoc_blue 1 i_fish_britain_crown_fish 1 i_fish_red_dart_fish 1 i_fish_small_mouth_sucker_fin 1 i_fish_fandancer 1 i_fish_golden_broadtail 1 i_fish_albino_courtesan_fish 1 i_fish_spined_scratcher_fish 1 i_fish_nujelm_honey 1 i_fish_yellow_fin_bluebelly 1 i_fish_vesper_reef_tiger 1 i_fish_spotted_bucaneer 1 i_fish_stripped_flake_fish 1}
[TEMPLATE random_cannibalized_fish]
ITEM={03b0c 1 i_fish_raw_whole 1 i_fish_raw_headless 1 i_fish_raw_head}
[TEMPLATE random_crustacean]
ITEM={i_fish_crab 1 044d2 1 i_fish_lobster 1 044d4 1 i_seahorse 1 i_shrimp_brine 1 i_jellyfish 1 i_crab_speckled 1 i_shrimp 1}
//////////////////////////////////////////////////////////////////////////////////////////////
///////       Items - i_net/i_lobster_cage/i_rope
//////////////////////////////////////////////////////////////////////////////////////////////
//fishing net
[ITEMDEF 01ea3]
DEFNAME=i_net
NAME=Fishing Net
FLIP=1
WEIGHT=50.0
VALUE=65
RESOURCES=10 i_rope,10 i_thread,8 i_fishing_weight,1 i_sewing_kit
SKILLMAKE=Tailoring 50.0,Tinkering 30.0,t_tinker_tools
CATEGORY=Items by Professions
SUBSECTION=Fisherman
DESCRIPTION=Weighted Fishing Net
DUPELIST=01ea4,01ea5,01ea6,03d8e,03d8f
ON=@Create
    UsesMax=25
    TAG._bait_type = t_meat_raw
    TAG0._bait_skill_difficulty = 30
    TAG._sea_critter_catch_difficulty = 50
    TAG0._max_catch = 6
    TAG._sea_critters = random_fish
    EVENTs +e_declining_uses
    EVENTs +e_sea_trapping 
    
//lobster trap    
[ITEMDEF 044cf]
DEFNAME=i_lobster_cage
NAME=lobster cage
FLIP=1
WEIGHT=25.0
VALUE=45
RESOURCES=4 i_board,10 i_thread,4 i_fishing_weight,1 i_sewing_kit
SKILLMAKE=Tinkering 20.0,Tailoring 40.0,Carpentry 30.0,t_tinker_tools
CATEGORY=Items by Professions
SUBSECTION=Fisherman
DESCRIPTION=Lobster Cage
DUPELIST=044d0
ON=@Create
    UsesMax=25
    TAG._bait_type = t_meat_raw
    TAG0._bait_skill_difficulty = 30
    TAG._sea_critter_catch_difficulty = 50
    TAG0._max_catch = 4
    TAG._sea_critters = random_crustacean
    EVENTs +e_declining_uses
    EVENTs +e_sea_trapping
    
//rope
[ITEMDEF 014f8]
DEFNAME=i_rope
FLIP=1
WEIGHT=20
TYPE=t_rope
VALUE=25
RESOURCES=40 i_thread
SKILLMAKE=Tinkering 21.0,Tailoring 40.0,t_tinker_tools 
CATEGORY=Decoration - Miscellaneous
SUBSECTION=Nautical
DESCRIPTION=Rope (W)
DUPELIST=014fa
ON=@Create
    UsesMax=25
    EVENTs +e_declining_uses
    EVENTs +e_rope_buoy
    
//////////////////////////////////////////////////////////////////////////////////////////////
///////       Events
//////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////
//// EVENT/TYPEDEF e_sea_trapping
//// -our event handler for ON=@ DClick/TargOn_Ground
//// -enforces targeting of water tiles only
//// -verifies user has the proper bait
//// -moves item to target location, makes it sink
//// -adds a buoy at location, sets buoys properties
//// -links buoy to item
////    -requires the below-
////    TAG._bait_type = the bait type (t_meat_raw)
////    TAG0._bait_skill_difficulty = fishing test to bait (30)
////    TAG._sea_critter_catch_difficulty = fishing test to catch critters (50)
////    TAG0._max_catch = max amount of catch (4)
////    TAG._sea_critters = critter template (random_crustacean)
/////////////////////////////////////////////////////
[TYPEDEF e_sea_trapping]
ON=@DClick
    //target to place item in water
    TARGETG Select deep water to place <name>
    RETURN 1
    
ON=@TargOn_Ground
    //make sure water tile was choosen
    IF ((<serv.map(<src.targp.x>,<src.targp.y>).type>!=t_normal) || (<serv.map(<src.targp.x>,<src.targp.y>).statics.0.dispid>!=i_water))
        src.sysmessage <name> can only be placed in deep water.
        return 1
    ENDIF    
    
    //make sure we have bait
    IF !(<src.findtype.<TAG0._bait_type>>)
        src.sysmessage You have no raw bait.
        return 1
    ENDIF
        
    local._bait = <src.findtype.<TAG0._bait_type>>
    //pass a fishing check to properly bait the net
    if !(<src.skillcheck 18,<dTAG0._bait_skill_difficulty>>)
        src.sysmessage You failed to bait the <name> properly.
        
        src.skillgain 18,<dTAG0._bait_skill_difficulty>
        
        return 1
    endif
    src.skillgain 18,<dTAG0._bait_skill_difficulty>
    
    //remove bait
    UID.<local._bait>.consume 1
    
    //place item in water
    p = <src.targp>
    
    //add splash effect & sound
    serv.newitem 01fa3
    new.p = <p.x>,<eval <p.y>-1>,<p.z>
    new.attr = attr_decay|attr_static
    new.timer = 3
    serv.newitem 01fa8 
    new.p = <eval <p.x>-1>,<p.y>,<p.z>
    new.attr = attr_decay|attr_static
    new.timer = 3
    serv.newitem 01fad 
    new.p = <eval <p.x>+1>,<p.y>,<p.z>
    new.attr = attr_decay|attr_static
    new.timer = 3
    serv.newitem 01fb6 
    new.p = <p.x>,<eval <p.y>+1>,<p.z>
    new.attr = attr_decay|attr_static
    new.timer = 3
    sfx 027 //splash
    
    //sink item    
    timerf 1 f_sink_item 
    
    //add a buoy, set it's properties
    serv.newitem i_lobster_buoy
    new.name = <name> Buoy
    new.p = <p>
    new.attr = attr_move_never
    new.events +e_sea_trapping_retrieval
    new.link = <uid>
    
    return 1
/////////////////////////////////////////////////////
//// FUNCTION f_sink_item
////    - all this does is make the item invisible & static
////    - so it looks to have sunk
/////////////////////////////////////////////////////
[FUNCTION f_sink_item]    
    //make item invisible
    attr = attr_invis|attr_static
    updatex
    
    
    
/////////////////////////////////////////////////////
//// EVENT/TYPEDEF e_sea_trapping_retrieval
//// -our event handler for ON=@ DClick
//// -makes linked item visible and back in inventory
//// -removes bouy
//// -runs a loop at random amounts creating critters each interval
////    when a fishing test is passed.
////    -requires the below on the linked object-
////    TAG._sea_critter_catch_difficulty = fishing test to catch critters (50)
////    TAG0._max_catch = max amount of catch (4)
////    TAG._sea_critters = criter template (random_crustacean)
/////////////////////////////////////////////////////    
[TYPEDEF e_sea_trapping_retrieval]
ON=@DClick
    sfx 05a4
    //make our item visible and able to decay
    //    move item to inventory
    //        remove buoy (this item)
    link.attr = attr_decay 
    link.bounce
    remove
    
    //pass fishing check to get fish (critters)
    IF (<src.skillcheck 18,<link.dTAG._sea_critter_catch_difficulty>>)
        FOR 1 <eval rand(<link.dTAG0._max_catch>)+1>
            serv.newitem <link.TAG._sea_critters>    //add critter
            new.p = <src.p>
        ENDFOR
        src.sysmessage Your <link.name> was full!
        
    ELSE
        src.sysmessage The <link.name> was empty.
        
    ENDIF
    src.skillgain 18,<link.dTAG0._sea_critter_catch_difficulty>
    return 1
    
    
/////////////////////////////////////////////////////
//// EVENT/TYPEDEF e_declining_uses
//// -our event handler for ON=@ DClick
//// -makes this item degrade when used
//// -when degredation is 0, item will break
//// -warns the user when about to break
/////////////////////////////////////////////////////    
[TYPEDEF e_declining_uses]    
ON=@DClick
    //reduce uses
    USESCUR --
    IF (<USESCUR><=0)
        destroy 
        SRC.SYSMESSAGE Your <name> broke.
        return 1
    ENDIF
    //notify when close to breaking
    IF (<USESCUR><=3)
        SRC.SYSMESSAGE Your <name> is going to break soon.
    ENDIF
    
    
/////////////////////////////////////////////////////
//// EVENT/TYPEDEF e_rope_buoy
//// -our event handler for ON=@ DClick/TargOn_Item
//// -enforces buoy targetting only
//// -forces the buoy to be doubleclicked as if used
/////////////////////////////////////////////////////    
[TYPEDEF e_rope_buoy]    
ON=@DClick    
    //target a buoy
    TARGET Select buoy to rope in
    RETURN 1
ON=@TargOn_Item
    //only works on buoys
    IF !(<argo.defname>==i_lobster_buoy)
        src.sysmessage Rope only works on buoys.
        return 1
    ENDIF
    //to far away
    IF (<src.distance <argo>> > 6)
        src.sysmessage Too far away from buoy.
        return 1
    ENDIF
    //trigger/use buoy
    argo.useitem
    return 1
    
//////////////////////////////////////////////////////////////////////////////////////////////
///////       Items - Misc - previously undefined
//////////////////////////////////////////////////////////////////////////////////////////////    
[ITEMDEF 03b10]
DEFNAME=i_seahorse
NAME=sea horse
TYPE=t_fish
VALUE=2
WEIGHT=1
ON=@Create
    COLOR={0 1 colors_pink 1 colors_blue 1 colors_orange 1 colors_red 1}
[ITEMDEF 03b11]
DEFNAME=i_shrimp_brine
NAME=brine shrimp
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b0e]
DEFNAME=i_jellyfish
NAME=jellyfish
TYPE=t_fish
VALUE=2
WEIGHT=1
ON=@Create
    COLOR={0 1 colors_pink 1 colors_blue 1 colors_green 1}
[ITEMDEF 03afc]
DEFNAME=i_crab_speckled
NAME=speckled crab
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b14]
DEFNAME=i_shrimp
NAME=shrimp
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03afd]
DEFNAME=i_fish_makoto_courtesan_fish
NAME=makoto courtesan fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03afe]
DEFNAME=i_fish_minoc_blue
NAME=Minoc blue fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03aff]
DEFNAME=i_fish_britain_crown_fish
NAME=Britain crown fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b00]
DEFNAME=i_fish_red_dart_fish
NAME=red dart fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b01]
DEFNAME=i_fish_small_mouth_sucker_fin
NAME=small mouth sucker fin
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b02]
DEFNAME=i_fish_fandancer
NAME=fandancer fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b03]
DEFNAME=i_fish_golden_broadtail
NAME=golden broadtail
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b04]
DEFNAME=i_fish_albino_courtesan_fish
NAME=albino courtesan fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b05]
DEFNAME=i_fish_spined_scratcher_fish
NAME=spined scratcher fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b06]
DEFNAME=i_fish_nujelm_honey
NAME=Nujel'm honey fish
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b07]
DEFNAME=i_fish_yellow_fin_bluebelly
NAME=yellow fin bluebelly
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b08]
DEFNAME=i_fish_vesper_reef_tiger
NAME=Vesper reef tiger
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b09]
DEFNAME=i_fish_spotted_bucaneer
NAME=spotted buccaneer
TYPE=t_fish
VALUE=2
WEIGHT=1
[ITEMDEF 03b0a]
DEFNAME=i_fish_stripped_flake_fish
NAME=stripped flake fish
TYPE=t_fish
VALUE=2
WEIGHT=1