tboi-creativelore/main.lua

165 lines
6.9 KiB
Lua

local Lore = RegisterMod( "thecreativelore", 1 );
--[[ USEFUL FUNCTIONS ]]--
local Room = Room
local function FindClosestEnemy( position, distance, validator )
local closestDistance = distance or 9999
local closestEnemy = nil
local enemies = Isaac.FindInRadius( position, closestDistance, EntityPartition.ENEMY )
for k,enemy in ipairs(enemies) do
if enemy:IsActiveEnemy() == true and enemy:IsVulnerableEnemy() == true and enemy:HasEntityFlags( EntityFlag.FLAG_FRIENDLY ) == false then
local distance = (position - enemy.Position):Length()
if distance < closestDistance then
if validator == nil or validator(enemy) == true then
closestEnemy = enemy
closestDistance = distance
end
end
end
end
return closestEnemy
end
--[[ ITEMS ]]--
ITEM_BRONZE_SCALE = Isaac.GetItemIdByName("Bronze Scale Collar")
ITEM_SCALY_EGG = Isaac.GetItemIdByName("Scaly Egg")
ITEM_ZAPPY_BREATH = Isaac.GetItemIdByName("Zappy Breath!")
ITEM_DRAGON_MARK = Isaac.GetItemIdByName("Dragon Mark")
--[[ CHARACTERS ]]--
-- 01_Ariel
local ARIEL_NAME = "01_Ariel";
local ARIEL_TYPE = Isaac.GetPlayerTypeByName(ARIEL_NAME);
local ARIEL_STATS = {
MoveSpeedNaturalBonus = 0.10,
MoveSpeedNaturalMultiplier = 0.9,
DamageNaturalMultiplier = 0.70,
ShotSpeedNaturalMultiplier = 0.8,
MaxFireDelayNaturalMultiplier = 1.0,
MaxFireDelayNaturalExponent = 0.9,
TearHeightBonus = 12,
};
local ARIEL_HEAD = Isaac.GetCostumeIdByPath("gfx/characters/players/01_Ariel_Head.anm2")
-- 02_Nerielle
local NERIELLE_NAME = "02_Nerielle";
local NERIELLE_TYPE = Isaac.GetPlayerTypeByName(NERIELLE_NAME);
local NERIELLE_STATS = {
MoveSpeedNaturalBonus = 0.10,
MoveSpeedNaturalMultiplier = 0.9,
DamageNaturalMultiplier = 0.70,
ShotSpeedNaturalMultiplier = 0.8,
MaxFireDelayNaturalMultiplier = 1.0,
MaxFireDelayNaturalExponent = 0.9,
TearHeightBonus = 12,
};
local NERIELLE_HEAD = Isaac.GetCostumeIdByPath("gfx/characters/players/02_Nerielle_Head.anm2")
-- 03_Sive
local SIVE_NAME = "03_Sive";
local SIVE_TYPE = Isaac.GetPlayerTypeByName(SIVE_NAME);
local SIVE_STATS = {
MoveSpeedNaturalBonus = 0.10,
MoveSpeedNaturalMultiplier = 0.9,
DamageNaturalMultiplier = 0.70,
ShotSpeedNaturalMultiplier = 0.8,
MaxFireDelayNaturalMultiplier = 1.0,
MaxFireDelayNaturalExponent = 0.9,
TearHeightBonus = 12,
};
local SIVE_HEAD = Isaac.GetCostumeIdByPath("gfx/characters/players/03_Sive_Head.anm2")
function Lore:PostPlayerInit( player )
if player:GetPlayerType() == ARIEL_TYPE then
player:AddNullCostume( ARIEL_HEAD );
end
if player:GetPlayerType() == NERIELLE_TYPE then
player:AddNullCostume( NERIELLE_HEAD );
end
if player:GetPlayerType() == SIVE_TYPE then
player:AddNullCostume( SIVE_HEAD );
end
end
Lore:AddCallback( ModCallbacks.MC_POST_PLAYER_INIT, Lore.PostPlayerInit );
function Lore:PlayerUpdate( player )
-- Collectibles!
-- if player:HasCollectible()
-- Characters!
if player:GetPlayerType() == ARIEL_TYPE then
ToCharm = FindClosestEnemy(player.Position, 100)
if ToCharm ~= nil
then ToCharm:AddCharmed(30)
end
--[[ If only one enemy left, bump up the damage!
if Room:GetAliveEnemiesCount() == 1 then
player:AnimateHappy()
end]]
end
if player:GetPlayerType() == NERIELLE_TYPE then
end
end
Lore:AddCallback( ModCallbacks.MC_POST_PLAYER_UPDATE, Lore.PlayerUpdate );
--[[ Stats ]]
function Lore:EvaluateCache( player, cacheFlag )
local player = Isaac.GetPlayer(0) -- get the player entity
if player:GetPlayerType() == ARIEL_TYPE then
--[[ if cacheFlag == CacheFlag.CACHE_SPEED then
player.MoveSpeed = player.Mññº
moveSpeed * ARIEL_STATS.MoveSpeedNaturalMultiplier + ARIEL_STATS.MoveSpeedNaturalBonus;
elseif cacheFlag == CacheFlag.CACHE_SHOTSPEED then
player.ShotSpeed = player.ShotSpeed * ARIEL_STATS.ShotSpeedNaturalMultiplier;
elseif cacheFlag == CacheFlag.CACHE_DAMAGE then
player.Damage = player.Damage * ARIEL_STATS.DamageNaturalMultiplier;
elseif cacheFlag == CacheFlag.CACHE_FIREDELAY then
player.MaxFireDelay = math.floor( math.max( 1, player.MaxFireDelay * ARIEL_STATS.MaxFireDelayNaturalMultiplier ) ^ ARIEL_STATS.MaxFireDelayNaturalExponent );
elseif cacheFlag == CacheFlag.CACHE_RANGE then
player.TearHeight = player.TearHeight + ARIEL_STATS.TearHeightBonus;
elseif cacheFlag == CacheFlag.CACHE_TEARCOLOR then
--player.TearColor = GAPPI_COLOR;
--Player.LaserColor = GAPPI_COLOR;
end]]
if cacheFlag == CacheFlag.CACHE_FLYING then
player.CanFly = 1
end
end
if player:GetPlayerType() == NERIELLE_TYPE then
--[[ if cacheFlag == CacheFlag.CACHE_SPEED then
player.MoveSpeed = player.Mññº
moveSpeed * ARIEL_STATS.MoveSpeedNaturalMultiplier + ARIEL_STATS.MoveSpeedNaturalBonus;
elseif cacheFlag == CacheFlag.CACHE_SHOTSPEED then
player.ShotSpeed = player.ShotSpeed * ARIEL_STATS.ShotSpeedNaturalMultiplier;
elseif cacheFlag == CacheFlag.CACHE_DAMAGE then
player.Damage = player.Damage * ARIEL_STATS.DamageNaturalMultiplier;
elseif cacheFlag == CacheFlag.CACHE_FIREDELAY then
player.MaxFireDelay = math.floor( math.max( 1, player.MaxFireDelay * ARIEL_STATS.MaxFireDelayNaturalMultiplier ) ^ ARIEL_STATS.MaxFireDelayNaturalExponent );
elseif cacheFlag == CacheFlag.CACHE_RANGE then
player.TearHeight = player.TearHeight + ARIEL_STATS.TearHeightBonus;
elseif cacheFlag == CacheFlag.CACHE_TEARCOLOR then
--player.TearColor = GAPPI_COLOR;
--Player.LaserColor = GAPPI_COLOR;
end]]
if cacheFlag == CacheFlag.CACHE_FLYING then
player.CanFly = 1
end
end
end
Lore:AddCallback( ModCallbacks.MC_EVALUATE_CACHE, Lore.EvaluateCache );
Lore:AddCallback(ModCallbacks.MC_POST_FIRE_TEAR, function(_, tear)
local player = Isaac.GetPlayer(0) -- get the player entity
if player:GetPlayerType() == ARIEL_TYPE then
tear.TearFlags = tear.TearFlags | TearFlags.TEAR_CHARM -- add slowing effect to the tear
end
if player:GetPlayerType() == NERIELLE_TYPE then
tear.TearFlags = tear.TearFlags | TearFlags.TEAR_BURN -- add slowing effect to the tear
end
end)