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.

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
Answer this question...

×   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.



×
×
  • Create New...