Jump to content

Polymorph Monsters After Death Spawn New


Recommended Posts

package net.sf.l2j.gameserver.scripting.scripts.ai.group;

import net.sf.l2j.gameserver.model.actor.Attackable;
import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.scripting.EventType;
import net.sf.l2j.gameserver.scripting.scripts.ai.L2AttackableAIScript;

/**
 * @author Reborn12
 *
 */
public class PartyZonePolymorph extends L2AttackableAIScript
{
		private static final int[] MONSTER_IDS =
		{
			1009, //Stage 1 spawn
			1010, //Stage 2 spawn
			1011, //Stage 3 spawn
		};
		
	public PartyZonePolymorph()
	{
		super("ai/group");
	}
	
	@Override
	protected void registerNpcs()
	{
		addEventIds(MONSTER_IDS, EventType.ON_KILL);
	}
	
	@Override
	public String onKill(Npc npc, Player killer, boolean isPet)
	{
	switch (npc.getNpcId())
		{
			case 1009:
			{
				final Attackable newNpc = (Attackable) addSpawn(1010, npc, true, 0, false);
				attack(newNpc, killer);
 			 break;
			}
			case 1010:
			{
				final Attackable newNpc = (Attackable) addSpawn(1011, npc, true, 0, false);
				attack(newNpc, killer);
  				break;
			}
				
		}
		return super.onKill(npc, killer, isPet);
	}
}

 

Edited by Reborn12
  • Thanks 2
Link to comment
Share on other sites

Nice one reborn ;)

 

You could add a despawn in case they dont kill the next mob (this can be like the classic anti-bot protection where a mob appearing with 1kk p.def and 1kk p.atk :P )

 

finally you can write your onKill like this

 

	@Override
	public String onKill(Npc npc, Player killer, boolean isPet)
	{
		switch (npc.getNpcId())
		{
			case 1009:
			case 1010:
			{
				final Attackable newNpc = (Attackable) addSpawn(npc.getNpcId()+1, npc, true, 0, false);
				attack(newNpc, killer);
				break;
			}	
		}
		return super.onKill(npc, killer, isPet);
	}

 

Link to comment
Share on other sites

So each time you make a case you will use repeatedly code? So if i use 100 cases i'll rewrite the variable over and over?

The whole code can be done in 2 lines.

Link to comment
Share on other sites

1 minute ago, melron said:

Nice one reborn ;)

 

You could add a despawn in case they dont kill the next mob (this can be like the classic anti-bot protection where a mob appearing with 1kk p.def and 1kk p.atk :P )

 

finally you can write your onKill like this

 


	@Override
	public String onKill(Npc npc, Player killer, boolean isPet)
	{
		switch (npc.getNpcId())
		{
			case 1009:
			case 1010:
			{
				final Attackable newNpc = (Attackable) addSpawn(npc.getNpcId()+1, npc, true, 0, false);
				attack(newNpc, killer);
				break;
			}	
		}
		return super.onKill(npc, killer, isPet);
	}

 

anyone can take it and do it what he wants..i was liked this way and i did this way...i like retails :P

Link to comment
Share on other sites

1 minute ago, Reborn12 said:

anyone can take it and do it what he wants..i was liked this way and i did this way...i like retails :P

Sure yeah. You will just receive some pms to add this thing for them :D

 

p.s move 'break' inside of cases

Link to comment
Share on other sites

2 minutes ago, melron said:

Sure yeah. You will just receive some pms to add this thing for them :D

 

p.s move 'break' inside of cases

didnt noticed that :D

  • Haha 1
Link to comment
Share on other sites

11 minutes ago, .Elfocrash said:

Oh my god you noticed an open-close principle violation. I'm proud of you! (Not sarcastic, seriously good job)

What your opinion about 

Arrays.asList(MONSTER_IDS).contains(npc.getId())

Enlight us :'(

Link to comment
Share on other sites

1 minute ago, Kara` said:

What your opinion about 


Arrays.asList(MONSTER_IDS).contains(npc.getId())

Enlight us :'(

 

it is actually useless check since onKill function is called based on MONSTER_IDS ids . so its always true this line and we dont want it.

addEventIds(MONSTER_IDS, EventType.ON_KILL);

 

it can be in one line as you mentioned (i thought it too) but he wants to skip the MONSTER_ID[2] polymorph since it is the last morph :p

 

another struture of this function:

 

public String onKill(Npc npc, Player killer, boolean isPet)
{
	if (npc.getNpcId() == MONSTER_IDS[0] || npc.getNpcId() == MONSTER_IDS[1])
		attack((Attackable) addSpawn(npc.getNpcId()+1, npc, true, 0, false), killer);
	return super.onKill(npc, killer, isPet);
}

 

Link to comment
Share on other sites

15 minutes ago, .Elfocrash said:

No reason for shitty switches and clunky if statements

 

You need if because if the mob with ID 1011 will die we dont want upgrade thats why i used my if and checking 2 ints

 

also i have two questions that i dont understand.

 

1) why you used poll since you get the head of the list

2) where do you spawn the next id based on the previous one?

 

p.s actually the 3rd id is useless to register it on kill case... and its about 2-3 lines the whole code

Edited by melron
Link to comment
Share on other sites

9 minutes ago, .Elfocrash said:

The the queue is empty you don't spawn a new one

 

1) you get the head and you remove so you start from 1009 and you go to the next which is 1010 etc

2) poll will give you the head which is the next of the current one before it was polled in the previous kill

 

 

(I haven't checked if l2j treats L2AttackableAIScript as an instance per mob. If it doesn't then my code won't work. If it does, I see no reason why it wouldnt)

yeah it does as i checked with my script some days ago.

 

'I think'

Your code as code could work like that:

package net.sf.l2j;


import net.sf.l2j.gameserver.model.actor.Attackable;
import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.scripting.EventType;
import net.sf.l2j.gameserver.scripting.scripts.ai.L2AttackableAIScript;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author Reborn12
 *
 */
public class PartyZonePolymorph extends L2AttackableAIScript
{
    private final Queue<Integer> monsterIds = new LinkedList<>();

    public PartyZonePolymorph()
    {
        super("ai/group");
    }

    @Override
    protected void registerNpcs()
    {
        monsterIds.add(1009);
        monsterIds.add(1010);
        addEventIds(monsterIds, EventType.ON_KILL);
    }

    @Override
    public String onKill(Npc npc, Player killer, boolean isPet)
    {
        if(monsterIds.size() == 0)
            return super.onKill(npc, killer, isPet);

        Attackable newNpc = (Attackable) addSpawn(monsterIds.poll() +1, npc, true, 0, false);
        attack(newNpc, killer);
        return super.onKill(npc, killer, isPet);
    }
}

correct me if im wrong. The one you posted will spawn the same mob when a mob die (we need the next upgrade) +1

 

also the monsterIds.add(1011); is useless :P

Edited by melron
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.
Note: Your post will require moderator approval before it will be visible.

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

    • /data/attachments/4/4519-0e10f165cf34562cd44d346d47967752.jpg Dear friends! September 27 we start Event for Olympiad games on Open Beta server Start Olympiad games in 19:00 (UTC +3) September 27 Fights will be till 23:40, then we get Heroes (after 00:00) All who get Hero status, will receive 500 ToDs. Best 5 Hero, who will get the most PTS, will get 800 ToDs instead of 500. ToDs you will get on your Master Account balance No class vs class fights Enchant Level Restrictions: S gr +6, A gr + 7, C/B gr + 16. On Olympiad, all items that higher than restriction level will be removed, and you won't be able to use them or wear them Talent Tree avaible only Tier 1 (same like will be on 1st Oly cycle on Live server) Skill enchant lvl: 15 max for 2nd profession, 7 for 3rd profession - its global rules for all Beta Good luck to Everyone!  
    • I'm currently working on an advanced auto-farm compatible with older chronicles (C4, IL, HF, etc) and older L2J-Mobius builds. https://imgur.com/a/LJS2OMC
    • GamezAION 4.8 High Quality Relaunch Coming Friday 4th October 2024   All Latest Retail Skin Appearances Unique RvR Battlegrounds (Guardian) (Battle of Gods) Added New PvPvE Map with Seasonal Ranking System Active Anticheat System & Shugo Console Support   Download links available on website   https://gamezaion.com Join the Action!
    • 🌟 Step Into Lin2Age C4 – Your Nostalgic Journey Awaits! 🌟 Get ready for an unforgettable adventure filled with fierce battles ⚔️, mighty clans 👑, and epic quests 🌍! Lin2Age is a custom Lineage 2 server designed to bring you the ultimate classic experience, enriched with modern features. Whether you're a battle-hardened veteran or a fresh-faced newcomer, there's a place for everyone in our world! 🛡️✨   🔥 Why Lin2Age is Your Best Choice 🔥 ✅ Dynamic Events & Rewards: Enjoy thrilling features like TVT, Magic Roulette, Daily Rewards, measures to enhance your gameplay. ✅ Advanced Security Features: Enjoy robust protections with Anti-Bot measures, Password Lock, and Raid Boss Information to keep your adventures safe and secure. ✅ Balanced Gameplay for All: Dive into a harmonious blend of PvP, PvE, and crafting! Lin2Age combines the finest elements from Scions of Destiny MasterWork and Interlude, ensuring an immersive experience for every playstyle! 🛡️⚔️ ✅ Epic Gear & AIO Buffer: Equip Legendary Armor and powerful jewels! Our All-In-One Buffer is at your service, empowering you to dominate the battlefield! 💎💪 ✅ Unique Custom Features: Embark on exclusive quests 📜 and take on formidable raid bosses 🐉! Lin2Age is filled with thrilling content that keeps your adventures lively and exciting. 🎯🎮 ✅ Thriving Community: Join a vibrant community where teamwork and friendship thrive! Whether leading a clan or joining one, support is always at your fingertips! 🤝👑 ✅ Regular Updates & Events: Experience continuous excitement! With frequent updates, fresh custom content, and epic events, Lin2Age is always evolving, thanks to your invaluable feedback! 🔄🏆 ✅ Smooth, Lag-Free Experience: Enjoy uninterrupted gameplay on our top-tier servers—say goodbye to lag! 🚀⚡   💎 Fair Play Above All 💎 At Lin2Age, we champion a balanced and equitable gaming experience. Our No Pay-to-Win policy ensures that success comes from skill, strategy, and teamwork, not your wallet! 💪 Everything you need to thrive can be earned through quests, crafting, and epic battles! 🏆🎮   🔑 Key Features You’ll Love 🔑 🔹 Rates: EXP x45, SP x45, ADENA x300—meticulously balanced for your enjoyment! 🔹 Custom Classes & Skills: Discover unique classes and skills that make PvP combat dynamic! ⚔️ 🔹 Epic Raid Bosses: Challenge yourself against custom bosses for legendary loot! 💀🏹 🔹 Clan Wars & Sieges: Test your strength in exhilarating clan wars and castle sieges! 🏰⚔️ 🔹 Dedicated Support Team: Our active Game Masters are committed to ensuring fairness and smooth gameplay! 👥🛡️ ⚔️ Join the Lin2Age Beta Test – Adventurers Needed! 🛡️ Are you ready to experience the glory of Lineage 2, reimagined for a new generation? 🌍 Become part of our exclusive beta test and help shape the future of Lin2Age! 🚀✨ Start your epic journey today. Welcome to Lin2Age C4! 💬 Connect with Us on Discord Join our community, stay updated, and take part in the latest events! Discord: https://discord.gg/qKJnQ7Kp5X Youtube: https://www.youtube.com/watch?v=nnO-J_uAqvg https://prnt.sc/b3tRHlxT6YS7
  • Topics

×
×
  • Create New...