Page 144 of 396
Re: Ask a simple question, get a simple answer
Posted: Wed Aug 17, 2016 9:26 pm
by Isaac
Strange results:
(Very interested in why...)
Code: Select all
defineTrait{
name = "aura_protection",
uiName = "Aura of Protection",
icon = 96,
description = "Grants the caster's protection bonus to a nearby companion.",
onRecomputeStats = function(champion, level)
if level > 0 then
if champion:isAlive() then
local bonus = champion:getProtection()
for c = 1,4 do
if party.party:getChampion(c):getOrdinal() == champion:getOrdinal() then
party.party:getChampion((c%3)+iff(c~=2,1,-1)):addStatModifier("protection", bonus)
-- The printed results show that the bonus is applied, but if the trait bearer PC is in an earlier [lower numbered] position than the receiver [ie. position #1], then the bonus does not update in the character sheet.
print(party.party:getChampion(c):getName().."("..bonus..")", ">>", party.party:getChampion((c%3)+iff(c~=2,1,-1)):getName().."("..party.party:getChampion((c%3)+iff(c~=2,1,-1)):getProtection()..")")
break
end
end
end
end
end,
}
*This trait could benefit greatly from a drawn gui element on the recipient, but I left out a any dependency on the party hook, just yet.
Re: Ask a simple question, get a simple answer
Posted: Wed Aug 17, 2016 10:13 pm
by AndakRainor
Again, it seems logical in this scenario:
- The game engine recomputes champions stats in the order of their position in the party.
- Doing this for one champion is done this way; clear all previous modifiers, then call all onRecomputeStats functions.
- Champion number i gives a modifier to champion number j, with i < j
- You print immediately the stat of champion number j, and see the effect applied.
- Then comes champion number j turn to be updated, and all previous modifiers are deleted, including the one you just gave.
Re: Ask a simple question, get a simple answer
Posted: Wed Aug 17, 2016 10:25 pm
by Isaac
The quick fix for this is simply to drop the sideways bonus, and have it just be for the champion in front.
A more complicated fix, would be to pass the bonus to a hidden trait held by champion 4; have it check the relative positions of both giver and receiver... and necessarily update who has this trait each time the party order is shuffled.
Re: Ask a simple question, get a simple answer
Posted: Wed Aug 17, 2016 10:46 pm
by zimberzimber
Isaac wrote:The quick fix for this is simply to drop the sideways bonus, and have it just be for the champion in front.
A more complicated fix, would be to pass the bonus to a hidden trait held by champion 4; have it check the relative positions of both giver and receiver... and necessarily update who has this trait each time the party order is shuffled.
The positioning is not the problem, but the stats applying.
Whats wrong with just giving every champion a hidden trait to calculate these extra bonuses? Not just for this trait, but have it aid in creating aura effects.
Like, for example, I have an item that increases regeneration bonuses for the entire party. What it does now, is give them all a hidden trait that gives that bonus. What it can be replaced with, is a trait that has a lot of checkers to see what should apply and what shouldn't.
If champion1 has trait Bulwark then give getarmor *0.5 end
if for i = 1,4 champion has item equipped then give regen bonus end
etc...
Re: Ask a simple question, get a simple answer
Posted: Wed Aug 17, 2016 10:50 pm
by Isaac
Whatever approach best facilitates the effect.
** I wondered if the bonus shouldn't be the caster's evasion; magical nimbleness. This could potentially allow untrained PCs to use heavy armor while the effect was active.
Re: Ask a simple question, get a simple answer
Posted: Wed Aug 17, 2016 11:00 pm
by zimberzimber
Isaac wrote:** I wondered if the bonus shouldn't be the caster's evasion; magical nimbleness. This could potentially allow untrained PCs to use heavy armor while the effect was active.
I don't see how a tank can help an assassin evade better, but I can see how he can help mitigate incoming damage
Re: Ask a simple question, get a simple answer
Posted: Thu Aug 18, 2016 12:23 am
by Isaac
zimberzimber wrote:Isaac wrote:** I wondered if the bonus shouldn't be the caster's evasion; magical nimbleness. This could potentially allow untrained PCs to use heavy armor while the effect was active.
I don't see how a tank can help an assassin evade better, but I can see how he can help mitigate incoming damage
Ah... So it's a fighter's trait; meant to imply them looking out for their companions during the fight.
(For some reason I tested the script out on a mage, and had the absent thought that this was a magical ability; and also I was thinking a mage wouldn't have much of a protection stat.)
**Fighters
can push or pull someone out of harm's way.
(But I don't know if it's worth coding the extra stat bonus.)
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 19, 2016 8:42 pm
by brzrkr
Does anyone have any idea why the editor keeps crashing when I call this function?
Code: Select all
function smotherLantern(monsta)
-- local mummyName = monsta.go.id
-- local lantern = mummyName.."Lantern"
villageMummy1Lantern.gameobject:destroy()
end
Ignore the commented parts for now.
This function is called with a connector when a certain monster dies. "villageMummy1Lantern" is the ID of a wall lantern nearby. The editor crashes whether I use "gameobject" or "go". There are two odd things:
1. Instead of giving me an error in the code and call it a day as it normally does when calling a nil value, the whole damn editor crashes, forcing me to reopen it and set up the interface all over again. Infuriating.
2. Why does it say that "gameobject" or "go" doesn't exist? All entities have one such component, right? And the wall lantern has that same exact ID. How am I supposed to destroy the lantern or disable one of its components when the monster dies, if this is not the correct way? I also tried using disable() on the "light" and "particle" components the lantern has, but the result was still a crash.
3. About the commented part, since the dying monster's ID is villageMummy, I was wondering if I could take his id, append "Lantern" to it in a string (thus creating the lantern's ID), and then use the string variable as if it were the lantern ID itself, to destroy the lantern directly. If not, how can I turn that string into the actual lantern entity?
Thanks for the help. This is driving me crazy.
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 19, 2016 9:02 pm
by Isaac
You are calling from a hook. Errors in the hook functions tend to crash the editor.
* Nothing has a 'gameobject' field; that will crash it.
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 19, 2016 9:45 pm
by brzrkr
Isaac wrote:You are calling from a hook. Errors in the hook functions tend to crash the editor.
* Nothing has a 'gameobject' field; that will crash it.
As I mentioned, I tried using "go" as well, and that results in a crash as well. But as you can see from the commented code, that works quite well for the monster itself. As the scripting reference says, every entity that is in the game world has a gameobject component, or have I misunderstood you?
In any case, how am I supposed to operate on that lantern object if I can't refer to its gameobject or components?