Jump to content

Recommended Posts

Posted (edited)
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
Posted

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);
	}

 

Posted

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.

Posted
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

Posted
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

Posted
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
Posted
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 :'(

Posted
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);
}

 

Posted (edited)
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
Posted (edited)
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

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

    • hello everyone! I am wanting to save the files (Ini. - Data - ) of the EP5 Client: Salvation... But they generate the error "corrupt files"... I tried several versions of L2FileEditor without good results. I need help! Thank you!
    • Opening December 6th at 19:00 (GMT +3)! Open Beta Test from November 30th!   https://l2soe.com/   🌟 Introducing L2 Saga of Eternia: A Revolution in Lineage 2 High Five! 🌟   Dear Lineage 2 enthusiasts, Prepare to witness the future of private servers! L2 Saga of Eternia is not just another High Five project—it’s a game-changing experience designed to compete with the giants of the Lineage 2 private server scene. Built for the community, by the community, we’re here to raise the bar in quality, innovation, and longevity. What Sets Us Apart? 💎 No Wipes, Ever Say goodbye to the fear of losing your progress. Our server is built to last and will never close. Stability and consistency are our promises to you. ⚔️ Weekly New Content Our dedicated development team ensures fresh challenges, events, and updates every week. From custom quests to exclusive features, there will always be something exciting to explore. 💰 No Pay-to-Win Skill and strategy matter most here. Enjoy a balanced gameplay environment where your achievements come from effort, not your wallet. 🌍 A Massive Community With 2000+ players expected, join a vibrant and active community of like-minded adventurers ready to conquer the world of Aden. 🏆 Fair and Competitive Gameplay Our systems are designed to promote healthy competition while avoiding abusive mechanics and exploits. 🔧 Professional Development From advanced bug fixes to carefully curated content, we pride ourselves on smooth performance, no lag, and unparalleled server quality. Key Features Chronicle: High Five with unique interface Rate: Dynamic x10 rates Class Balance: Carefully fine-tuned for a fair experience PvP Focused: PvP Ranking & aura display effect for 3 Top PvPers every week Custom Events: Seasonal and permanent events to keep you engaged Additional Features:   Custom Endgame Content: Introduce unique dungeons, raids, or zones unavailable in other servers. Player-Driven Economy: Implement a strong market system and avoid overinflated drops or rewards. Epic Siege Battles: Announce special large-scale sieges and PvP events. Incentives for Streamers and Clans: Attract influencers and big clans to boost server publicity. Roadmap Transparency: Share a public roadmap of planned updates to build trust and excitemen   Here you can read all the features: https://l2soe.com/features   Video preview: Join the Revolution! This is your chance to be part of something legendary. L2 Saga of Eternia is not just a server; it’s a movement to redefine what Lineage 2 can be. Whether you’re a seasoned veteran or a newcomer to the world of Aden, we invite you to experience Lineage 2 at its finest.   Official Launch Date: December 6th 2024 Website: https://l2soe.com/ Facebook: https://www.facebook.com/l2soe Discord: https://discord.com/invite/l2eternia   Let’s build the ultimate Lineage 2 experience together. See you in-game! 🎮
    • That's like a tutorial on how to run l2 on MacOS Xd but good job for the investigation. 
    • small update: dc robe set sold   wts adena 1kk = 1.5$ 
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt
  • Topics

×
×
  • Create New...