'AIFightingEvents': type: world events: on npc damaged by entity: - if queue stop - define status - define attackerType - define attacker - inject s@AIAttackedEvent p:_ 'AIAttackedEvent': type: task debug: off script: - narrate "Herp is a Derp" player_Wandering: - flag npc Pathfind.Status:Fighting - flag npc WorkingSet:! - flag npc WorkingSet:|:|Fighting| - flag Fighting.NPC: - flag npc Fighting.PlayerList: - run s@AIAttackResponses as: id:_AttackResponseQueue 'AIAttackResponses': type: task script: - ^define workingSet - ^define player - ^define task - ^define previousStatus - ^flag npc WorkingSet:! - ^flag npc WeightedRandomChoice:35/FightBackWeak|25/CryChat|20/RunAway|10/FightBackStrong|10/Lightning - ^inject s@WeightedRandomChoice instantly - ^flag npc WeightedRandomChoice:! - ^flag npc WorkingSet:|:|| - ^run s@PathfindPauseActivity as: def: instantly - ^inject s@AIAttackResponses p: - ^run s@AIAttackResponses p:StopFighting as: def:| FightBackWeak: - ^define equipment "hand:" - ^run s@EquipEscapingArgs "def:" - ^execute as_server "npc sel " - ^execute as_server "npc speed 0.8" - ^trigger name:proximity state:true cooldown:3 radius:8 - ^follow - ^wait t - ^look duration:20t - ^animate animation:ARM_SWING - ^hurt - ^execute as_server "npc sel " - ^execute as_server "npc speed 1.0" - ^equip hand: - ^if ! || ! { - run s@AIAttackResponses p:StopFighting as: def:| - queue clear } - ^inject s@AIAttackResponses p:FightBackWeak 'WeightedRandomChoice': # # Choose a random number from 1 to 100 and return which category the number is # within. # type: task script: - define list - define listSize - define number - define counter 0 - foreach { - if { - define counter - define entry_ ]> - define percentChance ].split[/].get[1]> - define returnValue ].split[/].get[2]> - define oldValue '' - define lowValue '' - define highValue '' - define oldValue '' - if { - ^flag npc WeightedRandomChoice: - ^foreach stop } } } - define result