OK.. if it is easier to lock the item to the alcove, so that once the HP, and immunity are removed, they cant be added back, then that isn't any type of showstopper, just if its possible to return it, it makes more sense.
Monster will only be on 1 level, there is only 1 of him, he's is sorta a boss type fight, but not a final fight.
Damage or reduction would be fine - chances are the players will not be looking at him when they place the items (most likely they would be avoiding him i would think...
[HELP] Need Script for Alcove Item to alter Monster stats
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: [HELP] Need Script for Alcove Item to alter Monster stat
it's actually not easier to lock the item... just wondered if that might make thematic sense.
OK so this should be the finished script entity immunity_script, I've not had chance to test it myself yet, so there may be a few bugs to work out. don't forget you'll need the monsters.lua entry from my earlier post.
You will need to change the 5 entries at the beginning to refer to the names of your items and monster.
you will also need to link each alcove to its appropriate function in this script entity.. e.g. fire_alcove to the fireAlcove function.
note I put in a failsafe that if the monsters health is ever less than 250 when it should lose 250, it instead sets health to 1, so the party can still have the honour of killing it!
Hope this all makes sense (and works as I intend).. I will give it a try myself when I get chance.
EDIT - tested and fixed a bug... seems ok with fire immunity.. and very easy kill once all 4 items in the alcoves!
OK so this should be the finished script entity immunity_script, I've not had chance to test it myself yet, so there may be a few bugs to work out. don't forget you'll need the monsters.lua entry from my earlier post.
You will need to change the 5 entries at the beginning to refer to the names of your items and monster.
Code: Select all
-- set variables for the immunity specific items and the immune monster
fire_item = "FIRE_ORB"
ice_item = "ICE_ORB"
shock_item = "SHOCK_ORB"
poison_item = "POISON_ORB"
monster_name = "immune_ogre"
-- set up the immunity variables
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 == "cold" 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
-- function to check if alcove contains item.
function containsItem(entity, item)
for i in entity:containedItems() do
if i.name == item then
return true
end
end
-- if we get here the item was not found
return false
end
-- function for fire alcove
function fireAlcove(trigger)
if containsItem(trigger, fire_item) and fire_immunity == 1 then
fire_immunity = 0
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = 1
if curr_health > 250 then
new_health = curr_health - 250
end
i:setHealth(new_health)
end
end
end
if not containsItem(trigger, fire_item) and fire_immunity == 0 then
fire_immunity = 1
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = curr_health + 250
i:setHealth(new_health)
end
end
end
end
-- function for ice alcove
function iceAlcove(trigger)
if containsItem(trigger, ice_item) and ice_immunity == 1 then
ice_immunity = 0
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = 1
if curr_health > 250 then
new_health = curr_health - 250
end
i:setHealth(new_health)
end
end
end
if not containsItem(trigger, ice_item) and ice_immunity == 0 then
ice_immunity = 1
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = curr_health + 250
i:setHealth(new_health)
end
end
end
end
-- function for shock alcove
function shockAlcove(trigger)
if containsItem(trigger, shock_item) and shock_immunity == 1 then
shock_immunity = 0
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = 1
if curr_health > 250 then
new_health = curr_health - 250
end
i:setHealth(new_health)
end
end
end
if not containsItem(trigger, shock_item) and shock_immunity == 0 then
shock_immunity = 1
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = curr_health + 250
i:setHealth(new_health)
end
end
end
end
-- function for poison alcove
function poisonAlcove(trigger)
if containsItem(trigger, poison_item) and poison_immunity == 1 then
poison_immunity = 0
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = 1
if curr_health > 250 then
new_health = curr_health - 250
end
i:setHealth(new_health)
end
end
end
if not containsItem(trigger, poison_item) and poison_immunity == 0 then
poison_immunity = 1
for i in allEntities(trigger.level) do
if i.name == monster_name then
local curr_health = i:getHealth()
local new_health = curr_health + 250
i:setHealth(new_health)
end
end
end
end
note I put in a failsafe that if the monsters health is ever less than 250 when it should lose 250, it instead sets health to 1, so the party can still have the honour of killing it!
Hope this all makes sense (and works as I intend).. I will give it a try myself when I get chance.
EDIT - tested and fixed a bug... seems ok with fire immunity.. and very easy kill once all 4 items in the alcoves!
Last edited by Grimwold on Thu Jan 03, 2013 6:18 pm, edited 1 time in total.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: [HELP] Need Script for Alcove Item to alter Monster stat
OK finally I think I am done testing and that this script does what is intended... please give it a try and if you find any odd behaviour let me know.
I tested with an immune ogre and simply used 4 appropriate scrolls as my items.
I tested with an immune ogre and simply used 4 appropriate scrolls as my items.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: [HELP] Need Script for Alcove Item to alter Monster stat
So.. I need to define what each Alcoves "purpose" is to the player, only linking it to one of the 4 functions, correct?you will also need to link each alcove to its appropriate function in this script entity.. e.g. fire_alcove to the fireAlcove function.
btw... Thank You!
amazing....
Re: [HELP] Need Script for Alcove Item to alter Monster stat
Yes each alcove will be for a specific immunity... you need some way to communicate that the player... and you will need to create the connections in the editor.undeaddemon wrote:So.. I need to define what each Alcoves "purpose" is to the player, only linking it to one of the 4 functions, correct?you will also need to link each alcove to its appropriate function in this script entity.. e.g. fire_alcove to the fireAlcove function.
Also, when you create the connections from the alcoves to the script.. make sure you tick "activate always" and change the connection type to "any" instead of just "activate"... so it will check when the item is removed.
my pleasure.undeaddemon wrote: btw... Thank You!
amazing....
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
- undeaddemon
- Posts: 157
- Joined: Fri Mar 02, 2012 3:38 pm
Re: [HELP] Need Script for Alcove Item to alter Monster stat
Yeah... sooooo awesome... soooo choice.
That works great.... really.. thanks again ... now... If I can just get this LoG Framework / EXSP working... I have some "wandering lights" the champions will have to avoid whilst performing this, as well !!
That works great.... really.. thanks again ... now... If I can just get this LoG Framework / EXSP working... I have some "wandering lights" the champions will have to avoid whilst performing this, as well !!
Re: [HELP] Need Script for Alcove Item to alter Monster stat
glad you got this worked out! A lot depends on your intentions, such as how you want to explain or describe the logic of what is happening, story-wise.
Finished Dungeons - complete mods to play
