Ask a simple question, get a simple answer
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
OK so as the lazy fuck I am, I really don't feel like redefening every monster attack component, so I went with modifying base_monster with a new 'Null' component, that calls a function through onInit, that iterates through every component the monster has, and do stuff from there.
Now I got two problems:
1) There doesn't seem to be a getPierce/setPierce
2) Monsters that are not placed on the map don't seem to call that function (thing like the spawn function)
Any help with those?
Now I got two problems:
1) There doesn't seem to be a getPierce/setPierce
2) Monsters that are not placed on the map don't seem to call that function (thing like the spawn function)
Any help with those?
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
Just have code like this in your init.lua before you import any monsters:zimberzimber wrote:OK so as the lazy fuck I am, I really don't feel like redefening every monster attack component, so I went with modifying base_monster with a new 'Null' component, that calls a function through onInit, that iterates through every component the monster has, and do stuff from there.
Now I got two problems:
1) There doesn't seem to be a getPierce/setPierce
2) Monsters that are not placed on the map don't seem to call that function (thing like the spawn function)
Any help with those?
Code: Select all
local orig_defineObject = defineObject
defineObject = function(def)
if def.components then
for i,c in ipairs(def.components) do
if c.class == "MonsterAttack" or c.class == "CrowernAttack" then
c.pierce = math.huge
end
end
end
orig_defineObject(def)
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
What I'm trying to do though is to set their pierce to 1000 + actual pierce so that pierce could be used in my damage filter, so I have to get their pierce later anyways
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
Then you could do something gross like this:
and when you want to use attack:getPierce(), which doesn't exist, use Config.pierceData[attack.go.name][attack:getName()] instead
Code: Select all
Config.pierceData = {}
local orig_defineObject = defineObject
defineObject = function(def)
if def.components then
for i,c in ipairs(def.components) do
if c.class == "MonsterAttack" or c.class == "CrowernAttack" then
if not Config.pierceData[def.name] then Config.pierceData[def.name] = {} end
Config.pierceData[def.name][c.name or string.lower(c.class)] = c.pierce
c.pierce = c.pierce+1000
end
end
end
orig_defineObject(def)
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
oh brother...
Will give it a try
Will give it a try
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
I see I see - Thankyou for explaining/confirmingminmay wrote:That was the save editor, which includes a button to remove nonstandard traits from the party to prevent this crash. But that's a tool for users to use, you can't integrate it in your mod obviously. There's no practical way to get rid of all the nonstandard traits from within your mod itself, because you don't know what the names of those traits are.
Hahah Isaac that is Fantastic man - Ive been knocking snails down pits for the last 10 minsIsaac wrote:Here is an experimental charge attack for the party; implemented as a magical "Horn of Berserker Charge'.
*It's not necessarily balanced for play, but it does have some usage checks (and experimental limitations). As-is it may well allow the breaking puzzles that can be broken by a faster than expected party —provided they don't need to change direction during the charge.
Thats pretty much how I had envisioned it coded up - didnt think to use a Condition though (nice idea!)
And yeah - only 1 Berserk Horn to avoid abuse
Perhaps Ill add a check for monsters in front of the party so that folks dont break puzzles with it too easily (limiting it to when a monster is 1 or 2 squares in front)
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
Hah, so apparently I'll have to redefine every monster that uses melee attacks after all /̵͇̿̿/’̿’̿ ̿ ̿̿ (Gotta index the monster when it melee hits a champion in a global table for future interactions)
So question - Would redefining the whole definition instead of defining an object with the same name and using the previous (original) definition as a base class have a significant difference?
So question - Would redefining the whole definition instead of defining an object with the same name and using the previous (original) definition as a base class have a significant difference?
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
Re: Ask a simple question, get a simple answer
Im (fairly) sure you can still do that Zimberzimberzimber wrote:Hah, so apparently I'll have to redefine every monster that uses melee attacks after all /̵͇̿̿/’̿’̿ ̿ ̿̿ (Gotta index the monster when it melee hits a champion in a global table for future interactions)
So you would be recording the monster name or id in a global table (like Config) from one of these hooks?:
SpoilerShow
MonsterAttackComponent.onAttack(self)
MonsterAttackComponent.onAttackHit(self, champion)
MonsterAttackComponent.onDealDamage(self, champion, damage)
MonsterAttackComponent.onAttackHit(self, champion)
MonsterAttackComponent.onDealDamage(self, champion, damage)
EDIT viewtopic.php?f=22&t=9863&p=108716#p108716
Sorry if Im not spot on with these shadow functions, ive been keeping examples but haven't started making my own just yet.
I will be needing to do so as I plan to use this method to set up and bunch of checks at various times through most monsters' monsterAttacks
Im thinking this is a good way to simplify and cut down on all the extra code...
(my checks will be to determine probability of champs counter striking various monster attacks)
Did you decide to use the CloneObject script ??zimberzimber wrote:So question - Would redefining the whole definition instead of defining an object with the same name and using the previous (original) definition as a base class have a significant difference?
(viewtopic.php?f=22&t=7951&p=110184&hili ... ct#p110184)
Ive been using to make templates for each item type
(although Ive found that if your base definition has a traits Table - those traits will not be merged with a new definitions trait Table - have to include all the traits in your new def's table)
Last edited by akroma222 on Thu Apr 13, 2017 4:31 am, edited 1 time in total.
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Ask a simple question, get a simple answer
Logging on despite the sudden lack of HTTPS, just to say that this terrible indentation is not my work. Here is the original.akroma222 wrote:I think this Example (this is minmays work) should demonstrate its doable:
SpoilerShowCode: Select all
local awardXp = function(self) local rval = Config.monsterOnDieMap[self.go.name] and Config.monsterOnDieMap[self.go.name](self) or true if rval then local xp = Config.monsterExpMap[self.go.name] if xp then xp = math.floor(xp * 1.1^(self:getLevel() - 1)) for i=1,4 do if party.party:getChampion(i):getEnabled() and not party.party:getChampion(i):hasTrait("farmer") then party.party:getChampion(i):gainExp(xp) end end self:showDamageText(string.format("+%d xp",xp),"0xffff88") end -- oh, while we're at it, fix the phantom flames bug if self.go.burning then self.go:removeComponent("burning") end end return rval end --------------------------------------this method makes MonsterComponent:getExp() useless. local orig_defineObject = defineObject Config.monsterExpMap = {} Config.monsterOnDieMap = {} -------------------------------------- defineObject = function(def) if def.components then for _,c in ipairs(def.components) do if c.class == "Monster" then Config.monsterExpMap[def.name] = c.exp Config.monsterOnDieMap[def.name] = c.onDie c.onDie = awardXp c.exp = false -- removes the +xp text end end end orig_defineObject(def) 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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Ask a simple question, get a simple answer
Your code, I had forgot Id messed up the indents since - sorryminmay wrote:Logging on despite the sudden lack of HTTPS, just to say that this terrible indentation is not my work. Here is the original.akroma222 wrote:I think this Example (this is minmays work) should demonstrate its doable:
SpoilerShowCode: Select all
local awardXp = function(self) local rval = Config.monsterOnDieMap[self.go.name] and Config.monsterOnDieMap[self.go.name](self) or true if rval then local xp = Config.monsterExpMap[self.go.name] if xp then xp = math.floor(xp * 1.1^(self:getLevel() - 1)) for i=1,4 do if party.party:getChampion(i):getEnabled() and not party.party:getChampion(i):hasTrait("farmer") then party.party:getChampion(i):gainExp(xp) end end self:showDamageText(string.format("+%d xp",xp),"0xffff88") end -- oh, while we're at it, fix the phantom flames bug if self.go.burning then self.go:removeComponent("burning") end end return rval end --------------------------------------this method makes MonsterComponent:getExp() useless. local orig_defineObject = defineObject Config.monsterExpMap = {} Config.monsterOnDieMap = {} -------------------------------------- defineObject = function(def) if def.components then for _,c in ipairs(def.components) do if c.class == "Monster" then Config.monsterExpMap[def.name] = c.exp Config.monsterOnDieMap[def.name] = c.onDie c.onDie = awardXp c.exp = false -- removes the +xp text end end end orig_defineObject(def) end
Should have just linked to the page - Fixed now
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)