Ask a simple question, get a simple answer

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
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Thanks, minmay, for the help.

But I'm a little bit confused. Is only the lock-component of your solution important for me? The function in it refers to GameMode.dm_tempLockItem. What is that? Do I have to define it somewhere first??
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

All you need is for the lock to reactivate itself, and the counter to disable the lock component when it hits 0.
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

The dm_tempLockItem hack is used to return the item to the player's hands, so that the coinslot only accepts 1 coin at a time from stacks. Without that, it would consume the entire stack.

If you just want a lock that can be used an infinite number of times all you need is:

Code: Select all

{
  class = "Lock",
  onActivate = function(self)
    self:enable()
  end,
}
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

If one wanted to alter its behavior, it should be possible to have it expect a stack of coins by default, whether a stack of one or more than one.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Is there a way to get damage done to a champion before reductions?
'onDamage' happens after reductions, and while I managed to 'un-calculate' damage for magical resistances, I'm having problems with physical because it only gets reduced by melee monster attacks, which is sort of useless considering they also shoot physical projectiles. While I could redefine all monster projectiles to deal pure damage instead of physical for the drawback of having monster protection not taken into account when taking damage from monster projectiles(And I can totally live with that), there's the part where the party could damage themselves with their own physical projectiles, which means they'll be taking more physical damage.
While that's a rather minuscule thing, I'd really like for that to not be a thing. (Because more armor = more 'bugged' damage)

And if there isn't a way and I'll have to resort to keeping that bug, will this physical damage 'un-calculation' formula work properly?

Code: Select all

local protection = champion:getCurrentStat("protection")
if protection > 0 then
	unreducedDamage = math.floor(damage + protection)
end
EDIT: Now that I think about it, I could just 'create' a new damage type (damageType = "notPhysical") and do the calculations there, but then there's the problem of the console spamming the "hurr hurr invalid damage type". Can be fixed with "Console.suppressWarnings(suppress)", but how do I use it? I tried multiple ways, which all resulted in an error.
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

zimberzimber wrote:And if there isn't a way and I'll have to resort to keeping that bug, will this physical damage 'un-calculation' formula work properly?

Code: Select all

local protection = champion:getCurrentStat("protection")
if protection > 0 then
	unreducedDamage = math.floor(damage + protection)
end
Not even close, sorry. The effect of protection is replicated by this function:

Code: Select all

function applyProtection(damage, protection, pierce)
   protection = protection-pierce
   if protection <= 0 then
      return damage
   elseif protection >= 1000 then
      return 0
   else
      return math.max(1,damage-math.floor((math.random()+0.5)*protection))
   end
end
You cannot simply undo protection because 1. it's randomized, 2. even if you could predict the state of the rng, it won't reduce damage below 1.
Just give all of your monsters' melee attacks pierce=math.huge instead. Changing their damage type wouldn't work anyway; protection doesn't have anything to do with damage type, it just applies to all melee attacks.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Wait, protection reduces damage from melee attacks REGARDLESS of damage type? When does it happen if magical resistance is also taken into account, before or after?
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

zimberzimber wrote:Wait, protection reduces damage from melee attacks REGARDLESS of damage type?
Yes.
zimberzimber wrote:When does it happen if magical resistance is also taken into account, before or after?
Resistance applies after protection in that case, for both players and monsters.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Please tell me charge attacks ignore protection
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

No, I'm pretty sure the only inherently special thing about secondaryActions is that (where applicable) they have a default critical multiplier of 1.5 instead of 2.5. They certainly do not ignore protection or evasion. The "bash" and "cleave" powerAttackTemplates have 10 pierce, though.

edit: oops I just realized you were probably talking about MonsterChargeComponent. MonsterChargeComponent's damage is reduced by math.floor((math.random()*0.5+0.5)*[base Protection of the champion's chest armor]), to a minimum of 0 (rather than 1). Armor skill bonus and other sources of protection do not apply, it's just the base protection of the chest armor. If they aren't wearing chest armor they take full damage.

edit2: at this point I should probably reassure you that no, I am not making this up.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply