Before you say it i know already theres a version on the steam workshop, however that one does not have the best of dan's snpcs the "horror."
So i went and downloaded the original and i got pretty far with editing the horror init.lua it to work with gmod 13.
however i am stumped at this error
[ERROR] lua/entities/npc_horror/init.lua:260: bad argument #1 to 'HasCondition' (number expected, got nil)
1. HasCondition - [C]:-1
2. SelectSchedule - lua/entities/npc_horror/init.lua:260
3. unknown - gamemodes/base/entities/entities/base_ai/schedules.lua:28
For some reason it looks like the string HasCondition is not working. Anyways here is the code Please tell me what is wrong with this and help me fix it.
[lua]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
ENT.Model = "models/horror/zm_f4zt.mdl"
ENT.health = 200
ENT.Alerted = false
ENT.Territorial = false
ENT.Bleeds = true
ENT.Leaps = true
ENT.Chasing = false
ENT.Flinches = false
ENT.moving = false
ENT.FriendlyToPlayer = false
ENT.Damage = 5
ENT.AcidBlood = true
ENT.BleedsRed = true
//ENT.LeapDamage = 15
ENT.LeapSpeed = 1000
ENT.LeapDistance = 300
ENT.MinLeapDistance = 200
ENT.MeleeAttacking = false;
ENT.Leaping = false
ENT.alert1 = "horror/alert_far2.wav"
ENT.alert2 = "horror/alert_far1.wav"
ENT.alert3 = "horror/fz_scream2.wav"
ENT.idle1 = "horror/screech.wav"
ENT.idle2 = ""
ENT.idle3 = ""
ENT.idle4 = ""
ENT.attack1 = "horror/warp1.wav"
ENT.attack2 = "horror/warp2.wav"
ENT.attack3 = "horror/warp3.wav"
ENT.attackmiss1 = "horror/warp1.wav"
ENT.attackmiss2 = "horror/warp2.wav"
ENT.attackmiss3 = "horrow/warp3.wav"
ENT.attackleap = "horror/leap1.wav"
ENT.hurt1 = "horror/pain1.wav"
ENT.hurt2 = "horror/pain2.wav"
ENT.hurt3 = "horror/pain3.wav"
ENT.hurt4 = "horror/pain4.wav"
ENT.die1 = "horror/die4.wav"
ENT.die2 = "horror/die3.wav"
ENT.die3 = "horror/die2.wav"
ENT.die4 = "horror/die1.wav"
ENT.dead = false;
ENT.target = NULL
local schedJump = ai_schedule.New( "Jump" )
schedJump:EngTask( "TASK_PLAY_SEQUENCE", ACT_JUMP )
function ENT:Initialize()
self:SetModel( self.Model )
self:SetHullType( HULL_MEDIUM )
self:SetHullSizeNormal()
self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )
self:CapabilitiesAdd( CAP_MOVE_GROUND ) ( CAP_SQUAD ) ( CAP_MOVE_JUMP ) ( CAP_MOVE_CLIMB )
self:SetMaxYawSpeed( 5000 )
self:SetHealth(self.health)
self.teleportPos = self:GetPos()
self.startPos = self:GetPos()
end
function ENT:HasPropInFrontOfMe()
local entstoattack = ents.FindInSphere(self:GetPos() + self:GetForward()*75,47)
for _,v in pairs(entstoattack) do
if v:GetClass() == "prop_physics" then
return true
end
end
return false
end
function ENT:Think()
//---------------
local function setmeleefalse()
if self:Health() < 0 then return end
self.MeleeAttacking = false
self.Leaping = false
self:SetSchedule(SCHED_RUN_RANDOM)
end
//---------------
local function Attack_Melee()
if self:Health() < 0 then return end
local entstoattack = ents.FindInSphere(self:GetPos() + self:GetForward()*75,47)
local randomsound = math.random(1,3)
local hit = false
if entstoattack != nil then
for _,v in pairs(entstoattack) do
if ( (v:IsNPC() || ( v:IsPlayer() && v:Alive())) && (v != self) && (v:GetClass() != "npc_drone_xenomorph") && (v:GetClass() != self:GetClass()) || (v:GetClass() == "prop_physics")) then
v:TakeDamage( self.Damage, self )
if v:IsPlayer() then
v:ViewPunch(Angle(math.random(-1,1)*self.Damage,math.random(-1,1)*self.Damage,math.random(-1,1)*self.Damage))
end
if v:GetClass() == "prop_physics" then
local phys = v:GetPhysicsObject()
if phys != nil && phys != NULL then
phys:ApplyForceOffset(self:GetForward()*1800,Vector(math.random(-1,1),math.random(-1,1),math.random(-1,1)))
end
end
hit = true
end
end
end
if hit == false then
if randomsound == 1 then
self:EmitSound( self.attackmiss1)
elseif randomsound == 2 then
self:EmitSound( self.attackmiss2)
elseif randomsound == 3 then
self:EmitSound( self.attackmiss3)
end
else
//make the sound
if randomsound == 1 then
self:EmitSound( self.attack1,450,math.random(80,120))
elseif randomsound == 2 then
self:EmitSound( self.attack2,450,math.random(80,120))
elseif randomsound == 3 then
self:EmitSound( self.attack3,450,math.random(80,120))
end
end
timer.Create( "melee_done_timer" .. self.Entity:EntIndex( ), 0.25, 1, setmeleefalse )
end
//---------------
if self:GetEnemy() != nil then
if self:GetEnemy():GetPos():Distance(self:GetPos()) < 220 then
self:SetColor( Color( 255, 255, 255, math.random(0,100) ) )
else
self:SetColor( Color( 0, 0, 0, 100) )
end
else
self:SetColor( Color( 0, 0, 0, 0) )
end
//---------------
if GetConVarNumber("ai_disabled") == 0 then
if self:GetEnemy() != nil then
self:UpdateEnemyMemory(self:GetEnemy(),self:GetEnemy():GetPos())
end
local randomteleport = math.random(1,320)
if randomteleport == 1 then
local subrandom = math.random(1,8)
if subrandom == 1 && self:GetEnemy() != nil && util.IsInWorld(self:GetEnemy():GetPos() + self:GetEnemy():GetForward() * 100) then
self.teleportPos = self:GetEnemy():GetPos() + self:GetEnemy():GetForward() * 100
elseif subrandom == 2 then
self.teleportPos = self.startPos
else
self.teleportPos = self:GetPos()
end
end
//make the sound
local randomsound = math.random(1,120)
if randomsound == 1 then
self:EmitSound( self.idle1,450,math.random(80,120))
elseif randomsound == 2 then
self:EmitSound( self.idle2,450,math.random(80,120))
elseif randomsound == 3 then
self:EmitSound( self.idle3,450,math.random(80,120))
elseif randomsound == 4 then
self:EmitSound( self.idle4,450,math.random(80,120))
end
//print( "Think start" );
//Get all the npc's and other entities.
local enttable = ents.FindByClass("npc_*")
local monstertable = ents.FindByClass("monster_*")
table.Add(monstertable,enttable)//merge
//sort through each ent.
for _, x in pairs(monstertable) do
if (!ents) then print( "No Entities!" ); return end
if (x:GetClass() != self:GetClass() && x:GetClass() != "npc_grenade_frag" && x:IsNPC()) then
x:AddEntityRelationship( self, 1, 10 )
end
end
if self.TakingCover == false then
//if(math.random(1,20) == 1) then
self:FindCloseEnemies()//get guys close to me
//end
end//Hit them.
if self:GetEnemy() != nil then
// && self:GetPos():Distance(self:GetEnemy():GetPos()) > self.MinLeapDistance
if math.random(1,15) == 1 && self:GetPos():Distance(self:GetEnemy():GetPos()) < self.LeapDistance && self.Leaps == true && self.Leaping == false then
self:SetSchedule(SCHED_RANGE_ATTACK1 )
self.Leaping = true
local enemypos = self:GetEnemy():GetPos()
//make sure we don't jump into the ground.
if enemypos.z < self:GetPos().z then
enemypos.z = self:GetPos().z
end
if math.random(1,2) == 1 then
self:SetVelocity( (enemypos-self:GetPos() + Vector(0,0,50)):Normalize() * self.LeapSpeed )
else
self:SetVelocity( self:GetForward() * self.LeapSpeed + Vector(0,0,60) )
end
timer.Simple(0.9,setmeleefalse)
end
if (self:GetEnemy():GetPos():Distance(self:GetPos()) < 70) || self:HasPropInFrontOfMe() then
if self.MeleeAttacking == false then
if self.Leaping == false then
self:SetSchedule( SCHED_MELEE_ATTACK1 )
else
self:EmitSound( self.attackleap)
self:SetLocalVelocity( Vector( 0, 0, 0 ) )
end
timer.Create( "melee_attack_timer" .. self.Entity:EntIndex( ), 0.25, 1, Attack_Melee )
self.MeleeAttacking = true;
end
end
else
self.MeleeAttacking = false
self:FindEnemyDan()
end
local friends = ents.FindByClass("npc_xenomorph")
for _, x in pai
ew. [lua] tags please
sorry
thought it was spoiler
cAN an admin change the tag icon to help instead? i think alot of people are bypassing this
!self:HasCondition( COND_ENEMY_TOO_FAR ) is where the problem exists. The enumeration is nil, but I checked the old wiki and found what the old value was. Just add this to the top of your code:
[lua]
COND_ENEMY_TOO_FAR = 27
[/lua]
thanks
[editline]22nd April 2013[/editline]
now im getting an error on this line
line 61 - self:CapabilitiesAdd( CAP_MOVE_GROUND ) ( CAP_SQUAD ) ( CAP_MOVE_JUMP ) ( CAP_MOVE_CLIMB )
would i just add those values at the top of the page too? i dont know what i should set them as.
[editline]22nd April 2013[/editline]
also this
[ERROR] lua/entities/npc_horror/init.lua:312: attempt to compare nil with number
1. unknown - lua/entities/npc_horror/init.lua:312
[editline]22nd April 2013[/editline]
Also i cannot get the alpha with random math to work so its not invisible when its far away, it just turns black
It sounds heavily broken, you might want to hire someone to fix it for you if you can't figure it out.
Well i was hoping someone could fix it thats why i posted it
[editline]22nd April 2013[/editline]
Im really a nub when it comes to coding, which is why i posted this, I don't deserved to be called dumb.
make it self:CapabilitiesAdd CAP_MOVE_GROUND and CAP_SQUAD and CAP_MOVE_JUMP and CAP_MOVE_CLIMB
K heres a better list of whats wrong
errors im getting
[ERROR] lua/entities/npc_horror/init.lua:312: attempt to compare nil with number
1. unknown - lua/entities/npc_horror/init.lua:312
[ERROR] lua/entities/npc_horror/init.lua:203: attempt to perform arithmetic on a nil value
1. unknown - lua/entities/npc_horror/init.lua:203
line 311,312,313
[lua]
local r,g,b,a = self:GetColor()
if a < 100 then -- do nothing if our alpha value is less than nominal.
return
[/lua]
line 197,203
[lua]
local enemypos = self:GetEnemy():GetPos()
self:SetVelocity( (enemypos-self:GetPos() + Vector(0,0,50)):Normalize() * self.LeapSpeed )
[/lua]
i think theres a problem with the (local "string" = "value or string" ) because it doesnt seem to be crediting "a" as a value in line 312 but it is clearly defined in line 311. Same goes for the string "enemypos", it is clearly defined in line 197
Please Help
im so close to figuring this out please help
[lua]
local r,g,b,a = self:GetColor()
if a < 100 then -- do nothing if our alpha value is less than nominal.
return
[/lua]
should be
[lua]
local col = self:GetColor()
if col.a < 100 then -- do nothing if our alpha value is less than nominal.
return
[/lua]
as shown by [url]http://wiki.garrysmod.com/page/Entity/GetColor[/url]
Not sure about the error on 203
Also try not to bump threads unless it has been at least a day.
thanks for fixing one :)
still having problems figuring out exactly whats wrong with line 203
Sorry, you need to Log In to post a reply to this thread.