FORMULA FOR RAISING ATK BASED ON HP LOST?

Posts

Pages: 1
KrimsonKatt
Gamedev by sunlight, magical girl by moonlight
3326
So in my game there is a state called Boiling Blood that increases damage based on how little HP you have remaining. Due to me using Visustella I only need to enter a specific formula that will determine the rate of ATK raised. Problem is I suck at math and can't figure out what formula to use! This is what I have so far:

<JS ATK Rate: 1 + (2 * (gameActors.user.hp / gameActors.user.mhp))

This seems fine on paper until you realize that this formula actually does the opposite of what I want. raising atk based on how high the HP is. Does anyone know a way I can reverse this formula so it raises attack based on how low the HP is rather than how high? Thanks.
KrimsonKatt
Gamedev by sunlight, magical girl by moonlight
3326
I think I may have figured it out. I think by using the - instead of a * between 2 and the first parameter I could get the result I wanted. So the new formula would be this:

<JS ATK Are: 1 + (2 - gameActors.user.hp / gameActors.user.mhp)>

Is this correct? The only thing that may be wrong is the coding for the params since in the script call list it never tells you what the script call is for determining the param of the user instead of a particular actor.
The second formula will return this:

ATK Rate = 1 + (2 - (a value between 0 and 1.) )

Assuming your character had 27/100 HP:

ATK Rate = 1 + (2 - 0.27)
ATK Rate = 1 + 1.73
ATK Rate = 2.73. So you'll have 273% ATK if you're at 27% health.

Another scenario, 95/100 HP:

ATK Rate = 1 + (2 - 0.95)
ATK Rate = 1 + 1.05
ATK Rate = 2.05, so you'll have 205% ATK if you're at 95% health.

Basically, it's almost there. IF you want the ATK range to go from 200 to 300% it's perfect. You probably want it to go from 100 to 200, though, which would mean you'd need to change that 2 to a 1.



EDIT: Actually, you probably just want to take off that 1+ part.

<JS ATK Rate: 2 - gameActors.user.hp / gameActors.user.mhp>

This way the rate will be < 200% - (0%~100%) >, meaning it'll always return between 100% and 200% attack depending on HP lost.
Marrend
Guardian of the Description Thread
21781
The default contents of Game_Actors does not contain a "user" variable that keeps track of skill-use. That might be under Game_Party...

Game_Party.prototype.targetActor = function() {
    let actor = $gameActors.actor(this._targetActorId);
    if (!this.members().includes(actor)) {
        actor = this.members()[0];
    }
    return actor;
};

Game_Party.prototype.setTargetActor = function(actor) {
    this._targetActorId = actor.actorId();
};

...to some degree? I can't really say for sure. An instance of Game_Action...

Game_Action.prototype.setSubject = function(subject) {
    if (subject.isActor()) {
        this._subjectActorId = subject.actorId();
        this._subjectEnemyIndex = -1;
    } else {
        this._subjectEnemyIndex = subject.index();
        this._subjectActorId = 0;
    }
};

Game_Action.prototype.subject = function() {
    if (this._subjectActorId > 0) {
        return $gameActors.actor(this._subjectActorId);
    } else {
        return $gameTroop.members()[this._subjectEnemyIndex];
    }
};

...definitely keeps track of that, but, I'm not sure how that data can be accessed to be of use.


*Edit: This thought just occurred to me, but, can you use the a/b delineators that indicate user and subject from the damage formula? So, for example, if I were to take JosephSeraph's latest suggestion, it might be something like...

<JS ATK Rate: 2 - a.hp / a.mhp>

...this?
Ah, my bad, I assumed the syntax was right T.T
But indeed, you can in fact use a.hp or b.mat for the formulae! it is in fact the suggested way to go iirc. So your last edit is probably the way to go!
KrimsonKatt
Gamedev by sunlight, magical girl by moonlight
3326
Thanks for all your help. I didn't know you could use damage formula equations in script calls. You learn something new every day!

As for the final formula, I think I got it as this:

<JS ATK Rate: 2 - a.hp / a.mhp>


Thanks for all the help guys. Whoever is in change can close the thread now.

Edit: Never mind, the formula is actually this:

<JS ATK Rate: 2 - user.hp / user.mhp>

Sorry for the error lol good thing I caught it before the thread was locked.
Pages: 1