The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom AI Events
Author Message
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #1
Custom AI Events
Hi friends,
I make these AI Events just to have fun in my local server.
I'm open to suggestions.

There we go:
PHP Code:
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                        "Custom AI EVENTS" by Extreme for SphereCommunity.
//                     Contact via PM in SphereCommunity Forum or in the thread.
//                Thread link: http://forum.spherecommunity.net/showthread.php?tid=1684
//
// - Setup
//
//   -- Copy this script to your Scripts folder.
//   -- Find C_RAT, C_A_RAT_SEWER and C_RAT_GIANT and set TEVENTS=E_AI_RAT, MOVERATE 20 and increase their INT and DEX to be smarter to flee.
//   -- Find C_CAT and set TEVENTS=E_AI_CAT, MOVERATE 50 and increase their INT and DEX to be smarter and quick.
//   -- Find C_DOG and set TEVENTS=E_AI_DOG, MOVERATE 50 and increase their INT and DEX to be smarter and quick.
//   -- Find C_WOLF, C_A_WOLF_GRAY, C_A_WOLF_WHITE and C_A_DIREWOLF, and set TEVENTS=E_AI_WOLF, MOVERATE 50 and change their INT and DEX.
//   -- Find all snakes and set TEVENTS=E_AI_SNAKE
//   -- Find all birds and eagle and set TEVENTS=E_AI_BIRD
//   -- Find all bears and set TEVENTS=E_AI_BEAR
//   -- Find C_CHICKEN and set TEVENTS=E_AI_CHICKEN
//
//
//   1.0 Update [19/08/2012]
//       -- Added E_AI_WOLF
//          Will attack any mob that aren't carnivores, cats, dogs, rats and rabbits.
//          Will seek and destroy the first target until it death or be dead.
//          If get attacked by anything, will attack back.
//          They will get +5 in each status bonus if have other wolves near.
//          Every 5s it will be checked if they are in radius of 18 tiles (not using forchars, is just <DISTANCE>)
//          If the wolf leave the radius, the one that gained the bonus will lose it.
//          @ 2 debug lines that are commented if you want to test, just uncomment them.
//          //SERV.B @026,,1 <NAME> loosing bonus from <QVAL <UID.<REF1>>?<REF1.NAME>:a dead wolf>
//          //SERV.B @044,,1 <NAME> getting bonus from <SRC.NAME>
//       -- Added E_AI_RAT
//          Will try flee of any npc, player or monster comes near or try attack.
//       -- Added E_AI_CAT
//          Will attack any rat, birds and rabbits.
//          Will try flee from wolves and dogs.
//       -- Added E_AI_DOG
//          Will attack any rat and cats.
//          Will fight with wolves if get attacked.
//
//   1.1 Update [20/08/2012]
//       -- E_AI_BIRD
//          Will attack all snake kind except giant snake.
//          Will try flee from other mobs.
//       -- Added E_AI_SNAKE
//          Will attack all birds, rats, cats, rabbits and dogs.
//          Will try flee from other mobs.
//       -- Added C_RABBIT and C_A_JACKRABBIT in combat table. Cats and Snakes will attack them.
//
//   1.2 Update [20/08/2012]
//       -- Added rat memory and rat poop.
//          All rats will pee in ground every 30~60s.
//          When steping the rat poop, if <SRC> is rat or already poisoned or ISGM, nothing will happen.
//          Else it will get poisoned.
//       -- Added E_AI_BEAR.
//          They will attack any BRAIN_ANIMAL except Bears if they are stronger than the target.
//          They will seek and destroy the targets like wolves.
//          They will not have bonuses of near bears.
//          They will fish if near water, 50% chance to pull out a fish. Will eat and toss the head.
//        * The fish will be eaten only one time, preventing 2 bears eat the same fish and create 2 head for 1 fish.
//       -- All AI's will come back to their HOME if they DISTANCE > HOMEDIST
//       -- Added E_AI_CHICKEN
//          They will lay eggs on ground in every 120~180s.
//          When stepped, they will crack and deleted in 10~30s.
//        * They are not eating anything yet.
//        * The eggs will not be cracked by snakes and chickens.
//       -- Modified E_AI_SNAKE
//          They will lay eggs on ground in every 120~180s.
//          They will eat chicken and snake eggs, but not yours.
//
//   1.3 Update [21/08/2012]
//       -- Eggs now will decay in 60~120s.
//       -- When the eggs crush, it will change their DISPID.
//       
/////////////////////////////////////////////////////////////////////////////////////////////////////

[FUNCTION F_WOLVES_PACK]
IF <EVAL <
ARGV[0]>> == 1
 STR 
+= 5
 INT 
+= 5
 DEX 
+= 5
 MAXHITS 
+= 5
 MAXMANA 
+= 5
 MAXSTAM 
+= 5
 HITS 
+= 5
 MANA 
+= 5
 STAM 
+= 5
ELSE
 
REF1 <ARGS>
 IF <
UID.<REF1>>
  IF <
DISTANCE <REF1>> <= 18 
   TIMERF 5
F_WOLVES_PACK <REF1>
   RETURN 
1
  
ENDIF
 ENDIF
 
//SERV.B @026,,1 <NAME> loosing bonus from <QVAL <UID.<REF1>>?<REF1.NAME>:a dead wolf>
 
TAG.<REF1>
 
STR -= 5
 INT 
-= 5
 DEX 
-= 5
 MAXHITS 
-= 5
 MAXMANA 
-= 5
 MAXSTAM 
-= 5
 HITS 
-= 5
 MANA 
-= 5
 STAM 
-= 5
 
RETURN 1
ENDIF

[
EVENTS E_AI_WOLF]
ON=@NPCLOOKATCHAR
IF STRMATCH(*CARNIVORES*,<SERV.CHARDEF.<SRC.BASEID>.AVERSIONS>) || STRMATCH(*<SRC.BASEID>*,C_CAT,C_DOG,C_A_RAT_SEWER,C_RAT_GIANT)
 IF <
FINDID.I_WOLF_BERSERKER>
  IF !<
UID.<FINDID.I_WOLF_BERSERKER.TAG.ATTACK>>
   
FINDID.I_WOLF_BERSERKER.TAG.ATTACK <SRC>
  ENDIF
  
FINDID.I_WOLF_BERSERKER.TIMER 0
 
ELSE
  
LOCAL.OLDNEW <NEW>
  
SERV.NEWITEM I_WOLF_BERSERKER
  REF1 
<NEW>
  NEW <
LOCAL.OLDNEW>
  
REF1.CONT <UID>
  
REF1.TAG.ATTACK <SRC>
  
REF1.TIMER 0
 
ENDIF
ENDIF
IF 
STRMATCH(*WOLF*,<SRC.BASEID>)
 IF !<
dTAG.<SRC>>
  
TAG.<SRC1
  F_WOLVES_PACK 1
  
//SERV.B @044,,1 <NAME> getting bonus from <SRC.NAME>
  
TIMERF 5F_WOLVES_PACK <SRC>
 ENDIF
ENDIF
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF

ON=@NpcActFight
ARGN2 1000

ON
=@ATTACK
IF STRMATCH(*<SRC.BASEID>*,C_RAT,C_A_RAT_SEWER)
 
SRC.FLEE 10
ENDIF

[
ITEMDEF I_WOLF_BERSERKER]
ID I_MEMORY
TYPE T_EQ_SCRIPT
NAME Wolf Berserker

ON
=@CREATE
COLOR 026

ON
=@TIMER
IF <UID.<TAG0.ATTACK>>
 IF <
CONT.DISTANCE <TAG0.ATTACK>> > 1
  CONT
.TAG.OVERRIDE.MOVERATE 10
  CONT
.TIMERF 2,TAG.OVERRIDE.MOVERATE 50
  CONT
.GOTO <UID.<TAG0.ATTACK.P>
  
CONT.ATTACK <TAG0.ATTACK>
  
TIMER 5
  
RETURN 1
 
ENDIF
ENDIF
TIMER 1
RETURN 1

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_RAT]
ON=@NPCLOOKATCHAR
IF !<FINDID.I_RAT_MEM>
 
LOCAL.OLDNEW <NEW>
 
SERV.NEWITEM I_RAT_MEM
 REF1 
<NEW>
 NEW <
LOCAL.OLDNEW>
 
REF1.CONT <UID>
 
REF1.TIMER 0
ENDIF  
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF

ON=@NPCActFollow
ARGN1 
-1000

ON
=@GETHIT
FLEE 10

ON
=@HITTRY
FLEE 10

ON
=@NPCACTFIGHT
ARGN2 
-1000

[ITEMDEF I_RAT_MEM]
ID I_MEMORY
NAME Rat Memory
TYPE T_EQ_SCRIPT

ON
=@CREATE
COLOR 044

ON
=@TIMER
LOCAL
.OLDNEW <NEW>
SERV.NEWITEM I_RAT_POOP
REF1 
<NEW>
NEW <
LOCAL.OLDNEW>
REF1.<CONT.P>
REF1.TAG.RAT <CONT>
REF1.FIX
TIMER 
<EVAL {30 60}>
RETURN 
1

[ITEMDEF I_RAT_POOP]
ID I_BLOOD_POOL_LARGE
NAME Rat poop
TYPE T_EQ_SCRIPT

ON
=@CREATE
COLOR 035
ATTR ATTR_MOVE_NEVER
|ATTR_CAN_DECAY
DORAND 5
    DISPID 0122a
    DISPID 0122b
    DISPID 0122c
    DISPID 0122d
    DISPID 0122e
ENDDO
TIMER 
<R10,15>

ON=@TIMER
REMOVE
RETURN 1

ON
=@STEP
IF <SRC.FLAGS>&STATF_POISONED
 
RETURN 1
ENDIF
IF 
STRMATCH(*RAT*,<SRC.BASEID>)
 RETURN 
1
ENDIF
IF <
SRC.ISGM>
 RETURN 
1
ENDIF
IF <
UID.<TAG.RAT>>
 
// I set poison attacker as the target to avoid the mislinked item when the attacker (rat) die.
 // Then I do one damage using the rat uid to create the fight memory.
 
SRC.SPELLEFFECT S_POISON,500,<SRC.UID>
 
SRC.DAMAGE 1 01 <TAG.RAT>
ELSE
 
SRC.POISON 500,<SRC.UID>
ENDIF

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_CAT]
ON=@NPCLOOKATCHAR
IF STRMATCH(*<SRC.BASEID>*,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_RABBIT,C_A_JACKRABBIT)
 
ATTACK
ENDIF
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF

ON=@NPCActFollow
IF STRMATCH(*<SRC.BASEID>*,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_RABBIT,C_A_JACKRABBIT)
 
ATTACK
ENDIF

ON=@NPCActFight
IF STRMATCH(*<SRC.BASEID>*,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_RABBIT,C_A_JACKRABBIT)
 
ARGN2 1000
ELIF STRMATCH
(*<SRC.BASEID>*,C_DOG,C_WOLF,C_A_WOLF_GRAY,C_A_WOLF_WHITE,C_A_DIREWOLF)
 
ARGN2 -1000
ENDIF

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_DOG]
ON=@NPCLOOKATCHAR
IF STRMATCH(*<SRC.BASEID>*,C_CAT,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT)
 
ATTACK
ENDIF
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF

ON=@NPCActFollow
IF STRMATCH(*<SRC.BASEID>*,C_CAT,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT)
 
ATTACK
ENDIF

ON=@NPCActFight
IF STRMATCH(*<SRC.BASEID>*,C_CAT,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_WOLF,C_A_WOLF_GRAY,C_A_WOLF_WHITE,C_A_DIREWOLF)
 
ARGN2 1000
ENDIF

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_BIRD]   
ON=@NPCLOOKATCHAR
IF STRMATCH(*<SRC.BASEID>*,C_SNAKE,C_ICE_SNAKE,C_LAVA_SNAKE)
 
ATTACK
ENDIF
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF

ON=@NPCActFollow
IF STRMATCH(*<SRC.BASEID>*,C_SNAKE,C_ICE_SNAKE,C_LAVA_SNAKE)
 
ATTACK
ENDIF

ON=@NPCActFight
IF STRMATCH(*<SRC.BASEID>*,C_SNAKE,C_ICE_SNAKE,C_LAVA_SNAKE)
 
ARGN2 1000
ELSE
 
ARGN2 -1000
ENDIF

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_SNAKE
ON=@NPCLOOKATCHAR
IF STRMATCH(*<SRC.BASEID>*,C_BIRD,C_BIRD_CROW,C_BIRD_EAGLE,C_BIRD_MAGPIE,C_BIRD_RAVEN,C_BIRD_TROPICAL,C_BIRD_JUNGLE,C_EAGLE,C_CAT,C_DOG,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_RABBIT,C_A_JACKRABBIT)
 
ATTACK
ENDIF
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF
IF !<
FINDID.I_SNAKE_MEM>
 
LOCAL.OLDNEW <NEW>
 
SERV.NEWITEM I_SNAKE_MEM
 REF1 
<NEW>
 NEW <
LOCAL.OLDNEW>
 
REF1.CONT <UID>
 
REF1.TIMER 0
ENDIF

ON=@NPCActFollow
IF STRMATCH(*<SRC.BASEID>*,C_BIRD,C_BIRD_CROW,C_BIRD_EAGLE,C_BIRD_MAGPIE,C_BIRD_RAVEN,C_BIRD_TROPICAL,C_BIRD_JUNGLE,C_EAGLE,C_CAT,C_DOG,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_RABBIT,C_A_JACKRABBIT)
 
ATTACK
ENDIF

ON=@NPCActFight
IF STRMATCH(*<SRC.BASEID>*,C_BIRD,C_BIRD_CROW,C_BIRD_EAGLE,C_BIRD_MAGPIE,C_BIRD_RAVEN,C_BIRD_TROPICAL,C_BIRD_JUNGLE,C_EAGLE,C_CAT,C_DOG,C_RAT,C_A_RAT_SEWER,C_RAT_GIANT,C_RABBIT,C_A_JACKRABBIT)
 
ARGN2 1000
ELSE
 
ARGN2 -1000
ENDIF

[
ITEMDEF I_SNAKE_MEM]
ID I_MEMORY
TYPE T_EQ_SCRIPT
NAME Snake Memory

ON
=@CREATE
COLOR 044

ON
=@TIMER
IF <dMOREX> <= 0
 LOCAL
.OLDNEW <NEW>
 
SERV.NEWITEM I_EGGS_FRESH
 REF1 
<NEW>
 NEW <
LOCAL.OLDNEW>
 
REF1.NAME Snake eggs
 REF1
.TAG.SNAKE <CONT>
 
REF1.<CONT.P>
 
REF1.FIX
 REF1
.ATTR ATTR_DECAY
 REF1
.TIMER <EVAL {60 120}>
 
MOREX <EVAL {180 300}>
ENDIF
CONT.F_SNAKE_EAT_EGGS
MOREX 
-= 15
TIMER 15
RETURN 1

[FUNCTION F_SNAKE_EAT_EGGS]
REF1 <UID>
FORITEMS 3
 
IF STRMATCH(*eggs*,<NAME>) && STRMATCH(*I_EGGS_FRESH*,<BASEID>) && !<dTAG.EATEN> && (<DISPID>==I_EGGS_FRESH)
  IF <
TAG0.SNAKE>
   IF <
TAG0.SNAKE> != <REF1>
    
LOCAL.EGGS <UID>
   ENDIF
  ELSE        
   
LOCAL.EGGS <UID>
  ENDIF
 ENDIF
ENDFOR
IF <
LOCAL.EGGS>
 
UID.<LOCAL.EGGS>.TAG.EATEN 1
 REF1
.TIMERF 2,EMOTE eating the eggs
 REF1
.ANIM 10
 REF1
.TIMERF 1,ANIM 10
 UID
.<LOCAL.EGGS>.TIMERF 2,REMOVE
ENDIF
RETURN 
1

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_BEAR]    
ON=@NPCLOOKATCHAR
IF (<SRC.BRAIN> == BRAIN_ANIMAL) && !(STRMATCH(*BEAR*,<SRC.BASEID>)) && (<STR> > <SRC.STR>)
 IF <
FINDID.I_BEAR_BERSERKER>
  IF !<
UID.<FINDID.I_BEAR_BERSERKER.TAG.ATTACK>>
   
FINDID.I_BEAR_BERSERKER.TAG.ATTACK <SRC>
  ENDIF
  
FINDID.I_BEAR_BERSERKER.TIMER 0
 
ELSE
  
LOCAL.OLDNEW <NEW>
  
SERV.NEWITEM I_BEAR_BERSERKER
  REF1 
<NEW>
  NEW <
LOCAL.OLDNEW>
  
REF1.CONT <UID>
  
REF1.TAG.ATTACK <SRC>
  
REF1.TIMER 0
 
ENDIF
ENDIF
IF !
STRMATCH(*-1,-1*,<HOME>) && <HOME>
 IF <
DISTANCE <HOME>> > <HOMEDIST>
  GOTO <
HOME>
 ENDIF
ENDIF
IF !<
FINDID.I_BEAR_MEM>
 
LOCAL.OLDNEW <NEW>
 
SERV.NEWITEM I_BEAR_MEM
 REF1 
<NEW>
 NEW <
LOCAL.OLDNEW>
 
REF1.CONT <UID>
 
REF1.TIMER 0
ENDIF

ON=@NPCActFight
ARGN2 1000

[ITEMDEF I_BEAR_MEM]
ID I_MEMORY
TYPE T_EQ_SCRIPT
NAME Bear Memory

ON
=@CREATE
COLOR 044

ON
=@TIMER
IF <R2> == 1
 
IF <CONT.ISNEARTYPE.T_WATER 3>
  
CONT.EMOTE pulling out a fish from water
  LOCAL
.OLDNEW <NEW>
  
SERV.NEWITEM i_fish_raw_whole 1 01e16 1}
  
REF1 <NEW>
  NEW <
LOCAL.OLDNEW>
  
REF1.<CONT.P>
  
REF1.FIX
  CONT
.GOTO <REF1.P>
 ENDIF
ENDIF    
CONT.F_BEAR_EAT_FISH
TIMER 5
RETURN 1

[FUNCTION F_BEAR_EAT_FISH]
REF1 <UID>
FORITEMS 1
 
IF STRMATCH(*raw fish*,<NAME>) && !<dTAG.EATEN>
  
LOCAL.FISH <UID>
 ENDIF
ENDFOR
IF <
LOCAL.FISH>
 
UID.<LOCAL.FISH>.TAG.EATEN 1
 REF1
.TIMERF 2,EMOTE eating the fish and tossing the head
 REF1
.ANIM 10
 REF1
.TIMERF 1,ANIM 10
 LOCAL
.OLDNEW <NEW>
 
SERV.NEWITEM 01E19 1 01E1A 1}
 
REF2 <NEW>
 NEW <
LOCAL.OLDNEW>
 
REF2.P 1,1
 REF2
.ATTR 010
 REF2
.TIMERF 2,<UID.<LOCAL.FISH>.P>
 
REF2.TIMERF 2,FIX
 REF2
.TIMERF <EVAL {15 30}>,REMOVE
 UID
.<LOCAL.FISH>.TIMERF 2,FIX
 UID
.<LOCAL.FISH>.TIMERF 2,REMOVE
ENDIF
RETURN 
1

[ITEMDEF I_BEAR_BERSERKER]
ID I_MEMORY
TYPE T_EQ_SCRIPT
NAME Bear Berserker

ON
=@CREATE
COLOR 026

ON
=@TIMER
IF <UID.<TAG0.ATTACK>>
 IF <
CONT.DISTANCE <TAG0.ATTACK>> > 1
  CONT
.TAG.OVERRIDE.MOVERATE 10
  CONT
.TIMERF 2,TAG.OVERRIDE.MOVERATE 50
  CONT
.GOTO <UID.<TAG0.ATTACK.P>
  
CONT.ATTACK <TAG0.ATTACK>
  
TIMER 5
  
RETURN 1
 
ENDIF
ENDIF
TIMER 1
RETURN 1

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EVENTS E_AI_CHICKEN]
ON=@NPCLOOKATCHAR
IF !<FINDID.I_CHICKEN_MEM>
 
LOCAL.OLDNEW <NEW>
 
SERV.NEWITEM I_CHICKEN_MEM
 REF1 
<NEW>
 NEW <
LOCAL.OLDNEW>
 
REF1.CONT <UID>
 
REF1.TIMER 0
ENDIF

[
ITEMDEF I_CHICKEN_MEM]
ID I_MEMORY
NAME Chicken Memory
TYPE T_EQ_SCRIPT

ON
=@CREATE
COLOR 044

ON
=@TIMER
LOCAL
.OLDNEW <NEW>
SERV.NEWITEM I_EGGS_FRESH
REF1 
<NEW>
NEW <
LOCAL.OLDNEW>
REF1.NAME Chicken eggs
REF1
.TAG.CHICKEN <CONT>
REF1.<CONT.P>
REF1.FIX
REF1
.ATTR ATTR_DECAY
REF1
.TIMER <EVAL {60 120}>
TIMER <EVAL {180 300}>
RETURN 
1

/////////////////////////////////////////////////////////////////////////////////////////////////////

[TYPEDEF T_FOOD_RAW]
ON=@STEP
IF (<BASEID> == I_EGGS_FRESH) && (<DISPID> != I_EGGSHELLS) && !(STRMATCH(*CHICKEN*,<SRC.BASEID>)) && !(STRMATCH(*SNAKE*,<SRC.BASEID>)) 
 
SRC.EMOTE crush <NAME>
 
NAME eggshells
 SOUND 01c3 
//skeletal crush sound
 
DISPID I_EGGSHELLS
 UPDATE
 ATTR ATTR_DECAY
|ATTR_MOVE_NEVER
 TIMER 
<EVAL {30 45}>
ENDIF

/////////////////////////////////////////////////////////////////////////////////////////////////////

[EOF
Updated! 20/08/2012 12:13PM

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
(This post was last modified: 08-22-2012 10:41 AM by Extreme.)
08-20-2012 01:36 PM
Find all posts by this user Like Post Quote this message in a reply
htid4life
Journeyman
*

Posts: 162
Likes Given: 27
Likes Received: 4 in 3 posts
Joined: Mar 2012
Reputation: 2



Post: #2
RE: Custom AI Events
I Like this do rats help rats n stuff? same for rest??
a system should work out like this for birds vs snakes n rats n stuff...

[Image: htid.jpg]
08-20-2012 08:23 PM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #3
RE: Custom AI Events
(08-20-2012 08:23 PM)htid4life Wrote:  I Like this do rats help rats n stuff? same for rest??
a system should work out like this for birds vs snakes n rats n stuff...
Hmm.. everything that it will do I wrote in top of script.
But I can do it, but its strange because sphere don't works as should work.
I will make the birds and snakes AI then I post here.

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
08-21-2012 12:34 AM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #4
RE: Custom AI Events
bears, polar bears and grizzly bears should attack any brain_animal with less str, but never attack their own bear <baseid>. They should also fish near the water, randomly pull out a fish if they're standing near the shore for a certain amount of time and eat any t_fish <type> near them within 3 tiles every 5-10 seconds, leaving a fish head behind (with emotes and chomping sounds) Smile

chickens should lay eggs every 30-60 seconds and the eggs should turn into egg shells on=@step Smile

rats should poo on the ground every 30 to 60 seconds, and character objects should become mildly poisoned on=@step except rats themselves, since they're already dirty.

snakes should lay eggs every 60-120 seconds, the eggs should be crushed if stepped on other than a snake or chicken itself. Snakes should eat any eggs not layed by the same snake. In other words, snakes will eat other snakes eggs, chicken eggs but never their own eggs. Chickens do not eat eggs, chickens should eat wheat and hay and seeds (but no seeds?) Can always rescript the NPC eating script by reading <FOODTYPES> and running a FORITEMS loop. 3 being the general reaching distance of any player and character.

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
(This post was last modified: 08-21-2012 02:06 AM by Skul.)
08-21-2012 01:58 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #5
RE: Custom AI Events
(08-21-2012 01:58 AM)Skul Wrote:  bears, polar bears and grizzly bears should attack any brain_animal with less str, but never attack their own bear <baseid>. They should also fish near the water, randomly pull out a fish if they're standing near the shore for a certain amount of time and eat any t_fish <type> near them within 3 tiles every 5-10 seconds, leaving a fish head behind (with emotes and chomping sounds) Smile

chickens should lay eggs every 30-60 seconds and the eggs should turn into egg shells on=@step Smile

rats should poo on the ground every 30 to 60 seconds, and character objects should become mildly poisoned on=@step except rats themselves, since they're already dirty.

snakes should lay eggs every 60-120 seconds, the eggs should be crushed if stepped on other than a snake or chicken itself. Snakes should eat any eggs not layed by the same snake. In other words, snakes will eat other snakes eggs, chicken eggs but never their own eggs. Chickens do not eat eggs, chickens should eat wheat and hay and seeds (but no seeds?) Can always rescript the NPC eating script by reading <FOODTYPES> and running a FORITEMS loop. 3 being the general reaching distance of any player and character.
Nice! Will do it soon!

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
08-21-2012 02:14 AM
Find all posts by this user Like Post Quote this message in a reply
htid4life
Journeyman
*

Posts: 162
Likes Given: 27
Likes Received: 4 in 3 posts
Joined: Mar 2012
Reputation: 2



Post: #6
RE: Custom AI Events
Nice 1 skul sounds good

Extreme cant wait for the next release

[Image: htid.jpg]
08-21-2012 02:27 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #7
RE: Custom AI Events
Updated! 20/08/2012 06:20PM
Script updated in main post.

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
08-21-2012 07:21 AM
Find all posts by this user Like Post Quote this message in a reply
Anarch Cassius
Master
**

Posts: 273
Likes Given: 19
Likes Received: 10 in 9 posts
Joined: Mar 2012
Reputation: 2



Post: #8
RE: Custom AI Events
I like this and intend to use some of these aspects in my AI pack. One thing I'd change would be using fewer firm coded checks and more refrencing the creature's data. That way fewer events can handle more creatures. Some examples:

Use the NPCs AVERSIONS to determine what types to run from. You can also check for the carnivore type events themselves rather than bodies.

Likewise for the wolf pack hunt you could store a list of wolves in their DESIRES and check against that. Then using the event for Raptors or somesuch is as easy as adding it and editing their DESIRES.

Using this logic the bird event becomes a generic event for a monster that attacks a few specific things listed in its AVERSIONS and runs from anything else.

The egg laying event can be one script that uses a LAYER (er, bad choice of name, maybe UIDMOTHER?) tag. Then the eaters can check if they are the layer, the layer is of their species, etc. So the snake would have 3 events, the laying event, the egg eating event and a combat control event. The laying event would be shared with chickens.

Not quite in the same vein but considering NPCSpecialAction, it can be enabled with a tag and scripted to do the eggs, poop and so on. Less fine control but also less need for timers. I know this is how spider webs and fire elemental flames work and I think herd animal poop is on the same system.

"-- All AI's will come back to their HOME if they DISTANCE > HOMEDIST" This shouldn't need to be scripted, I rely on the fact they do this automatically to move NPCs along paths and to follow other NPCs.

Finally the big one. I'd like to see the bear fishing really use skill and be comparable to PC gathering. Make it work for other skills so we can have a mining Iron Beetle. Trouble is that these skills need tools so you can't just start the action and let Sphere handle it. We'd need a comparable gathering script for NPCs that don't use tools but still runs through normal checks and uses the actual resource pool of the region.

Current Projects: Necromancy SCP overhaul. Custom Faction AI/System. Imbuing.
(This post was last modified: 08-21-2012 08:17 AM by Anarch Cassius.)
08-21-2012 08:16 AM
Find all posts by this user Like Post Quote this message in a reply
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #9
RE: Custom AI Events
very nice
one idea from me aboot laying eggs.
one day the world will be over spawn with eggs.
maybe the chicken will lay a new egg if the old one was pickup from ground?
or maybe the chick lay 3 eggs and then if a player pick up one of the egg the chicken will lay another one after x seconds.
08-21-2012 03:30 PM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #10
RE: Custom AI Events
(08-21-2012 03:30 PM)admin phoenix Wrote:  very nice
one idea from me aboot laying eggs.
one day the world will be over spawn with eggs.
maybe the chicken will lay a new egg if the old one was pickup from ground?
or maybe the chick lay 3 eggs and then if a player pick up one of the egg the chicken will lay another one after x seconds.

Decay timer? <serv.decaytimer>, pretty sure it's set to 15 for 15 minutes
Code:
serv.newitem=i_eggs_fresh
new.attr |= attr_decay
new.p=<p>
new.timer=<eval <serv.decaytimer> *60>
emote lay eggs

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
08-22-2012 06:30 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)