Golden Sun Hacking Community

General Hacking => Assets & Discussion => Coding => Topic started by: jjppof on 21, May, 2014, 04:08:08 PM

Title: Elemental Weapons
Post by: jjppof on 21, May, 2014, 04:08:08 PM
That weapons like elven rapier, fire brand, gaia blade, sylph rapier... these elemental weapons... how it works?
Title: Re: Elemental Weapons
Post by: leaf on 21, May, 2014, 04:30:31 PM
They treat your basic attack as being an EPA of their given element (uses same formula as say... ragnarok or an unleash), but with a 1.0 multiplier and +0 added damage.

edit: Here's a good source for battle mechanics: http://www.gamefaqs.com/gba/561356-golden-sun-the-lost-age/faqs/22880
Title: Re: Elemental Weapons
Post by: jjppof on 21, May, 2014, 10:37:45 PM
Quote from: leaf on 21, May, 2014, 04:30:31 PM
They treat your basic attack as being an EPA of their given element (uses same formula as say... ragnarok or an unleash), but with a 1.0 multiplier and +0 added damage.

edit: Here's a good source for battle mechanics: http://www.gamefaqs.com/gba/561356-golden-sun-the-lost-age/faqs/22880

Thank you... I'm gonna read this to implement elemental weapons.

-------------EDIT------------------------

Just to see whether It's right:

A gaia blade normal attack formula:

((Attack - Defense) / 2 + bonus damage) * (1 + (Caster Venus Power - Taker Venus Resistance) / 400)
bonus damage = 0
Title: Re: Elemental Weapons
Post by: leaf on 22, May, 2014, 01:04:28 AM
Yep. More accurately, it's

([([(Attack - Defense) / 2] * multiplier bonus) + add bonus] * [1 + (Attacker Venus Power - Defender Venus Resistance) / 400]) + rand(0,3)
multiplier bonus = 1
add bonus = 0

You just forgot the multiplier bonus (which is still just 1, granted, but it's important if you plan on reusing the formula for all EPAs) and the rand(0,3).

Gaia blade normal attack: mult = 1, add = 0
Gaia blade crit (not unleash): mult = 1.25, add = some voodoo based on enemy level; you can check the document I linked for details
Gaia blade unleash: mult = 1, add = 70
Flint unleash: mult = 1.6, add = 0
Raganarok psynergy: mult = 1, add = 35
etc.

I'm not sure if the way crits truly work is actually documented anywhere (as in, how it calculates when an attack hits "critically" instead of doing an unleash). Sala or teawater might be able to give you some insight into that.
Title: Re: Elemental Weapons
Post by: Daddy Poi's Oily Gorillas on 23, May, 2014, 02:45:41 PM
From what I'm seeing in the code, critical damage looks like this:

if 0
No critical hit.

if 1
Critical Hits:
    Damage = [Base Damage * 1.25] + [Target's Level / 5] + 6

if 2
Critical Hits:
    Damage = [Base Damage * 1.5] + [Target's Level / 5] + 6


I'm still looking at the chance that a critical attack would occur, but I believe I have the general area to research, and it does make use of the random number generator.

081244DC = When "1" is used.
08124624 = When "2" is used.

It's quite much to study.

Looks like ability effects 36-40 might be used for one part. The *1.5 crit (Labeled as "?" in the editor.) So time to dive in!
36 = x1.5 dmg (1/64 chance)
37 = x1.5 dmg (1/32 chance)
38 = x1.5 dmg (1/16 chance)
39 = x1.5 dmg (1/8 chance)
40 = x1.5 dmg (1/4 chance)
41 = x2 dmg (32/256 chance)
42 = x2 dmg (64/256 chance)
43 = x3 dmg (32/256 chance)
44 = x3 dmg (64/256 chance)

65 = x2 dmg (153/256 chance)

68 = x3 dmg (153/256 chance)


89 = x3 dmg (128/256 chance), x2 dmg (51/256 chance), x1 dmg (77/256 chance)

Some numbers may or may not be off by 1/256... Since one may need to check the branching to know for sure. (Ex: Difference between > and >=)

(I'll have to see the rest of the formula to know if these are used by themselves or not.)
Title: Re: Elemental Weapons
Post by: jjppof on 23, May, 2014, 03:54:54 PM
An EPA weapon, like gaia blade, has a elemental critical (if this really exist), not unleash, or it uses the normal critical formula?

Look this snippet from goldensunwiki.net/Critical:
"Criticals are not aligned with an element, and have no additional effects besides the extra damage."

And...
From this formula:

final damage = ((base damage * 1.25) + (target's level / 5) + 6)
base damage = (atk - def)/2, right?

Teawater, are you saying that criticals aren't always with this 1.25, could be 1.5 but you don't know when it happens? I didnt understand the if 0, if 1 and if 2.
Title: Re: Elemental Weapons
Post by: Aile~♥ on 23, May, 2014, 04:18:50 PM
Criticals with an elemental weapon uses whatever element the weapon has assigned. For example, the Sylph Rapier's normal attacks are Wind-aligned, so its critical hits are also Wind-aligned. You can observe this effect in-game by wielding the Sylph Rapier and scoring a critical on something like, for example, a Seabird. The text will display "Seabird1 takes XX damage!!!" with triple exclamation marks, just as if using an elemental ability the foe is weak to.

And yes, what Teawater is saying is that sometimes criticals use 1.25x damage, and other times they use 1.5x damage, and he has no idea what triggers this difference. It might be weapon-dependent, or there might be two different kinds of critical hits.

It's also rather interesting that criticals appear to have set effect rates like that, instead of being calculated in a manner similar to unleash rate. Does this mean that "increases criticals" doesn't actually increase critical rate, it ONLY increases unleash rate? Or am I missing something here?
Title: Re: Elemental Weapons
Post by: jjppof on 23, May, 2014, 04:30:41 PM
Quote from: JamietheFlameUser on 23, May, 2014, 04:18:50 PM
Criticals with an elemental weapon uses whatever element the weapon has assigned. For example, the Sylph Rapier's normal attacks are Wind-aligned, so its critical hits are also Wind-aligned. You can observe this effect in-game by wielding the Sylph Rapier and scoring a critical on something like, for example, a Seabird. The text will display "Seabird1 takes XX damage!!!" with triple exclamation marks, just as if using an elemental ability the foe is weak to.

How the final formula stays?

Then GS wiki is wrong about saying that criticals are not aligned to an element?
Title: Re: Elemental Weapons
Post by: leaf on 23, May, 2014, 05:32:27 PM
It's not wrong but it's not fully accurate, either. Most weapon's basic attacks are null element, even if they have an elemental unleash. So, most weapon's crits are also null element. Gaia blade is an exception to the rule, since its basic attack is of a non-null element. Perhaps a more accurate way to phrase the rule then is "The critical of a weapon has the same element as that weapon's basic attack (usually no element)."
Title: Re: Elemental Weapons
Post by: Daddy Poi's Oily Gorillas on 24, May, 2014, 12:36:13 PM
Small update!

x1.25 applies to ability 1.

x1.5 applies only to the 5 ability effects. (Interesting enough.)
36 = x1.5 dmg (1/64 chance)
37 = x1.5 dmg (1/32 chance)
38 = x1.5 dmg (1/16 chance)
39 = x1.5 dmg (1/8 chance)
40 = x1.5 dmg (1/4 chance)

So yeah, seeing as those are labeled"?", these may be unused, which may explain one reason why x1.5 may not have ever been documented?


@Attack:
If you have delusion, this check is made: If rand(0,255) <= 152, you'll miss. (aka: Multiplier thingy set to 0)
There is another check made regardless: 1/32 chance of missing.


As for Criticals...
-First check: 1/32 chance of a critical hit.
-Second check: ((Adds up Increases Criticals values from equipped items) << 16) / 200 > rand(0x0, 0xFFFF)

So what I recommend you do for Crits, is the 1/32 check, and then Increases Criticals values for equipped items. (Without the <<16 and /200 part, since you can probably base you numbers from 0x0 to 0xFFFF directly.)
Title: Re: Elemental Weapons
Post by: leaf on 24, May, 2014, 02:21:40 PM
So would it be accurate to say that the first check is for the typical "critical," while the second check is for an unleash (which then becomes a standard crit if the weapon doesn't have one)? And if that's the case, does the second check override the first? E.g. first check runs and is a success, second check runs and is also a success. Or does the second check not run at all if the first is a success?
Title: Re: Elemental Weapons
Post by: Aile~♥ on 24, May, 2014, 03:10:25 PM
I dunno if it's that simple. I've seen weapons with an unleash appear to land more criticals if you have "Increases Criticals" effects active. If, for example, the weapon has by default a 5% unleash rate, and you have 30% worth of "Increases Criticals" effects, you're still going to land criticals fairly often in addition to unleashes.

I wouldn't be surprised if x1.5 criticals are used for regular attacks made by certain foes. It's also possible that some weapons may have a hardcoded override to use those ability effects instead. (Nobody would be likely to notice, especially if the weapons in question are early-game weapons or also have an unleash rate.)
Title: Re: Elemental Weapons
Post by: Daddy Poi's Oily Gorillas on 24, May, 2014, 03:56:51 PM
@leaf:Whoops. I forgot to explain that bit.

If first check is a success, the Critical Hit is applied.
If first check is not a success, the second check is done.

Both checks will do the same thing by setting the same RAM value to 1.

I didn't see the Unleash Rate used in the above Critical Hits study... however, I did just do a quick look-up on some  Unleash stuff...

When looking up unleashes... at least the part near the "lets out a howl" stuff... I find there's another part where Increased Criticals is calculated... unlike what I studied with Critical Hits, this one divides by 100 instead of 200.

((Unleash Rate + Adds up Increases Criticals values from equipped items) << 16) / 100 > rand(0x0, 0xFFFF)


@Jamie: From what I have seen in the code, this is as much as I know of, so far... I could be missing other things... but it just takes so long to study and verify every code trail. (And with so much to study, there may even be room for error. I try to be careful, though.)

And your hard-code idea sounds plausible...  but not sure yet, until I see an example in the code where they are done explicitly with ability effects.
Title: Re: Elemental Weapons
Post by: leaf on 24, May, 2014, 04:20:59 PM
Oh, interesting. So then, does that mean a "+12% increased criticals" effect is actually only +6% in terms of getting a true crit?

There's also still the matter of which properties win out over other ones. For instance:
- Unleash
- Crit
- Miss

Which of these takes priority over the others? Intuitively, it seems unleashes should take priority over crits, but where do misses fit in to all this?
Title: Re: Elemental Weapons
Post by: Aile~♥ on 24, May, 2014, 09:28:45 PM
Another thing I'm curious about is an unused Ability Effect that was mentioned a long time ago.

I don't remember what number it was, but when the ability targets a combatant the following text appears:

"[target] rises to the challenge!"

I'm wondering if perhaps this ability effect changes the target's 1/32 critical (the first check) to use one of the ability effects from 36 to 40. As I recall, whoever brought that effect up mentioned that there was some code that they didn't understand what it did.
Title: Re: Elemental Weapons
Post by: jjppof on 25, May, 2014, 05:58:26 AM
So, to crit, first I have to do 1/32 check. If It's applied, the crit is released without any equipment boost. If it isn't applied, a second check is done with 1/32 chance again, but now, the crit is boosted if there is equipments that can do it.

If first check is applied: ((base damage * 1.25) + (target's level / 5) + 6)
If second check is applied: ((base damage * 1.25) + (target's level / 5) + 6) * (equipBoost(%) + 100%)


And all this has nothing to do with weapon unleash whose chance is almost always 35% and formula is EPA, right?

Another doubt is whether the equip crit booster increases only crits or crits and weapon unleashes?

Confusing...
Title: Re: Elemental Weapons
Post by: Rolina on 25, May, 2014, 07:41:33 AM
I think it applies to both, but crit chance is only checked when unleash doesn't go off.  If you have all crit gear and you equip a mundane weapon such as a greatsword, it'll still have a super high critical hit chance.
Title: Re: Elemental Weapons
Post by: Daddy Poi's Oily Gorillas on 25, May, 2014, 09:10:26 AM
-Don't think I mentioned anything on equipment boosts. (Except for Increases Criticals and Unleash Rates.)
-On the second check, I don't think you do the 1/32 check again. That's what the first check was for.
Title: Re: Elemental Weapons
Post by: jjppof on 25, May, 2014, 10:39:52 AM
Quote from: Teawater on 25, May, 2014, 09:10:26 AM
-Don't think I mentioned anything on equipment boosts. (Except for Increases Criticals and Unleash Rates.)

Sorry, then. That was what I understood from this:

Adds up Increases Criticals values from equipped items

English isn't my native language. Sometimes I have some difficults to understand stuff. I confused crit chance boost with damage boost.

Well... I'm completely lost.

Let me explain how the system currently is:

For each regular attack a test to crit is done. The chance of this test be positive is 1/32 + equips chance increases. If the test is positive I apply this formula:
((base damage * 1.25) + (target's level / 5) + 6)
Title: Re: Elemental Weapons
Post by: leaf on 25, May, 2014, 03:10:05 PM
I'm not actually sure why GS uses such a convoluted way to determine crits, but if you're aiming for accuracy you need two checks:

Check 1: [1/32] chance to crit.
Check 2 (if check 1 failed): [(Increased Criticals)/2] chance to crit.

If either check succeeds, apply the formula: [(base damage * 1.25) + (target's level / 5) + 6]

Intuitively, unleashes should have priority over normal crits. The check for an unleash is: [(Base unleash rate) + (Increased Criticals)] chance for unleash.
Title: Re: Elemental Weapons
Post by: jjppof on 25, May, 2014, 03:49:09 PM
Quote from: leaf on 25, May, 2014, 03:10:05 PM
I'm not actually sure why GS uses such a convoluted way to determine crits, but if you're aiming for accuracy you need two checks:

Check 1: [1/32] chance to crit.
Check 2 (if check 1 failed): [(Increased Criticals)/2] chance to crit.

If either check succeeds, apply the formula: [(base damage * 1.25) + (target's level / 5) + 6]

Intuitively, unleashes should have priority over normal crits. The check for an unleash is: [(Base unleash rate) + (Increased Criticals)] chance for unleash.

Nooow I understood... why two damn checks... and moreover divided by 2 the second one. hahahahaha

Just a question only to ensure, if I dont have increased criticals, the second check is null, right?
0/2 = 0%
just to be sure..
Title: Re: Elemental Weapons
Post by: Aile~♥ on 25, May, 2014, 04:26:47 PM
Yeah. If you have no increased critical rate, the second critical check has 0 chance of being true.

Divided by 2 because that's how it works. Increased Critical effects increase your actual critical rate by 1/2 the stated amount, but increase your Unleash rate by the full amount. (In my opinion it should have been done the opposite way, but I didn't make the game.)

Also, @Teawater's edit on last page: Do Ability Effects 41-44 also use the "+ (target's level / 5) + 6" part of the equation? I think we know for sure that 65, 68, and 89 do not. Come to think of it, I'm pretty sure 42 and 44 also do not use it... 41 and 43 are unused?
Title: Re: Elemental Weapons
Post by: Daddy Poi's Oily Gorillas on 25, May, 2014, 05:15:56 PM
QuoteAlso, @Teawater's edit on last page: Do Ability Effects 41-44 also use the "+ (target's level / 5) + 6" part of the equation? I think we know for sure that 65, 68, and 89 do not. Come to think of it, I'm pretty sure 42 and 44 also do not use it... 41 and 43 are unused?
No, I don't think they do. Just 36-40, and Ability 1 (Attack.) From which I know of.
Title: Re: Elemental Weapons
Post by: jjppof on 25, May, 2014, 05:23:46 PM
This divided by two...
If someone want a item to get 100% of crit, he has to put 200% of chance?
I think I'm gonna take this /2 off...
What you guys think?
Title: Re: Elemental Weapons
Post by: Aile~♥ on 25, May, 2014, 05:48:11 PM
I have no particular objections. Actually, I'd be inclined to put the /2 on Unleash Rate.

So the Unleash check is: [(Base Unleash rate) + (Increases Criticals / 2)]% chance for an unleash.

This would mean that if you want to get a 99% unleash rate (it is impossible to have 100% unleash rate in GS. The game hard-caps it at 99%), you have to put +128% worth of Increases Critical effects. Since Unleashes have a general tendency to be much more powerful than a standard critical hit, and have priority over criticals, this makes sense to me.
Title: Re: Elemental Weapons
Post by: Rolina on 25, May, 2014, 10:47:01 PM
Eh, but that's balancing.  He's going for a 1:1 replication. Hax included.
Title: Re: Elemental Weapons
Post by: leaf on 26, May, 2014, 05:00:01 AM
Yeah, leave the /2. In practice, weapons without an unleash are rarely used, and by the time you even start getting equipment that raises crit rate, you'll probably be using artifacts almost exclusively anyway.
Title: Re: Elemental Weapons
Post by: Aile~♥ on 26, May, 2014, 12:21:08 PM
Well, jippof was the one who suggested taking it off.

If you're going for a 1:1 recreation, the /2 has to stay on Critical chance.

If you're not, I'd recommend putting it on Unleash chance's Increases Criticals modifier instead, as described in my previous post.
Title: Re: Elemental Weapons
Post by: jjppof on 26, May, 2014, 02:54:33 PM
I'll let naturally with /2 and a option for who wants to take it off.