Jump to content

Gettng monster aggro


Recommended Posts

Hey there,

I am wondering if there's a way to gain monsters attention?

I do have a damage aura around my custom character that deals damage to monsters around every couple of seconds, but it doesn't bother the monsters themselfs. I mean - if a players sets aura range high enough - he can be dealing damage to them without them noticing - I'd like to change that.

Anyone got the idea how to make it?

Link to comment
Share on other sites

33 minutes ago, Near4422 said:

I've no idea what am I looking for while scrolling through the combat.lua to be honest.

Or actually how to use it.

If you can post the code for your damage aura. I can show you how to make a simple addition to taunt their aggro.

  • Like 1
Link to comment
Share on other sites

local function DMGaura(inst)
local x,y,z = inst.Transform:GetWorldPosition() 
local pt = inst:GetPosition()
local range = TUNING.LIFESTEAL_RANGE  -- range of ability
local DMG = -TUNING.LIFESTEAL_DAMAGE -- Damage dealt to enemies around per tick
local HP = TUNING.LIFESTEAL_HEAL -- HP restored per tick
local tagz = {"monster"}
local canttagz = {"scarecrow"}

	local check = TheSim:FindEntities(pt.x,pt.y,pt.z, range, tagz, canttagz)	
		for _,ent in ipairs(check) do
			if not ent.components.health:IsDead() and ent.prefab == "spider" or ent.prefab == "spider_hider" or ent.prefab == "spider_spitter" or ent.prefab == "deerclops" or ent.prefab == "hound" or ent.prefab == "firehound" or ent.prefab == "icehound" or ent.prefab == "houndfire" or ent.prefab == "houndbone" or ent.prefab == "houndmound" or ent.prefab == "krampus" or ent.prefab == "mosquito" or ent.prefab == "crawlinghorror" or ent.prefab == "terrorbeak" or ent.prefab == "spider_warrior" or ent.prefab == "spiderqueen" or ent.prefab == "tallbird" or ent.prefab == "tentacle" or ent.prefab == "dragonfly" or ent.prefab == "klaus" or ent.prefab == "bearger" or ent.prefab == "stalker" or ent.prefab == "antlion" or ent.prefab == "bunnyman" or ent.prefab == "pigman" or ent.prefab == "merm" or ent.prefab == "walrus" or ent.prefab == "little_walrus" or ent.prefab == "leif" then			
				ent.components.health:DoDelta(DMG)	
				SpawnPrefab("toadstool_cap_releasefx").Transform:SetPosition(ent.Transform:GetWorldPosition())
				inst.components.health:DoDelta(HP)				
				SpawnPrefab("wortox_portal_jumpin_fx").Transform:SetPosition(inst.Transform:GetWorldPosition())
				
			end
		end
end

local function maincheck(inst)
 	if not inst.components.health:IsDead() and not inst:HasTag("playerghost") and not inst:HasTag("playermonster") then		
		DMGaura(inst)
	end
end

-- 1 time interval between every tick (seconds-ish, it's not 100% accurate)
inst:DoPeriodicTask(2, maincheck, nil, inst)

 

Link to comment
Share on other sites

Spoiler
2 hours ago, Near4422 said:


local function DMGaura(inst)
local x,y,z = inst.Transform:GetWorldPosition() 
local pt = inst:GetPosition()
local range = TUNING.LIFESTEAL_RANGE  -- range of ability
local DMG = -TUNING.LIFESTEAL_DAMAGE -- Damage dealt to enemies around per tick
local HP = TUNING.LIFESTEAL_HEAL -- HP restored per tick
local tagz = {"monster"}
local canttagz = {"scarecrow"}

	local check = TheSim:FindEntities(pt.x,pt.y,pt.z, range, tagz, canttagz)	
		for _,ent in ipairs(check) do
			if not ent.components.health:IsDead() and ent.prefab == "spider" or ent.prefab == "spider_hider" or ent.prefab == "spider_spitter" or ent.prefab == "deerclops" or ent.prefab == "hound" or ent.prefab == "firehound" or ent.prefab == "icehound" or ent.prefab == "houndfire" or ent.prefab == "houndbone" or ent.prefab == "houndmound" or ent.prefab == "krampus" or ent.prefab == "mosquito" or ent.prefab == "crawlinghorror" or ent.prefab == "terrorbeak" or ent.prefab == "spider_warrior" or ent.prefab == "spiderqueen" or ent.prefab == "tallbird" or ent.prefab == "tentacle" or ent.prefab == "dragonfly" or ent.prefab == "klaus" or ent.prefab == "bearger" or ent.prefab == "stalker" or ent.prefab == "antlion" or ent.prefab == "bunnyman" or ent.prefab == "pigman" or ent.prefab == "merm" or ent.prefab == "walrus" or ent.prefab == "little_walrus" or ent.prefab == "leif" then			
				ent.components.health:DoDelta(DMG)	
				SpawnPrefab("toadstool_cap_releasefx").Transform:SetPosition(ent.Transform:GetWorldPosition())
				inst.components.health:DoDelta(HP)				
				SpawnPrefab("wortox_portal_jumpin_fx").Transform:SetPosition(inst.Transform:GetWorldPosition())
				if ent.components.combat then
                      ent.components.combat:SuggestTarget(inst)
                    end
			end
		end
end

local function maincheck(inst)
 	if not inst.components.health:IsDead() and not inst:HasTag("playerghost") and not inst:HasTag("playermonster") then		
		DMGaura(inst)
	end
end

-- 1 time interval between every tick (seconds-ish, it's not 100% accurate)
inst:DoPeriodicTask(2, maincheck, nil, inst)

 

 

--all you need to do is place this inside your DMGaura function's for loop's after you check to make sure the ent is valid.
if ent.components.combat then
  ent.components.combat:SuggestTarget(inst)
end

 

Edited by IronHunter
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...