Jump to content

[L2Off] Donate Merchant Ai Source Code


Recommended Posts

class 1 l2_merchant : merchant

{

parameter:

   string   fnHi = "l2r_shop_welcome.htm";

   int   donationCoin = 57;



   //clan donations

   int   costLevel3 = 1;

   int   costLevel4 = 1;

   int   costLevel5 = 1;

   int   costLevel6 = 1;

   int   costLevel7 = 1;

   int   costLevel8 = 1;



   //noble

   int   costNoble = 1;



   //wyvern

   //int   WyvernPrice = 1;



   // third class

   int   cost = 0;

   int   requiredLevel = 1;

   string   name = "do_not_meet_requirements_class.htm";









handler:

   EventHandler TALKED (talker)

   {

      myself::ShowPage (talker, fnHi);

      return;

   }



   EventHandler MENU_SELECTED (talker, i0, i1, i2, i4, ask, reply)

   {

      if (ask == -303)

      {

         super;

      }



      if (reply == 111)

      {

         if (talker.level <= 78 && talker.level >= 70)

         {

            myself::IncrementParam (talker, 0, 7000000);

            myself::IncrementParam (talker, 1, 7000000);

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (talker.level <= 70 && talker.level >= 50)

         {

            myself::IncrementParam (talker, 0, 1000000);

            myself::IncrementParam (talker, 1, 1000000);

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (talker.level <= 50 && talker.level >= 20)

         {

            myself::IncrementParam (talker, 0, 500000);

            myself::IncrementParam (talker, 1, 500000);

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (talker.level <= 20)

         {

            myself::IncrementParam (talker, 0, 50000);

            myself::IncrementParam (talker, 1, 50000);

            myself::ShowPage (talker, fnHi);

            return;

         }

      }

      if (reply == 222)

      {

         if (talker.level <= 78 && talker.level >= 70)

         {

            myself::IncrementParam (talker, 0, -7000000);

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (talker.level <= 70 && talker.level >= 50)

         {

            myself::IncrementParam (talker, 0, -1000000);

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (talker.level <= 50 && talker.level >= 20)

         {

            myself::IncrementParam (talker, 0, -500000);

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (talker.level <= 20 && talker.level >= 10)

         {

            myself::IncrementParam (talker, 0, -5000);

            myself::ShowPage (talker, fnHi);

            return;

         }

      }

      //ride wyvern

      //if (reply == 91)

      //{

      //    if( ( myself::OwnItemCount( talker, donationCoin ) >= WyvernPrice && talker.yongma_type == 1 ) && talker.strider_level >= 55 )

      //   {

      //     myself::DeleteItem1( talker, donationCoin, WyvernPrice );

      //     myself::RideWyvern( talker, 1012621 );

      //     myself::ShowPage (talker, fnHi);

      //   }

      //   else

      //   {

      //      myself::Say ("You must have be riding a level 55+ Strider to fly a Wyvern.");

      //      myself::ShowPage (talker, fnHi);

      //      return;

      //   }

      //}



      if (reply == 91)

      {

         if (talker.level >= requiredLevel)

            {

               if (myself::IsInCategory(7, talker.occupation))

               {

                  if (myself::OwnItemCount (talker, 57) >= cost)

                  {

                     //class change portion

                     if (talker.occupation == 2)

                     {

                        myself::ClassChange (talker, 88);

                     }

                     else if (talker.occupation == 3)

                     {

                        myself::ClassChange (talker, 89);

                     }

                     else if (talker.occupation == 5)

                     {

                        myself::ClassChange (talker, 90);

                     }

                     else if (talker.occupation == 6)

                     {

                        myself::ClassChange (talker, 91);

                     }

                     else if (talker.occupation == 9)

                     {

                        myself::ClassChange (talker, 92);

                     }

                     else if (talker.occupation == 8)

                     {

                        myself::ClassChange (talker, 93);

                     }

                     else if (talker.occupation == 12)

                     {

                        myself::ClassChange (talker, 94);

                     }

                     else if (talker.occupation == 13)

                     {

                        myself::ClassChange (talker, 95);

                     }

                     else if (talker.occupation == 14)

                     {

                        myself::ClassChange (talker, 96);

                     }

                     else if (talker.occupation == 16)

                     {

                        myself::ClassChange (talker, 97);

                     }

                     else if (talker.occupation == 17)

                     {

                        myself::ClassChange (talker, 98);

                     }

                     else if (talker.occupation == 20)

                     {

                        myself::ClassChange (talker, 99);

                     }

                     else if (talker.occupation == 21)

                     {

                        myself::ClassChange (talker, 100);

                     }

                     else if (talker.occupation == 23)

                     {

                        myself::ClassChange (talker, 101);

                     }

                     else if (talker.occupation == 24)

                     {

                        myself::ClassChange (talker, 102);

                     }

                     else if (talker.occupation == 27)

                     {

                        myself::ClassChange (talker, 103);

                     }

                     else if (talker.occupation == 28)

                     {

                        myself::ClassChange (talker, 104);

                     }

                     else if (talker.occupation == 30)

                     {

                        myself::ClassChange (talker, 105);

                     }

                     else if (talker.occupation == 33)

                     {

                        myself::ClassChange (talker, 106);

                     }

                     else if (talker.occupation == 34)

                     {

                        myself::ClassChange (talker, 107);

                     }

                     else if (talker.occupation == 36)

                     {

                        myself::ClassChange (talker, 108);

                     }

                     else if (talker.occupation == 37)

                     {

                        myself::ClassChange (talker, 109);

                     }

                     else if (talker.occupation == 40)

                     {

                        myself::ClassChange (talker, 110);

                     }

                     else if (talker.occupation == 41)

                     {

                        myself::ClassChange (talker, 111);

                     }

                     else if (talker.occupation == 43)

                     {

                        myself::ClassChange (talker, 112);

                     }

                     else if (talker.occupation == 46)

                     {

                        myself::ClassChange (talker, 113);

                     }

                     else if (talker.occupation == 48)

                     {

                        myself::ClassChange (talker, 114);

                     }

                     else if (talker.occupation == 51)

                     {

                        myself::ClassChange (talker, 115);

                     }

                     else if (talker.occupation == 52)

                     {

                        myself::ClassChange (talker, 116);

                     }

                     else if (talker.occupation == 55)

                     {

                        myself::ClassChange (talker, 117);

                     }

                     else if (talker.occupation == 57)

                     {

                        myself::ClassChange (talker, 118);

                     }

                     //end class change portion

                     myself::DeleteItem1 (talker, 57, cost);

                     myself::ShowPage (talker, fnHi);

                     myself::AddUseSkillDesire( talker, 1150209, 0, 0, 1000000 );

                     return;

                  }

               }

            }

            myself::ShowPage (talker, "do_not_meet_requirements_class.htm");

         }

      //clan donations

      if (ask == 41)

      {

         if (reply == 3)

         {

            i0 = costLevel3;

         }

         else if (reply == 4)

         {

            i0 = costLevel4;

         }

         else if (reply == 5)

         {

            i0 = costLevel5;

         }

         else if (reply == 6)

         {

            i0 = costLevel6;

         }

         else if (reply == 7)

         {

            i0 = costLevel7;

         }

         else if (reply == 8)

         {

            i0 = costLevel8;

         }

         if (myself::OwnItemCount (talker, donationCoin) >= i0)

         {

            if (talker.pledge_id != 0)

            {

               i1 = myself::GetPledgeSkillLevel(talker);

               if (i1 + 1 == reply)   //clan right level for choice selected

               {

                  myself::PledgeLevelUp (talker, reply);

                  myself::DeleteItem1 (talker, donationCoin, i0);

                  myself::SoundEffect( talker, "ItemSound.quest_fanfare_2" );

                  myself::ShowPage (talker, fnHi);

                  return;

               }

               else if (i1 + 1 > reply)   //clan too high of level

               {

                  myself::Say ("Sorry, " + talker.name + " your clan is already a higher level than the option you have selected.");

                  myself::ShowPage (talker, fnHi);

                  return;

               }

               else if (i1 + 1 < reply)   //clan too low of level

               {

                  myself::Say ("Sorry, " + talker.name + " your clan is too low for the option you have selected.");

                  myself::ShowPage (talker, fnHi);

                  return;

               }

            }

         }

         else

         {

         myself::ShowPage (talker, "do_not_meet_requirements.htm");

         return;

         }

      }



      // + 15 donations

      else if (ask == 200 || ask == 300 || ask == 400)

      {

         if (ask == 200)

         {

            if (myself::OwnItemCount (talker, donationCoin) < 25000)

            {

               return;

            }

            myself::DeleteItem1 (talker, donationCoin, 25000);

            myself::GiveItemEx (talker, reply, 15, 1);

            myself::Say ("+15 Has been created!");

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (ask == 300)

         {

            if (myself::OwnItemCount (talker, donationCoin) < 50000)

            {

               return;

            }

            myself::DeleteItem1 (talker, donationCoin, 50000);

            myself::GiveItemEx (talker, reply, 15, 1);

            myself::Say ("+15 Has been created!");

            myself::ShowPage (talker, fnHi);

            return;

         }

         else if (ask == 400)

         {

            if (myself::OwnItemCount (talker, donationCoin) < 100000)

            {

               return;

            }

            myself::DeleteItem1 (talker, donationCoin, 100000);

            myself::GiveItemEx (talker, reply, 15, 1);

            myself::Say ("+15 Has been created!");

            myself::ShowPage (talker, fnHi);

            return;

         }

         else

         {

            myself::Say ("Sorry " + talker.name + " but you don't have enough to buy that.");

            myself::ShowPage (talker, fnHi);

            return;

         }

      }

      //noblesse donation

      else if (reply == 1454) //ask == 78 && reply == 1

      {

         if (myself::OwnItemCount (talker, 5011) != 0)   //check star

         {

            if (myself::OwnItemCount (talker, donationCoin) >= costNoble)

            {

               if (talker.nobless_type < 1)   //check already noble

               {

                  if (myself::IsInCategory(@fourth_class_group, talker.occupation) ==1)   //check class

                  {

                     if (talker.level >= 76)   //check level

                     {

                        myself::SetNobless(talker);

                        myself::DeleteItem1 (talker, donationCoin, costNoble);

                        myself::GiveItem1(talker, 7694, 1);

                        myself::ShowPage (talker, fnHi);

                        myself::SoundEffect(talker, "ItemSound.quest_finish");

                        if (myself::HaveMemo (talker, 951) == 1)

                        {

                           myself::RemoveMemo(talker, 951);

                        }

                        return;

                     }

                     myself::Say ("Sorry, " + talker.name + " you must be level 76+ to become Noblesse.");

                     return;

                  }

                  myself::Say ("Sorry, " + talker.name + " you must be on Fourth class to become Noblesse.");

                  return;

               }

               myself::Say ("Sorry, " + talker.name + " you are already Noblesse.");

               return;

            }

            //myself::Say ("Sorry, " + talker.name + " you need more SoJ to become Noblesse.");

            return;

         }

         myself::Say ("Sorry, " + talker.name + " you need the star of Destiny to become Noblesse.");

         return;

      }



   }

}

The Code will:

Increase EXP (reply=111)

Decrease EXP (reply=222)

Sell any Multisells (ask=-303&reply=MULTISELLID)

Set final class change (reply=91) (gladiator -> duelist)

Increases Clan levels

Variable option to set cost item and cost amount

Edited by Mr.Parker
  • Upvote 1
Link to comment
Share on other sites

Why no switchcase instead of this if else sled? xDD

the excuse which i always use...

"sry i started python as first language"  :dat:

 

So imma go like ... (y they are all if elif)

 

g5JbwgS.png

Edited by bravetobe
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

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

Guest
Reply to this topic...

×   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.



  • Posts

    • https://github.com/binance/binance-futures-connector-java   Use their API, And then you can convert it to be used on your Multisell.
    • WTB 414 interface source (4game), compiler, xdat editor.  
    • Edit ItemsAutoDestroy#addItem method, simply enforce whatever timer you want. L2J already handles your case, eg. herbs naturally dissapear after a while.
    • https://www.youtube.com/watch?v=VjJ2uLlRGOc LF something similar to this. ability to do transactions/verify/withdraw/add and history. Do NOT need new window, can be done in html as long as the function works   Serious people only, paying well
    • Hello, I'm having a problem with my drop rates, due to the high amount of loot that Champions give I made it so that non-stackable items drop on the ground (since going over 500 items in the inventory disables a character), the problem is that in the long run sometimes Champions dropped hundreds or thousands of non-stackable items on the ground, causing massive lag, lowering the drop rate/chance isn't a possibility since that would mean massively decreasing the chance of item to be dropped from a regular mob, to solve this I just set the MultipleItemDrop config to False, with that only 1 item is created if the item is non-stackable   HOWEVER the problem is that now whenever I'm doing a quest and the NPC gives 2 or more items of the same ID (like the Spirit of Mirrors quest in the Human Village) I get only 1 instead, making the quest impossible to complete, I went into the core and noticed 2 variables affected by the MultipleItemDrop config: dropItem and addItem, I thought that maybe creating a new config and separating both would solve the problem, and it did, but after that if someone logged out while having equipped any item other than NG then the character would be unable to enter again, and a massive error appears on the console when someone tries to login said character, the error was basically StackOverflowError which with my really lacking knowledge of java it means that something is on an infinite loop   With that situation happening I think that now my safest option is to just limit the amount of items dropped on the ground, how can I do this? here's the code for the item drop:   public L2ItemInstance dropItem(L2PcInstance player, int itemId, long itemCount) { L2ItemInstance item = null; for (int i = 0; i < itemCount; i++) { // Randomize drop position. final int newX = (getX() + Rnd.get((RANDOM_ITEM_DROP_LIMIT * 2) + 1)) - RANDOM_ITEM_DROP_LIMIT; final int newY = (getY() + Rnd.get((RANDOM_ITEM_DROP_LIMIT * 2) + 1)) - RANDOM_ITEM_DROP_LIMIT; final int newZ = getZ() + 20; if (ItemTable.getInstance().getTemplate(itemId) == null) { LOG.error("Item doesn't exist so cannot be dropped. Item ID: {} Quest: {}", itemId, getName()); return null; } item = ItemTable.getInstance().createItem("Loot", itemId, itemCount, player, this); if (item == null) { return null; } if (player != null) { item.getDropProtection().protect(player); } item.dropMe(this, newX, newY, newZ); // Add drop to auto destroy item task. if (!Config.LIST_PROTECTED_ITEMS.contains(itemId)) { if (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect())) { ItemsAutoDestroy.getInstance().addItem(item); } } item.setProtected(false); // If stackable, end loop as entire count is included in 1 instance of item. if (item.isStackable() || !Config.MULTIPLE_ITEM_DROP) { break; } } return item; } And the code for the itemdrop on L2Attackable.java:   public void doItemDrop(L2NpcTemplate npcTemplate, L2Character mainDamageDealer) { if (mainDamageDealer == null) { return; } L2PcInstance player = mainDamageDealer.getActingPlayer(); // Don't drop anything if the last attacker or owner isn't L2PcInstance if (player == null) { return; } CursedWeaponsManager.getInstance().checkDrop(this, player); if (isSpoiled()) { _sweepItems.set(npcTemplate.calculateDrops(DropListScope.CORPSE, this, player)); } Collection<ItemHolder> deathItems = npcTemplate.calculateDrops(DropListScope.DEATH, this, player); if (deathItems != null) { for (ItemHolder drop : deathItems) { L2Item item = ItemTable.getInstance().getTemplate(drop.getId()); // Check if the autoLoot mode is active if (isFlying() || ((!item.hasExImmediateEffect() && ((!isRaid() && Config.AUTO_LOOT) && (item.isStackable() || (isRaid() && Config.AUTO_LOOT_RAIDS)))) || (item.hasExImmediateEffect() && Config.AUTO_LOOT_HERBS))) { player.doAutoLoot(this, drop); // Give the item(s) to the L2PcInstance that has killed the L2Attackable } else { dropItem(player, drop); // drop the item on the ground } // Broadcast message if RaidBoss was defeated if (isRaid() && !isRaidMinion() && (drop.getCount() > 0)) { final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DIED_DROPPED_S3_S2); sm.addCharName(this); sm.addItemName(item); sm.addLong(drop.getCount()); broadcastPacket(sm); } } } }   Thanks in advance
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock