ogre: spawn otherOgre
otherOgre: set parent to ogre.uid
---repeat 2 times
---> otherOgre: spawn ogre
---> ogre: set parent to otherOgre.uid
on function "getParent"
function: set return value to -2
---pick ogre by uid function.param(0)
---> function: set return value to ogre.parent
global number dist=0
global number ang=0
global number X=100
// ogre is the grandson, otherOgre here is the grandfather
// i don't want the grandsons to be further than X distance from his grandfather
for each ogre
pick otherOgre by uid function.call("getParent", ogre.parent)
set dist to distance(otherOgre.x, otherOgre.y, ogre.x, ogre.y)
set ang to angle(otherOgre.x, otherOgre.y, ogre.x, ogre.y)
--- dist > X
---> ogre: set position to otherOgre
---> ogre: move X pixels at angle ang
//the grandfathers will move to his sons
// here otherOgre is the father, ogre is the son
for each ogre
pick otherOgre by uid ogre.parent
otherOgre: move 100*dt pixels at angle angle(otherOgre.x, otherOgre.y, ogre.x, ogre.y)
//At the same time, the 5 grandfathers are not related so they will fight each other but will not harm their own family and will not damage grandsons of anybody, but the grandsons may hurt their own brothers but not their fathers.
// If I understand that correctly you want
// 1. gradparents to fight with each other
// 2. grandchildren to fight with brothers
// ogre and otherOgre are grandparents
ogre: parent=-1
otherOgre: parent=-1
for each ogre
for each otherOgre
fight
// ogre is a grandchild, and otherOgre is a brother
ogre: pick by comparison function.call("getParent", ogre.parent) = -1
for each ogre
otherOgre: parent = ogre.parent
for each otherOgre
fight[/code:143vi5gb]