The Mugen Fighters Guild

Help => M.U.G.E.N Development Help => Code Library => Topic started by: Jesuszilla on August 15, 2014, 07:52:02 pm

Title: Making up for the broken DefenceMulSet SCTRL
Post by: Jesuszilla on August 15, 2014, 07:52:02 pm
As you may or may not know, DefenceMulSet doesn't work for the first hit. That makes the SCTRL effectively broken because you don't get the results you expect.

Fortunately, there's a way to get the same results.

And now for an example code snippet that does the actual work. This adds 25% more damage to any taken.
Code:
[State -2, DefenseMulSet]
type = LifeAdd
triggerall = Alive && MoveType = H
trigger1 = (FVar(8)-life)>0
value = ifElse((FVar(8)-life)<life,-floor((FVar(8)-life)/4),0)

As you can see, you will need one variable to keep track of life like so:

Code:
[State -2, Combo]
type = VarSet
trigger1 = 1
fvar(8) = life
ignorehitpause = 1

It doesn't have to be a float variable; int should work. And yes, IT MUST GO BELOW THE LIFEADD.

But you probably want to use it by plugging in the same value you'd use for DefenceMulSet, right? Then use this:

Code:
[State -2, DefenseMulSet]
type = LifeAdd
triggerall = Alive && MoveType = H
trigger1 = (FVar(8) - life)>0
value = floor(([insert value here] - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))

So to increase damage by 25%, you'd do this:
Code:
[State -2, DefenseMulSet]
type = LifeAdd
triggerall = Alive && MoveType = H
trigger1 = (FVar(8) - life)>0
value = floor((1.25 - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))

And to reduce damage by half, you'd to this:
Code:
[State -2, DefenseMulSet]
type = LifeAdd
triggerall = Alive && MoveType = H
trigger1 = (FVar(8) - life)>0
value = floor((0.5 - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))
Title: Re: Making up for the broken DefenceMulSet SCTRL
Post by: Alex Sinigaglia on August 15, 2014, 09:25:07 pm
DefenceMulSet works from the second hit (the first hit does the normal damage, the second, third, fourth etc. hits will be conditioned from the DefenceMulSet), if you put a value that is less than 1. It doesn't work as intended (it should start instantly), that's for sure, but then it works. I've seen a lot of people used to describe DefenceMulSet as something that doesn't work saying it's broken, which is not really correct.

I tried to put a code that makes it work everytime (in state -2, trigger1 equal to 1, value less than 1, like 0.5), just to test it.
I put the code in KFM and tried doing the crouch strong punch against himself: without the DefenceMulSet it deals 73, with DefenceMulSet it deals 55.
Calling it DefenceMulSet was wrong since the code doesn't multiply but it divides for the value you put to it.
So if you put 0.5, your defence is twice the normal value, if you put, let's say, 20, it divides 100 (normal/default value in the data).
100/20 = 5
The defence value becomes 5 (for the second hit).
If you put 0,
100/0 = ∞ , let's say it is infinite, normally that operation can't be done, but you know what I mean (no damage from the second hit)

In any case, I just wanted to put this here.

I'm sure your code is much more flexible than how the DefenceMulSet is now.
Title: Re: Making up for the broken DefenceMulSet SCTRL
Post by: Jesuszilla on August 16, 2014, 02:20:18 am
I updated the first post. You have to put the lifeadd BEFORE the varset.

Also, you're incorrect. You must have replaced the wrong value, or used the wrong code snippet, because I get the expected behavior when when I plug in values for KFM vs. KFM.

For .5, I get 12 for LP, just as I should. If I plug in .2, I get 5, just as I should.


I don't get why you're bringing up division by 0 when that's not happening in this:
Code:
[State -2, DefenseMulSet]
type = LifeAdd
triggerall = Alive && MoveType = H
trigger1 = (FVar(8) - life)>0
value = floor(([insert value here] - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))

... at all.

Read.
Title: Re: Making up for the broken DefenceMulSet SCTRL
Post by: Alex Sinigaglia on August 16, 2014, 02:30:39 pm
Spoiler, click to toggle visibilty
...
And when I finished making this post I read the first line of the first post. >_<
Oh well, at least I brought up some examples of the effectiveness of the original DMS. If you want to see them click the spoiler.

Everyone, use JZ's code!  :)