Jump to content
  • 0

[Help] NPC Attacking help


Question

Posted

Hello.. I am making a mod, where you can get territories... but i have a small problem. I have some NPC which are guards, and they hit the enemies... the problem is that when i hit the flag, and i take the territorry, the guards still hit me.. if i go back to the base, and go again, they won't hit me... the same with the enemies, if they go near guards, while near the flag, if they go near the guards the guards does not hit him. Also it takes a lil bit time to attack...

 

I used code like this:

 

int hating2 = npc.getHating(target);
	                				if (hating2 == 0)
	                					npc.addDamageHate(target, 5000, 5000);

	                				setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);

 

this code in L2AttackableAI.java, in ThinkActive...

 

maybe another idea to make it faster and work as I want? thanks in advance.

6 answers to this question

Recommended Posts

  • 0
Posted

Basically guards should be spawn at same time than territorie capture. That's the only mean to do same action on one group of NPCs without hurting others.

 

Except that previous method which is the best, you can improve guard IA to act differently according to flag owner. It has to switch when flag cast is over so at same time you got "blabla took bubu territorie", you should have a IA related action.

 

That means guards are linked to that place somehow (unique name, unique title, unique... something has to be unique in order to make checks on it and retrieve some NPCs on the total amount of NPCs).

 

Not the best solution for sure.

  • 0
Posted

Hey Tryskell... I am actually using your pack, and i tried to do it with AI.. right now my problem is that, if i attack the crystal, and capture the place, if i go near the guards they hit me. if i die and i go again, they dont hit me... I need something like a timer to fix it.. but I am not damn sure how to make it.

  • 0
Posted

I told you, you have to create a "switch IA button" once flag is taken.

 

Basically, clean aggro of any guard you need and put their intentions to idle. About the "any guard you need" part, you have to find a mean to create a group linked to the flag. You have to control spawns and behavior of a whole group according to flag/zone.

 

For more infos about how to spawn things, you can check Four sepulchers (where opening a chest spawn an entire room), castle guards aswell is a good thing to leech on.

 

The pack has nothing to do on it (for one time :P). Except some russian packs, AI system looks the same from a pack to another.

  • 0
Posted

Im not really sure if i can make it.. i thought of changing ittention to attack when he sees a player, and then check again, and if the player is friendly player change to active again... or something like.. it could work...

 

EDIT: I made some changes and looks fine now, but i still have a small problem, if there is for example giran is under control by good faction, and there is a member of good faction near the guards, and an evil faction member come near the guards, the guards wont hit him unless good member goes away... if someone has any idea about this, please let me know.

 

2nd EDIT: Fixed, please lock the thread. Thanks everyone for the help.

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