thoughts on a 'Frozen' condition

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

thoughts on a 'Frozen' condition

Post by akroma222 »

Hey All,
Firstly, apologies for moaning about us having to use Paralyzed to mimic the same effect in other custom conditions
I believe I have made some progress here... (small steps :lol: )

Party hooks I have involved so far
SpoilerShow

Code: Select all

onDrawAttackPanel = function(self, champion, g, x, y, scaleX, scaleY, translationX, translationY)
		if champion:hasCondition("frozen") then
			g.color(30,100,300)     --not sure exactly how to mess with colours yet
            champion:showAttackResult("", "ChampionConditionOverlay")
            champion:showAttackResult("Frozen", "SpellNoEnergy")
        end
    end,
                    
	onAttack = function(self, champion, action, slot)
		if champion:hasCondition("frozen") then
			return false
        end
    end,
                    
	onClickItemSlot = function(self, champion, container, slot, button)
		if slot and (button == 0 or button == 1) then
			if champion then
				if champion:hasCondition("frozen") then
					return false
                end
            end
        end
    end
The condition definition is irrelevant here, just aiming for that Paralyzed functionality (ie - cant attack or perform actions etc)
(happy to share the condition def, its pretty unrefined atm though)
I might be tripped up by unarmed attacks though... which dont call party hooks :(

Im uploading a video of the condition now, will post the link once its uploaded... pic for now
SpoilerShow
Image
video...
https://youtu.be/HLDVgU9_YXI

thoughts.....
Last edited by akroma222 on Tue Aug 16, 2016 5:45 pm, edited 1 time in total.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: thoughts on a 'Frozen' condition

Post by zimberzimber »

How about preventing the party from moving when everyone is frozen? :twisted:

EDIT: Script removed because there are better ways of doing it
Updated scrip posted below (for those who need it)
Last edited by zimberzimber on Tue Aug 16, 2016 6:36 pm, edited 2 times in total.
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: thoughts on a 'Frozen' condition

Post by akroma222 »

zimberzimber wrote:How about preventing the party from moving when everyone is frozen? :twisted:
(working on it)
Oh! How could we not?? :lol:
Ive been running this...
SpoilerShow

Code: Select all

----------------------------------------------------------------------------------------checkFrozenAll()
function checkFrozenAll()
	if party.party:getChampion(1):hasCondition("frozen")
	and party.party:getChampion(2):hasCondition("frozen")
	and party.party:getChampion(3):hasCondition("frozen")
	and party.party:getChampion(4):hasCondition("frozen") then
		return true
	else
		return false
	end
end		
but should probably get real and upgrade to this....
SpoilerShow

Code: Select all

function checkConditionAll(cond)
	for i = 1,4 do
		if not party.party:getChampion(i):hasCondition(cond) then
			return false
		else
			return true
		end
	end
end		
EDIT: Great hooks there good sir! Im always forgetting to check if poeple are still alive + able :roll:
Also, vidoe is up... (excuse all the theatrics)
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: thoughts on a 'Frozen' condition

Post by AndakRainor »

akroma222 wrote:

Code: Select all

function checkConditionAll(cond)
	for i = 1,4 do
		if not party.party:getChampion(i):hasCondition(cond) then
			return false
		else
			return true
		end
	end
end
You have a problem here; you start a loop that returns a result (true or false) immediatly (when i=1).
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: thoughts on a 'Frozen' condition

Post by zimberzimber »

akroma222 wrote:EDIT: Great hooks there good sir! Im always forgetting to check if poeple are still alive + able :roll:
Also, vidoe is up... (excuse all the theatrics)
Removed it and made a better version that includes the function method.
This in the party hooks:

Code: Select all

onMove = function(self, direction)	
	if functions.script:entirePartyHasCondition("frozen") then
		playSound("party_move_overloaded")
		return false
	end
end,
onTurn = function(self, direction)		
	if functions.script:entirePartyHasCondition("frozen") then
		playSound("party_move_overloaded")
		return false
	end
end,
And this into a script entity named "functions":

Code: Select all

function entirePartyHasCondition(con)
	local enabledChampions, afflictedChampions = 0,0
	for i = 1, 4 do
		local c = party.party:getChampion(i)
		if c and c:isAlive() then
			enabledChampions = enabledChampions + 1
			if c:hasCondition("frozen") then
				afflictedChampions = afflictedChampions + 1
	end end end
	if afflictedChampions == enabledChampions then
		return true
	else
		return false
	end
end
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: thoughts on a 'Frozen' condition

Post by akroma222 »

AndakRainor wrote:
akroma222 wrote:

Code: Select all

function checkConditionAll(cond)
	for i = 1,4 do
		if not party.party:getChampion(i):hasCondition(cond) then
			return false
		else
			return true
		end
	end
end
You have a problem here; you start a loop that returns a result (true or false) immediatly (when i=1).
A problem indeed!
Im always forgetting to check ... everything :roll:
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: thoughts on a 'Frozen' condition

Post by akroma222 »

zimberzimber wrote:How about preventing the party from moving when everyone is frozen? :twisted:

EDIT: Script removed because there are better ways of doing it
Updated scrip posted below (for those who need it)
Yup your new method is great - Id been meaning to clean up onTurn / onMove for a while - that helps!
Do you know of any way to prevent a champ from attacking barehanded while frozen though?
Ive gone to some stupidly extreme lengths to stop it with no success :?
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: thoughts on a 'Frozen' condition

Post by zimberzimber »

Do you know of any way to prevent a champ from attacking barehanded while frozen though?
I have no idea. I remember Isaac telling me something about it being nearly impossible or something like that though.
As a workaround, you could prevent the player from removing items from hand slots. Won't stop it 100%, but it'll prevent the player from exploiting it whenever a champion gets frozen.

Also this:

Code: Select all

onDamage = function(self, champion, damage, damageType)
	if damageType == "fire" and champion:hasCondition("frozen") then
		champion:removeCondition("frozen")
	elseif damageType == "cold" then
		if damage > math.random(25,125) then
			champion:setCondition("frozen")
		end
	end
end,
Every source of cold damage has a chance to freeze a champion as long as its above 25. More damage = Higher chance.
And the player can thaw champions with fire damage.

EDIT: setCondtiotion instead of addCondition
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: thoughts on a 'Frozen' condition

Post by akroma222 »

zimberzimber wrote:
Do you know of any way to prevent a champ from attacking barehanded while frozen though?
I have no idea. I remember Isaac telling me something about it being nearly impossible or something like that though.
As a workaround, you could prevent the player from removing items from hand slots. Won't stop it 100%, but it'll prevent the player from exploiting it whenever a champion gets frozen.
Yup, returning false from onClickItemSlot takes care of that... its only the off chance someone is running a bare handed build that Id like to cover...
I remember someone saying almost Impossible also - oh well!!

Hold up - Ill dig up and post my definitions for Frozen & also Burning conditions ....
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: thoughts on a 'Frozen' condition

Post by zimberzimber »

akroma222 wrote:Hold up - Ill dig up and post my definitions for Frozen & also Burning conditions ....
Sharing conditions are we? Here are mine :lol:
Frozen -
In addition to what we already did, it also prevents the player from using right mouse look around to hack through onTurn being disabled.
Will not apply if the champions cold resistance is high enough, but will not get removed if they suddenly achieve it.

Code: Select all

defineCondition{
	name = "frozen",
	uiName = "Frozen",
	description = "Unable to act.",
	iconAtlas = "mod_assets/textures/gui/conditions.dds",
	icon = 0,
	beneficial = false,
	harmful = true,
	tickInterval = 1,
	onStart = function(self, champion)
	
		if champion:getResistance("cold") > 85 then
			champion:removeCondition("frozen")
		end
		
		self:setDuration(math.random(8,15))
	
		if champion:getResistance("cold") > 85 then
			champion:removeCondition("frozen")
			return
		end
		
		if math.random()> 0.85 then
			hudPrint(champion:getName().." has to let it go")
		else
			hudPrint(champion:getName().." is frozen solid")
		end
	end,

	onTick = function(self, champion)
		if not champion:isAlive() then
			champion:removeCondition("frozen")
		end
		if functions.script:entirePartyHasCondition("frozen") then
			GameMode.setGameFlag("DisableMouseLook", false)
		end
	end,
	
	onStop = function(self, champion)
		GameMode.setGameFlag("DisableMouseLook", false)
	end,
}
Burning -
Small fire damage over time. Will get removed if the party has high fire resistance (even if they get it mid condition)
If the champion is be be frozen or considered underwater, the condition is removed.

Code: Select all

defineCondition{
	name = "burning",
	uiName = "ON FIRE!",
	description = "YOU ARE ON FIRE!",
	iconAtlas = "mod_assets/textures/gui/conditions.dds",
	icon = 2,
	beneficial = false,
	harmful = true,
	tickInterval = 0.25,
	
	onStart = function(self, champion)
		hudPrint(champion:getName().." is on fire!")
		self:setDuration(math.random(7,15))
		playSound("burn")
	end,
	
	onTick = function(self, champion)
		local tile = party.map:getAutomapTile(party.x, party.y)
		
		if champion:isAlive() then
			if champion:getResistance("fire") > 85 or (tile == 2 and party:getElevation() < 0) or champion:hasCondition("frozen") then
				champion:removeCondition("burning")
			else
				champion:damage(math.random(2,4), "fire")
			end
		else
			champion:removeCondition("burning")
		end
	end,
}
NOTE: Every water tile must have its automap tile set to 2, otherwise it will not be put out on every water tile. The castle water tile doesn't have that, so it has to be redefined.

Bleeding -
Deals pure damage over time based on the champions max health, while also halting heath regeneration.
Lizardmen recover faster, part of me trying to make them a viable race.

Code: Select all

defineCondition{
	name = "bleeding",
	uiName = "Bleeding",
	description = "Health regeneration halted, losing health over time.",
	iconAtlas = "mod_assets/textures/gui/conditions.dds",
	icon = 4,
	beneficial = false,
	harmful = true,
	tickInterval = 1,
	
	onStart = function(self, champion)
		playSound("bleed")
		hudPrint(champion:getName().." is bleeding!")
		if champion:getRace() == "lizardman" then
			self:setDuration(math.random(16,24))
		else
			self:setDuration(math.random(26,34))
		end
	end,
	
	onRecomputeStats = function(self, champion)
		champion:addStatModifier("health_regeneration_rate", champion:getCurrentStat("health_regeneration_rate")*-1)
	end,
	
	onTick = function(self, champion)
		if champion:isAlive() then
			champion:damage(champion:getMaxHealth() * 0.035, "pure")
		else
			champion:removeCondition("bleeding")
		end
	end,
}
Got a whole lot more, and one I am especially proud of, but I'll leave it for some other time ;)

EDIT: These conditions were written before I meddled with party hooks (except for frozen), so I'm moving the conditions getting removed on death to the onDie hook.
My asset pack [v1.10]
Features a bit of everything! :D
Post Reply