Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local revengemod = RegisterMod("REVENGE! challenge",1.0);
- local killed = false
- local started = false
- local unspawned = true
- local continuedrun = false
- local playerEntity;
- local playerID = -9;
- local playerType = -9;
- local playerVariant = 0;
- local playerSub = 0;
- local pos
- local vel = Vector(0,0)
- local isplayeratdoor = false
- local tearvel = Vector(0,0)
- local invincibletime = 0
- debug_text = ""
- function revengemod:PostPlayerInit(player)
- if Isaac.GetChallenge() == Isaac.GetChallengeIdByName("Revenge!") then
- playerVariant = 0;
- playerSub = 0;
- unspawned = true
- if Game():GetFrameCount() < 2 then
- playerID = -9
- playerType = -9
- killed = false
- started = false
- Isaac.SaveModData(revengemod, playerType)
- end
- playerType = tonumber(Isaac.LoadModData(revengemod))
- if playerType ~= -9 then
- started = true
- killed = true
- unspawned = false
- continuedrun = true
- end
- end
- end
- function revengemod:tick()
- if Isaac.GetChallenge() == Isaac.GetChallengeIdByName("Revenge!") then
- local player = Isaac.GetPlayer(0);
- local currentLevel = Game():GetLevel()
- playerType = tonumber(Isaac.LoadModData(revengemod))
- if playerType ~= -9 then
- killed = true
- if started then
- if unspawned then
- unspawned = false
- player.Position = pos
- playerEntity = Isaac.Spawn(playerType, playerVariant, playerSub, pos, vel, player);
- playerEntity:AddCharmed(-1);
- playerID = playerEntity.Index
- local maxhealth = playerEntity.MaxHitPoints/3.5
- maxhealth = math.floor(maxhealth + 0.5)
- player:AddMaxHearts(-player:GetMaxHearts(), true)
- player:AddMaxHearts(maxhealth, true)
- if maxhealth % 2 == 1 then
- player:AddMaxHearts(1, true)
- end
- player:AddHearts(maxhealth)
- player:AddSoulHearts(-player:GetSoulHearts())
- end
- if continuedrun then
- continuedrun = false
- local entities = Isaac.GetRoomEntities()
- for ent = 1, #entities do
- local entity = entities[ent]
- if playerType == entity.Type and entity:HasEntityFlags(256) then
- playerEntity = entity
- playerID = entity.Index
- playerVariant = entity.Variant
- playerSub = entity.SubType
- break
- end
- end
- end
- player:SetColor(Color(1,1,1,0,1,1,1),0,0,false,false)
- playerEntity.TargetPosition = player.Position
- playerEntity.Position = player.Position
- playerEntity.MaxHitPoints = 99999
- playerEntity.HitPoints = 99999
- player.FireDelay = 9999
- --player.MaxFireDelay = 99999999
- if player:GetFireDirection() > -1 then
- if playerEntity:ToNPC().ProjectileCooldown == 0 then
- player.FireDelay = 0
- playerEntity:ToNPC().ProjectileDelay = 0
- playerEntity:ToNPC().ProjectileCooldown = 5
- end
- local entities = Isaac.GetRoomEntities()
- for ent = 1, #entities do
- local entity = entities[ent]
- if entity.Type == 2 and entity:GetLastParent().Index == player.Index and entity.Variant ~= TearVariant.BOBS_HEAD and entity.Variant ~= 21 then
- tearvel = entity.Velocity
- entity:Remove()
- break
- end
- end
- for ent = 1, #entities do
- local entity = entities[ent]
- if entity.Type == 9 and entity:GetLastParent().Index == playerEntity.Index then
- entity.Velocity = tearvel
- end
- end
- else
- if playerEntity:ToNPC().ProjectileCooldown < 1 then
- playerEntity:ToNPC().ProjectileCooldown = 1
- end
- end
- else
- checkisplayeratdoor()
- if isplayeratdoor then
- started = true
- end
- end
- end
- end
- end
- function revengemod:NPCtick(entity)
- if Isaac.GetChallenge() == Isaac.GetChallengeIdByName("Revenge!") then
- local player = Isaac.GetPlayer(0);
- playerType = tonumber(Isaac.LoadModData(revengemod))
- if playerType == -9 then
- if killed == false then
- if entity:IsDead() then
- if entity:ToNPC():IsBoss() == false and entity:ToNPC():IsChampion() == false then
- playerType = entity.Type
- playerVariant = entity.Variant
- playerSub = entity.SubType
- pos = entity.Position
- Isaac.SaveModData(revengemod, playerType)
- killed = true
- end
- end
- end
- end
- end
- end
- function revengemod:takeDamage(target,amount,flag,source,num)
- if Isaac.GetChallenge() == Isaac.GetChallengeIdByName("Revenge!") then
- if started then
- if target.Type == EntityType.ENTITY_PLAYER then
- if source.Type > 9 and source.Type ~= 33 and flag ~= DamageFlag.DAMAGE_FIRE and flag ~= DamageFlag.DAMAGE_EXPLOSION and flag ~= DamageFlag.DAMAGE_TNT and flag ~= DamageFlag.DAMAGE_SPIKES and flag ~= DamageFlag.DAMAGE_POOP and flag ~= DamageFlag.DAMAGE_ACID and flag ~= DamageFlag.DAMAGE_LASER then
- return false
- end
- else
- local player = Isaac.GetPlayer(0);
- if source.Type == playerEntity.Type then
- target:TakeDamage(player.Damage, 0, EntityRef(player), 1)
- return false
- end
- end
- end
- end
- end
- function checkisplayeratdoor()
- local player = Isaac.GetPlayer(0);
- local currentLevel = Game():GetLevel()
- local currentroom = currentLevel:GetCurrentRoom()
- local distance = 20;
- isplayeratdoor = false
- for i = 0, 7 do
- local poscheck = true
- local door = currentroom:GetDoor(i)
- if not door then
- poscheck = false
- end
- if poscheck then
- if door:IsOpen() then
- local doorpos = door.Position
- if player.Position.X > doorpos.X - distance and player.Position.X < doorpos.X + distance then
- if player.Position.Y > doorpos.Y - distance and player.Position.Y < doorpos.Y + distance then
- isplayeratdoor = true
- break
- end
- end
- end
- end
- end
- end
- function revengemod:debug()
- Isaac.RenderText(debug_text, 50, 50, 0, 255, 0, 255)
- end
- revengemod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, revengemod.PostPlayerInit);
- revengemod:AddCallback(ModCallbacks.MC_POST_UPDATE, revengemod.tick);
- revengemod:AddCallback(ModCallbacks.MC_NPC_UPDATE, revengemod.NPCtick);
- revengemod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, revengemod.takeDamage);
- revengemod:AddCallback(ModCallbacks.MC_POST_RENDER, revengemod.debug)
Advertisement
Add Comment
Please, Sign In to add comment