Here's the code I have:
Code: Select all
void DoLightningLeaderTakeDamage(int damage, Name damageType, Actor inflictor, Actor source)
{
//don't teleport on death
if (Owner.Health - damage < 0)
return;
if (!IsTimedOutExpired())
return;
SetTimeout();
int moveTries = 0;
Vector2 newPos;
let oldPos = Owner.Pos;
while (moveTries >= 0 && moveTries < 10)
{
moveTries++;
newPos.x = random(-LIGHTNINGBOSS_TELEPORT_DIST, LIGHTNINGBOSS_TELEPORT_DIST) + Owner.Pos.X;
newPos.y = random(-LIGHTNINGBOSS_TELEPORT_DIST, LIGHTNINGBOSS_TELEPORT_DIST) + Owner.Pos.Y;
if (Owner.TryMove(newPos, 1, true))
{
let mo = Spawn("LightningLeaderFx1");
if (mo)
mo.SetOrigin(oldPos + (0,0,28), false);
moveTries = -1;
}
}
}
Has anyone ran into this before? I just want to know if it is a safe move position.
These two methods don't have a whole lot of documentation, and I had to go into the C++ code to figure out what the dropoff field does in TryMove (apparently 1 is yes, and 2 is yes sometimes but the logic is really complex and confusing)