Jump to content

Question

Posted
final L2DecoyInstance decoy = new L2DecoyInstance(npcTemplate, player, _despawnDelay);
				decoy.setCurrentHp(decoy.getMaxHp());
				decoy.setCurrentMp(decoy.getMaxMp());
				decoy.setHeading(player.getHeading());
				decoy.setInstanceId(player.getInstanceId());
				decoy.setSummoner(player);
				decoy.spawnMe(player.getX(), player.getY(), player.getZ());
				player.setDecoy(decoy);
				break;

This is part of code for npc type = L2Decoy . 

 

I want do that when player summon this type npc , attack the target (take target from player).

 

Any idea who can do that ? 

 

Thank you very much

Recommended Posts

  • 0
Posted (edited)

I would say

final L2Object target = player.getTarget();
if (target instanceof L2Character && target.isAutoAttackable(player))
{
    decoy.setTarget(target);
    decoy.setRunning();
    decoy.getAI().setIntention(CtrlIntention.ATTACK, target);
}

But it depends of :

- if decoy got knownlist

- if decoy got AI system

 

From what I read on random SVN (googled it 5min), L2Decoy inherits L2Character, so *it should* work.

 

Put code between

	player.setDecoy(decoy);
        *_*
	break;

Explanations :

 

L2Character instance check will check both null and invalid targets (notably static objects, thrones, etc).

 

isAutoAttackable normally check for any state (pvp, pk, etc). If target can be autoattacked, it will be otherwise it won't (avoid to attack white ppl, ppl on peace zone, etc).

Edited by Tryskell
  • 0
Posted

Someone wants to do Clone Attack :D

 

It will way more complicated than attack on spawn ^^

  • 0
Posted (edited)

Import L2Character, for Baium's love.

yes yes :P worng error is not right that , just i try now add logs ... 

Who add the log ?

 

 

Is right that?


try{decoy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
catch(Exception e)
{
_log.warning(SummonNpc.class.getSimpleName() + "setIntention: " + e.getMessage());


}
Edited by BlackDevilDev
  • 0
Posted (edited)

 

yes yes :P worng error is not right that , just i try now add logs ... 

Who add the log ?

 

 

Is right that?


try{decoy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
catch(Exception e)
{
_log.warning(SummonNpc.class.getSimpleName() + "setIntention: " + e.getMessage());


}

MY eyes My eyes

tumblr_m9vxd0gZ7G1qgleipo1_400-1.jpg

 

It hurts, this java stuff is just s**t,  

 

P.S.

How you pass target - just writing that string there ? Check if its null or not, but that java is .....

P.S.S.

If you spawn decoy, how the hell - its targeting player  that spawned it, its implemented somewhere, or you just hope it is ?

ohh now i see 

decoy.spawnMe(player.getX(), player.getY(), player.getZ());

Well then that assigment must be done inside check - like that

L2DecoyInstance(npcTemplate, player, _despawnDelay);
				decoy.setCurrentHp(decoy.getMaxHp());
				decoy.setCurrentMp(decoy.getMaxMp());
				decoy.setHeading(player.getHeading());
				decoy.setInstanceId(player.getInstanceId());
				decoy.setSummoner(player);
				decoy.spawnMe(player.getX(), player.getY(), player.getZ());
				player.setDecoy(decoy);
                                decoy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player.getTarget());
 

break;

decoy.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player.getTarget());

Edited by LightFusion
  • 0
Posted

Ok the critique if you want help just do it... 

check ingame what its writed, just curiouse :D if that S***it would work....

 

but well its java, you can write all kind of stuff in just giberrish way and it might work.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • DEVELOPMENT UPDATE #3   PLAYER SHOPS AND OFFLINE TRADING   Vaelor keeps trading in the hands of players while providing tools that make private stores easier to find and maintain. Search active player stores through Alt+B. Search by item name and view the available quantities and prices. Use Locate to mark the selected store on the map. Open a private store and continue selling while the game client is closed. Offline shops can remain active for up to 48 hours. A maximum of one offline shop can be active per device. Store information is saved after activation and updated as items are sold. Saved shops are restored following a server restart.   ━━━━━━━━━━━━━━━━━━━━━━   Open Beta is currently running.   Create account: https://l2vaelor.com/register Download: https://l2vaelor.com/#download Discord: https://discord.gg/qMgPxH2fd4
    • 🔒 Zero Password Required: 1-Click upgrade link gives you instant 5TB + Gemini Pro without sharing sensitive account credentials!     FINAL CALL: Google is Shutting This Down After October 2026! Google will NEVER bring back this window of opportunity again. Once this month ends, this massive backdoor upgrade is gone permanently!  BUY 2, GET 1 FREE IS STILL LIVE! Stock up now for yourself, your family, your business, and your friends! Think about it: Every single person you know uses a Gmail account, and everyone is running out of storage. Don't let your loved ones get trapped paying $20–$30 every single month when you can set them up with 5TB Cloud Storage + Gemini Advanced (12–18 Months) right now for only $15! Why Buy Bulk Activations Today? Instant Gift Value: Perfect lifetime-style gift for clients, family, or team members. 100% Private & Safe: Activates on personal Gmails—zero passwords or logins required. Global Access: Works worldwide with zero VPN hassles. Instant Automated Delivery: Receive your activation links in seconds 24/7! ‍ Time is running out fast—secure your extra free licenses before the October deadline hits! Order Your Bundle Now on the Website
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..