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

    • Thank you for your reply. I have removed it from the L2Server.exe file, but the L2Server still crashes. It doesn't crash if I don't start l2npc, otherwise it will crash within a few days at the latest.
    • Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11 Telegram : https://t.me/ultrastore1 Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11
    • L2 ArenaWar: Low Rate PvP Server with Free Buffs & Autofarm [PVP]⚔️ [Free]🆓 Classic Interlude with  3x XP rates! Free starter pack(no grade) to kickstart your adventure! Autofarm for convenient grinding! Free buffs to keep you fighting fit! (2 job buffs) No experience loss on death! (Except with Karma) Clear Karma system to keep things fair! ⚖️ Active community of 800-1k players! Join our Discord to learn more! >> Discord <<     Server website: https://l2arenawar.com/en/    
    • This is dedication! 2 years working on a problem. Congratulations!
    • You indeed have to save player position over Enterworld to properly clean it up later (if you don't, even trying to delete packet content would eventually keep it up), that's what we do with debug packet (which is a reusable Map of ExServerPrimitive packets) on aCis.   It doesn't solve the FPS stuttering - more you draw/delete lines, more your client becomes laggy. It's like if client wasn't deleting drawn points/lines properly, but instead simply hide them and redrawn content above.   If you got a solution, I would happy to integrate it.   You should check aCis#Player _debug packet integration, it allows very big amount of lines/points to be drawn, it is also reusable.   https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java?ref_type=heads https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java?ref_type=heads  
  • Topics

×
×
  • Create New...