#Flags for mobs: # .isMob = All hostile mobs should get this one # .isMonster = All basic hostiles that need basic targeting and pathing # .isBoss = For bosses that do stuff during update. # .basicIgnoreTargeting = Hostiles with this flag will be ignored by basic hostiles # # Runs repeatedly as the mobAI logic loop mobAI_task_logic: type: task debug: false script: #get all our custom mob npc's - event "mobai logic" - foreach { #logic loop for default mob AI tagged as .isMonster - if && ! { #Tell it to attack/check its target - run mobAI_task_attack as: instantly #if it still doesn't have a target, resume pathing - if == null { - resume waypoints npc:%value% } - queue clear } #Check for another monstertype - boss - run mobAI_task_logic delay:10t # Chooses a nearby target mobAI_task_picktarget: type: task debug: false script: - ^flag npc mobAI.target:null - ^define entities ]> - ^define entity null - ^foreach %entities% { - if !<%value%.flag[mobAI.basicIgnoreTargeting]> { - define entities } elseif <%value%.distance[]> > { - define entities } elseif <%value%.is_player> { if <%value%.gamemode.id> != 0 { - define entities } } } - ^foreach %entities% { - if { - define entity %value% - foreach stop } } - ^flag npc mobAI.target:%entity% - event "mobai found_target" context:npc||target|%entity% # Makes a sentry NPC attack the target mobAI_task_attack: type: task debug: true script: #increment attack cooldown - ^flag npc mobAI.attackCooldown: #check if it's time to reset its attack cooldown and start attack - ^if >= { - flag npc mobAI.attackCooldown:0 } else { - queue clear } #pick new target if it doesnt have one - ^if == null { - ^inject mobAI_task_picktarget } #otherwise check if its current target is not valid anymore and get a new one else { - if !]> || !]||false> { - inject mobAI_task_picktarget - if == null { - flag npc mobAI.lostTarget:true } } } #if still no target, end attack - ^if == null { - if == true { - event "mobai lost_target" context:npc| } - inject mobAI_task_pathfind - queue clear } #get location of target and calculate if it's in attack range - ^define loc - if < { - ^look %loc% - ^pause waypoints - event "mobai attack" context:npc||target| mobAI_task_pathfind: type: task debug: false script: - if ]> > { - walk speed: lookat: - queue clear } - if > 0 { - flag npc mobAI.lastPathfind: - queue clear } - walk speed: lookat: radius:lookat: mobAI_attack: type: task debug: false script: #get fail chance - if == true { - if <= { - queue clear } #get base damage - if == true { - flag npc mobAI.currentDmg: } else { - flag npc mobAI.currentDmg: } #critical - if == true { - if <= { - flag npc mobAI.critBonus:]> } } #condition effects #armor calculations for players - if == true { #base values #slashing #crushing #shattering #piercing } mobAI_task_removearrow: type: task debug: false script: - if %hit_entities% == li@ remove %shot_entities%