@name Basic Pet
@inputs Scan Attack
@persist NPC:entity

O = owner()
OP = O:pos()

if (Scan & ~Scan) { findByClass("npc_*")
    NPC = findClosest(OP)
    NPC:npcRelationship("player","neutral",900)
    NPC:npcRelationship(O,"like",999)
}

if (NPC) {interval(1000)
    DPos = NPC:pos() - OP
    WP = OP + DPos:normalized()*100
    
    if (DPos:length()>120) {NPC:npcGoRun(WP)}
    else {NPC:npcStop()}
    
if (Attack) {NPC:npcAttack()}}
