setResistances to remove resistances
-
Emera Nova
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
setResistances to remove resistances
I'd Like to be able to remove a resistance from an enemy mid battle and replace it with another one. So say going from resist to fire and weak against shock to weak against fire and resist to shock.
IS it possible with setResistance? because what ever I just tossed in broke it hard xD monstername.monster:setResistances (fire ~= false) <--- thats what I put in, not really sure what I told it to do tho x]
IS it possible with setResistance? because what ever I just tossed in broke it hard xD monstername.monster:setResistances (fire ~= false) <--- thats what I put in, not really sure what I told it to do tho x]
Re: setResistances to remove resistances
Resistances are a table in which the keys are the damage types (fire, cold, poison, shock, physical, dispel) and the values are "weak" (increased damage, red text), "vulnerable" (increased damage, red text, not sure if it is different from weak), "resist" (reduced damage, normal text), "immune" (no damage, normal text), "absorb" (damage converted to healing, green text). If a field is not present then the monster takes normal damage.
For example, ice guardians have:
Note that dispel damage won't hit the monster in the first place if the monster doesn't have the "elemental" trait.
For example, ice guardians have:
Code: Select all
resistances = {
fire = "weak",
cold = "absorb",
},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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
-
Emera Nova
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: setResistances to remove resistances
so I could put the code
and that would fix the problem?
Code: Select all
setResistances = (
fire = "weak",
cold = "absorb",
),Re: setResistances to remove resistances
No, that syntax won't even compile...setResistances is a function that takes a table (of resistances) as its only parameter.
If you want to replace certain resistances while keeping the rest, you should make a function like this:
Then to do the substitution you mentioned in your original post, you'd make this call:
This will overwrite the monster's fire and shock resistances with weak and resist, respectively, and leave all of its other resistances the same.
If you want to replace certain resistances while keeping the rest, you should make a function like this:
Code: Select all
function changeResistances(monster,newResistances)
local damageTypes = {"fire","cold","shock","poison","physical","dispel"}
local resists = {}
for _,type in ipairs(damageTypes) do
resists[type] = newResistances[type] or monster:getResistance(type)
end
monster:setResistances(resists)
endCode: Select all
changeResistances(monstername.monster,{fire = "weak", shock = "resist"})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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
-
Emera Nova
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: setResistances to remove resistances
Code: Select all
function changeResistances(monster,newResistances)
local damageTypes = {"fire","cold","shock","poison","physical","dispel"}
local resists = {}
for _,type in ipairs(damageTypes) do
resists[type] = newResistances[type] or monster:getResistance(type)
end
monster:setResistances(resists)
endRe: setResistances to remove resistances
No, you call it once and it changes the passed MonsterComponent's resistances. There's nothing to be filled in.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
-
Emera Nova
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: setResistances to remove resistances
How does it know what monster to be assigned to? 
Sorry about all teh questions xD I know literally nothing programming wise so I don't understand it all I just come up with ideas I think should work.
Sorry about all teh questions xD I know literally nothing programming wise so I don't understand it all I just come up with ideas I think should work.
Re: setResistances to remove resistances
The first parameter is the MonsterComponent to give the resistances to.Emera Nova wrote:How does it know what monster to be assigned to?
This is highly unlikely to work, it would be much faster to learn some basic programming concepts first.Emera Nova wrote:Sorry about all teh questions xD I know literally nothing programming wise so I don't understand it all I just come up with ideas I think should work.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
-
Emera Nova
- Posts: 146
- Joined: Wed Jun 11, 2014 1:31 am
Re: setResistances to remove resistances
I put this in as a script that gets trigged by a pressure plate and when I stepped on the pressureplate it made my game go nonresponsive o-o which is different from it just ending the play test and saying something is broken.
Code: Select all
function changeResistances(mummy_2,newResistances)
local damageTypes = {"fire","cold","shock","poison","physical","dispel"}
local resists = {}
for _,type in ipairs({fire = "resist", shock = "shock"}) do
resists[fire] = newResistances[fire] or monster:getResistance(fire)
end
monster:setResistances(fire)
end
function resist()
changeResistances(mummy_2.monster,{fire = "resist", shock = "shock"})
endRe: setResistances to remove resistances
That's because you broke the script in about 500 different ways. Why didn't you just copy/paste it?
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.