Hi everyone, decided to get into a bit of LUA and I'm just having a complete nightmare. I've been trying to get many character scripts working for the past year with not much success. I've brought back the great models from FPSCx9 that I have purchased long ago and would like to to use in GG. I figure it be no problem to get them to work. I was able to get the Lobotomite to work fine. Though the green one floats during test game always (started happening after a few updates). Anywho, I've been trying to get the very large creature Dante to work since about this time last year with no success. The original script i had allowed for him to attack in 3 random ways but it bugs out to much. The issue im having even with the current script is he keeps stopping in his tracks once he gets close enough to the player. He just doesn't attack unless you move the player in an odd fashion in front of him.
Here is my script (i have no idea what I'm doing anymore) and I feel I'm wasting more time to get a simple script functioning and its been a dreadful experience for when I was able to get simple tasks working in FPI. I feel I have to limit the characters AI just to get them to remotely do what I want them to.
-- LUA Script - precede every function and global member with lowercase name of script
attackstart = {}
attackend = {}
damageframestart = {}
damageframeend = {}
lastroar = {}
lastswipe = {}
exp = 0
local damage = 25
function ai_dante_init(e)
ai_soldier_state[e] = "idle"
CharacterControlLimbo(e)
SetAnimationFrames(2,79)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
attackstart[e]=175
attackend[e]=256
damageframestart[e]=220
damageframeend[e]=254
lastroar[e]=0
lastswipe[e]=0
end
function ai_dante_main(e)
PlayerDist = GetPlayerDistance(e)
EntObjNo = g_Entity[e]['obj']
if (PlayerDist < AIGetEntityViewRange(EntObjNo) and ai_soldier_state[e] == "idle" and g_Entity[e]['plrvisible'] == 1)
or (AIGetEntityHeardSound(EntObjNo) == 1 and ai_soldier_state[e] == "idle") or (PlayerDist < 100 and ai_soldier_state[e]
== "idle") then
RotateToPlayer(e)
if GetTimer(e) > lastroar[e] then
lastroar[e]=GetTimer(e)+5000
PlaySound(e,0)
end
end
if PlayerDist < AIGetEntityViewRange(EntObjNo) and g_Entity[e]['plrvisible']==1 then
RotateToPlayer(e)
if PlayerDist < 120 and g_Entity[e]['plrvisible']==1 then
if ai_soldier_state[e]~="attack" then
SetAnimationSpeed(e,1.75)
if GetAnimationFrame(e)<attackstart[e] or GetAnimationFrame(e)>attackend[e] then
AIEntityStop(EntObjNo)
ai_soldier_state[e] = "attack"
CharacterControlLimbo(e)
SetAnimationFrames(attackstart[e],attackend[e])
PlayAnimation(e)
end
end
if ai_soldier_state[e]=="attack" then
if GetAnimationFrame(e)>damageframestart[e] and GetAnimationFrame(e)<damageframeend[e] then
if GetPlayerDistance(e)<120 then
if GetTimer(e) > lastswipe[e] then
lastswipe[e]= GetTimer(e)+1200
PlaySound(e,1)
randomdamage=math.random(damage*0.9,damage*1.1)
HurtPlayer(e,randomdamage)
end
end
end
if GetAnimationFrame(e)>attackend[e]-1 then
CharacterControlUnarmed(e)
ai_soldier_state[e] = "roam"
if GetPlayerDistance(e) < 120 then
ai_soldier_state[e] = "idle"
CharacterControlUnarmed(e)
SetAnimationFrames(attackstart[e]-1,attackstart[e]-1)
PlayAnimation(e)
RotateToPlayer(e)
end
end
end
else
if ai_soldier_state[e]~="roam" then
ai_soldier_state[e] = "roam"
CharacterControlUnarmed(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
SetCharacterToWalk(e)
end
rndx=math.random(1,360)
rndz=math.random(1,360)
rndx2=math.sin(rndx)*30
rndz2=math.cos(rndz)*30
AIEntityGoToPosition(EntObjNo,g_PlayerPosX+rndx2,g_PlayerPosZ+rndz2)
end
else
if PlayerDist >= AIGetEntityViewRange(EntObjNo) and ai_soldier_state[e] ~= "idle" or g_Entity[e]['plrvisible'] == 0 and
GetPlayerDistance(e) > AIGetEntityViewRange(EntObjNo) / 4 then
ai_soldier_state[e] = "idle"
CharacterControlLimbo(e)
SetAnimationFrames(2,79)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
end
end
--PromptLocal(e,"ZOMBIEWALK : Dist=" .. PlayerDist .. " State=" .. ai_soldier_state[e] .. " Vis=" .. g_Entity[e]
['plrvisible'] .. " Frm=" .. GetAnimationFrame(e) )
end
function ai_dante_exit(e)
PlaySound(e,2)
exp = exp + 200
PromptDuration("+200XP /".. exp,3000)
CollisionOff(e)
end
Any help would be great as I'm find this struggle to be depressing.
Twitter -
Teabone3 | Youtube -
Teabone3 | Twitch -
Teabone3
i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GT 740