I find their range quite short and they need a better weapon
EDIT
I should explore more before asking questions...anyway I found out the way to edit range I just edit the npc.lua file but still I don't know how to change the weapon
Is it also possible to not make them run towards you and just stay in place and shoot from distance ?
Here is the entire npc code
Spoiler
local SListCombRifle = {}
function UpdtCombRifle()
for k, v in pairs(SListCombRifle) do
-- Calculate Information
local Ang = math.rad(v.rot)
local rot = v.rot
x = v.x + math.sin(Ang) * 55
y = v.y - math.cos(Ang) * 55
v.distance = v.distance + 10
-- Check if the fly can pass it
if tile(math.floor(x/32), math.floor(y/32), "wall") or v.distance > 360 then
freeimage(v.img)
SListCombRifle[k] = nil
end
-- Update fly information
v.x = x
v.y = y
v.rot = rot
tween_move(v.img, 50, x, y, rot)
for n, i in pairs(NPC_Tab) do
if SListCombRifle[k] and DistBetween(i:x(), i:y(), v.x, v.y) < 35 then
freeimage(v.img)
SListCombRifle[k] = nil
i:onHit(k, "CombineR", 3 + math.random(-1,1), true)
break
end
end
if SListCombRifle[k] then
for _, id in pairs(player(0,"table")) do
if DistBetween(player(id,"x"), player(id,"y"), v.x, v.y) < 45 then
freeimage(v.img)
SListCombRifle[k] = nil
local h, a = CalcDamage(player(id,"health"), player(id,"armor"), 3 + math.random(-1,1))
if h > 0 then
parse("sethealth "..id.." "..h)
parse("setarmor "..id.." "..a)
else
parse('customkill 0 "Elite Combine" '..id)
end
break
end
end
end
end
end
timer(80, "UpdtCombRifle", "",0)
local npc_combrifle = npc_class:new()
RegisterNPC("Combrifle", npc_combrifle)
npc_combrifle.team = 1
npc_combrifle.health = 200
npc_combrifle.attackdelay = 150
npc_combrifle.attackdist = 1080
npc_combrifle.attackmindist = 32
npc_combrifle.meleeattackdist = 45
npc_combrifle.meleeattackdelay = 400
npc_combrifle.movementdelay = 80
npc_combrifle.movementspeed = 14
npc_combrifle.movementmax = 14
npc_combrifle.sprite = "gfx/! 2Gen Other Sprites/zomb_base.png"
npc_combrifle.hitzonemode = 20
npc_combrifle.viewdist = 1080
npc_combrifle.HitSound = {
{Dir = "! 2Gen npc mod/combine/pain1.wav", Duration = 400},
{Dir = "! 2Gen npc mod/combine/pain2.wav", Duration = 400},
{Dir = "! 2Gen npc mod/combine/pain3.wav", Duration = 400},
}
function npc_combrifle:init()
self.timer = {}
self.StepTimer = 0
self.ShotCount = 0
self.ShotDelay = 0
self.sprcomrifle = image("gfx/! 2Gen Other Sprites/combine_rifle"..math.random(1,2)..".png",0,0,3)
imagepos(self.sprcomrifle, self:x(), self:y(), self:rot())
imagescale(self.sprcomrifle, 1.1,1.1)
end
function npc_combrifle:tweenUpdateSprite(t,x,y)
local _r = self.var.lastrot or 0
tween_move(self.sprcomrifle, t, x, y)
tween_rotate(self.sprcomrifle, t, self:rot())
end
function npc_combrifle:onDie()
self:sound3("! 2Gen npc mod/combine/die"..math.random(1,3)..".wav", 300)
self:freeslot()
if self.sprcomrifle and object(self.sprcomrifle, "exists") then
freeimage(self.sprcomrifle)
end
end
function npc_combrifle:onHit(Attacker, Weapon, Damage, isNPC)
self.health = self.health - Damage
if self.health <= 0 then
self:onDie()
elseif not self.HitSoundID or Millisecs() >= self.LastHit + self.HitSound[self.HitSoundID].Duration then
self.LastHit = Millisecs()
self.HitSoundID = math.random(1, #self.HitSound)
self:sound3(self.HitSound[self.HitSoundID].Dir, 300)
end
end
function npc_combrifle:moveAvail()
if self.LastMelee then
if Millisecs() - self.LastMelee < self.meleeattackdelay then
return false
end
end
if self.LastSpit then
if Millisecs() - self.LastSpit < self.attackdelay + 100 then
return false
end
end
return Millisecs() - self.last_move >= self.movementdelay and Millisecs() - self.last_move >= self.movementsleep
end
function npc_combrifle:onMove(x, y)
if Millisecs() - self.StepTimer >= 0 then
local tilex, tiley = self:tilex(), self:tiley()
self.StepTimer = Millisecs() + 350
Sound3("! 2Gen npc mod/combine/gear"..math.random(1,6)..".wav", self:x(), self:y(), 300)
if self:distObject(self.lastTarget, self.targetNPC) < 320 then
local saychancemp1 = math.random(1,22)
if saychancemp1 > 21 then
Sound3("! 2Gen npc mod/combine/search"..math.random(1,7)..".wav", self:x(), self:y(), 380)
end
end
end
end
function npc_combrifle:onAttack(id,isNPC)
tween_rotate(self.sprcomrifle, 100, self:rot())
if Millisecs() - self.ShotDelay >= 1200 then
if self:distObject(id, isNPC) < self.meleeattackdist then
if isNPC then
NPC_Tab[id]:onHit(self.id, 78, 20, true)
else
local h, a = CalcDamage(player(id,"health"), player(id,"armor"), math.random(10, 15))
if h > 0 then
parse("sethealth "..id.." "..h)
parse("setarmor "..id.." "..a)
else
parse('customkill 0 "Elite Combine" '..id)
end
end
self:sound3("weapons/knife_hit.wav", 300)
self.LastMelee = Millisecs()
self.attackdelay = 400 + math.random(-50, 50)
else
local rot = self:rot()
local rad = math.rad(rot)
self:spawnSpit(self:x() + math.sin(rad) * 32, self:y() - math.cos(rad) * 32, rot)
self.LastSpit = Millisecs()
Sound3("! 2Gen npc mod/guns/comb_rifle.wav", self:x(), self:y(), 1080)
self.attackdelay = 100 + math.random(-10, 10)
self.ShotCount = self.ShotCount + 1
if self.ShotCount == 1 then
local saymppist1 = math.random(1,15)
if saymppist1 > 13 then
Sound3("! 2Gen npc mod/combine/alert"..math.random(1,9)..".wav", self:x(), self:y(), 350)
end
elseif self.ShotCount >= 9 then
self.ShotDelay = Millisecs()
self.ShotCount = 0
local grechapolsmg = math.random(1,15)
if grechapolsmg >14 then
parse("spawnprojectile 0 51 "..self:x().." "..self:y().." "..self:distObject(id, isNPC).." "..self:rot())
Sound3("! 2Gen npc mod/combine/grenade.wav", self:x(), self:y(), 320)
end
end
end
end
end
function npc_combrifle:spawnSpit(x, y, rot)
local Spit = {
x = x,
y = y,
rot = rot,
distance = 0,
img = image("gfx/! 2Gen Other Sprites/shot5.png", 0, 1, 3)
}
imagepos(Spit.img, x, y, rot)
table.insert(SListCombRifle, Spit)
end
function UpdtCombRifle()
for k, v in pairs(SListCombRifle) do
-- Calculate Information
local Ang = math.rad(v.rot)
local rot = v.rot
x = v.x + math.sin(Ang) * 55
y = v.y - math.cos(Ang) * 55
v.distance = v.distance + 10
-- Check if the fly can pass it
if tile(math.floor(x/32), math.floor(y/32), "wall") or v.distance > 360 then
freeimage(v.img)
SListCombRifle[k] = nil
end
-- Update fly information
v.x = x
v.y = y
v.rot = rot
tween_move(v.img, 50, x, y, rot)
for n, i in pairs(NPC_Tab) do
if SListCombRifle[k] and DistBetween(i:x(), i:y(), v.x, v.y) < 35 then
freeimage(v.img)
SListCombRifle[k] = nil
i:onHit(k, "CombineR", 3 + math.random(-1,1), true)
break
end
end
if SListCombRifle[k] then
for _, id in pairs(player(0,"table")) do
if DistBetween(player(id,"x"), player(id,"y"), v.x, v.y) < 45 then
freeimage(v.img)
SListCombRifle[k] = nil
local h, a = CalcDamage(player(id,"health"), player(id,"armor"), 3 + math.random(-1,1))
if h > 0 then
parse("sethealth "..id.." "..h)
parse("setarmor "..id.." "..a)
else
parse('customkill 0 "Elite Combine" '..id)
end
break
end
end
end
end
end
timer(80, "UpdtCombRifle", "",0)
local npc_combrifle = npc_class:new()
RegisterNPC("Combrifle", npc_combrifle)
npc_combrifle.team = 1
npc_combrifle.health = 200
npc_combrifle.attackdelay = 150
npc_combrifle.attackdist = 1080
npc_combrifle.attackmindist = 32
npc_combrifle.meleeattackdist = 45
npc_combrifle.meleeattackdelay = 400
npc_combrifle.movementdelay = 80
npc_combrifle.movementspeed = 14
npc_combrifle.movementmax = 14
npc_combrifle.sprite = "gfx/! 2Gen Other Sprites/zomb_base.png"
npc_combrifle.hitzonemode = 20
npc_combrifle.viewdist = 1080
npc_combrifle.HitSound = {
{Dir = "! 2Gen npc mod/combine/pain1.wav", Duration = 400},
{Dir = "! 2Gen npc mod/combine/pain2.wav", Duration = 400},
{Dir = "! 2Gen npc mod/combine/pain3.wav", Duration = 400},
}
function npc_combrifle:init()
self.timer = {}
self.StepTimer = 0
self.ShotCount = 0
self.ShotDelay = 0
self.sprcomrifle = image("gfx/! 2Gen Other Sprites/combine_rifle"..math.random(1,2)..".png",0,0,3)
imagepos(self.sprcomrifle, self:x(), self:y(), self:rot())
imagescale(self.sprcomrifle, 1.1,1.1)
end
function npc_combrifle:tweenUpdateSprite(t,x,y)
local _r = self.var.lastrot or 0
tween_move(self.sprcomrifle, t, x, y)
tween_rotate(self.sprcomrifle, t, self:rot())
end
function npc_combrifle:onDie()
self:sound3("! 2Gen npc mod/combine/die"..math.random(1,3)..".wav", 300)
self:freeslot()
if self.sprcomrifle and object(self.sprcomrifle, "exists") then
freeimage(self.sprcomrifle)
end
end
function npc_combrifle:onHit(Attacker, Weapon, Damage, isNPC)
self.health = self.health - Damage
if self.health <= 0 then
self:onDie()
elseif not self.HitSoundID or Millisecs() >= self.LastHit + self.HitSound[self.HitSoundID].Duration then
self.LastHit = Millisecs()
self.HitSoundID = math.random(1, #self.HitSound)
self:sound3(self.HitSound[self.HitSoundID].Dir, 300)
end
end
function npc_combrifle:moveAvail()
if self.LastMelee then
if Millisecs() - self.LastMelee < self.meleeattackdelay then
return false
end
end
if self.LastSpit then
if Millisecs() - self.LastSpit < self.attackdelay + 100 then
return false
end
end
return Millisecs() - self.last_move >= self.movementdelay and Millisecs() - self.last_move >= self.movementsleep
end
function npc_combrifle:onMove(x, y)
if Millisecs() - self.StepTimer >= 0 then
local tilex, tiley = self:tilex(), self:tiley()
self.StepTimer = Millisecs() + 350
Sound3("! 2Gen npc mod/combine/gear"..math.random(1,6)..".wav", self:x(), self:y(), 300)
if self:distObject(self.lastTarget, self.targetNPC) < 320 then
local saychancemp1 = math.random(1,22)
if saychancemp1 > 21 then
Sound3("! 2Gen npc mod/combine/search"..math.random(1,7)..".wav", self:x(), self:y(), 380)
end
end
end
end
function npc_combrifle:onAttack(id,isNPC)
tween_rotate(self.sprcomrifle, 100, self:rot())
if Millisecs() - self.ShotDelay >= 1200 then
if self:distObject(id, isNPC) < self.meleeattackdist then
if isNPC then
NPC_Tab[id]:onHit(self.id, 78, 20, true)
else
local h, a = CalcDamage(player(id,"health"), player(id,"armor"), math.random(10, 15))
if h > 0 then
parse("sethealth "..id.." "..h)
parse("setarmor "..id.." "..a)
else
parse('customkill 0 "Elite Combine" '..id)
end
end
self:sound3("weapons/knife_hit.wav", 300)
self.LastMelee = Millisecs()
self.attackdelay = 400 + math.random(-50, 50)
else
local rot = self:rot()
local rad = math.rad(rot)
self:spawnSpit(self:x() + math.sin(rad) * 32, self:y() - math.cos(rad) * 32, rot)
self.LastSpit = Millisecs()
Sound3("! 2Gen npc mod/guns/comb_rifle.wav", self:x(), self:y(), 1080)
self.attackdelay = 100 + math.random(-10, 10)
self.ShotCount = self.ShotCount + 1
if self.ShotCount == 1 then
local saymppist1 = math.random(1,15)
if saymppist1 > 13 then
Sound3("! 2Gen npc mod/combine/alert"..math.random(1,9)..".wav", self:x(), self:y(), 350)
end
elseif self.ShotCount >= 9 then
self.ShotDelay = Millisecs()
self.ShotCount = 0
local grechapolsmg = math.random(1,15)
if grechapolsmg >14 then
parse("spawnprojectile 0 51 "..self:x().." "..self:y().." "..self:distObject(id, isNPC).." "..self:rot())
Sound3("! 2Gen npc mod/combine/grenade.wav", self:x(), self:y(), 320)
end
end
end
end
end
function npc_combrifle:spawnSpit(x, y, rot)
local Spit = {
x = x,
y = y,
rot = rot,
distance = 0,
img = image("gfx/! 2Gen Other Sprites/shot5.png", 0, 1, 3)
}
imagepos(Spit.img, x, y, rot)
table.insert(SListCombRifle, Spit)
end
edited 2×, last 02.01.18 08:07:51 pm