//!tgscript v1 //! script name=Pet //! region graph //! node 1 OnUpdate pos=(60,80) export function onUpdate(ctx) { //! node 2 FindEntity pos=(60,220) entity=Hero const n2_value = ctx.findEntity("Hero"); //! node 3 GetEntityPosition2D pos=(260,220) const n3_value = ctx.getEntityPosition2D(n2_value); //! node 4 GetPosition2D pos=(260,340) const n4_value = ctx.getPosition2D(); //! node 5 SubVec2 pos=(460,260) const n5_out = ctx.subVec2(n3_value, n4_value); //! node 6 Vec2Length pos=(660,340) const n6_out = ctx.vec2Length(n5_out); //! node 7 ConstNumber pos=(660,440) const n7_value = 1.50; //! node 8 Greater pos=(860,340) const n8_out = (n6_out > n7_value); //! node 9 Branch pos=(1060,80) if (n8_out) { //! node 10 Vec2Normalize pos=(660,180) const n10_out = ctx.vec2Normalize(n5_out); //! node 11 ConstNumber pos=(860,180) const n11_value = 3.50; //! node 12 ScaleVec2 pos=(1060,200) const n12_out = ctx.scaleVec2(n10_out, n11_value); //! node 13 SetVelocity2D pos=(1260,80) ctx.setVelocity2D(n12_out); } else { //! node 14 ConstVec2 pos=(1060,320) const n14_value = ctx.vec2(0.00, 0.00); //! node 15 SetVelocity2D pos=(1260,240) ctx.setVelocity2D(n14_value); } } //! endregion