Proper Poison Damage While Resting - no more cheating!

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Proper Poison Damage While Resting - no more cheating!

Post by Komag »

Proper Poison Damage While Resting
no more cheating!

I always felt it was cheap that if you got poisoned you could just rest away the poison and heal faster than the poison hurts you. With this code that is no longer the case, making it much more realistic and plausible, forcing you to actually use some antidote potions and have a little more immersive tension and urgency in the case of getting poisoned.

add a script entity lua item, name it poisonScript, containing the following code:

Code: Select all

function extraPoison()
  if not party:isResting() then return end
  if poisonTick < 2 then poisonTick = poisonTick + 1 return end
  poisonTick = 0

  for i=1,4 do
    local champ = party:getChampion(i)
    if champ:hasCondition("poison") then
      local amt = champ:getCondition("poison")
      local resist = champ:getResistance("poison")
      pr.nt(champ:getName(),amt,"resist"..resist)
      champ:damage(amt/3*(1-((resist+0.1)/100)), "poison")
    end
  end
end

poisonTick = 0
While resting, any champion who is poisoned will take extra damage over time (although the damage amount will be reduced by percentage according to their poison resistance)

The final part to make this work is left to you:

You'll need a Universal Timer set up in your dungeon (every mod should have one!), and have it run the above function every 1 second (which is sped up during resting). For example, if your universal timer is set up to tick every 1/5 of a second, then have it run the poison function poisonScript.extraPoison() once every 5 ticks.
Finished Dungeons - complete mods to play
User avatar
Asteroth
Posts: 471
Joined: Wed Oct 24, 2012 10:41 am
Location: Eastern U.S.

Re: Proper Poison Damage While Resting - no more cheating!

Post by Asteroth »

Everyone who experienced poison in Eye of the Beholder is shuddering...
I am the God of darkness and corruption.
viewtopic.php?f=14&t=4250
badhabit
Posts: 467
Joined: Sat May 05, 2012 2:24 pm

Re: Proper Poison Damage While Resting - no more cheating!

Post by badhabit »

Komag wrote:Proper Poison Damage While Resting
no more cheating! <snip>

great! added it to the other scripts under [Patch] community made fixes
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: Proper Poison Damage While Resting - no more cheating!

Post by Dr.Disaster »

Nice work.

Yet won't preventing the Rest of poisoned characters do the same if not a better job? Depending on a characters max health adding such a script could almost instantly kill a poisoned character anyway due to increased time and poison damage applied, so ...
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Proper Poison Damage While Resting - no more cheating!

Post by Komag »

Your concern is important to me as well, so I tested it on a wide variety of health levels and vitality, poison resistance, etc, and I tried to balance it as well as I could. The amount of poison the game inflicts is already scaled to champion's health/vitality somewhat, so that helps. I'll be doing more lengthy playtesting next week as well.

I'm wary of the idea of preventing rest overall because if only one champion is poisoned it could still make sense to have the party rest for a bit for their benefit (health/energy regain), then feed that one poisoned person a health potion
Finished Dungeons - complete mods to play
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Proper Poison Damage While Resting - no more cheating!

Post by bongobeat »

Hello,
thanks for this job!
I m gonna use it to improve difficulty. That's true it's easy to sleep while poisoned to get cure of poison, the potion start to be of no use!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Proper Poison Damage While Resting - no more cheating!

Post by bongobeat »

I just test it, but I have some trouble.
the script gives me an error message.
do you have any idea to avoid this?
Image
the timer linked to the script
Image

another thing:
I ve read that a timer running in a level will not run at the same time on another level. Should these timer and script be implemented on each level?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Proper Poison Damage While Resting - no more cheating!

Post by Diarmuid »

bongobeat wrote: another thing:
I ve read that a timer running in a level will not run at the same time on another level. Should these timer and script be implemented on each level?
The "pr.nt" is a Komag custom print function. Just replace it with print and it'll work. As for timers, yes, you need an "universal Timer". Here's my implementation, set to run at 1/4s but you can adjust it with the timerInterval variable. There's also a handy isTick(numberOfTicks) function that can automatically execute calls at different intervals. For example, if isTick(8) would run every 2s (1/4s x 8).

Code: Select all

timerInterval = 0.25;
timerTick = 0;

function setUniversalTimers()
	levels = getMaxLevels()
	for i = 1, levels do
		spawn("timer", i, 0, 0, 0, "universalTimer_"..i)
			:setTimerInterval(timerInterval)
			:addConnector("activate", "universalTimer", "universalTimer")
			:activate()
	end
end

setUniversalTimers();

function isTick(tickNumber)

	if timerTick%tickNumber == 0 then return true; else return false; end
end

function universalTimer(sourceTimer)

	if sourceTimer.level == party.level then
		timerTick = timerTick + 1
	
		-- Place your function calls here:
		
		if isTick(5) then
			print("Every 5 ticks!") 
		end
		
		if isTick(9) then
			print("Every 9 ticks!") 
		end		
		
	end
	
end


bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Proper Poison Damage While Resting - no more cheating!

Post by bongobeat »

hi,
thanks for your help!
this is deadly!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply