effect:getPower Question

Post Reply
Telthir
Posts: 13
Joined: Thu Nov 22, 2012 7:04 am

effect:getPower Question

Post by Telthir » Sat Jun 04, 2016 1:07 am

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.

User avatar
kjLotus
Lead Developer
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: effect:getPower Question

Post by kjLotus » Sat Jun 04, 2016 1:42 am

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)

Telthir
Posts: 13
Joined: Thu Nov 22, 2012 7:04 am

Re: effect:getPower Question

Post by Telthir » Sat Jun 04, 2016 3:30 am

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.

User avatar
kjLotus
Lead Developer
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: effect:getPower Question

Post by kjLotus » Sat Jun 04, 2016 1:45 pm

MOD_ATTP is attack (percent)

Telthir
Posts: 13
Joined: Thu Nov 22, 2012 7:04 am

Re: effect:getPower Question

Post by Telthir » Sat Jun 11, 2016 8:46 am

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;

Post Reply