[HELP] Need Script for Alcove Item to alter Monster stats

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

[HELP] Need Script for Alcove Item to alter Monster stats

Post by undeaddemon »

Please help, if you can! (Sorry - only basic scripting skill)
4 items
4 alcoves
1 monster
1 or maybe more spawners

placing and item in alcove needs to - lower monster hit points and remove an immunity (obviously he has 4 immunities)
AND
when all 4 items are in alcove, destroy a spawner(s)

The first one, dealing with the monster - I had thought that I could just destroy the monster and spawn a lesser version, but I need each item in alcove to be cumulative, so I just don't know a way to do that.

Thanks!!!

:oops:
UD
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by undeaddemon »

I suppose I should ask if this is even possible too.... currently looking to install the LoG Framework, not sure if that will help at all [embarrassed to be shooting in the dark here]
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by undeaddemon »

bump... anyone??
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by Komag »

You could still do the destroy/spawn method, just with four different custom defined monsters :)
Finished Dungeons - complete mods to play
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by Grimwold »

Using different custom monsters would probably require more than 4 as it would depend which order you placed items as to which immunities were removed...

What I'd suggest is setting up 4 variables in a script entity for the 4 immunities and giving the monster a custom onDamage() hook that checks the variables, and if the appropriate immunity is still in place "return false" on the damage hook so that no damage is dealt to the monster.

Along with that, I'd have functions that when each item is placed in the correct alcove it checks for the immunity variable.. if still on, it turns it off and then deals the monster an amount of damage using that damage type... e.g. remove fire immunity and deal 50 fire damge (probably using damageTile)

The immunity variables would be something like

fire = 1
ice = 1
shock = 1
poison = 1

and you would set them to 0 when the immunity is removed.


This is just a rough outline... With a bit more time I could whip up some script along these lines if you like.
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by undeaddemon »

@Komag - Well that is exactly how I thought I was going to do it... then.. when I went to do it, I realized that to get the effect of each item reducing the HP and removing an immunity, I also need a check, for what other items have been placed in the alcoves, to know what monster to spawn, and it becomes like 16 or more..??? My lack of scripting skills, it sorta makes my brain explode...

@Grimwold - Can you please please provide some framework script that would work for this?!!!? :D :D
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by undeaddemon »

SO my thinking is, you place one item in an alcove -
-350HP and remove a specific immunity (each item ties to the monsters immunity)

So when 2 of the items are in alcoves -

The monster has now lost 700HP and 2 specific immunities, etc, etc.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by Grimwold »

OK lemme see if I can flesh out this idea in script...


You would need a custom monster with an onDamage hook... so for example if you were using an Ogre. you would put the following in your monsters.lua file in the folder YOUR_DUNGEON/mod_assets/scripts

Code: Select all

cloneObject{
name = "immune_ogre",
baseObject = "ogre",
onDamage = function(monster,amount,type)
  return immunity_script.checkImmunity(monster,amount,type)
end,
}

you would also need a script entity in your dungeon called immunity_script

Code: Select all

-- set up the immunity variables at the start
fire_immunity = 1
ice_immunity = 1
shock_immunity = 1
poison_immunity = 1

-- check immunity when the monster is damaged
function checkImmunity(monster,amount,type)
  if type == "fire" and fire_immunity == 1 then
    return false
  elseif type == "ice" and ice_immunity == 1 then
    return false
  elseif type == "shock" and shock_immunity == 1 then
    return false
  elseif type == "poison" and poison_immunity == 1 then
    return false
  end
end

-- alcove scripts to adjust immunity variables and deal damage

That's for the monster immunity part.. Still needing to be added are alcove scripts to adjust the immunities and damage the monster.


Note that with this method every instance of the monster immune_ogre (assuming you spawn more than 1!) will have the exact same immunities... so remove fire immunity and all "immune_ogre"s suddenly become vulnerable to fire!


Regarding the alcove setup I have a couple of questions... can the items be removed from the altars once inserted? If yes, then what happens when they are??
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by undeaddemon »

Well, I would think that it makes more sense that if one item is removed, then the immunities and HPs return, ... ??
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: [HELP] Need Script for Alcove Item to alter Monster stat

Post by Grimwold »

I was thinking it might be tricky to give the HP back to the monster, but it might not be that bad with getHealth() and setHealth()

An alternative, which would be tricky to script, but not impossible, would be to prevent the item being removed from the alcove once placed.


a few more questions then..
#1 will these monsters ever be on different dungeon levels to the alcoves? e.g. specifically when they would take damage from an item being inserted
#2 do you want the monsters to take damage when the immunity is removed or just have their health reduced? The difference would be in how it looked.
Post Reply