Ir para conteúdo
  • Cadastre-se
  • 0

custom-quest-random-reward


TheBeasT

Pergunta

Boa noite galera alguem pode me ajudar nessa quest gostaria de limitar o drop a 400, por exemplo quando o player dropa 400 itens para de dropar e aparecer aquela alerta para ele voltar ao npc e entregar os itens, desde ja agradeço obrigado

 

 

/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/
package net.sf.l2j.gameserver.scripting.quests;

import java.util.HashMap;
import java.util.Map;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.scripting.Quest;
import net.sf.l2j.gameserver.scripting.QuestState;
import net.sf.l2j.commons.random.Rnd;


public class Q999_RandonItemReward extends Quest
{
private static final String qn = "Q999_RandonItemReward";

//Status
private static final boolean QUEST_ENABLE = Config.CUSTOM_QUEST_ENABLE;

// NPCs
private static final int NPC = Config.CUSTOM_QUEST_NPC_ID;

// Items Drop Quest
private static int[][] ITEMS = Config.CUSTOM_QUEST_REQUIRED_ITENS_LIST;
private static int MINIMUM_LEVEL = Config.CUSTOM_QUEST_MINIMUM_LEVEL;
private static int[][] MONSTERS = Config.CUSTOM_QUEST_MONSTERS_CHANCE_LIST;
private static int[][] REWARD_STATUS = Config.CUSTOM_QUEST_STATUS_REWARD;
private static int[][] LIST_REWARD_ITEMS = Config.CUSTOM_QUEST_GROUP_ITEM_ID;

public int[] SortItem(){


int[] premiacao = new int[]{57,1};

double sorteio = Math.random() * 100;

for(int i = 0 ; i < REWARD_STATUS.length ; i++)
{

if((sorteio -= REWARD_STATUS[0]) < 0){
int premio = Rnd.get(LIST_REWARD_ITEMS.length);
int quantidade = Rnd.get(REWARD_STATUS[1], REWARD_STATUS[2]);
premiacao = new int[]{LIST_REWARD_ITEMS[premio],quantidade};
break;
}
}

return premiacao;
}


// Drop chances
private static final Map CHANCES = new HashMap<>();
{
for(int i = 0 ; i < MONSTERS.length ; i++){
CHANCES.put(MONSTERS[0], MONSTERS[1]);
}
}

public Q999_RandonItemReward()
{
super(999, "Quest do Teste");

if(QUEST_ENABLE){

for(int i = 0 ; i < ITEMS.length ; i++)
{
setItemsIds(ITEMS[0]);
}


addStartNpc(NPC);
addTalkId(NPC);

for (int mobs : CHANCES.keySet())
addKillId(mobs);
}

}

@Override
public String onAdvEvent(String event, Npc npc, Player player)
{
String htmltext = event;
QuestState st = player.getQuestState(qn);
if (st == null)
return htmltext;

if (event.equalsIgnoreCase(NPC + "-3.htm"))
{
st.setState(STATE_STARTED);
st.set("cond", "1");
st.playSound(QuestState.SOUND_ACCEPT);
}
else if (event.equalsIgnoreCase(NPC + "-5.htm"))
{
if (CheckItemsRequire(player))
{
int[] sorteado = this.SortItem();
htmltext = NPC + "-6.htm";
for(int i = 0 ; i < ITEMS.length ; i++)
st.takeItems(ITEMS[0], ITEMS[1]);
st.giveItems(sorteado[0],sorteado[1]);
}
}
else if (event.equalsIgnoreCase(NPC + "-7.htm"))
{
for(int i = 0 ; i < ITEMS.length ; i++)
st.takeItems(ITEMS[0], -1);
st.exitQuest(true);
}

return htmltext;
}


@SuppressWarnings("static-method")
private boolean CheckItemsRequire(Player player){
QuestState st = player.getQuestState(qn);
for(int i = 0 ; i < ITEMS.length ; i++){
if(st.getQuestItemsCount(ITEMS[0]) < ITEMS[1])
return false;
}
return true;
}

@Override
public String onTalk(Npc npc, Player player)
{
String htmltext = getNoQuestMsg();
QuestState st = player.getQuestState(qn);
if (st == null)
return htmltext;

switch (st.getState())
{
case STATE_CREATED:
htmltext = npc.getNpcId() + ((player.getLevel() >= MINIMUM_LEVEL) ? "-1.htm" : "-2.htm");
break;

case STATE_STARTED:
if(npc.getNpcId() == NPC){
boolean stQ = false;
for(int i = 0 ; i < ITEMS.length ; i++)
{
if(st.getQuestItemsCount(ITEMS[0]) >= ITEMS[1]){
stQ = true;
}
else
{
stQ = false;
break;
}
}
htmltext = (stQ) ? NPC + "-4.htm" : NPC + "-5.htm";
}
break;
}

return htmltext;
}

@Override
public String onKill(Npc npc, Player player, boolean isPet)
{
Player partyMember = getRandomPartyMemberState(player, npc, STATE_STARTED);
if (partyMember == null)
return null;
for(int i = 0 ; i < ITEMS.length ; i++)
partyMember.getQuestState(qn).dropItems(ITEMS[0], 1, 0, CHANCES.get(npc.getNpcId()));

return null;
}

}

,>

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts recomendados

Até agora não há respostas para essa pergunta

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  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.

Processando...




×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.