Jump to content
  • 0

drop on all monsters


worn

Question


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  40
  • Reputation:   6
  • Joined:  09/17/13
  • Last Seen:  

Hey guys, I would like to know if there is a way to make all monsters drop a certain item with drop percentage, without putting it in drop one by one in mob_db I would also like to know if you can only put it on certain example maps lhz_dun03 all monsters from lhz drop this item and other maps do not

Link to comment
Share on other sites

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  40
  • Reputation:   6
  • Joined:  09/17/13
  • Last Seen:  

On 1/2/2022 at 9:37 AM, Rynbef said:

Você ativou a depuração? O que o console depura?@desgastado

 

Rynbef ~

it doesn't show anything, the script in the debugger, it's just not dropping the item, and the drop is 100%

 

On 1/2/2022 at 7:48 AM, sader1992 said:

o que eu quis dizer são as outras variáveis também, se a variável é usada apenas dentro do npc, você deve usar a variável npc, também você pode ter problemas ao editar o npc e recarregar apenas esse npc porque $ @ é global

a função retornará se alguma das chances falhar, (setarray $ @ item_chance [0], 1,1,1000;) [tente obter o terceiro item do terceiro mapa com esta chance]

também não há necessidade da função se ela for chamada apenas uma vez.

com outros erros no script, você pode verificar se testar o script (raramente testo meus scripts ao responder a uma postagem, então é xD compreensível)

 

as mensagens de depuração são demais, mas essa é minha opinião

com otimização este é o resultado


este script otimizado não suporta a entrada do mesmo mapa duas vezes, você pode editá-lo para fazer isso se quiser

 

if I want to repeat the map 2x to drop 2 different items how would it look?

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  795
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

I've changed an if statement. I hope that's the final solution. U can add the same map as often as u want. 

Spoiler
/*
rAthena Script
Author: @Rynbef
Create Date: 2021-19-12
Last Updated: 2022-01-01

Changelogs:
    2022-01-01:
        *changed OnNPCLoadEvent to OnNPCKillEvent
        *added check if killed enemie is player
        *removed space on callfunc after OnNPCKillEvent
        *fixed if statement syntax error
        *fixed if statement getarraysize of integer to getarraysize of specified getarg
        *removed callfunc OnInit
        *added console debugging can be disabled or enabled
        *changed variable types
        *fixed cant get item cause of wrong if statement
        *fixed for loop used array size instead random chance from argument getarg(3)
        *fixed player can't get item if random chance was equals to specified item chance
        *added argument amount to debug message
        *added map notification if player get lucky but not on a listed map. This can disabled or enabled seperat at OnInit below. Debugging needs to be enabled
        *added notification if everything works fine. Can be disabled or enabled on bottom of OnInit. Debugging needs to disabled
        #fixed wrong array output in for loop from getarg(0)[.i] to getelementofarray(getarg(0),.i)
        #changed .retval and .i vsriables to scope variables .@retval and .@i

Feature planned:
    #Player get zeny if he get lucky
    #Player get zeny only if items disabled
    #Player get zeny or item if both enabled

Description:
    Give a specified item getarg(1) of amount getarg(2) on specified map getarg(0) with a percentage of getarg(3) (0.1 to 100 percent) to a player
    
IMPORTANT:
    All arrays needs to have the same sizes
    It's importent to set all 3 arguments to callfunc

Terms:
    Dont name this as yours
    Dont sell this script
    Dont upload this script on download-/s section or share it otherwise for pay
    Modifications are included from this terms
    Otherwise feel free to edit

Other:
    Don't hestiate to contact me at the forum as pm if u've any error,question,suggestion or want a modification

Script:
*/

-   script  GetItemByMap    -1,{

OnNPCKillEvent:
    set .@retval,callfunc("F_GetItemByMap",.@maps$,.@items,.@item_amounts,.@item_chance);
    if(!.@debug)
        end;
    if(.@retval == 1)
        debugmes "[F_GetItemByMap]: Works fine! Player get item.";
    else if(.@retval == 2)
        debugmes "[F_GetItemByMap]: Works fine! Player is unlucky and get no item.";
    else if(.@retval == 3 && .@debugmap)
        debugmes "[F_GetItemByMap]: Player isn't on a listed map. Current map: "+strcharinfo(3);
    else if(.@retval == 4 && .@debugworking)
        debugmes "[F_GetItemByMap]: Everything works fine!";
    else
        debugmes "[F_GetItemByMap]: Causes in errors. Debug logs on top!";
    end;

OnInit:
    setarray .@maps$[0],"prontera","alberta","izlude";
    serarray .@items[0],501,4012,512;
    setarray .@item_amounts[0],100,1,5;
    setarray .@item_chance[0],1000,500,800;//Chance begins by 0.1 percentage. 1 = 0.1 and 1000 = 100 percent
    set .@debug,1;//0 = disable debugging,1 = enable
    set .@debugmap,1;//0 = disable map notification,1 = enable
    set .@debugworking,1;//0 = disable notification if everything works fine,1 = enable
    end;
}

function    script    F_GetItemByMap    {

if(getargcount() != 4 || getarraysize(getarg(0)) != getarraysize(getarg(1)) || getarraysize(getarg(0)) != getarraysize(getarg(2)) || getarraysize(getarg(0)) != getarraysize(getarg(3))){
    if(.@debug){
        debugmes "[F_GetItemByMap]: An error is occurupted";
        debugmes "[Function arguments]: Function arguments are empty or to short. Arguments: "+getargcount();
        debugmes "[Array sizes]: Maps:"+getarraysize(getarg(0))+" - Items:"+getarraysize(getarg(1))+" - Amounts:"+getarraysize(getarg(2))+" - Chances:"+getarraysize(getarg(3));
        debugmes "[Function arguments]: Maps:"+getarg(0)+" - Items:"+getarg(1)+" - Amounts:"+getarg(2)+" - Chances:"+getarg(3);
    }
    return 0;
} else {
    for(.@i = 0; .@i<getarraysize(getarg(0)); .@i++){
        if(rand(1,1000) < getelementofarray(getarg(3),.@i))
            return 2;
        if(strcharinfo(3) == getelementofarray(getarg(0),.@i)){
            getitem getelementofarray(getarg(1),.@i),getelementofarray(getarg(2),.@i);
            return 1;
        } else {
            return 3;
        }
    }
    }
    return 4;
    
OnInit:
    set .@debug,1;//0 = disable debugging,1 = enable
    end;
}

Download file below

getItemByMapFunction v7.txt

 

Rynbef~

 

It could looks like:

    setarray .@maps$[0],"prontera","prontera","prontera";

    serarray .@items[0],501,4012,512;

    setarray .@item_amounts[0],100,1,5;

    setarray .@item_chance[0],1000,500,800;

 

But the player will get only one item. If u set items to 100% he will get everytimes the first listed one. It's a good idea to change. I'll do it soon if everything works yet.

 

Rynbef~

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  40
  • Reputation:   6
  • Joined:  09/17/13
  • Last Seen:  

40 minutes ago, Rynbef said:

Pode ser parecido com:

    setarray . @ maps $ [0], "prontera", "prontera", "prontera";

    serarray . @ items [0], 501,4012,512;

    setarray . @ item _amounts [0], 100,1,5;

    setarray . @ item _chance [0], 1000,500,800;

 

Mas o jogador receberá apenas um item. Se você definir os itens para 100%, ele obterá sempre o primeiro listado. É uma boa ideia mudar. Farei isso em breve se tudo funcionar ainda.

 

Rynbef ~

 

51 minutes ago, Rynbef said:

Eu mudei uma declaração if. Espero que essa seja a solução final. Você pode adicionar o mesmo mapa quantas vezes quiser. 

  Revelar conteúdos ocultos
/*
rAthena Script
Author: @Rynbef
Create Date: 2021-19-12
Last Updated: 2022-01-01

Changelogs:
    2022-01-01:
        *changed OnNPCLoadEvent to OnNPCKillEvent
        *added check if killed enemie is player
        *removed space on callfunc after OnNPCKillEvent
        *fixed if statement syntax error
        *fixed if statement getarraysize of integer to getarraysize of specified getarg
        *removed callfunc OnInit
        *added console debugging can be disabled or enabled
        *changed variable types
        *fixed cant get item cause of wrong if statement
        *fixed for loop used array size instead random chance from argument getarg(3)
        *fixed player can't get item if random chance was equals to specified item chance
        *added argument amount to debug message
        *added map notification if player get lucky but not on a listed map. This can disabled or enabled seperat at OnInit below. Debugging needs to be enabled
        *added notification if everything works fine. Can be disabled or enabled on bottom of OnInit. Debugging needs to disabled
        #fixed wrong array output in for loop from getarg(0)[.i] to getelementofarray(getarg(0),.i)
        #changed .retval and .i vsriables to scope variables .@retval and .@i

Feature planned:
    #Player get zeny if he get lucky
    #Player get zeny only if items disabled
    #Player get zeny or item if both enabled

Description:
    Give a specified item getarg(1) of amount getarg(2) on specified map getarg(0) with a percentage of getarg(3) (0.1 to 100 percent) to a player
    
IMPORTANT:
    All arrays needs to have the same sizes
    It's importent to set all 3 arguments to callfunc

Terms:
    Dont name this as yours
    Dont sell this script
    Dont upload this script on download-/s section or share it otherwise for pay
    Modifications are included from this terms
    Otherwise feel free to edit

Other:
    Don't hestiate to contact me at the forum as pm if u've any error,question,suggestion or want a modification

Script:
*/

-   script  GetItemByMap    -1,{

OnNPCKillEvent:
    set .@retval,callfunc("F_GetItemByMap",.@maps$,.@items,.@item_amounts,.@item_chance);
    if(!.@debug)
        end;
    if(.@retval == 1)
        debugmes "[F_GetItemByMap]: Works fine! Player get item.";
    else if(.@retval == 2)
        debugmes "[F_GetItemByMap]: Works fine! Player is unlucky and get no item.";
    else if(.@retval == 3 && .@debugmap)
        debugmes "[F_GetItemByMap]: Player isn't on a listed map. Current map: "+strcharinfo(3);
    else if(.@retval == 4 && .@debugworking)
        debugmes "[F_GetItemByMap]: Everything works fine!";
    else
        debugmes "[F_GetItemByMap]: Causes in errors. Debug logs on top!";
    end;

OnInit:
    setarray .@maps$[0],"prontera","alberta","izlude";
    serarray .@items[0],501,4012,512;
    setarray .@item_amounts[0],100,1,5;
    setarray .@item_chance[0],1000,500,800;//Chance begins by 0.1 percentage. 1 = 0.1 and 1000 = 100 percent
    set .@debug,1;//0 = disable debugging,1 = enable
    set .@debugmap,1;//0 = disable map notification,1 = enable
    set .@debugworking,1;//0 = disable notification if everything works fine,1 = enable
    end;
}

function    script    F_GetItemByMap    {

if(getargcount() != 4 || getarraysize(getarg(0)) != getarraysize(getarg(1)) || getarraysize(getarg(0)) != getarraysize(getarg(2)) || getarraysize(getarg(0)) != getarraysize(getarg(3))){
    if(.@debug){
        debugmes "[F_GetItemByMap]: An error is occurupted";
        debugmes "[Function arguments]: Function arguments are empty or to short. Arguments: "+getargcount();
        debugmes "[Array sizes]: Maps:"+getarraysize(getarg(0))+" - Items:"+getarraysize(getarg(1))+" - Amounts:"+getarraysize(getarg(2))+" - Chances:"+getarraysize(getarg(3));
        debugmes "[Function arguments]: Maps:"+getarg(0)+" - Items:"+getarg(1)+" - Amounts:"+getarg(2)+" - Chances:"+getarg(3);
    }
    return 0;
} else {
    for(.@i = 0; .@i<getarraysize(getarg(0)); .@i++){
        if(rand(1,1000) < getelementofarray(getarg(3),.@i))
            return 2;
        if(strcharinfo(3) == getelementofarray(getarg(0),.@i)){
            getitem getelementofarray(getarg(1),.@i),getelementofarray(getarg(2),.@i);
            return 1;
        } else {
            return 3;
        }
    }
    }
    return 4;
    
OnInit:
    set .@debug,1;//0 = disable debugging,1 = enable
    end;
}

Download file below

getItemByMapFunction v7.txt 4,33 kB · 1 download

 

Rynbef ~

Look, using the script, no error appears, but when killing monsters on the map, it still doesn't drop anything, nothing just happens,

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  795
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

@wornHere two versions the first with a change and the 2nd one with extended experimental debugging. Try the first one and then 2nd one.

getItemByMapFunction v9.txt

 

getItemByMapFunction v8 - Experimentell - Extended Debugging.txt

 

Rynbef~

 

 

Edited by Rynbef
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  40
  • Reputation:   6
  • Joined:  09/17/13
  • Last Seen:  

6 minutos atrás, Rynbef disse:

@desgastadoAqui, duas versões, a primeira com uma alteração e a segunda com uma depuração experimental estendida. Experimente o primeiro e depois o segundo.

getItemByMapFunction v9.txt 4,51 kB  ·  0 downloads

 

getItemByMapFunction v8 - Experimentell - Extended Debugging.txt 5,4 kB  ·  0 downloads

 

Rynbef ~

 

 

https://prnt.sc/25ncf98

getItemByMapFunction v8 - Experimentell - Extended Debugging.txt5,4 kB · 0 downloads

passa por discórdia 

Edited by worn
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  795
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

Have u killed a mob?

 

Do u've tried on other monsters?

 

Do u use the newest version of rAthena?

 

Rynbef~

Edited by Rynbef
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   381
  • Joined:  02/03/12
  • Last Seen:  

9 hours ago, worn said:

in this case it would be for all maps correct? I would like to put on some maps just not all

example in pay_dun04 I want to drop x item on any monster that is killed on the map native monsters even on the map already in lhz I want another item to drop in all monsters on the map and so on with a percentage at the time of the drop, in addition to gaining the standard mob drops

Ahh topic title is misleading then.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  40
  • Reputation:   6
  • Joined:  09/17/13
  • Last Seen:  

Have u killed a mob?

yes

Do u've tried on other monsters?

yes

Do u use the newest version of rAthena?

yes

 

@Rynbef

Edited by worn
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  795
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

@wornTry this. The debug should now prompt on Ingame chat.

getItemByMapFunction v10 - Experimentell - Extended Debugging.txt

 

Rynbef~

Edited by Rynbef
Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

1 hour ago, Rynbef said:

@wornTry this. The debug should now prompt on Ingame chat.

getItemByMapFunction v10 - Experimentell - Extended Debugging.txt 5.43 kB · 1 download

 

Rynbef~

again you need to know why you are using a type of variable , you don't have to stick to one variable type , you should use what the script needs, check my old reply for more info

looking at your script you should use .var + .@var + $@var 

and there is no "debuglog" command

and "serarray" is misspelled

you should not use oninit or npc variables in a function

 

here I just fixed all the above without editing the script

getItemByMapFunction v10 - Experimentell - Extended Debugging.txt

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  795
  • Reputation:   101
  • Joined:  05/23/12
  • Last Seen:  

@sader1992I know which variable type I'm using but u misslrading me much. 

.is a temporary veritable used in NPCs

.@too but it is a scope variable too

$@ is a global temporary variable. It will reset after reload or restart server. 

 

But of course thanks for helping. I'm currently not at home therefore I can't check it and needs to edit everything on mobile phone.

 

May it works now @worn

 

Rynbef~

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

7 hours ago, Rynbef said:

@sader1992I know which variable type I'm using but u misslrading me much. 

did I mislead you by giving you the link for the official documents?

or telling you that you are using the incorrect variable types and it will lead to bugs in the script ? 

or by the example that I included with the correct variable usage ?

????

 

well , there still a problem in the script that I mentioned before , maybe it's your chance to reach version 99 in your script.

  • MVP 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...