Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Помогите переписать скрипт с Python на Java
#1
Помогите пожалуйста переписать скрипт с Python на Java
Код:
# Made by disKret
import sys
from com.l2scoria import Config
from com.l2scoria.util.random import Rnd
from com.l2scoria.gameserver.model import Inventory
from com.l2scoria.gameserver.model.actor.instance import L2ItemInstance
from com.l2scoria.gameserver.model.quest import State
from com.l2scoria.gameserver.model.quest import QuestState
from com.l2scoria.gameserver.model.quest.jython import QuestJython as JQuest

qn = "9990_CraftSystem"

#NPC
NPC_ID = 30086

#QUEST ITEM
PACKAGE = 7263

ONE_TYPE_WEAPON = [1, 2, 3, 4]
ONE_TYPE_DROP_ID = [4037, 57, 4356, 4357, 6673]
ONE_TYPE_DROP_COUNT = 1
ONE_TYPE_DROP_CHANCE = 100
ONE_MOB_ID = [18342, 18341, 18343, 18330, 18331]

TWO_TYPE_WEAPON = [1, 2, 3, 4]
TWO_TYPE_DROP_ID = [1, 2, 3, 4, 5]
TWO_TYPE_DROP_COUNT = 1
TWO_TYPE_DROP_CHANCE = 100
TWO_MOB_ID = [111, 111, 111, 111, 111]

THREE_TYPE_WEAPON = [1, 2, 3, 4]
THREE_TYPE_DROP_ID = [1, 2, 3, 4, 5]
THREE_TYPE_DROP_COUNT = 1
THREE_TYPE_DROP_CHANCE = 100
THREE_MOB_ID = [111, 111, 111, 111, 111]

FO_TYPE_WEAPON = [1, 2, 3, 4]
FO_TYPE_DROP_ID = [1, 2, 3, 4, 5]
FO_TYPE_DROP_COUNT = 1
FO_TYPE_DROP_CHANCE = 100
FO_MOB_ID = [111, 111, 111, 111, 111]

FIVE_TYPE_WEAPON = [1, 2, 3, 4]
FIVE_TYPE_DROP_ID = [1, 2, 3, 4, 5]
FIVE_TYPE_DROP_COUNT = 1
FIVE_TYPE_DROP_CHANCE = 100
FIVE_MOB_ID = [111, 111, 111, 111, 111]


print "E6aTb KoIIaTb 3arpy3uJIocb!"

class Quest (JQuest) :

def __init__(self,id,name,descr):
     JQuest.__init__(self,id,name,descr)
     self.questItemIds = [PACKAGE]

def onTalk (self,npc,player):
   htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
   st = player.getQuestState(qn)
   if not st : return
   st.setState(State('Started', QUEST))
   return

def onAttack (self, npc, player, damage, isPet):
   st = player.getQuestState(qn)
   if not st : return
   player = st.getPlayer()
   npcId = npc.getNpcId()
   if player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND) != None:
       type = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND)
   elif player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != None:
       type = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND)
   else :
       return

   itemId = type.getItemId()
   if itemId in ONE_TYPE_WEAPON and npcId in ONE_MOB_ID:
       if itemId == ONE_TYPE_WEAPON[0] :
           if ONE_TYPE_DROP_CHANCE > Rnd.get(1, 100):
               st.giveItems(ONE_TYPE_DROP_ID[0], ONE_TYPE_DROP_COUNT)
           if ONE_TYPE_DROP_CHANCE > Rnd.get(1, 100):
               st.giveItems(ONE_TYPE_DROP_ID[1], ONE_TYPE_DROP_COUNT)
  ........................................

   else :
       return
      
   return
  
  
QUEST       = Quest(9990, qn, "Craft System")

for i in ONE_MOB_ID :
    QUEST.addAttackId(i)
for i in TWO_MOB_ID :
    QUEST.addAttackId(i)
for i in THREE_MOB_ID :
    QUEST.addAttackId(i)
for i in FO_MOB_ID :
    QUEST.addAttackId(i)
for i in FIVE_MOB_ID :
    QUEST.addAttackId(i)

QUEST.addStartNpc(NPC_ID)
QUEST.addTalkId(NPC_ID)

Вот что пытался переделать, дальше не знаю как:
Код:
package net.sf.l2j.gameserver.scripting.quests;

import net.sf.l2j.commons.random.Rnd;
import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.scripting.Quest;
import net.sf.l2j.gameserver.scripting.QuestState;

public class 9990_CraftSystem extends Quest
{
    private static final String qn = "9990_CraftSystem";
    
    // Item
    private static final int PACKAGE = 7263;
    private static final int ONE_TYPE_DROP_COUNT = 1;
    private static final int[] ONE_TYPE_WEAPON =
        {
            21314,
            21316,
            21317,
            21319,
            21321,
            21322
        };
    private static final int[] ONE_TYPE_DROP_ID =
        {
            4037,
            57,
            4356,
            4357,
            6673
        };
    // NPC
    private static final int NPC_ID = 30086;
    
    // Chance
    private static final int ONE_TYPE_DROP_CHANCE = 100;
    
    // Monster
    private static final int[] ONE_MOB_ID =
        {
            18342,
            18341,
            18330,
            18343,
            18331
        };
    
    public 9990_CraftSystem()
    {
        super(9990, "CraftSystem");
        
        setItemsIds(PACKAGE);
        
        addStartNpc(NPC_ID);
        
        addKillId(ONE_MOB_ID);
    }
    
    @Override
    public String onTalk(L2Npc npc, L2PcInstance player)
    {
        String htmltext = getNoQuestMsg();
        QuestState st = player.getQuestState(qn);
        if (st == null)
            return htmltext = "0-01.htm";
        
    }
    public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet)
    {
        QuestState st = player.getQuestState(qn);
        if (st == null)
            return;
        L2PcInstance player = st.getPlayer();
        int npcId = npc.getNpcId();
        ItemInstance type = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
        if (type == null)
        {
        return;
        }
        int itemId = type.getItemId();
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  java прогер Light87 0 1,923 01-18-2021, 12:15 AM
Последний пост: Light87
  Скрипт для альт+б Jm0t 0 1,812 03-21-2019, 04:18 PM
Последний пост: Jm0t
  Ребята помогите с логин и геймом Lackyjack 4 1,876 04-04-2018, 05:46 PM
Последний пост: MasVild
  Помогите со сборкой lostworld HF voland3 1 2,133 03-22-2018, 12:54 AM
Последний пост: Kampina
  кто может открыть .u формат скрипт? velterna 1 1,923 01-31-2018, 09:49 PM
Последний пост: PROGRAMMATOR
  Скрипт не срабатывает сразу Froust 4 2,383 09-22-2017, 02:14 PM
Последний пост: Froust
  скрипт на превращение зарича по id v1kt0r 3 2,127 05-07-2017, 10:04 PM
Последний пост: Emperor
  Ищу исполнителя [Java] Abstragetic 3 2,140 02-05-2017, 03:01 AM
Последний пост: Deazer
  альт+G java HiredKiller 10 3,422 12-15-2015, 09:40 AM
Последний пост: HiredKiller
  Servise Manager Lucera 2 Java 8. DiName 8 2,696 12-07-2015, 07:43 AM
Последний пост: Deazer

Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)