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:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blitz NPC AI
Author Message
Lestatnine
Apprentice
*

Posts: 10
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Dec 2019
Reputation: 0



Post: #1
Blitz NPC AI
I really like the idea of this script where you can in effect have a populated shard without having "real" players playing just npc's.

In the directions it suggests you have to define your maps in order for it to run correctly.
[comment installation]
"You will need to add e_npcai_players to eventsplayer and e_npcai
to eventspet in sphere.ini in order for this script to work properly. "

I got the above done.

"When first loading this script be sure to set npcai_maps and:
use .enable_npcai once to enable all NPCs with this AI script or
use .enable_npcai <map#> to enable all NPCs on <map#> with this
AI script"

This part is not computing. If someone installed this script can you explain exactly how it is done. How do you set the maps..what maps? World maps?

"When first loading this script be sure to set npcai_maps"

Thx
12-30-2019 05:46 AM
Find all posts by this user Like Post Quote this message in a reply
Lestatnine
Apprentice
*

Posts: 10
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Dec 2019
Reputation: 0



Post: #2
RE: Blitz NPC AI
I finally got this working, you have to use one map at a time. But i have concluded since a vendor is saying "I am wandering now" and then "I am working now." they are not going to utilize the the scripts ability because they are tried to their spawn points.
So what has to happen is maybe you have to just create and not spawn some npcs and then they will do things, or maybe just spawn some guys but make their radius very large.
12-31-2019 02:48 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #3
RE: Blitz NPC AI
This seems to be a custom script, so maybe if you post the script ppl will be able to help you better
01-13-2020 10:15 AM
Find all posts by this user Like Post Quote this message in a reply
Lestatnine
Apprentice
*

Posts: 10
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Dec 2019
Reputation: 0



Post: #4
RE: Blitz NPC AI
In order to get it into shape so it can be edited to make it so an Admin can create an npc and that npc will go into the world with no limits relative to radius and can basically act just like a actual player character is to figure out what this script does and then tweak it... so here it is.
Its pretty big but the functions are pretty big so not too many actual functions.




VERSION=0.56b

[comment installation]
You will need to add e_npcai_players to eventsplayer and e_npcai to eventspet in sphere.ini in order for this script to work properly.

When first loading this script be sure to set npcai_maps and:

use .enable_npcai once to enable all NPCs with this AI script
or
use .enable_npcai <map#> to enable all NPCs on <map#> with this AI script

Enjoy.

[plevel 6]
enable_npcai

[defname npcai]
npcai_maps 5 //Total amount of maps your server uses.

npcai_can_eatfood_pack 1 //Do NPCs eat food out of pack?
npcai_can_eatfood_corpse 1 //Do NPCs eat corpses?
npcai_can_eatfood_hunt 1 //Do NPCs hunt and kill for food?
npcai_can_eatfood_eggs 1 //Do NPCs eat eggs?
npcai_can_eatfood_changecolor 1 //Do NPCs change colors if they eat?
npcai_can_poo_rat 1 //Do Rats 'poo'?
npcai_can_poo_horse 1 //Do Horses 'poo'?
npcai_can_poo_effect 1 //Do Rat 'poos' have a spelleffect? (Defined below)
npcai_can_mine 1 //Do NPCs mine ore?
npcai_can_chop 1 //Do NPCs chop wood?
npcai_can_chop_kindling 1 //Do NPCs chop kindling?
npcai_can_fish 1 //Do NPCs fish?
npcai_can_lay_eggs_alligators 1 //Do Alligators lay eggs?
npcai_can_lay_eggs_birds 1 //Do Birds lay eggs?
npcai_can_lay_eggs_chickens 1 //Do Chickens lay eggs?
npcai_can_lay_eggs_snakes 1 //Do Snakes lay eggs?
npcai_can_step_eggs 1 //Do eggs get crushed when stepped on?
npcai_can_throw_rock 1 //Do NPCs throw rocks?
npcai_can_throw_rock_need 1 //Do NPCs need a rock in their pack?
npcai_can_breath_fire 1 //Do NPCs breath fire?

npcai_id_eatfood_changecolor t_ore, t_ingot, t_log, t_board //NPCs will change colors to these item ids and types when eaten.
npcai_id_poo_rat i_horse_dung //ID of 'poo' for Rats
npcai_id_poo_horse i_horse_dung //ID of 'poo' for Horses
npcai_id_kindling i_kindling //ID of the kindling NPCs chop
npcai_id_rock i_rock_plain //ID of Rock(s) thrown by Cyclops, Ettins, Ogres, Titans, Trolls
npcai_id_breath i_fire_column //ID of fire breathed by NPCs
npcai_id_breath_explosion i_fx_explode //ID of explosion breathed by NPCs
npcai_id_eggs i_eggs_fresh //ID of freshly laid eggs
npcai_id_eggs_stepped i_eggshells //ID of stepped on eggs

npcai_resource_ore mr_nothing, mr_rusty, mr_iron, mr_copper //Region Resource ID(s) for NPCs that mine ore
npcai_resource_chop mr_nothing, mr_tree //Region Resource ID(s) for NPCs that chop wood
npcai_resource_fish mr_nothing, mr_fish1, mr_fish2, mr_fish3, mr_fish4 //Region Resource ID(s) for NPCs that fish fish

npcai_snd_eat {03a 03c} //SFX for eating food, corpses, eggs
npcai_snd_fish {025 026} //SFX for fishing fish
npcai_snd_chop {0147 0148} //SFX for chopping a tree
npcai_snd_mine {0125 0126} //SFX for mining ore
npcai_snd_eggs_stepped {01c2 01c6} //SFX of stepping on eggs

npcai_poo_effect s_poison //Spelleffect of poisonous Rat 'poo'
npcai_poo_effect_strength 10.0 //Strength of the spelleffect of poisonous Rat 'poo'

npcai_dam_rock {10 15} //Damage received when being hit by a rock
npcai_dam_breath {45 50} //Damage received when being hit by dragon's breath

npcai_timer_delay {1 360} //Delay in seconds between 'checks' for NPCs to do 'things' - larger the range in value the less CPU this script will use, lower the value and NPCs will do 'things' more often, default: {1 360} - Use cautiously
npcai_timer_fish {15 30} //Time between the use of fishing by NPCs
npcai_timer_chop {15 30} //Time between the use of lumberjacking by NPCs
npcai_timer_mine {15 30} //Time between the use of mining by NPCs
npcai_timer_eatfood_decay 10 //Time until food drops by 1 in value
npcai_timer_eatfood_hungry {600 660} //Time between eating food if NPC is hungry
npcai_timer_eatfood_hungrier {330 360} //Time between eating food if NPC is very hungry
npcai_timer_eatfood_hungriest {180 210} //Time between eating food if NPC is extremely hungry
npcai_timer_eatfood_replenish 30 //Time until an NPC replenishes it's foodtypes after becoming full
npcai_timer_poo_rat {1200 1800} //Time between each Rat 'poo'
npcai_timer_poo_horse {900 1200} //Time between each Horse 'poo'
npcai_timer_lay_eggs {450 600} //Time between eggs laid by NPCs
npcai_timer_throw_rock {15 30} //Time between each rock thrown by an NPC

[function enable_npcai]
if (<dargn2>==1)
if (<ischar>)
if (<isplayer>)
if !(<isevent.e_npcai_players>)
events +e_npcai_players
endif
else
if !(<tag0.npcai>)
npcai
endif
endif
endif
elseif (<dargn2>==2)
forchars 9999
enable_npcai 0, 1
endfor
region.allcharsidle enable_npcai 0, 1
else
local.p=<p>
local.maxlooptimes=<serv.maxlooptimes>
local.freezerestarttime=<serv.freezerestarttime>
serv.maxlooptimes=0
serv.freezerestarttime=0fffffff
local.p=<p>
if !(<argn1>)
for map 0 <def0.npcai_maps>
p=<serv.map(1,1,0,<dlocal.map>).region.name>
enable_npcai 0, 2
endwhile
else
p=<serv.map(1,1,0,<dargn1>).region.name>
enable_npcai 0, 2
endif
serv.maxlooptimes=<local.maxlooptimes>
serv.freezerestarttime=<local.freezerestarttime>
p=<local.p>
endif

[function npcai]
if (<ischar>)
if !(<isplayer>)
if (<p.x> > 0) && (<p.y> > 0)
tag.npcai=1
if !(strmatch(*e_npcai*,<serv.eventspet>)
if !(<isevent.e_npcai>)
events +e_npcai
endif
endif
if !( <flags> & statf_invul ) && !( <flags> & statf_freeze ) && !( <flags> & statf_invisible ) && !( <flags> & statf_sleeping ) && !( <flags> & statf_insubstantial ) && !( <flags> & statf_stone ) && !( <flags> & statf_hidden ) && !( <flags> & statf_ridden )
if !(<tag0.ate>)
if (<food> < 15)
if (<def0.npcai_can_eatfood_pack>)
npcai_eatfoodtype <npc>
endif
if (<def0.npcai_can_eatfood_corpse>)
npcai_eatcorpse <body>
endif
if (<def0.npcai_can_eatfood_hunt>)
npcai_huntforfood <body>
endif
if (<body>==c_alligator) || (<body>==c_snake) || (<body>==c_snake_giant)
if (<def0.npcai_can_eatfood_eggs>)
npcai_eateggs <body>
endif
endif
endif
endif
if (<food> > 0)
if (<dargn1> >= <eval <qval <isempty <def.npcai_timer_eatfood_decay>> ?<serv.gameminutelength>:<def0.npcai_timer_eatfood_decay>>>)
food -= 1
argn1=0
endif
else
argn1=0
endif
if (<npc>==brain_animal)
if (<body>==c_bear_grizzly) || (<body>==c_bear_polar) || (<body>==c_bear_brown)
if (<food> < 10)
if !(<notogetflag <uid>>==6)
tag.old_karma=k:<karma>
karma=-2999
endif
else
if (<notogetflag <uid>>==6)
if !(<isempty <tag.old_karma>>)
karma=<strsub 2 0 <tag0.old_karma>>
tag.old_karma=
else
karma=-799
endif
endif
endif
if !(<tag0.usingskill>)
if (<def0.npcai_can_fish>)
npcai_fish
endif
endif
elseif (<body>==c_alligator)
if (<def0.npcai_can_lay_eggs_alligators>)
if !(<tag0.actioninuse>)
npcai_lay_eggs <body>
endif
endif
elseif (<body>==c_bird) || (<body>==c_eagle)
if (<def0.npcai_can_lay_eggs_birds>)
if !(<tag0.actioninuse>)
npcai_lay_eggs <body>
endif
endif
elseif (<body>==c_chicken)
if (<def0.npcai_can_lay_eggs_chickens>)
if !(<tag0.actioninuse>)
npcai_lay_eggs <body>
endif
endif
elseif (<body>==c_snake) || (<body>==c_snake_giant)
if (<def0.npcai_can_lay_eggs_snakes>)
if !(<tag0.actioninuse>)
npcai_lay_eggs <body>
endif
endif
elseif (<body>==c_rat) || (<body>==c_rat_giant)
if (<def0.npcai_can_poo_rat>)
if !(<tag0.actioninuse>)
npcai_poo <body>
endif
endif
elseif (<body>==c_horse_brown_lt) || (<body>==c_horse_brown_dk) || (<body>==c_horse_tan) || (<body>==c_horse_gray)
if (<def0.npcai_can_poo_horse>)
if !(<tag0.actioninuse>)
npcai_poo <body>
endif
endif
endif
elseif (<npc>==brain_vendor) || (<npc>==brain_human)
if (<def0.npcai_can_mine>)
if !(<tag0.usingskill>)
if (<findtype.t_weapon_mace_pick>)
npcai_mine
endif
endif
endif
if (<def0.npcai_can_chop>)
if !(<tag0.usingskill>)
if (<findtype.t_weapon_sword>)
npcai_chop
endif
endif
endif
if (<def0.npcai_can_chop_kindling>)
if !(<tag0.usingskill>)
if (<findtype.t_weapon_fence>)
npcai_chop_kindling
endif
endif
endif
if (<def0.npcai_can_fish>)
if !(<tag0.usingskill>)
if (<findtype.t_fish_pole>)
npcai_fish
endif
endif
endif
endif
endif
timerf <eval <qval <isempty <def.npcai_timer_delay>> ?{1 360}:<def0.npcai_timer_delay>>>, npcai <eval <argn1> +1>
endif
endif
endif

[function npcai_fish]
for x -3 3
for y -3 3
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics>)
local.isplatform=
for s 0 <eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics> +-1>
if !(<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.type>==t_water)
if (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +15> >= <z>) && (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +-15> <= <z>)
if ( <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.can> & can_i_platform )
local.isplatform=1
endif
endif
endif
endfor
if (<local.isplatform>)
for s 0 <eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics> +-1>
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.type>==t_water)
local.water += 1
local.water_p<dlocal.water>=<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z>,<map>
endif
endfor
endif
endif
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).type>==t_water)
local.water += 1
local.water_p<dlocal.water>=<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).terrain.z>,<map>
endif
endfor
endfor
if (<local.water>)
local.water=<eval {1 <local.water>}>
local.water_p=<local.water_p<dlocal.water>>
local.resource=<npcai_getresource t_water, <local.water_p>>
if !(<local.resource>)
serv.newitem=i_worldgem_bit
new.type=t_water
new.attr=attr_move_never|attr_invis|attr_decay
new.p=<local.water_p>
local.resource=<new.uid>
endif
if !(<isempty <def.npcai_resource_fish>>)
local.resourceid=<def0.npcai_resource_fish>
while !(strmatch(<local.resourceid>,0))
local.x += 1
local.id.<dlocal.x>=<strarg <local.resourceid>>
local.resourceid=<streat <local.resourceid>>
endwhile
local.x=<eval {1 <local.x>}>
endif
if (<serv.regionresource.<local.id.<dlocal.x>>>)
uid.<local.resource>.more1=<local.id.<dlocal.x>>
else
dorand 5
uid.<local.resource>.more1=mr_nothing
uid.<local.resource>.more1=mr_fish1
uid.<local.resource>.more1=mr_fish2
uid.<local.resource>.more1=mr_fish3
uid.<local.resource>.more1=mr_fish4
enddo
endif
uid.<local.resource>.timer=<eval {<serv.regionresource.<uid.<local.resource>.more1>.regen>}>
act=<local.resource>
for t 0 <eval <eval <serv.skill.skill_fishing.delay> /10> +1>
timerf <dlocal.t>, sound=<eval {025 026}>
timerf <dlocal.t>, bow
timerf <dlocal.t>, face=<act.uid>
endfor
emote splashes around the shoreline
timerf <eval <eval <serv.skill.skill_fishing.delay> /10> +1>, trigger @npcai_skillsuccess,1,<eval <def0.skill_fishing> & ~0c0000000>, <act.uid>
tag.usingskill=1
endif

[function npcai_mine]
for x -3 3
for y -3 3
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics>)
for s 0 <eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics> +-1>
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.type>==t_rock)
if (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +5> >= <z>) && (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +-5> <= <z>)
local.rock += 1
local.rock_p<dlocal.rock>=<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z>,<map>
endif
endif
endfor
endif
endfor
endfor
if !(<local.rock>)
for x -3 3
for y -3 3
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).type>==t_rock)
if (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).terrain.z> +5> >= <z>) && (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).terrain.z> +-5> <= <z>)
local.rock += 1
local.rock_p<dlocal.rock>=<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).terrain.z>,<map>
endif
endif
endfor
endfor
endif
if (<local.rock>)
local.rock=<eval {1 <local.rock>}>
local.rock_p=<local.rock_p<dlocal.rock>>
local.resource=<npcai_getresource t_rock, <local.rock_p>>
if !(<local.resource>)
serv.newitem=i_worldgem_bit
new.type=t_rock
new.attr=attr_move_never|attr_invis|attr_decay
new.p=<local.rock_p>
local.resource=<new.uid>
endif
if !(<isempty <def.npcai_resource_mine>>)
local.resourceid=<def0.npcai_resource_mine>
while !(strmatch(<local.resourceid>,0))
local.x += 1
local.id.<dlocal.x>=<strarg <local.resourceid>>
local.resourceid=<streat <local.resourceid>>
endwhile
local.x=<eval {1 <local.x>}>
endif
if (<serv.regionresource.<local.id.<dlocal.x>>>)
uid.<local.resource>.more1=<local.id.<dlocal.x>>
else
dorand 4
uid.<local.resource>.more1=mr_nothing
uid.<local.resource>.more1=mr_rusty
uid.<local.resource>.more1=mr_iron
uid.<local.resource>.more1=mr_copper
enddo
endif
uid.<local.resource>.timer=<eval {<serv.regionresource.<uid.<local.resource>.more1>.regen>}>
act=<local.resource>
for t 0 <eval <eval <eval <serv.skill.skill_mining.delay> /10> +1> *3>
timerf <dlocal.t>, sound=<eval {0125 0126}>
timerf <dlocal.t>, anim 9
timerf <dlocal.t>, face=<act.uid>
endfor
emote dig the earth for ore
timerf <eval <eval <eval <serv.skill.skill_mining.delay> /10> +1> *3>, trigger @npcai_skillsuccess,1,<eval <def0.skill_mining> & ~0c0000000>, <act.uid>
tag.usingskill=1
endif

[function npcai_chop]
if (<isneartype t_tree 1>)
local.dist=1
elseif (<isneartype t_tree 2>)
local.dist=2
else
local.dist=3
endif
for x -<dlocal.dist> <local.dist>
for y -<dlocal.dist> <local.dist>
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics>)
for s 0 <eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics> +-1>
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.type>==t_tree)
if (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +5> >= <z>) && (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +-5> <= <z>)
local.tree += 1
local.tree_p<dlocal.tree>=<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z>,<map>
endif
endif
endfor
endif
endfor
endfor
if (<local.tree>)
local.tree=<eval {1 <local.tree>}>
local.tree_p=<local.tree_p<dlocal.tree>>
local.resource=<npcai_getresource t_tree, <local.tree_p>>
if !(<local.resource>)
serv.newitem=i_worldgem_bit
new.type=t_tree
new.attr=attr_move_never|attr_invis|attr_decay
new.p=<local.tree_p>
local.resource=<new.uid>
endif
if !(<isempty <def.npcai_resource_chop>>)
local.resourceid=<def0.npcai_resource_chop>
while !(strmatch(<local.resourceid>,0))
local.x += 1
local.id.<dlocal.x>=<strarg <local.resourceid>>
local.resourceid=<streat <local.resourceid>>
endwhile
local.x=<eval {1 <local.x>}>
endif
if (<serv.regionresource.<local.id.<dlocal.x>>>)
uid.<local.resource>.more1=<local.id.<dlocal.x>>
else
dorand 2
uid.<local.resource>.more1=mr_nothing
uid.<local.resource>.more1=mr_tree
enddo
endif
uid.<local.resource>.timer=<eval {<serv.regionresource.<uid.<local.resource>.more1>.regen>}>
act=<local.resource>
for t 0 <eval <eval <eval <serv.skill.skill_lumberjack.delay> /10> +1> *4>
timerf <dlocal.t>, sound=<eval {0147 0148}>
timerf <dlocal.t>, anim 9
timerf <dlocal.t>, face=<act.uid>
endfor
emote chop a tree
timerf <eval <eval <eval <serv.skill.skill_lumberjack.delay> /10> +1> *4>, trigger @npcai_skillsuccess,1,<eval <def0.skill_lumberjack> & ~0c0000000>, <act.uid>
tag.usingskill=1
endif

[function npcai_chop_kindling]
for x -3 3
for y -3 3
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics>)
for s 0 <eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics> +-1>
if (<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.type>==t_tree)
if (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +5> >= <z>) && (<eval <serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z> +-5> <= <z>)
local.tree += 1
local.tree_p<dlocal.tree>=<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,<serv.map(<eval <p.x> +<local.x>>,<eval <p.y> +<local.y>>,0,<map>).statics.<local.s>.z>,<map>
endif
endif
endfor
endif
endfor
endfor
if (<local.tree>)
local.tree=<eval {1 <local.tree>}>
local.tree_p=<local.tree_p<dlocal.tree>>
local.resource=<npcai_getresource t_tree, <local.tree_p>>
if !(<local.resource>)
serv.newitem=i_worldgem_bit
new.type=t_tree
new.attr=attr_move_never|attr_invis|attr_decay
new.p=<local.tree_p>
local.resource=<new.uid>
endif
if !(<isempty <def.npcai_resource_chop>>)
local.resourceid=<def0.npcai_resource_chop>
while !(strmatch(<local.resourceid>,0))
local.x += 1
local.id.<dlocal.x>=<strarg <local.resourceid>>
local.resourceid=<streat <local.resourceid>>
endwhile
local.x=<eval {1 <local.x>}>
uid.<local.resource>.more1=<local.id.<dlocal.x>>
else
dorand 2
uid.<local.resource>.more1=mr_nothing
uid.<local.resource>.more1=mr_tree
enddo
endif
uid.<local.resource>.timer=<eval {<serv.regionresource.<uid.<local.resource>.more1>.regen>}>
act=<local.resource>
for t 0 <eval <eval <eval <serv.skill.skill_lumberjack.delay> /10> +1> *4>
timerf <dlocal.t>, sound=<eval {0147 0148}>
timerf <dlocal.t>, anim 9
timerf <dlocal.t>, face=<act.uid>
endfor
emote chop a tree for kindling
timerf <eval <eval <eval <serv.skill.skill_lumberjack.delay> /10> +1> *4>, trigger @npcai_skillsuccess,1,<eval <def0.skill_lumberjack> & ~0c0000000>, <act.uid>, 1
tag.usingskill=1
endif

[function npcai_getresource]
local.p=<p>
p=<streat <args>>
foritems 0
if (<baseid>==i_worldgem_bit)
if (<type>==<strarg <args>>)
local.resource=<uid>
endif
endif
endfor
p=<local.p>
return <local.resource>

[function npcai_eatfoodtype]
local.foodtype=<foodtype>
if (<argn1>==<def0.brain_banker>) || (<argn1>==<def0.brain_vendor>) || (<argn1>==<def0.brain_guard>) || (<argn1>==<def0.brain_human>)
while !(<isempty <strarg <streat <local.foodtype>>>>)
if !(<local.ate>)
if (<findlayer.21>)
if (<serv.typedef.<strarg <streat <local.foodtype>>>>)
if (<findlayer.21.findtype.<strarg <streat <local.foodtype>>>>)
emote eat a <findlayer.21.findtype.<strarg <streat <local.foodtype>>>.name>
if (<eval <findlayer.21.findtype.<strarg <streat <local.foodtype>>>.amount> +-1> < 1)
findlayer.21.findtype.<strarg <streat <local.foodtype>>>.remove
else
findlayer.21.findtype.<strarg <streat <local.foodtype>>>.amount=<findlayer.21.findtype.<strarg <streat <local.foodtype>>>.amount> +-1
findlayer.21.findtype.<strarg <streat <local.foodtype>>>.update
endif
if (<def0.npcai_can_eatfood_changecolor>)
local.changecolortypes=<def0.npcai_types_eatfood_changecolor>
while !(strmatch(<local.changecolortypes>,0))
if !(<local.atecolor>)
if (strmatch(<strarg <streat <local.foodtype>>>,<strarg <local.changecolortypes>>)
local.atecolor=<findlayer.21.findtype.<strarg <streat <local.foodtype>>>.color>
endif
endif
local.changecolortypes=<streat <local.changecolortypes>>
endwhile
endif
local.ate=1
endif
elseif (<serv.itemdef.<strarg <streat <local.foodtype>>>>)
if (<findlayer.21.findid.<strarg <streat <local.foodtype>>>>)
emote eat a <findlayer.21.findid.<strarg <streat <local.foodtype>>>.name>
if (<eval <findlayer.21.findid.<strarg <streat <local.foodtype>>>.amount> +-1> < 1)
findlayer.21.findid.<strarg <streat <local.foodtype>>>.remove
else
findlayer.21.findid.<strarg <streat <local.foodtype>>>.amount=<findlayer.21.findid.<strarg <streat <local.foodtype>>>.amount> +-1
findlayer.21.findid.<strarg <streat <local.foodtype>>>.update
endif
if (<def0.npcai_can_eatfood_changecolor>)
local.changecolortypes=<def0.npcai_types_eatfood_changecolor>
while !(strmatch(<local.changecolortypes>,0))
if !(<local.atecolor>)
if (<findlayer.21.findid.<strarg <streat <local.foodtype>>>.type>==<strarg <local.changecolortypes>>)
local.atecolor=<findlayer.21.findid.<strarg <streat <local.foodtype>>>.color>
endif
endif
local.changecolortypes=<streat <local.changecolortypes>>
endwhile
endif
local.ate=1
endif
endif
endif
endif
if (<def0.<strarg <streat <local.foodtype>>>>==<def0.t_food>) || (<def0.<strarg <streat <local.foodtype>>>>==<def0.t_fruit>) || (<serv.itemdef.<strarg <streat <local.foodtype>>>.type>==t_food) || (<serv.itemdef.<strarg <streat <local.foodtype>>>.type>==t_fruit)
local.replenishable=1
endif
local.foodtype=<streat <streat <local.foodtype>>>
endwhile
endif
local.uid=<uid>
if !(<local.ate>)
foritems 3
if !(<local.ate>)
if (<uid.<local.uid>.canseelos <uid>>)
local.foodtype=<uid.<local.uid>.foodtype>
while !(<isempty <strarg <streat <local.foodtype>>>>)
if (<serv.typedef.<strarg <streat <local.foodtype>>>>)
if (<type>==<strarg <streat <local.foodtype>>>)
if (<type>==t_fish)
serv.newitem=i_fish_raw_whole
new.color=<color>
trysrc <local.uid> new.drop
elseif (<dispid>==i_eggs_fresh)
serv.newitem=i_eggshells
new.color=<color>
trysrc <local.uid> new.drop
sound=<eval {01c3 01c6}>
endif
uid.<local.uid>.emote eat a <name>
amount=<amount> +-1
if (<amount> < 1)
remove
else
update
endif
if (<def0.npcai_can_eatfood_changecolor>)
local.changecolortypes=<def0.npcai_types_eatfood_changecolor>
while !(strmatch(<local.changecolortypes>,0))
if !(<local.atecolor>)
if (<type>==<strarg <local.changecolortypes>>)
local.atecolor=<color>
endif
endif
local.changecolortypes=<streat <local.changecolortypes>>
endwhile
endif
local.ate=1
endif
elseif (<serv.itemdef.<strarg <streat <local.foodtype>>>>)
if (<baseid>==<strarg <streat <local.foodtype>>>)
if (<type>==t_fish)
serv.newitem=i_fish_raw_whole
new.color=<color>
trysrc <local.uid> new.drop
elseif (<dispid>==i_eggs_fresh)
serv.newitem=i_eggshells
new.color=<color>
trysrc <local.uid> new.drop
sound=<eval {01c3 01c6}>
endif
uid.<local.uid>.emote eat a <name>
amount=<amount> +-1
if (<amount> < 1)
remove
else
update
endif
if (<def0.npcai_can_eatfood_changecolor>)
local.changecolortypes=<def0.npcai_types_eatfood_changecolor>
while !(strmatch(<local.changecolortypes>,0))
if !(<local.atecolor>)
if (<baseid>==<strarg <local.changecolortypes>>)
local.atecolor=<findlayer.21.findid.<strarg <streat <local.foodtype>>>.color>
endif
endif
local.changecolortypes=<streat <local.changecolortypes>>
endwhile
endif
local.ate=1
endif
endif
if (<local.ate>)
local.foodtype=
else
local.foodtype=<streat <streat <local.foodtype>>>
endif
endwhile
endif
endif
endfor
endif
if (<local.ate>)
salute
sound=<eval <qval <isempty <def.npcai_snd_eat>> ?{03a 03c}:<def0.npcai_snd_eat>>>
food += 1
tag.ate=1
if (<food> < 5)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungriest>> ?{5 15}:<def0.npcai_timer_eatfood_hungriest>>>, tag.ate=
elseif (<food> < 10)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungrier>> ?{30 60}:<def0.npcai_timer_eatfood_hungrier>>>, tag.ate=
elseif (<food> < 15)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungry>> ?{90 120}:<def0.npcai_timer_eatfood_hungry>>>, tag.ate=
else
timerf <eval <qval <isempty <def.npcai_timer_eatfood_replenish>> ?{180 210}:<def0.npcai_timer_eatfood_replenish>>>, npcai_replenishfoodtype
endif
else
if (<local.replenishable>)
npcai_replenishfoodtype
endif
endif

[function npcai_replenishfoodtype]
if (<ischar>)
for <eval {3 5}>
if (<maxweight> > <weight>)
serv.newitem=random_food
if (<maxweight> > <eval <weight> +<new.weight>>)
trysrc <uid> new.bounce
else
new.remove
endif
endif
endfor
endif

[function npcai_eatcorpse]
if (<serv.chardef.<argv[0]>.baseid>==c_bear_grizzly) || (<serv.chardef.<argv[0]>.baseid>==c_bear_polar) || (<serv.chardef.<argv[0]>.baseid>==c_bear_brown) || (<serv.chardef.<argv[0]>.baseid>==c_wolf) || (<serv.chardef.<argv[0]>.baseid>==c_snake_giant) || (<serv.chardef.<argv[0]>.baseid>==c_spider_giant) || (<serv.chardef.<argv[0]>.baseid>==c_toad_giant)
local.uid=<uid>
foritems 3
if !(<local.corpse>)
if (<type>==t_corpse)
if (<uid.<local.uid>.canseelos <uid>>)
if (<tag0.npc>==<def0.brain_human>) || (<tag0.npc>==<def0.brain_vendor>) || (<tag0.npc>==<def0.brain_banker>) || (<tag0.npc>==<def0.brain_guard>) || (<tag0.npc>==<def0.brain_animal>) || (<tag0.npc>==<def0.brain_monster>) || (<tag0.npc>==<def0.brain_dragon>) || (<link.isplayer>)
if !(<tag0.waseaten>)
local.corpse=<uid>
endif
endif
endif
endif
endif
endfor
if (<local.corpse>)
face=<local.corpse>
goto <uid.<local.corpse>.p>
uid.<local.corpse>.tag.waseaten=1
serv.newitem=i_blood_pool_large
new.color=<serv.chardef.<uid.<local.corpse>.tag0.baseid>.bloodcolor>
new.attr=attr_move_never|attr_decay
new.p=<uid.<local.corpse>.p>
new.timer=<eval <serv.decaytimer> *60>
bow
emote eat some <uid.<local.corpse>.name>
sound=<eval <qval <isempty <def.npcai_snd_eat>> ?{03a 03c}:<def0.npcai_snd_eat>>>
food += 1
tag.ate=1
if (<food> < 5)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungriest>> ?{5 15}:<def0.npcai_timer_eatfood_hungriest>>>, tag.ate=
elseif (<food> < 10)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungrier>> ?{30 60}:<def0.npcai_timer_eatfood_hungrier>>>, tag.ate=
elseif (<food> < 15)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungry>> ?{90 120}:<def0.npcai_timer_eatfood_hungry>>>, tag.ate=
else
timerf <eval <qval <isempty <def.npcai_timer_eatfood_replenish>> ?{180 210}:<def0.npcai_timer_eatfood_replenish>>>, npcai_replenishfoodtype
endif
endif
endif

[function npcai_eateggs]
if (<serv.chardef.<argv[0]>.baseid>==c_alligator) || (<serv.chardef.<argv[0]>.baseid>==c_snake) || (<serv.chardef.<argv[0]>.baseid>==c_snake_giant)
local.uid=<uid>
foritems 3
if !(<local.ate>)
if (<uid.<local.uid>.canseelos <uid>>)
if (<baseid>==<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>)
local.ate=<uid>
endif
endif
endif
endfor
if (<local.ate>)
face=<local.ate>
goto <uid.<local.ate>.uid>
bow
emote eat <uid.<local.ate>.name>
if (<uid.<local.ate>.amount> > 1)
uid.<local.ate>.amount -= 1
uid.<local.ate>.update
else
uid.<local.ate>.remove
endif
sound=<eval <qval <isempty <def.npcai_snd_eat>> ?{03a 03c}:<def0.npcai_snd_eat>>>
food += 1
tag.ate=1
if (<food> < 5)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungriest>> ?{5 15}:<def0.npcai_timer_eatfood_hungriest>>>, tag.ate=
elseif (<food> < 10)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungrier>> ?{30 60}:<def0.npcai_timer_eatfood_hungrier>>>, tag.ate=
elseif (<food> < 15)
timerf <eval <qval <isempty <def.npcai_timer_eatfood_hungry>> ?{90 120}:<def0.npcai_timer_eatfood_hungry>>>, tag.ate=
else
timerf <eval <qval <isempty <def.npcai_timer_eatfood_replenish>> ?{180 210}:<def0.npcai_timer_eatfood_replenish>>>, npcai_replenishfoodtype
endif
endif
endif

[function npcai_huntforfood]
if !(<tag0.isattacking>)
if (<serv.chardef.<argv[0]>.baseid>==c_bear_grizzly) || (<serv.chardef.<argv[0]>.baseid>==c_bear_polar) || (<serv.chardef.<argv[0]>.baseid>==c_bear_brown)
local.uid=<uid>
forchars <serv.distancetalk>
if !(<local.attack>)
if !(<uid>==<local.uid>)
if (<notogetflag <uid>>==3)
if (<str> < <uid.<local.uid>.str>)
if !(<body>==c_bear_grizzly) && !(<body>==c_bear_polar) && !(<body>==c_bear_brown)
if !( <flags> & statf_invul ) && !( <flags> & statf_freeze ) && !( <flags> & statf_invisible ) && !( <flags> & statf_sleeping ) && !( <flags> & statf_insubstantial ) && !( <flags> & statf_stone ) && !( <flags> & statf_hidden ) && !( <flags> & statf_ridden )
local.attack=<uid>
endif
endif
endif
endif
endif
endif
endfor
if (<local.attack>)
emote growl
bark 2
tag.isattacking=<local.attack>
attack=<local.attack>
uid.<local.attack>.tag.isattackedby=<uid>
endif
elseif (<serv.chardef.<argv[0]>.baseid>==c_wolf)
forchars <serv.distancetalk>
if !(<local.attack>)
if !(<uid>==<local.uid>)
if (<notogetflag <uid>>==3)
if (<str> < <uid.<local.uid>.str>)
if !(<body>==c_wolf)
if !( <flags> & statf-invul ) && !( <flags> & statf_freeze ) && !( <flags> & statf_invisible ) && !( <flags> & statf_sleeping ) && !( <flags> & statf_insubstantial ) && !( <flags> & statf_stone ) && !( <flags> & statf_hidden ) && !( <flags> & statf_ridden )
local.attack=<uid>
endif
endif
endif
endif
endif
endif
endfor
if (<local.attack>)
emote growl
bark 2
tag.isattacking=<local.attack>
attack=<local.attack>
uid.<local.attack>.tag.isattackedby=<uid>
endif
elseif (<serv.chardef.<argv[0]>.baseid>==c_toad_giant)
forchars <serv.distancetalk>
if !(<local.attack>)
if !(<uid>==<local.uid>)
if (<notogetflag <uid>>==3) || (<notogetflag <uid>>==6)
if (<str> < <uid.<local.uid>.str>)
if !(<body>==c_toad_giant)
if !( <flags> & statf-invul ) && !( <flags> & statf_freeze ) && !( <flags> & statf_invisible ) && !( <flags> & statf_sleeping ) && !( <flags> & statf_insubstantial ) && !( <flags> & statf_stone ) && !( <flags> & statf_hidden ) && !( <flags> & statf_ridden )
local.attack=<uid>
endif
endif
endif
endif
endif
endif
endfor
if (<local.attack>)
bark 2
tag.isattacking=<local.attack>
attack=<local.attack>
uid.<local.attack>.tag.isattackedby=<uid>
endif
elseif (<serv.chardef.<argv[0]>.baseid>==c_spider_giant)
forchars <serv.distancetalk>
if !(<local.attack>)
if !(<uid>==<local.uid>)
if (<notogetflag <uid>>==3) || (<notogetflag <uid>>==6)
if (<str> < <uid.<local.uid>.str>)
if !(<body>==c_spider_giant)
if !( <flags> & statf-invul ) && !( <flags> & statf_freeze ) && !( <flags> & statf_invisible ) && !( <flags> & statf_sleeping ) && !( <flags> & statf_insubstantial ) && !( <flags> & statf_stone ) && !( <flags> & statf_hidden ) && !( <flags> & statf_ridden )
local.attack=<uid>
endif
endif
endif
endif
endif
endif
endfor
if (<local.attack>)
bark 2
tag.isattacking=<local.attack>
attack=<local.attack>
uid.<local.attack>.tag.isattackedby=<uid>
endif
elseif (<serv.chardef.<argv[0]>.baseid>==c_snake_giant)
forchars <serv.distancetalk>
if !(<local.attack>)
if !(<uid>==<local.uid>)
if (<notogetflag <uid>>==3) || (<notogetflag <uid>>==6)
if (<str> < <uid.<local.uid>.str>)
if !(<body>==c_snake_giant)
if !( <flags> & statf-invul ) && !( <flags> & statf_freeze ) && !( <flags> & statf_invisible ) && !( <flags> & statf_sleeping ) && !( <flags> & statf_insubstantial ) && !( <flags> & statf_stone ) && !( <flags> & statf_hidden ) && !( <flags> & statf_ridden )
local.attack=<uid>
endif
endif
endif
endif
endif
endif
endfor
if (<local.attack>)
emote hiss
bark 2
tag.isattacking=<local.attack>
attack=<local.attack>
uid.<local.attack>.tag.isattackedby=<uid>
endif
endif
endif

[function npcai_lay_eggs]
if (<serv.chardef.<argv[0]>.baseid>==c_alligator)
serv.newitem=<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>
new.name=alligator eggs
new.link=<uid>
new.attr |= attr_decay
new.p=<p>
new.timer=<eval <serv.decaytimer> *60>
emote lay <new.name>
bark 2
anim=4
tag.actioninuse=1
timerf <eval <qval <isempty <def.npcai_timer_lay_eggs>> ?{300 450}:<def0.npcai_timer_lay_eggs>>>, tag.actioninuse=
elseif (<serv.chardef.<argv[0]>.baseid>==c_bird) || (<serv.chardef.<argv[0]>.baseid>==c_eagle)
serv.newitem=<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>
new.name=bird eggs
new.color=colors_blue
new.link=<uid>
new.attr |= attr_decay
new.p=<p>
new.timer=<eval <serv.decaytimer> *60>
emote lay <new.name>
bark 2
anim=4
tag.actioninuse=1
timerf <eval <qval <isempty <def.npcai_timer_lay_eggs>> ?{300 450}:<def0.npcai_timer_lay_eggs>>>, tag.actioninuse=
elseif (<serv.chardef.<argv[0]>.baseid>==c_chicken)
serv.newitem=<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>
new.link=<uid>
new.attr |= attr_decay
new.p=<p>
new.timer=<eval <serv.decaytimer> *60>
emote lay <new.name>
bark 2
anim=4
tag.actioninuse=1
timerf <eval <qval <isempty <def.npcai_timer_lay_eggs>> ?{300 450}:<def0.npcai_timer_lay_eggs>>>, tag.actioninuse=
elseif (<serv.chardef.<argv[0]>.baseid>==c_snake) || (<serv.chardef.<argv[0]>.baseid>==c_snake_giant)
serv.newitem=<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>
new.name=snake eggs
new.color=colors_green
new.link=<uid>
new.attr |= attr_decay
new.p=<p>
new.timer=<eval <serv.decaytimer> *60>
emote lay <new.name>
bark 2
anim=4
tag.actioninuse=1
timerf <eval <qval <isempty <def.npcai_timer_lay_eggs>> ?{300 450}:<def0.npcai_timer_lay_eggs>>>, tag.actioninuse=
endif

[function npcai_poo]
if (<serv.chardef.<argv[0]>.baseid>==c_rat) || (<serv.chardef.<argv[0]>.baseid>==c_rat_giant)
emote lay a turd
anim 1
bark 4
if !(<isempty <def.npcai_id_poo_rat>>)
local.pooid=<def0.npcai_id_poo_rat>
while !(strmatch(<local.pooid>,0))
local.x += 1
local.id.<dlocal.x>=<strarg <local.pooid>>
local.pooid=<streat <local.pooid>>
endwhile
local.x=<eval {1 <local.x>}>
endif
if (<serv.itemdef.<local.id.<dlocal.x>>>)
serv.newitem=<local.id.<dlocal.x>>
else
serv.newitem=i_horse_dung
endif
new.name=rat poo
new.attr |= attr_move_never|attr_decay
if (<def0.npcai_can_poo_effect>)
new.morex=<qval !<def0.npcai_poo_effect> ?s_poison:<def0.npcai_poo_effect>>
new.morey=<qval !<def0.npcai_poo_effect_strength> ?10.0:<def0.npcai_poo_effect_strength>>
endif
new.p=<p>
new.timer=<eval <serv.decaytimer> *60>
new.link=<uid>
tag.actioninuse=1
timerf <eval <qval <isempty <def.npcai_timer_poo_rat>> ?{600 900}:<def0.npcai_timer_poo_rat>>>, tag.actioninuse=
elseif (<serv.chardef.<argv[0]>.baseid>==c_horse_brown_lt) || (<serv.chardef.<argv[0]>.baseid>==c_horse_brown_dk) || (<serv.chardef.<argv[0]>.baseid>==c_horse_tan) || (<serv.chardef.<argv[0]>.baseid>==c_horse_gray)
emote pinch a loaf
anim 3
bark 3
if !(<isempty <def.npcai_id_poo_horse>>)
local.pooid=<def0.npcai_id_poo_horse>
while !(strmatch(<local.pooid>,0))
local.x += 1
local.id.<dlocal.x>=<strarg <local.pooid>>
local.pooid=<streat <local.pooid>>
endwhile
local.x=<eval {1 <local.x>}>
endif
if (<serv.itemdef.<local.id.<dlocal.x>>>)
serv.newitem=<local.id.<dlocal.x>>
else
serv.newitem=i_horse_dung
endif
new.attr |= attr_move_never|attr_decay
doswitch <dir>
new.p=<p.x>,<eval <p.y> +1>,<z>,<map>
new.p=<eval <p.x> +-1>,<eval <p.y> +1>,<z>,<map>
new.p=<eval <p.x> +-1>,<p.y>,<z>,<map>
new.p=<eval <p.x> +-1>,<eval <p.y> +-1>,<z>,<map>
new.p=<p.x>,<eval <p.y> +-1>,<z>,<map>
new.p=<eval <p.x> +1>,<eval <p.y> +-1>,<z>,<map>
new.p=<eval <p.x> +1>,<p.y>,<z>,<map>
new.p=<eval <p.x> +1>,<eval <p.y> +1>,<z>,<map>
end
new.timer=<eval <serv.decaytimer> *60>
tag.actioninuse=1
timerf <eval <qval <isempty <def.npcai_timer_poo_horse>> ?{600 900}:<def0.npcai_timer_poo_horse>>>, tag.actioninuse=
endif

[function npcai_throw_rock]
local.rockid=<findid.<argv[0]>.dispiddec>
local.color=<findid.<argv[0]>.color>
if (<def0.npcai_can_throw_rock_need>)
if (<findid.<argv[0]>>)
consume 1 <argv[0]>
local.canthrowrock=1
endif
else
local.canthrowrock=1
endif
if (<local.canthrowrock>)
serv.newitem=<local.rockid>
new.attr |= attr_decay
new.color=<local.color>
new.p=<streat <streat <args>>>
new.timer=30
effectto <new.dispiddec>, <p.x>, <p.y>, <eval <p.z> +7>, <new.p.x>, <new.p.y>, <eval <new.z> +3>, 0, 0, 0, <qval <local.color> ? <eval <local.color> +-1>:<local.color>>, 0
if (<distance <argv[1]>> < <serv.distancetalk>)
if (<uid.<argv[1]>.distance <new.uid>>==0)
uid.<argv[1]>.damage=<eval <qval <isempty <def.npcai_dam_rock>> ?{10 15}:<def0.npcai_dam_rock>>> 01 <uid>
endif
endif
bark=2
endif
tag.npcfightaction=2

[function npcai_breath_fire]
serv.newitem=<qval <isempty <def.npcai_id_breath_explosion>> ?i_fx_explode:<def0.npcai_id_breath_explosion>>
new.attr |= attr_decay|attr_move_never
if !(<isempty <def.color_ice>>)
if (<color>==<def0.color_ice>)
local.color=<def0.color_ice>
endif
endif
new.color=<local.color>
new.p=<streat <args>>
new.timer=3
effectto <qval <isempty <def.npcai_id_breath>> ?<new.dispiddec>:<def0.npcai_id_breath>>, <p.x>, <p.y>, <eval <p.z> +7>, <new.p.x>, <new.p.y>, <eval <new.z> +3>, 1, 0, 0, <qval <local.color> ? <eval <local.color> +-1>:<local.color>>, 0
new.npcai_breath_fire_explosion <uid>
new.timerf 1, npcai_breath_fire_explosion <uid>
new.timerf 2, npcai_breath_fire_explosion <uid>
bark=3
tag.npcfightaction=2

[function npcai_breath_fire_explosion]
local.uid=<uid>
forchars 3
if (<isplayer>)
damage=<eval <eval <qval <isempty <def.npcai_dam_breath>> ?{45 50}:<def0.npcai_dam_breath>>> /<qval !<distance <local.uid>> ?1:<distance <local.uid>>>> 01 <argn1>
endif
endfor

[events e_npcai]
on=@deathcorpse
uid.<argo.uid>.tag.npc=<npc>

on=@destroy
if (<uid.<tag0.isattackedby>.ischar>)
uid.<tag0.isattackedby>.tag.isattacking=
endif

on=@npcactfight
if (<dtag0.npcfightaction>==1)
return 1
elseif (<dtag0.npcfightaction>==2)
tag.npcfightaction=3
timerf 30, tag.npcfightaction=
endif
if !(<tag0.npcfightaction>)
if (<serv.skill.<action>.key>==wrestling)
if (<distance> > 3)
if (<body>==c_cyclops) || (<body>==c_ettin) || (<body>==c_ettin_w_axe) || (<body>==c_ogre) || (<body>==c_titan) || (<body>==c_troll) || (<body>==c_troll_w_mace) || (<body>==c_troll_w_axe)
if (<def0.npcai_can_throw_rock>)
if !(<isempty <def.npcai_id_rock>>)
local.rock=<def0.npcai_id_rock>
while !(strmatch(<local.rock>,0))
local.x += 1
local.rock.<dlocal.x>=<strarg <local.rock>>
local.rock=<streat <local.rock>>
endwhile
local.x=<eval {1 <local.x>}>
local.rock=<local.rock.<dlocal.x>>
else
local.rock=i_rock_plain
endif
if (<def0.npcai_can_throw_rock_need>)
if (<restest <local.rock>>)
local.canthrowrock=1
endif
else
local.canthrowrock=1
endif
if (<local.canthrowrock>)
anim=12
emote throw a rock at <src.name>
timerf 3, npcai_throw_rock <local.rock>, <src.uid>, <src.p>
tag.npcfightaction=1
endif
endif
endif
if (<npc>==brain_dragon)
if (<def0.npcai_can_breath_fire>)
anim=12
emote breath fire at <src.name>
timerf 3, npcai_breath_fire <src.uid>, <src.p>
tag.npcfightaction=1
endif
endif
endif
endif
endif
return 0

on=@skillgain
if (<eval <<serv.skill.<argn1>.key>>> < <qval <serv.skillclass.0.<serv.skill.<argn1>.key>> ?<serv.skillclass.0.<serv.skill.<argn1>.key>>:1000>)
local.rand=<eval {<eval <<serv.skill.<argn1>.key>> <qval <serv.skillclass.0.<serv.skill.<argn1>.key>> ?<serv.skillclass.0.<serv.skill.<argn1>.key>>:1000>}>
if (<dlocal.rand> < 25)
<serv.skill.<argn1>.key>=<<serv.skill.<argn1>.key>> +0.1
endif
endif

on=@regionenter
if !(<tag0.npcai>)
npcai
endif

on=@npcai_skillsuccess
if (<serv.skill.<argn1>.key>==fishing)
if (<uid.<argn2>.isitem>)
if !(<uid.<argn2>.more1>==mr_nothing)
local.rand=<eval {<eval <fishing>> 1000}>
if (<dlocal.rand> > 25)
uid.<argn2>.amount=1
serv.newitem=<serv.regionresource.<uid.<argn2>.more1>.reap>
new.amount=<uid.<argn2>.amount>
effectto <new.dispiddec>, <uid.<argn2>.p.x>, <uid.<argn2>.p.y>, <eval <uid.<argn2>.z> +3>, <p.x>, <p.y>, <eval <z> +7>, 1, <dir>, 0, <qval <new.color> ?<eval <new.color> +-1>:0>, 0
trysrc <uid> new.drop
emote catch a <new.name>
sound=<eval <qval <isempty <def.npcai_snd_fish>> ?{025 026}:<def0.npcai_snd_fish>>>
endif
skillgain fishing <eval <fishing> /10>
endif
else
emote could not find anything
endif
timerf <eval <qval <isempty <def.npcai_timer_fish>> ?{15 30}:<def0.npcai_timer_fish>>>, tag.usingskill=
elseif (<serv.skill.<argn1>.key>==mining)
if (<uid.<argn2>.isitem>)
if !(<uid.<argn2>.more1>==mr_nothing)
local.rand=<eval {<eval <mining>> 1000}>
if (<dlocal.rand> > 25)
uid.<argn2>.amount=<eval {1 5}>
serv.newitem=<serv.regionresource.<uid.<argn2>.more1>.reap>
new.amount=<uid.<argn2>.amount>
effectto <new.dispiddec>, <uid.<argn2>.p.x>, <uid.<argn2>.p.y>, <eval <uid.<argn2>.z> +3>, <p.x>, <p.y>, <eval <z> +7>, 1, <dir>, 0, <qval <new.color> ?<eval <new.color> +-1>:0>, 0
trysrc <uid> new.bounce
emote dig <new.name>
sound=<eval <qval <isempty <def.npcai_snd_mine>> ?{0125 0126}:<def0.npcai_snd_mine>>>
endif
skillgain mining <eval <mining> /10>
endif
else
emote could not find anything
endif
timerf <eval <qval <isempty <def.npcai_timer_mine>> ?{15 30}:<def0.npcai_timer_mine>>>, tag.usingskill=
elseif (<serv.skill.<argn1>.key>==lumberjacking)
if (<uid.<argn2>.isitem>)
if !(<uid.<argn2>.more1>==mr_nothing)
local.rand=<eval {<eval <lumberjacking>> 1000}>
if (<dlocal.rand> > 25)
uid.<argn2>.amount=<eval {1 3}>
if (<argn3>)
serv.newitem=i_kindling
else
serv.newitem=<serv.regionresource.<uid.<argn2>.more1>.reap>
endif
new.amount=<uid.<argn2>.amount>
effectto <new.dispiddec>, <uid.<argn2>.p.x>, <uid.<argn2>.p.y>, <eval <uid.<argn2>.z> +3>, <p.x>, <p.y>, <eval <z> +7>, 1, <dir>, 0, <qval <new.color> ?<eval <new.color> +-1>:0>, 0
trysrc <uid> new.bounce
if (<new.baseid>==i_log) || (<new.baseid>==i_kindling)
emote chop <new.name>
else
emote chop <qval <new.amount>==1 ?<new.name> log:<new.name> logs>
endif
sound=<eval <qval <isempty <def.npcai_snd_chop>> ?{0147 0148}:<def0.npcai_snd_chop>>>
endif
skillgain mining <eval <lumberjacking> /10>
endif
else
emote could not find anything
endif
timerf <eval <qval <isempty <def.npcai_timer_chop>> ?{15 30}:<def0.npcai_timer_chop>>>, tag.usingskill=
endif

[events e_npcai_players]
on=@itemstep
if (<def0.npcai_can_poo_effect>)
if (<act.baseid>==<qval <isempty <def.npcai_id_poo>> ?i_horse_dung:<def0.npcai_id_poo>>)
if (<act.morex>) && (<act.morey>)
spelleffect <act.morex>, <act.morey>, <act.link.uid>
//effectcmp=3,<serv.spell.<act.morex>.effect_id>,15,15,1
//sound=<serv.spell.<act.morex>.sound>
endif
endif
endif
if (<def0.npcai_can_step_eggs>)
if (<serv.itemdef.<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>>)
if (<act.dispid>==<qval <isempty <def.npcai_id_eggs>> ?i_eggs_fresh:<def0.npcai_id_eggs>>)
act.dispid=<qval <isempty <def.npcai_id_eggs_stepped>> ?i_eggshells:<def0.npcai_id_eggs_stepped>>
act.name=<serv.itemdef.<act.dispid>.name>
act.update
act.sound=<eval <def0.npcai_snd_eggs_stepped>>
endif
endif
endif

[function effectto]
forclients 18
if (<account.resdisp> >= 4)
sendpacket 0c0 00 00 00 00 00 00 00 00 00 W<argv[0]> W<argv[1]> W<argv[2]> B<argv[3]> W<argv[4]> W<argv[5]> B<argv[6]> B<argv[7]> 00 00 00 B<argv[8]> B<argv[9]> D<argv[10]> D<argv[11]>
endif
endfor

[function effectcmp]
if !(<isempty <strarg <argv[4]>>>)
local.explode=<strarg <argv[4]>>
endif
if !(<isempty <strarg <streat <argv[4]>>>>)
local.color=<strarg <streat <argv[4]>>>
endif
if !(<isempty <strarg <streat <streat <argv[4]>>>>>)
local.render=<strarg <streat <streat <argv[4]>>>>
endif
if !(<isempty <argv[5]>>)
local.render=<argv[5]>
endif
local.src=<uid>
if !(<eval <argv[0]>>)
forclients 18
if (<account.resdisp> >= 4)
sendpacket 0c0 b<argv[0]> d<src.uid> d<local.src> w<argv[1]> w<src.p.x> w<src.p.y> b<src.z> w<uid.<local.src>.p.x> w<uid.<local.src>.p.y> b<uid.<local.src>.z> b<argv[2]> b<argv[3]> w0 b01 b<local.explode> d<local.color> d<local.render>
endif
endfor
elseif (<eval <argv[0]>>==1) && !(<isitem>)
forclients 18
if (<account.resdisp> >= 4)
sendpacket 0c0 b<argv[0]> d<local.src> d<uid> w0 w0 w0 b0 w0 w0 b0 b0 b0 w0 b0 b0 d0 d0
endif
endfor
elseif (<eval <argv[0]>>==2) && (<isitem>)
forclients 18
if (<account.resdisp> >= 4)
sendpacket 0c0 b<argv[0]> d<local.src> d<uid> w<argv[1]> w<uid.<local.src>.p.x> w<uid.<local.src>.p.y> b<uid.<local.src>.z> w0 w0 b0 b<argv[2]> b<argv[3]> w0 b01 b0 d<local.color> d<local.render>
endif
endfor
elseif (<eval <argv[0]>>==3) && !(<isitem>)
forclients 18
if (<account.resdisp> >= 4)
sendpacket 0c0 b<argv[0]> d<local.src> d<uid> w<argv[1]> w<uid.<local.src>.p.x> w<uid.<local.src>.p.y> b<uid.<local.src>.z> w0 w0 b0 b<argv[2]> b<argv[3]> w0 b01 b0 d<local.color> d<local.render>
endif
endfor
elseif (<eval <argv[0]>>==4)
if (<account.resdisp> >= 4)
sendpacket 070 b<argv[0]> d<local.src> d<uid> w<argv[1]> w0 w0 b0 w0 w0 b0 b0 b0 w0 b0 b0
endif
endif

[eof]

********************************************************************************​*

*****************************************************************
[plevel 6]
enable_npcai
//******************************************** This command enables the script in game



[defname npcai]
npcai_maps 5 //Total amount of maps your server uses.

//****************************************** This is how many maps you want the script to work on..Mine is set to one

/////*********************** All these are variables (things the npc can so ) so this could be stuff like fight and one thing is sell and buy from vendors.. Kind of have to think what a player does, but buy and sell to vendors would add the ability to create an AI functioning economy..



npcai_can_eatfood_pack 1 //Do NPCs eat food out of pack?
npcai_can_eatfood_corpse 1 //Do NPCs eat corpses?
npcai_can_eatfood_hunt 1 //Do NPCs hunt and kill for food?
npcai_can_eatfood_eggs 1 //Do NPCs eat eggs?
npcai_can_eatfood_changecolor 1 //Do NPCs change colors if they eat?
npcai_can_poo_rat 1 //Do Rats 'poo'?
npcai_can_poo_horse 1 //Do Horses 'poo'?
npcai_can_poo_effect 1 //Do Rat 'poos' have a spelleffect? (Defined below)
npcai_can_mine 1 //Do NPCs mine ore?
npcai_can_chop 1 //Do NPCs chop wood?
npcai_can_chop_kindling 1 //Do NPCs chop kindling?
npcai_can_fish 1 //Do NPCs fish?
npcai_can_lay_eggs_alligators 1 //Do Alligators lay eggs?
npcai_can_lay_eggs_birds 1 //Do Birds lay eggs?
npcai_can_lay_eggs_chickens 1 //Do Chickens lay eggs?
npcai_can_lay_eggs_snakes 1 //Do Snakes lay eggs?
npcai_can_step_eggs 1 //Do eggs get crushed when stepped on?
npcai_can_throw_rock 1 //Do NPCs throw rocks?
npcai_can_throw_rock_need 1 //Do NPCs need a rock in their pack?
npcai_can_breath_fire 1 //Do NPCs breath fire?

npcai_id_eatfood_changecolor t_ore, t_ingot, t_log, t_board //NPCs will change colors to these item ids and types when eaten.
npcai_id_poo_rat i_horse_dung //ID of 'poo' for Rats
npcai_id_poo_horse i_horse_dung //ID of 'poo' for Horses
npcai_id_kindling i_kindling //ID of the kindling NPCs chop
npcai_id_rock i_rock_plain //ID of Rock(s) thrown by Cyclops, Ettins, Ogres, Titans, Trolls
npcai_id_breath i_fire_column //ID of fire breathed by NPCs
npcai_id_breath_explosion i_fx_explode //ID of explosion breathed by NPCs
npcai_id_eggs i_eggs_fresh //ID of freshly laid eggs
npcai_id_eggs_stepped i_eggshells //ID of stepped on eggs

npcai_resource_ore mr_nothing, mr_rusty, mr_iron, mr_copper //Region Resource ID(s) for NPCs that mine ore
npcai_resource_chop mr_nothing, mr_tree //Region Resource ID(s) for NPCs that chop wood
npcai_resource_fish mr_nothing, mr_fish1, mr_fish2, mr_fish3, mr_fish4 //Region Resource ID(s) for NPCs that fish fish

npcai_snd_eat {03a 03c} //SFX for eating food, corpses, eggs
npcai_snd_fish {025 026} //SFX for fishing fish
npcai_snd_chop {0147 0148} //SFX for chopping a tree
npcai_snd_mine {0125 0126} //SFX for mining ore
npcai_snd_eggs_stepped {01c2 01c6} //SFX of stepping on eggs

npcai_poo_effect s_poison //Spelleffect of poisonous Rat 'poo'
npcai_poo_effect_strength 10.0 //Strength of the spelleffect of poisonous Rat 'poo'

npcai_dam_rock {10 15} //Damage received when being hit by a rock
npcai_dam_breath {45 50} //Damage received when being hit by dragon's breath

npcai_timer_delay {1 360} //Delay in seconds between 'checks' for NPCs to do 'things' - larger the range in value the less CPU this script will use, lower the value and NPCs will do 'things' more often, default: {1 360} - Use cautiously


//****************** This section is where stuff like fight and craft would be extended and also buy and sell.

npcai_timer_fish {15 30} //Time between the use of fishing by NPCs
npcai_timer_chop {15 30} //Time between the use of lumberjacking by NPCs
npcai_timer_mine {15 30} //Time between the use of mining by NPCs


// Some ideas to add to make the npc more player like

// npcai_timer_sell {15 30}
// npcai_timer_buy {15 30}
// npcai_timer_huntmonsters {15 30}
//npcai_timer_craft_tinker{15 30}
//npcai_timer_craft_blacksmith{15 30}
//npcai_timer_craft_carpentry{15 30}



//*******************************************************************

npcai_timer_eatfood_decay 10 //Time until food drops by 1 in value
npcai_timer_eatfood_hungry {600 660} //Time between eating food if NPC is hungry
npcai_timer_eatfood_hungrier {330 360} //Time between eating food if NPC is very hungry
npcai_timer_eatfood_hungriest {180 210} //Time between eating food if NPC is extremely hungry
npcai_timer_eatfood_replenish 30 //Time until an NPC replenishes it's foodtypes after becoming full
npcai_timer_poo_rat {1200 1800} //Time between each Rat 'poo'
npcai_timer_poo_horse {900 1200} //Time between each Horse 'poo'
npcai_timer_lay_eggs {450 600} //Time between eggs laid by NPCs
npcai_timer_throw_rock {15 30} //Time between each rock thrown by an NPC
*******************************************************************************

//*************** So thats a nice chunk of the entire code just used for variables.
(This post was last modified: 01-16-2020 12:50 PM by Lestatnine.)
01-16-2020 03:01 AM
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)