Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 19.04.2006, 14:38   #1
humordwarf
Архивный участник
 
Join Date: Feb 2006
Posts: 453
Default [AI TUT] aggro mobs: changing aggro logic

first lets look on common code for aggro mobs:
class warrior_aggressive_patrol : warrior_patrol
inside SEE_CREATURE handler:
Code:
EventHandler SEE_CREATURE(creature, myself) {
    if ((GetLifeTime() > 7)  &&  InMyTerritory(myself.sm)) {
        AddAttackDesire(creature, 1, 200);
    }
}
// 3 functions called (1+2)
we see, mob will attack only if his lifetime>7 (to let player go away after mob respawn), he is in hometerritory (not too far from respawn point) and [s:da6fe7aa15]also attack desire will be adden only if distance_to_creature < 200[/s:da6fe7aa15]
sorry, 200 - is not distance.. its something like probability

easy, we can change 200 to 500 or to 50 to some mobs, just for diversify somehow mobs behaviour

or we can add something like "if Rand(100)<5" so mob will desire attack only 5%

and turn on your lively imagination =)
example 1: what if mob desire attack players with level>40 only?
example 2: what if mob desire attack only if player not have some quest item (OwnItemCount function) hmm.. (almost same as "silence" skill =))?
example 3: what if mob desire attack orcs only ?

etc... etc...
humordwarf is offline  
Old 19.04.2006, 15:15   #2
GeNtOo
Архивный участник
 
Join Date: Jan 2006
Posts: 69
Default

nice thx
GeNtOo is offline  
Old 19.04.2006, 16:01   #3
humordwarf
Архивный участник
 
Join Date: Feb 2006
Posts: 453
Default Re: [AI TUT] aggro mobs: changing aggro logic

Quote:
Originally Posted by humordwarf
example 1: what if mob desire attack players with level>40 only?
example 2: what if mob desire attack only if player not have some quest item (OwnItemCount function) hmm.. (almost same as "silence" skill =))?
example 3: what if mob desire attack orcs only ?
1.
Code:
EventHandler SEE_CREATURE(creature, myself) { 
    if ((GetLifeTime() > 7)  &&  (creature.level > 40) &&  InMyTerritory(myself.sm)) { 
        AddAttackDesire(creature); 
    } 
}
2.
Code:
EventHandler SEE_CREATURE(creature, myself) { 
    if ((GetLifeTime() > 7)  &&  (OwnItemCount(creature, MaigcItemID)!=0) &&  InMyTerritory(myself.sm)) { 
        AddAttackDesire(creature); 
    } 
}
3.
Code:
EventHandler SEE_CREATURE(creature, myself) { 
    if ((GetLifeTime() > 7)  &&  (creature.race == OrcRaceID) &&  InMyTerritory(myself.sm)) { 
        AddAttackDesire(creature); 
    } 
}
humordwarf is offline  
Old 19.04.2006, 16:11   #4
humordwarf
Архивный участник
 
Join Date: Feb 2006
Posts: 453
Default

example 4. coward mob (run from high level players) =)

Code:
EventHandler SEE_CREATURE(creature, myself) {
    if ((creature.level-myself.level)>20)
    {
        AddFleeDesire(creature, 200);
    }
    else if ((GetLifeTime() > 7)  &&  InMyTerritory(myself.sm)) {
        AddAttackDesire(creature);
    }
}
humordwarf is offline  
Old 19.04.2006, 17:11   #5
Virexor
Архивный участник
 
Join Date: May 2005
Posts: 81
Default

nice tutorial HD thx
Virexor is offline  
Old 19.04.2006, 18:07   #6
snikr
Архивный участник
 
Join Date: Mar 2006
Posts: 57
Default Re: [AI TUT] aggro mobs: changing aggro logic

Quote:
Originally Posted by humordwarf
attack desire will be adden only if distance_to_creature < 200
With this can I make a guard kill a player who has become PK in front of him? (Now the guards won't kill him unless he goes away and then come back with karma).
snikr is offline  
Old 19.04.2006, 18:43   #7
humordwarf
Архивный участник
 
Join Date: Feb 2006
Posts: 453
Default Re: [AI TUT] aggro mobs: changing aggro logic

Quote:
Originally Posted by snikr
Quote:
Originally Posted by humordwarf
attack desire will be adden only if distance_to_creature < 200
With this can I make a guard kill a player who has become PK in front of him? (Now the guards won't kill him unless he goes away and then come back with karma).
i dont think so...
guard handler is just:
Code:
EventHandler SEE_CREATURE(creature) {
    if (creature.karma > 0) {
        AddAttackDesire(creature, 0, 1500);
    }
}
// 1 functions called (1+0)
1. called periodicaly but not frequently (or by some logic) for existing players.
2. called each time when new player appears nearby
3. called ? after EnableMakingSeeEvent() (not tested, if its true - add this using AddTimerEx(), handlers CREATED, TIMER_FIRED using e.g. 30 seconds)

you can also try to use handler from class guard_move_around
Code:
EventHandler NO_DESIRE() {
    AddMoveAroundDesire(5, 5);
}
only make sure your guard will not go too far from point
or try put there EnableMakingSeeEvent(); instead of around desire...

anyway... more expeiments = better results
humordwarf is offline  
Old 19.04.2006, 19:34   #8
snikr
Архивный участник
 
Join Date: Mar 2006
Posts: 57
Default

Thanks, we'll try this (moving around maybe) and also if there is any fox for veil when you're PK.
snikr is offline  
Old 19.04.2006, 19:42   #9
Sunrise
Архивный участник
 
Join Date: Mar 2006
Posts: 97
Default

Great tutorial. Respect HD
Sunrise is offline  
Old 19.04.2006, 20:39   #10
Sauron
Архивный участник
 
Join Date: Feb 2005
Posts: 357
Default Re: [AI TUT] aggro mobs: changing aggro logic

Quote:
Originally Posted by snikr
Quote:
Originally Posted by humordwarf
attack desire will be adden only if distance_to_creature < 200
With this can I make a guard kill a player who has become PK in front of him? (Now the guards won't kill him unless he goes away and then come back with karma).
give me an example
Sauron is offline  
Old 19.04.2006, 21:11   #11
toolpunk
Архивный участник
 
Join Date: May 2005
Posts: 2,033
Default

he didnt say its possible...
he ASKED IF its possible...
toolpunk is offline  
Old 19.04.2006, 21:57   #12
TuMBLer
Архивный участник
 
Join Date: Apr 2005
Posts: 127
Default

what about time ?
som like spawn mob only on monday? or mog say somthing every hour (for example "2:00 PM ! please take a rest for eat !").

and other thing:
mob teleport/kill/giveitem only 2/3/5 playres choisen by som criteria.
(now i use stupid system when mog when choise player by see_creature(own item) taking damage and when choic another just die and cant choice more >< )

thx forward.
TuMBLer is offline  
Old 19.04.2006, 22:04   #13
toolpunk
Архивный участник
 
Join Date: May 2005
Posts: 2,033
Default

Quote:
what about time ?
som like spawn mob only on monday? or mog say somthing every hour (for example "2:00 PM ! please take a rest for eat !").
i think timers should be able to handle that...
at least the 2nd thingy when used together with the Say function... (NASC)
toolpunk is offline  
Old 20.04.2006, 06:10   #14
Firedaemon
Архивный участник
 
Join Date: Oct 2005
Posts: 267
Default

Various time thingies from nasc

EventHandler TIME() {}

Castle_GetRawSystemTime();

EnableTimeEvent(i0);

SayInt(time);

All of which would allow you to manage timed events.
Firedaemon is offline  
Old 20.04.2006, 13:32   #15
silverdog
Архивный участник
 
Join Date: Apr 2005
Posts: 42
Default

Another good job HD, you are sexy <3
silverdog is offline  
Old 20.04.2006, 13:58   #16
humordwarf
Архивный участник
 
Join Date: Feb 2006
Posts: 453
Default

also... u can use somthing like below to see when handler works
Code:
EventHandler SEE_CREATURE(creature) {
        Say(creature.name);
}
humordwarf is offline  
Old 20.04.2006, 15:56   #17
snikr
Архивный участник
 
Join Date: Mar 2006
Posts: 57
Default

Mmm, this is like the printfs for a first debugging, great idea, I'll consider it when I have time to "play" with AI.

Thank you very much master
snikr is offline  
Old 23.04.2006, 14:48   #18
Xelat
Архивный участник
 
Join Date: Apr 2006
Posts: 70
Default Re: [AI TUT] aggro mobs: changing aggro logic

Quote:
Originally Posted by humordwarf
sorry, 200 - is not distance.. its something like probability
Small correction!
200 it's a desire! :roll:

But you have a nice idea! :wink:
Xelat is offline  
Old 23.04.2006, 14:54   #19
Xelat
Архивный участник
 
Join Date: Apr 2006
Posts: 70
Default Re: [AI TUT] aggro mobs: changing aggro logic

Quote:
Originally Posted by humordwarf
Code:
EventHandler SEE_CREATURE(creature) {
    if (creature.karma > 0) {
        AddAttackDesire(creature, 0, 1500);
    }
}
// 1 functions called (1+0)
Look at this
Code:
EventHandler SEE_CREATURE(creature) { 
    if (creature.karma > 0) { 
      if (creature.karma > 1000) AddAttackDesire(creature, 1, 1500); 
      else AddAttackDesire(creature, 0, 1500);
    } 
}
Xelat is offline  
Old 26.04.2006, 14:14   #20
TuMBLer
Архивный участник
 
Join Date: Apr 2005
Posts: 127
Default

btw
on oficial servers some mobs use only magic. no physical attack.
ive make som changes in warrior_casting_ddmagic and create new class

here is example

Code:
EventHandler ATTACKED(attacker, damage)
	{

	{
		if(attacker.is_pc != 0 || IsInCategory(@summon_npc_group, attacker.npc_class_id))
			AddUseSkillDesire(attacker, DDMagic, @ST_ATTACK, @AMT_MOVE_TO_TARGET, 1000000);
			AddAttackDesire(attacker, @AMT_MOVE_TO_TARGET, (damage/myself.sm.max_hp/0.05) * 100);
	}



	}
mob strikes back magic attack.
but skills have reload time and when skill is reloading mob hit by physical attack.

ive createt special class and replace all warrior_casting_ddmagic with that. and aggro to.
looks nice.
TuMBLer is offline  
Old 05.05.2006, 17:50   #21
kitchenknife
Архивный участник
 
Join Date: May 2006
Posts: 9
Default

if it works it sounds like an awsome idea
kitchenknife is offline  
Old 18.05.2006, 12:32   #22
Drego
Архивный участник
 
Join Date: Apr 2006
Posts: 23
Default

NASC seems to be haunted with some kind of evil force that opposes me when I try to do smth with ai )

I can't understand why when I first compile a txt file with a script, NASC says that there are errors, but when I add a space somewhere in script, compile it, than remove that space - and NASC says "Success!!!".
Moving a "{" symbol to the next line could "fix" a bunch of errors... What the ?.. Is there some kind of "random error generator" built-in in NASC?))
Drego is offline  
Old 19.05.2006, 12:09   #23
ccline123
Архивный участник
 
Join Date: May 2006
Posts: 24
Default

handler 5 have problem
because handler 5 is l2NPC offer one touch off event
NPC must update npcinfo all the time
you can made a test
you fist summon a guard_npc
then //setkarma
npc must update npcinfo ,so,npc attack you
ccline123 is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 20:10.