Page 199 of 396
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 11, 2017 10:24 pm
by zimberzimber
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?
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 11, 2017 11:03 pm
by minmay
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?
Just have code like this in your init.lua before you import any monsters:
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
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 11, 2017 11:21 pm
by zimberzimber
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
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 11, 2017 11:43 pm
by minmay
Then you could do something gross like this:
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
and when you want to use attack:getPierce(), which doesn't exist, use Config.pierceData[attack.go.name][attack:getName()] instead
Re: Ask a simple question, get a simple answer
Posted: Wed Apr 12, 2017 12:19 am
by zimberzimber
oh brother...
Will give it a try
Re: Ask a simple question, get a simple answer
Posted: Wed Apr 12, 2017 2:14 am
by akroma222
minmay 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.
I see I see - Thankyou for explaining/confirming
Isaac 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.
Hahah Isaac that is Fantastic man - Ive been knocking snails down pits for the last 10 mins
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)
Re: Ask a simple question, get a simple answer
Posted: Wed Apr 12, 2017 11:06 pm
by zimberzimber
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?
Re: Ask a simple question, get a simple answer
Posted: Thu Apr 13, 2017 3:23 am
by akroma222
zimberzimber 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)
Im (fairly) sure you can still do that Zimber
So you would be recording the monster name or id in a global table (like Config) from one of these hooks?:
MonsterAttackComponent.onAttack(self)
MonsterAttackComponent.onAttackHit(self, champion)
MonsterAttackComponent.onDealDamage(self, champion, damage)
I think minmays Example should demonstrate its doable:
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)
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?
Did you decide to use the CloneObject script ??
(
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)
Re: Ask a simple question, get a simple answer
Posted: Thu Apr 13, 2017 3:40 am
by minmay
akroma222 wrote:I think this Example (this is minmays work) should demonstrate its doable:
Code: 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
Logging on despite the sudden lack of HTTPS, just to say that this terrible indentation is
not my work.
Here is the original.
Re: Ask a simple question, get a simple answer
Posted: Thu Apr 13, 2017 4:35 am
by akroma222
minmay wrote:akroma222 wrote:I think this Example (this is minmays work) should demonstrate its doable:
Code: 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
Logging on despite the sudden lack of HTTPS, just to say that this terrible indentation is
not my work.
Here is the original.
Your code, I had forgot Id messed up the indents since - sorry
Should have just linked to the page - Fixed now