BlackDevilDev Posted May 15, 2016 Posted May 15, 2016 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 Quote
0 Tryskell Posted May 15, 2016 Posted May 15, 2016 (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 May 15, 2016 by Tryskell Quote
0 BlackDevilDev Posted May 15, 2016 Author Posted May 15, 2016 (edited) Thank you very much for your help i will try this code :). Need add on xml file for npc ai type? Edited May 15, 2016 by BlackDevilDev Quote
0 Sdw Posted May 15, 2016 Posted May 15, 2016 Someone wants to do Clone Attack :D It will way more complicated than attack on spawn ^^ Quote
0 BlackDevilDev Posted May 15, 2016 Author Posted May 15, 2016 Yes i want do a clone attack , you have any idea who do? Quote
0 Sdw Posted May 15, 2016 Posted May 15, 2016 It's way more complicated than just that. If you struggle with attack ... Quote
0 Tryskell Posted May 15, 2016 Posted May 15, 2016 Put some logs on L2CharacterAI onIntentionAttack to see what is happening. Quote
0 BlackDevilDev Posted May 15, 2016 Author Posted May 15, 2016 (edited) I will add soon log . Edited May 15, 2016 by BlackDevilDev Quote
0 BlackDevilDev Posted May 15, 2016 Author Posted May 15, 2016 (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 May 15, 2016 by BlackDevilDev Quote
0 SweeTs Posted May 15, 2016 Posted May 15, 2016 Why it's under try, aa? Long time ago, there was similar topic, about Strider attack :P Quote
0 LightFusion Posted May 15, 2016 Posted May 15, 2016 (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 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 May 15, 2016 by LightFusion Quote
0 BlackDevilDev Posted May 15, 2016 Author Posted May 15, 2016 (edited) Ok thank you for help i test and i right here again ... Edited May 15, 2016 by BlackDevilDev Quote
0 LightFusion Posted May 15, 2016 Posted May 15, 2016 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. Quote
0 SweeTs Posted May 15, 2016 Posted May 15, 2016 Put code between player.setDecoy(decoy); *_* break; Quote
Question
BlackDevilDev
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
20 answers to this question
Recommended Posts
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.