azureXtwilight wrote:I am wondering if I can use the code for temporary increasing own skill to make a skill that decrease the enemy's skill? Which parts should be modified for it?
The same kind of code should work fine for any kind of stat modification on anyone, really! You'll need to:
- modify the targeting data for the skill so that it targets enemies instead of friendlies
- change the effect so that the methods which modify the stat reduce instead of increase the stat
The main thing you need to bear in mind is the same as for positive stat modification: simply that whatever modification you do in OnRetrieveStat - which is the change that effect makes on the fighter's stat - needs to be absolutely reversed in InSetStat, to make sure that anything else that modifies a fighter's stats while the effect is in place acts in an appropriate manner. So if you're making a "half health plus a small extra" effect which is applied to enemies, then perhaps OnRetrieveStat does this:
Code: Select all
if name == 'Health':
return (value / 2) + 10;
else:
return value
in which case OnSetStat needs to do this:
Code: Select all
if name == 'Health':
return int((value - 10) * 2)
else:
return value
... because you also need to perform all the operations in the opposite order. Like this, if a fighter's on 100 health then OnRetrieveStat will report his health as (100/2)+10 = 60, and then if he gets attacked for 15 damage and his Health is set to (60 - 15) = 45, his actual base health (currently 100) will be set to (45 - 10) * 2 = 70. Then when displayed through OnRetrieveStat, (70 / 2) + 10 = 45, so it does indeed look like he's losing 15 health.
The difference between his original base health of 100 and his new base health of 70 is 30, which is twice the damage of 15 - correct, because making someone's health half what it normally is should be the same as making all damage twice what it normally is, in terms of how much damage it takes to kill them!
If the OnSetStat calculation had been int((value * 2) - 10), the other way around, then the end result would have been (45 * 2) - 10 = 80, which would then have been displayed through OnRetrieveStat as (80 / 2) + 10 = 50... so he would have been shown as only losing 10 health for a 15-damage attack!
(You'll probably also want to give those classes - the Skill and the Effect - completely new names, as well as changing the name the effect uses to apply itself to the fighter, of course; so they don't overwrite the classes you've previously defined for the stat-raising effect!)