initial commit

This commit is contained in:
2021-10-24 15:36:18 -04:00
commit b9a5a8fe23
11982 changed files with 220468 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
---------------------------------------------------------------------------
-- Arrow Trap
---------------------------------------------------------------------------
function OnTrigger( trigger )
if thisEntity.isTrapActivated then
printf( "Trap Skip" )
return
end
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.TrapActivate", thisEntity )
thisEntity.isTrapActivated = true
thisEntity.hArrowAbility = thisEntity:FindAbilityByName( "arrow" )
if thisEntity.hArrowAbility == nil then
print( "ERROR: thisEntity.hArrowAbility not found" )
return
end
local fDelay = 0.6
thisEntity:SetContextThink( "ArrowTrapActivate", function() return ArrowTrapActivate() end, fDelay )
end
---------------------------------------------------------------------------
function ArrowTrapActivate()
if not IsServer() then
return
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if thisEntity.isTrapActivated == true then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hArrowAbility, -1 )
thisEntity.isTrapActivated = false
end
return -1
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,56 @@
--print( "fire_trap_cycle_a" )
---------------------------------------------------------------------------
-- Fire Trap Cycle
---------------------------------------------------------------------------
function OnTrigger( trigger )
thisEntity.fRefireTime = 1.5
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
end
return 0.5
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,90 @@
---------------------------------------------------------------------------
-- Fire Trap
---------------------------------------------------------------------------
function OnTrigger( trigger )
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fRefireTime = 1.8
thisEntity.fQuickRefireTime = 0.5
thisEntity.bNextAttackIsNormal = false
thisEntity.nQuickRefires = 0
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
thisEntity:SetContextThink( "FireTrapActivateAlternating", function() return FireTrapActivateAlternating() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivateAlternating()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
if thisEntity.bNextAttackIsNormal == false then
return QuickRefire()
else
return NormalRefire()
end
end
return 0.25
end
---------------------------------------------------------------------------
function QuickRefire()
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.nQuickRefires = thisEntity.nQuickRefires + 1
if thisEntity.nQuickRefires <= 2 then
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
else
thisEntity.bNextAttackIsNormal = true
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity.nQuickRefires = 0 -- reset counter
end
return 0.25
end
---------------------------------------------------------------------------
function NormalRefire()
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity.bNextAttackIsNormal = false
return 0.25
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,54 @@
---------------------------------------------------------------------------
-- Fire Trap Cycle
---------------------------------------------------------------------------
function OnTrigger( trigger )
thisEntity.fRefireTime = 2.0
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
end
return 0.5
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,54 @@
---------------------------------------------------------------------------
-- Fire Trap Cycle
---------------------------------------------------------------------------
function OnTrigger( trigger )
thisEntity.fRefireTime = 2.5
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
end
return 0.5
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,54 @@
---------------------------------------------------------------------------
-- Fire Trap Cycle
---------------------------------------------------------------------------
function OnTrigger( trigger )
thisEntity.fRefireTime = 3.9
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
end
return 0.5
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,220 @@
--print( "fire_trap_cycle_shuffle" )
---------------------------------------------------------------------------
-- Fire Trap Cycle Shuffle
---------------------------------------------------------------------------
function Spawn( entityKeyValues )
if not IsServer() then
return
end
if thisEntity == nil then
return
end
-- Determine the type of trap
-- If any one type is weighted we can insert more entries into the table
thisEntity.hTrapTable = { "standard", "standard", "standard", "tripleshot", "alternating" }
local nRandomType = RandomInt( 1,5 ) -- Change this number to correspond to the trap table entries
thisEntity.szTrapType = thisEntity.hTrapTable[nRandomType]
thisEntity.hRefireTable = { 1.5, 2.0, 2.5, 3.9 }
thisEntity.nQuickRefires = 0
thisEntity.bNextAttackIsNormal = false
thisEntity.fRefireTime = 1.5
thisEntity.fQuickRefireTime = 0.5
if thisEntity.szTrapType == "standard" then
--print("Standard Trap")
local nRandomRefireTime = RandomInt( 1,4 )
thisEntity.fRefireTime = thisEntity.hRefireTable[ nRandomRefireTime ]
--print( "Refire time = " .. thisEntity.fRefireTime )
elseif thisEntity.szTrapType == "tripleshot" then
--print("Triple Shot Trap")
thisEntity.fRefireTime = 2.0
--print( "Refire time = " .. thisEntity.fRefireTime )
elseif thisEntity.szTrapType == "alternating" then
--print("Alternating Trap")
thisEntity.fRefireTime = 1.8
--print( "Refire time = " .. thisEntity.fRefireTime )
end
end
function OnTrigger( trigger )
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
if thisEntity.szTrapType == "standard" then
-- Standard
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity:SetContextThink( "FireTrapActivate", function() return FireTrapActivate() end, 0 )
elseif thisEntity.szTrapType == "tripleshot" then
-- TripleShot
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
thisEntity:SetContextThink( "FireTrapActivateTriple", function() return FireTrapActivateTriple() end, 0 )
elseif thisEntity.szTrapType == "alternating" then
-- Alternating
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
thisEntity:SetContextThink( "FireTrapActivateAlternating", function() return FireTrapActivateAlternating() end, 0 )
end
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
end
return 0.5
end
---------------------------------------------------------------------------
function FireTrapActivateTriple()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
return QuickRefireTriple()
end
return 0.25
end
---------------------------------------------------------------------------
function QuickRefireTriple()
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.nQuickRefires = thisEntity.nQuickRefires + 1
if thisEntity.nQuickRefires <= 2 then
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
else
thisEntity.bNextAttackIsNormal = true
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity.nQuickRefires = 0 -- reset counter
end
return 0.25
end
---------------------------------------------------------------------------
function FireTrapActivateAlternating()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
if thisEntity.bNextAttackIsNormal == false then
return QuickRefireAlternating()
else
return NormalRefire()
end
end
return 0.25
end
---------------------------------------------------------------------------
function QuickRefireAlternating()
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.nQuickRefires = thisEntity.nQuickRefires + 1
if thisEntity.nQuickRefires <= 2 then
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
else
thisEntity.bNextAttackIsNormal = true
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity.nQuickRefires = 0 -- reset counter
end
return 0.25
end
---------------------------------------------------------------------------
function NormalRefire()
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity.bNextAttackIsNormal = false
return 0.25
end
---------------------------------------------------------------------------
function PickRandomShuffle( reference_list, bucket )
if ( #reference_list == 0 ) then
return nil
end
if ( #bucket == 0 ) then
-- ran out of options, refill the bucket from the reference
for k, v in pairs(reference_list) do
bucket[k] = v
end
end
-- pick a value from the bucket and remove it
local pick_index = RandomInt( 1, #bucket )
local result = bucket[ pick_index ]
table.remove( bucket, pick_index )
return result
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,73 @@
---------------------------------------------------------------------------
-- Fire Trap
---------------------------------------------------------------------------
function OnTrigger( trigger )
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fRefireTime = 2.0
thisEntity.fQuickRefireTime = 0.5
thisEntity.nQuickRefires = 0
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
return QuickRefire()
end
return 0.25
end
---------------------------------------------------------------------------
function QuickRefire()
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.nQuickRefires = thisEntity.nQuickRefires + 1
if thisEntity.nQuickRefires <= 2 then
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fQuickRefireTime
else
thisEntity.bNextAttackIsNormal = true
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity.nQuickRefires = 0 -- reset counter
end
return 0.25
end
---------------------------------------------------------------------------

View File

@@ -0,0 +1,49 @@
---------------------------------------------------------------------------
-- Fire Trap
---------------------------------------------------------------------------
function OnTrigger( trigger )
if thisEntity.isTrapActivated then
print( "Trap Skip" )
return
end
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", thisEntity )
thisEntity.isTrapActivated = true
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
function FireTrapActivate()
if not IsServer() then
return
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if thisEntity.isTrapActivated == true then
--[[
print( "----------------------------------------------------------" )
print( "FireTrapActivate... thisEntity:" )
PrintTable( thisEntity, " " )
]]
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.isTrapActivated = false
end
return -1
end

View File

@@ -0,0 +1,41 @@
require("ai/shared")
--------------------------------------------------------------------------------
function Spawn( entityKeyValues )
if IsServer() == false then
return
end
--printf( "thisEntity:GetUnitName() == %s", thisEntity:GetUnitName() )
thisEntity.hSwingAbility = thisEntity:FindAbilityByName( "pendulum_swing" )
thisEntity:SetContextThink( "PendulumTrapThink", PendulumTrapThink, RandomFloat( 0.1, 1.0 ) )
end
--------------------------------------------------------------------------------
function PendulumTrapThink()
if IsServer() then
local enemies = GetEnemyHeroesInRange( thisEntity, 2048 ) -- will need to search just in room
if not enemies or #enemies == 0 then
--print( "no enemies" )
thisEntity:InterruptChannel()
return RandomFloat( 0.1, 1.0 )
end
if not thisEntity:IsChanneling() then
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_NO_TARGET,
AbilityIndex = thisEntity.hSwingAbility:entindex(),
Queue = false,
})
end
end
return 1
end
--------------------------------------------------------------------------------

View File

@@ -0,0 +1,38 @@
--[[ spike_trap_ai.lua ]]
---------------------------------------------------------------------------
-- AI for the Spike Trap
---------------------------------------------------------------------------
local triggerActive = true
function Fire(trigger)
local triggerName = thisEntity:GetName()
--print(tostring(triggerName))
local level = trigger.activator:GetLevel()
local target = Entities:FindByName( nil, triggerName .. "_target" )
local spikes = triggerName .. "_model"
local dust = triggerName .. "_particle"
local fx = triggerName .. "_fx"
--print(spikes)
if target ~= nil and triggerActive == true then
local spikeTrap = thisEntity:FindAbilityByName("spike_trap")
thisEntity:CastAbilityOnPosition(target:GetOrigin(), spikeTrap, -1 )
EmitSoundOn( "AghanimsFortress.TrapActivate" , spikeTrap)
DoEntFire( spikes, "SetAnimation", "spiketrap_activate", 0, self, self )
DoEntFire( dust, "Start", "", 0, self, self )
DoEntFire( dust, "Stop", "", 2, self, self )
DoEntFire( fx, "Start", "", 0, self, self )
DoEntFire( fx, "Stop", "", 2, self, self )
--thisEntity:SetContextThink( "ResetTrapModel", function() ResetTrapModel( spikes ) end, 3 )
triggerActive = false
thisEntity:SetContextThink( "ResetTrapModel", function() ResetTrapModel() end, 4 )
end
end
function ResetTrapModel()
DoEntFire( spikes, "SetAnimation", "spiketrap_idle", 0, self, self )
triggerActive = true
end