I've created a simple script for flying?stinging insects, and it works quite well apart from a few issues. Firstly, the MoveUp command doesn't work. It worked in an earlier version of the script, but the insect wouldn't follow the ground contours. After fiddling with the FPE file, I got it to follow the contours, but MoveUp no longer works. Is there another command that could fulfil this function? Secondly, the HurtPlayer command does too much damage - even set at 1 it's still a two-shot kill for the player (not the end of the world - it could be a super deadly insect
). Lastly, for some reason PlayerDist returns the distance between the entity and the start marker, not the entity and the player. Once the distance gets above 500 and the insect is flying, you can run alongside the insect and the PlayerDist value just gets bigger and bigger. This one is a complete mystery to me, as it's worked fine other scripts.
Any help would be appreciated.
function insectflying_init(e)
descent = 0
totaldescent = 0
rotation = 0
flying = 1
attacking = 0
stinging = 0
end
GravityOff(e);
function insectflying_main(e)
PlayerDist = GetPlayerDistance(e)
descent = math.random(-500,500)
rotation = math.random(-100,100)
if PlayerDist < 500 and PlayerDist >50 then
flying = 0
attacking = 1
stinging = 0
end
if PlayerDist < 51 then
flying = 0
attacking = 0
stinging = 1
end
if PlayerDist > 500 then
flying = 1
attacking = 0
stinging = 0
end
if flying == 1 then
MoveForward(e,100)
MoveUp(e,20)
RotateY(e,rotation)
totaldescent = totaldescent + descent
end
if attacking == 1 then
MoveForward(e,100)
MoveUp(e,20)
RotateToPlayer(e)
totaldescent = totaldescent + descent
end
if stinging == 1 then
MoveForward(e,100)
MoveUp(e,20)
RotateToPlayer(e)
HurtPlayer(e,1)
totaldescent = totaldescent + descent
end
if totaldescent <-50 then
MoveUp(e,10)
totaldescent = totaldescent + 10
end
end