Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slime Boss - Code #2176

Merged
merged 22 commits into from
May 12, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better aggro/leash
  • Loading branch information
TideSofDarK committed Apr 21, 2018
commit 54ee6f8b2f8e93540781aab6e764ab4ef43831d3
27 changes: 25 additions & 2 deletions game/scripts/vscripts/units/slime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function SlimeBossThink()
if not thisEntity.bInitialized then
thisEntity.vInitialSpawnPos = thisEntity:GetOrigin()
thisEntity.bInitialized = true
thisEntity.bHasAgro = false
thisEntity.fAgroRange = thisEntity:GetAcquisitionRange()
thisEntity:SetIdleAcquire(false)
thisEntity:SetAcquisitionRange(0)
end

local enemies = FindUnitsInRadius(
Expand All @@ -40,8 +44,27 @@ function SlimeBossThink()
false
)

if (thisEntity.vInitialSpawnPos - thisEntity:GetAbsOrigin()):Length() >= BOSS_LEASH_SIZE or #enemies == 0 then
return RetreatHome()
local hasDamageThreshold = thisEntity:GetMaxHealth() - thisEntity:GetHealth() > thisEntity.BossTier * BOSS_AGRO_FACTOR
local fDistanceToOrigin = ( thisEntity:GetOrigin() - thisEntity.vInitialSpawnPos ):Length2D()

if (fDistanceToOrigin < 10 and thisEntity.bHasAgro and #enemies == 0) then
thisEntity.bHasAgro = false
thisEntity:SetIdleAcquire(false)
thisEntity:SetAcquisitionRange(0)
return 2
elseif (hasDamageThreshold and #enemies > 0) then
if not thisEntity.bHasAgro then
thisEntity.bHasAgro = true
thisEntity:SetIdleAcquire(true)
thisEntity:SetAcquisitionRange(thisEntity.fAgroRange)
end
end

if not thisEntity.bHasAgro or #enemies == 0 or fDistanceToOrigin > BOSS_LEASH_SIZE then
if fDistanceToOrigin > 10 then
return RetreatHome()
end
return 1
end

-- Slam
Expand Down