Page 1 of 1
effect:getPower Question
Posted: Sat Jun 04, 2016 1:07 am
by Telthir
So this is a very newbie question, but I'm learning, so I thought I'd ask the experts. I was looking into customizing a few of the job abilities just to learn more about how it's all handled, and I run across this effect quite a lot. I was curious as to what exactly it did? Does it calculate the strength of an ability based on the job's primary stat, or is there something more to it than that? Sorry if this has been asked before; I ran quite a few searches and dug around in status.lua in hopes of figuring it out for myself, but couldn't find anything about it.
Let's take Warriors Charge for instance:
Code: Select all
function onEffectGain(target,effect)
target:addMod(MOD_TRIPLE_ATTACK, effect:getPower());
target:addMod(MOD_DOUBLE_ATTACK, 100);
end;
How is the MOD_TRIPLE_ATTACK value calculated with effect:getPower()?
Thanks for any and all help.
Re: effect:getPower Question
Posted: Sat Jun 04, 2016 1:42 am
by kjLotus
the power is whatever it was assigned when the effect was added (probably in addStatusEffect, which in this case would be in scripts/globals/abilities/warriors_charge.lua)
Re: effect:getPower Question
Posted: Sat Jun 04, 2016 3:30 am
by Telthir
That makes a lot more sense now, thank you! One last thing. I'm under the impression that I can use player:getStat(MOD_STR) to pull the base strength value from a player. For example, could I use player:getStat(MOD_STR) and store that value in a local variable to be called as an object later to say, increase the MOD_ATTP value of Berserk?
I tried this, and it seems to work in game, but it only raises my attack power value by 9 when my character's strength is 21 (no bonuses from food or gear currently.)
Code: Select all
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
local berserkbonus = player:getStat(MOD_STR)
player:addStatusEffect(EFFECT_BERSERK,berserkbonus,0,180);
return EFFECT_BERSERK;
end;
Code: Select all
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
--Checks the character's strength and uses that value to apply the attack mod.
target:addMod(MOD_DEFP,-25);
target:addMod(MOD_ATTP, effect:getPower());
target:addMod(MOD_ACC,-10);
end;
Thanks again for the help.
Re: effect:getPower Question
Posted: Sat Jun 04, 2016 1:45 pm
by kjLotus
MOD_ATTP is attack (percent)
Re: effect:getPower Question
Posted: Sat Jun 11, 2016 8:46 am
by Telthir
Thanks for all of your help, Lotus. One more thing and I should be able to do everything I'd like with ability adjustments. I'll give a small explanation so you'll know what I'm trying to do, though.
Basically, I want berserk to scale attack power off of a player's strength value, divided by 2 if their main job is warrior. If the player has it as a subjob instead, then I'd like it to do the same, but divide that value by 3. I'm pretty sure this is how it's set up, but I figured I'd ask here first since you're all experts.
globals\abilities\berserk.lua:
Code: Select all
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
local berserkbonus;
if (player:getMainJob() == JOBS.WAR) then
berserkbonus = player:getStat(MOD_STR) / 2;
else
berserkbonus = player:getStat(MOD_STR) / 3;
end
player:addStatusEffect(EFFECT_BERSERK,berserkbonus,0,180);
return EFFECT_BERSERK;
end;
In theory, this could be called by the berserk effect script below without any problems, correct?
globals\effects\berserk.lua:
Code: Select all
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEFP,-35);
target:addMod(MOD_ACC,-10);
target:addMod(MOD_ATTP, effect:getPower());
end;