fishing problem

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
User avatar
Mallary
Novice Poster
Posts: 40
Joined: Thu Aug 14, 2008 2:54 pm

fishing problem

Post by Mallary »

I need a help, as do the fishing rod along with the dagger already let the fish cut into the bag when I'm fishing macro, because today he is leaving is not cutting whole fish in bag.


Code: Select all

Use uo;
Use cfgfile;
Use os;

Include "include/client";
Include "include/objtype";
Include "include/skillpoints";
Include "include/dist";
Include "include/starteqp";
Include "include/checkcity";
Include "fishing";
Include "include/random";
Include "include/itemutil";
Include "include/autoloop";

Const UOBJECT_TREASURE_CHEST := 0x0E40;
Const UACTION_FISHING := 0x9;
Const SFX_SKILL_FISHING	:= 0x0240;
Const UOBJ_SOS_BOTLE_TILE := 0xA365;
Const UOBJ_SOS_BOTLE := 0xA360;
Const FISHING_RANGE := 6;

Const MAX_CHANCE	:= 155;
Const DEFAULT_POINTS	:= 100;
Const POINTS_MULTIPLIER	:= 15;

Program use_fishpole( character , pole )
    //A vara de pescar é reservada se não for ele termina o script.
    If( !ReserveItem( pole ) )
        Return;
    Endif
    
    //eu acho que esta pegando o numero do slot da vara de pescar... esta funcao nao esta definida aqui????????????????????????
    Var equipped :=whatequipped( character, pole );
    
    // Pega o target de onde o jogador quer pescar.
    Var use_on := Targetcoordinates( character );
    
    // se nao tiver um tgt ele nao pode pescar e o script para.
    If ( !use_on )
        SendSysMessage( character, "Canceled" );
        Return;
    Endif
    
    // verifica se o tgt esta a menos de 8 caras do character
    If ( coordist( character.x,character.y,use_on.x, use_on.y ) > 8 )
        SendSysmessage( character,"That is too far away" );
        Return 0;
    Endif
    
    //eu acho que esta funcao esta pegando o tipo do tile e verificando se é um tile de agua.?????????????????????????????
    If( !IsWater( use_on ) )
        SendSysmessage( character, "You can't use that on this" );
        Return;
    Endif

    //eu acho que est aparte seria para pescar ou abrir os SOS( garrafas que dao um bau com itens).
    Foreach item in ListItemsNearLocation( use_on.x,use_on.y,-5, FISHING_RANGE )
        If( item.objtype == UOBJ_SOS_BOTLE_TILE )
            If ( FetchBottle( character, item ) == 1 )
                return;
            Endif
        Endif
    Endforeach
    
    // eu nao sei oq isso esta fazendo ...??????????????????  acho que imprime o loop para o char.
    Autoloop_init( character );

	// se o jogador tem loops e se nao estiver morto entao ele vai
    While( Autoloop_more() && NOT character.dead )
        Var newsplash;
        //animacao de pescar.
        Performaction( character, UACTION_FISHING );
        //som de pescar
        PlaySoundEffect( character, SFX_SKILL_FISHING );
        // isso aqui é a animacao da agua em movimento por que o jogador pescou ali. ele cria um item e muda o grafico para indicar que a agua se moveu.
        newsplash := CreateItemAtLocation( use_on.x, use_on.y, use_on.z,  0x352d, 1 );
        newsplash.movable := 0;
        Sleepms( 500 );
        newsplash.graphic := 0x352e;
        Sleepms( 500 );
        newsplash.graphic := 0x352f;
        Sleepms( 500 );
        newsplash.graphic := 0x3530;
        Sleepms( 500 );
        DestroyItem( newsplash );
        var x := character.x;
        var y := character.y;
        Var loop := 2;
        // acho que isso aqui é uma espera para verificar se o jogador ainda esta no mesmo local e tem loops.
        While( ( character.x == x ) and ( character.y == y ) and loop > 0 )
            Sleep( 1 );
            loop := loop - 1;
        Endwhile

        //ele cria um loop e consome ele no while acima se o jogador ficar parado ele vai zerar este loop e nao vai entrar aqui, que seria o fim do programa."que nojo"
        If( loop )
            SendSysMessage( character, "You must be patient while fishing" );
            Autoloop_finish();
            Return 0;
        Endif

        Var water := GetMapInfo( use_on.x, use_on.y ).landtile;

        Var fishamount := HarvestResource( "fish" , use_on.x , use_on.y , 1 , Cint( GetAttribute( character , ATTRIBUTEID_FISHING ) / 10 ) + 1 );
    
        If( !fishamount )
            SendSysMessage( character, "There don't seem to be any more fish." );
            SendSysMessage( character, "You stop fishing." );
            Autoloop_finish();
            Return 0;
        Endif
    
        fishamount := fishamount + Cint( RandomDiceStr( "1d5" ) );
        
        If( CheckSkill( character , SKILLID_FISHING , -1 , DEFAULT_POINTS ) )
            GetStuff( character , fishamount , pole );
            If( RandomDiceStr("1d150") <= fishamount )
                DoSomething( character );
            Endif
        Else
            SendSysmessage( character , "The fish don't seem to be biting." );
        Endif

    Endwhile

    SendSysMessage(character, "You stop fishing.");
    Autoloop_finish();

Endprogram

Function GetStuff( character , fishamount , tool )

    Var to_make_colored := Cint( GetAttribute( character , ATTRIBUTEID_FISHING ) / 5 ) + 35;
    Var ranger := GetObjProperty( character , CLASSEID_RANGER );

    Var tool_bon := GetObjProperty( tool , "FishingBonus" );
    
    If( tool_bon )
        to_make_colored := to_make_colored + (10 * tool_bon );
        fishamount	:= fishamount * tool_bon;
    Endif

    If( to_make_colored > 75 )
        to_make_colored := 75;
    Endif

    If( ranger )
        to_make_colored := Cint( to_make_colored * CLASSE_BONUS );
        If( to_make_colored > 90 )
            to_make_colored := 90;
        Endif
    Endif

    If( RandomDiceStr("1d100") <= to_make_colored )
        SendSysmessage( character , "You begin to struggle with the fish." );
        MakeRareFish( character , fishamount , tool , equipped );
    Else
        If( ranger )
            fishamount := Cint( fishamount * CLASSE_BONUS );
        Endif
        CreateItemInBackpack( character , 0x09cc , fishamount );
        SendSysMessage( character , "You catch " + fishamount + " fish(s) and place them in your backpack." );
    Endif

Endfunction

Function MakeRareFish( character , fishamount , tool )

    Var skill := GetAttribute( character , ATTRIBUTEID_FISHING );
    Var maxamount := Cint( skill / 15 );
    Var tool_bon := GetObjProperty( tool , "FishingBonus" );
    
    If( tool_bon )
        maxamount := maxamount * tool_bon;
    Endif

    If( fishamount > maxamount )
        fishamount := maxamount;
    Endif

    If( fishamount < 1 )
    fishamount := 1;
    Endif

    Var chance := RandomDiceStr( "1d" + MAX_CHANCE );
    Var cfg := ReadConfigFile( "itemdesc" );
    Var thekeys := GetConfigStringKeys( cfg );
    Var possibles := {};
    Var min_chance:= MAX_CHANCE * 2;
    Var the_fish;

    If( Random(2) )
        Var bonus := Cint( skill / 4 );
        Var to_mod := 80;
        If( GetObjProperty( character , CLASSEID_RANGER ) )
            bonus := Cint( bonus * CLASSE_BONUS );
            fishamount := Cint( fishamount * CLASSE_BONUS );
            to_mod := Cint( to_mod / CLASSE_BONUS );
        Endif
        If( tool_bon )
            bonus  := bonus + (6 * tool_bon);
            to_mod := to_mod - (5 * tool_bon);
        Endif
        If( chance > to_mod )
            chance := chance - bonus;
        Endif
    Endif

    Foreach key in thekeys
    Var the_chance := Cint( cfg[key].HarvestChance );
    If( the_chance and chance <= the_chance )
        If( CheckSkill( character , SKILLID_FISHING , Cint(cfg[key].HarvestDiff) , 0 ) )
        possibles.append( key );
        Endif
    Endif
    Endforeach

    If( len( possibles ) )
        Foreach key in possibles
            Var hchance := Cint( cfg[key].HarvestChance );
            If( hchance < min_chance )
                the_fish := key;
                min_chance := hchance;
            Endif
        Endforeach
        CreateItemInBackpack( character , Cint(the_fish) , fishamount );
        SendSysMessage( character , "You catch " + fishamount + " strong fish(s) and place them in your backpack." );
    Else
        SendSysmessage( character , "The fish got away." );
    Endif

Endfunction


Function DoSomething( character )

    Var tnum := Random( 13 );
    Var msg;
    Var it;
    
    Case ( tnum )
    
    0:
        If( Random( 100 ) < 20 )
            CreateItemInBackpack( character, 0xa366, 1 );
            msg := "You just found a special fishing net.";
        Endif
        Break;
    
    1:
        If( Random( 100 ) < 15 )
            it := CreateItemInBackpack( character , 0x6004, 1 );
            it.decay :=120;
            msg := "You find a tattered old map!";
        Endif
        Break;

    2:
        If( Random( 100 ) < 25 )
            it := CreateItemInBackpack( character ,0x0E75,1);
            it.decay :=120;
            Var ranger := GetObjProperty( character , CLASSEID_RANGER );
            If( ranger )
                CreateItemInContainer( it, 0xeed, Random(300)+100 * ranger );
                msg := "You find an old backpack!";
            Else
                CreateItemInContainer( it, 0xeed, Random(300)+100 );
                msg := "You find an old backpack!";
            Endif
        Endif
        Break;
    
    3:
        If( Random( 100 ) < 10 )
            CreateItemInBackpack( Character, RandomShell( Character ), 1 );
            msg := "You find something valuable!";
        Endif
        Break;
    
    4:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0x91BA, 1 );
            msg := "You find a strange lockbox";
        Endif
        Break;
    
    5:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0x91BB, 1 );
            msg := "You find a strange lockbox";
        Endif
        Break;
    
    6:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0x91BC, 1 );
            msg := "You find a strange lockbox";
        Endif
        Break;
    
    7:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0x91BD, 1 );
            msg := "You find a strange lockbox";
        Endif
        Break;
    
    8:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0x91BE, 1 );
            msg := "You find a strange lockbox";
        Endif
        Break;
    
    9:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0xc538, 1 );
            msg := "You find a strange looking blue gem!";
        Break;
        Endif

    10:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0xc539, 1 );
            msg := "You find a strange looking red gem!";
        Break;
        Endif

    11:
        If( Random( 100 ) < 1 )
            CreateItemInBackpack( character, 0xc53a, 1 );
            msg := "You find a glowing bright white gem!";
        Endif
        Break;
    
    12:
        If( Random( 100 ) < 15 )
            CreateSosBottle( character );
            msg := "You find a bottle with a message inside!";
        Endif
        Break;
    Endcase
    
    If( msg )
        SendSysMessage( character, msg );
    Endif
    
Endfunction

Function RandomShell( Character )

    Case ( Random( 5 ) )
    0:
        Return 0x80ae;
    
    1:
        Return 0x80be;
    
    2:
        Return 0x80ce;
    3:
    
    4:
        If( GetAttribute( Character, ATTRIBUTEID_FISHING ) > 100 )
            If( Random( 3 ) == 2 )
                Return 0x80de;
            Else
                Return 0x80ee;
            Endif
        Else
            Return 0x80ce;
        Endif
        
    Endcase

Endfunction

function FetchBottle(who, tile)

    var spot, good:=0;
    var i, msg:=getObjProperty(tile, "msgserial");

    foreach item in EnumerateItemsInContainer( who.backpack )
        if (item.objtype == 0xa363 && item.serial == msg)
            good:=1;
        endif
    endforeach

    if (good)
        if(CheckSkill(who, SKILLID_FISHING, 70, 1000))
            SendSysMessage(who,"You catch a sunken treasure!");
	    Spot := FindSpot(who);
            if(Spot !=0)
                CreateChest(spot[1],spot[2],spot[3]);
            endif
            CleanSos(tile);
        else
            good:=0;
        endif
    endif

    return good;

endfunction

function FindSpot(who)

    var spot :={0,0,0};
    var testval :=0;
    var i;

    for(i:=1;i<9;i:=i+1)
        case(i)
        1:testval := GetStandingHeight( (who.x-1),(who.y-1),who.z);
            spot[1] := who.x-1;
            spot[2]:= who.y-1;
        2:testval := GetStandingHeight((who.x-1),(who.y),who.z);
            spot[1] := who.x-1;
            spot[2] := who.y;
        3:testval := GetStandingHeight((who.x-1),(who.y+1),who.z);
            spot[1] := who.x-1;
            spot[2] := who.y+1;
        4:testval := GetStandingHeight((who.x),(who.y-1),who.z);
            spot[1] := who.x;
            spot[2] := who.y-1;
        5:testval := GetStandingHeight((who.x),(who.y+1),who.z);
            spot[1] := who.x;
            spot[2] := who.y+1;
        6:testval := GetStandingHeight((who.x+1),(who.y-1),who.z);
            spot[1] := who.x+1;
            spot[2] := who.y-1;
        7:testval := GetStandingHeight((who.x+1),(who.y-1),who.z);
            spot[1] := who.x+1;
            spot[2] := who.y;
        8:testval := GetStandingHeight((who.x+1),(who.y-1),who.z);
            spot[1] := who.x+1;
            spot[2] := who.y+1;
        endcase
    
        if(!testval.errortext)
            spot[3] := testval.z;
            return spot;
        endif
    endfor
    
    syslog("aqui");

    return 0;

endfunction

function CreateChest( x , y , z )

    var chest := CreateItemAtLocation(x,y,z,UOBJECT_TREASURE_CHEST,1);

    MakeLoot( chest , Random(5)+4);

endfunction

function CleanSos(tile);

    var msg := GetObjProperty(tile, "msgserial");
    msg :=SystemFindObjectBySerial(msg);
    if(msg)
        destroyitem(msg);
    endif
    destroyitem(tile);

endfunction
Post Reply