Hi guys, I've been working on this script and it works fine, the entity moves towards the player and damages him when in range, however I can't seem to add anything else to the script without getting an error message in gameguru or causing the script to stop working entirely. I want to set collision on in the script and give the entity health (so that it's killable by the player) and to set a 3d sound to it, any help would be appreciated.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- By SS Slothman
local active_range = 1000
local move_speed = 175
local damage = 10
local attack_range = 100
local attack_delay = 1000
local attack_delay_init = attack_delay
function fire_sprite_init(e)
end
function fire_sprite_main(e)
PlayerDist = GetPlayerDistance(e) -- This finds the players distance from the Entity
if PlayerDist <= active_range then -- 1000 is ok for games set inside buildings
RotateToPlayer(e) -- Rotates the entity to face the player
end
if PlayerDist <= attack_range then
if GetTimer(e) > attack_delay ~= 1 then
HurtPlayer(e,damage)
attack_delay = GetTimer(e) + attack_delay_init
end
else
MoveForward(e,move_speed)
attack_delay = GetTimer(e) + attack_delay_init
end
end