Kitty Corp Meow Mix Forums

Super Smash Bros. Brawl Hacking => Programming => Topic started by: KingJigglypuff on November 01, 2015, 07:57:48 PM



Title: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: KingJigglypuff on November 01, 2015, 07:57:48 PM
From Brawl Minus comes entirely new PSA commands! This was all done from Mawootad from the Brawl Minus Dev Team.

These new commands allow you to limit aerial Specials, have a Sub Routine that lasts outside the Action it was activated in, and changing Character Attributes on the fly.

Code:
Limited Specials [Mawootad]
4A000000 8077f218
60000001 00000000
D2000000 00000017
2C040112 41A000A0
2C040115 41A10098
807F00D8 80630064
81830000 818C0018
3C801000 38840047
7D8903A6 4E800421
5460843E 2C002718
40A20054 80810010
3884FEEE 5484083C
20A40020 5C602FBF
40A20014 38A5FFF8
5C602FBF 41A20030
48000050 38A00001
7CA42030 3CA01000
38A50047 807F00D8
80630064 81830000
818C0030 7D8903A6
4E800421 819E0000
7FE5FB78 7FC3F378
80810010 818C0014
7D8903A6 4E800421
38600001 48000008
38600000 00000000
14000004 2C030001
14000008 41A201CC
4A000000 8077f3b4
62000000 00000000
14000008 41A20030
C283c814 0000000C
4E800421 807900D8
80630064 81830000
818C0018 3C801000
38840047 7D8903A6
4E800421 5460843E
2C002718 40A20030
5460C63E 5464002E
7C840378 807900D8
80630064 81830000
818C001C 3CA01000
38A50047 7D8903A6
4E800421 00000000

Setting LA-Basic[71] to the special format 2718XXYY limits repeated use of specials in the air. XX is the max specials in the binary format DDUUSSNN (set to zero to disable limiting of that special), YY is the current available number of specials.  Available refreshes to max on landing.  Refreshing on swimming/damage is implementer's responsibility.

Example: Basic Variable Set: LA-Basic [71]: 27189C9C
This would give you 2 Down Specials, 1 Up Special, 3 Side Specials, and unlimited Neutral Specials.

You would set this Variable in the Wait1 Sub Action and the Squat Sub Action (If making the Variable effect Down Special).

The max for any Special is 3. So if you wanted 3 Down Specials, 3 Up Specials, 3 Side Specials, and 3 Neutral Specials, you would set the Value to 2718FFFF

Code:
Independent Subroutines [Mawootad]
C277CFB4 00000021
2C000005 41A00014
2C000007 41820014
41810008 3803FFFB
2C000003 480000E8
3B600000 7FC3F378
38000000 7FC3F378
90010080 38810080
98010084 7F65DB78
819E0000 818C0020
7D8903A6 4E800421
2C030000 41820020
88810084 28040001
41820014 80610080
80030000 2C000000
41A2000C 38600001
4800007C 2C1B0001
41820010 3B7B0001
83830004 4BFFFF98
83630004 807D0020
7C7D1B78 81830000
818C0018 7D8903A6
4E800421 7C7F1B78
3BC00000 48000034
819D0010 387D0010
7FC4F378 818C0010
7D8903A6 4E800421
80030008 7C1C0000
40A2000C B363000C
48000010 3BDE0001
7C1EF800 4180FFCC
38600001 3D808078
398CD56C 7D8903A6
4E800420 00000000
C277d098 00000006
7C1F0378 819E0000
7FC3F378 818C0010
7D8903A6 4E800421
2C030005 41A0000C
57E006F7 48000008
57E0077B 00000000
C277d0cc 00000003
7C600774 2C000005
41A00008 3803FFFB
2C000000 00000000
0477cf8c 2C000008
C278250c 00000019
28040060 40A200B8
7F63DB78 38800000
3D808078 398C22E0
7D8903A6 4E800421
80030000 2C000000
41A2000C 38600001
4800007C 83A30004
807C00D8 8063006C
80630020 7C7B1B78
81830000 818C0018
7D8903A6 4E800421
7C7F1B78 3BC00000
48000040 819B0010
387B0010 7FC4F378
818C0010 7D8903A6
4E800421 80030008
7C1D0000 40A20018
80630000 8063000C
7C600034 5403D97E
48000014 3BDE0001
7C1EF800 4180FFC0
38600001 3D808078
398C54B4 7D8903A6
4E800420 2804004C
60000000 00000000

Adds the commands 0D050200, 0D060100, and 0D070200 -- Independent Subroutine, Terminate Independent Subroutine, and Set Thread Type, as well as the requirement 60 -- Thread is null.  Set Thread Type sets the type of a PSA thread to a given value.  0x4 denotes a concurrent infinite loop.  0x10 denotes an independent subroutine, which functions similarly to a normal subroutine but ignores frame speed modifiers and does not terminate when the current action or subaction changes.  Threads 8 and 7 are available and unused for all fighters. Threads 5 and 6 may be safe.

Example: If: Thread is Null (Custom): 8
Set Thread Type (Custom) (0D070200): (Thread 8 ): 10
Independent Subroutine (Custom) (0D050200): (Thread 8 ): *Offset*
End If

What this will do is check to see if a thread is in use. If a thread isn't being used, then it will set a thread before executing an Independent Sub Routine.

You can also use this for Concurrent Infinite Loops in case you already have a Concurrent Infinite Loop in progress and want to be able to easily modify the code that you're running.

Set Thread Type (Custom) (0D070200): (Thread 7): 4
Concurrent Infinite Loop: (Thread 7 ): *Offset*

Take note that it's not very safe to use Thread 9 outside of Specials, as the Fighter.pac might be using Thread 9 with various Concurrent Infinite Loops. So you can use that coding if you need to have a Concurrent Infinite Loop in a given Action/Sub Action.

Code:
On the Fly Attribute Modification (Item Crash Fix) [codes, Mawootad]
C27AD58C 00000019
28000020 418000B8
28000025 408000B0
1FA0000C 3BBDFE80
80FF00D8 3C6080B8
808368D8 806700C4
1C8401C8 38A00BB8
54A0103A 7C632214
7C630214 3B83D138
57DFA53E 57DE053E
48000005 7C0802A6
3BBD001C 7FBD0214
7FA903A6 57C0103A
7C1C042E 4E800420
7FFC052E 48000034
60000000 EC00F82A
7C1C052E 48000024
EC00F828 7C1C052E
48000018 EC0007F2
7C1C052E 4800000C
EC00F824 7C1C052E
3BDE0001 7C1EF800
4081FFB4 3D80807B
398CD5BC 7D8903A6
4E800420 3C6080AD
60000000 00000000
047ACE78 2C000025
C27ACEA0 00000005
28000025 4080001C
28000020 41A00014
3C60807B 3863D2A0
7C6903A6 4E800420
60000000 00000000

Adds the commands 12200200 - 12240200 -- set, add, subtract, multiply, and divide attribute range.  Commands take two inputs, the first is a variable or scalar, the second is a specially formatted variable.  The second command should be a variable (type is irrelevant) with a hexadecimal id of 0xBBBAAA.  AAA is first attribute to write to, as counted in the 0-indexed attribute value table.  BBB is the last attribute to write to.  If BBB is less than AAA, the single attribute referenced by AAA is modified.  The code does not check whether the given attribute is valid and specifying a value for AAA or BBB that is too large may result in crashes.  Attribute changes reset upon respawning.

Parameter 1 uses Scalar while Parameter 2 uses an IC-Basic Variable. These commands won't work with Integer Attributes though, so if you wanted to find a specific attribute, you would count down while skipping any Integer Attributes. The Attributes start at IC-Basic [ 0 ].

Example: Attribute Range Set (12200200): 152, IC-Basic [40] would change the Weight Attribute to 152 until the character dies or if the attribute is changed again.

This thread will be updated with more info, as Mawootad still needs to write down documentation on it (and I'm still asking him things).


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: Large Leader on November 01, 2015, 08:01:23 PM
This is so hype.

But maybe too little too late v:


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: Mawootad on November 01, 2015, 09:01:39 PM
Hey, just wanted to provide some technical info and usage tips for these codes.  First off for independent subroutines, the currently available specials (last byte of the basic) are set to the max available specials whenever the fighter becomes grounded (grabs a ledge or physically makes contact with the ground and are decremented each time the corresponding special is used.  When a given group of bits becomes 0 and it has a max number of specials set that special cannot be activated.  This has a couple of important things to note: 1) if you have a special that changes to itself (specifically to the first 11X action) for some reason it will consume multiple uses of the special and potentially fail to work properly, 2) if the user becomes grounded during the special they will recover all uses (many DO NOT become grounded even when they touch the ground), and 3) if the user uses the special and remains grounded for the entire move the special's uses will be consumed and will not refresh until the user jumps or lands.  The specials also do not refresh on taking damage, as this is not always intended behavior and refreshing on taking damage is fairly easy to implement.  Create a subroutine setting LA-Basic[71] to the value of your choice and copy past that subroutine call to wait1, squat, swim, and if you want refresh on damage all of the damage and captureDamage subactions.

For the independent subroutines code threads 5-8 are generally safe to use (I think, 7 and 8 are safe on every fighter as far as I can tell).  Thread 0 is the action thread, threads 1-4 are the subaction threads (main, gfx, sfx, and other tabs in PSA), thread 9 is the default concurrent infinite loop thread, thread A is the default independent subroutine thread.  Articles and other non-fighter entities that run PSA commands do not necessarily have the same number of threads as fighters, and may not have any free threads.  Also, the specific thread number does matter for some commands, flash overlay effects for instance behave differently when called from thread A.  In terms of how to use independent subroutines, there are a couple of very nice general purpose uses.  The first is for generating flashing effects for fully charged moves.  The way that you'd implement one of these is something like:

if flashing condition
if thread is null: A
independent subroutine: (Thread A):  @flashing subroutine
end if
end if

With the flashing subroutine of the form (this is actually how flashing effects are implemented in Brawl)

Flash Overlay Effect:  Color 1
Sync Wait: 1 frame
Change Flash Overlay Color: Transition Time=4 Color 2
Sync Wait: 4 frames
Terminate Flash Effect
Synch Wait: 1 frame
goto: @flashing subroutine

The second general purpose method for independent subroutines is in conjunction with limited specials to create cooldowns for specials.  This is implemented using two different threads, one of which runs once per character frame and one which runs once per actual frame.  So if you wanted to give neutral special a 3 second cooldown starting from when it's activated you could put the following code in neutral special:

Float variable set: LA-Float[255] = 180

Then in an independent subroutine in thread 8 you can run this code:
if compare: LA-Float[255] > 0
Float variable subtract: LA-Float[255] - 1
End if
Sync wait: 1 frame
Goto start

And in thread 7 run this code:

If compare: LA-Float[255] > 0
Basic variable set: LA-Basic[71] = 27180100
else
Basic variable set: LA-Basic[71] = 0
end if
sync wait: .1 frames
goto start

This code turns on limited specials and sets neutral special to be limited and have no remaining uses whenever LA-Float[255] is non-zero.  Because of how action changes are checked this very easily prevents neutral special from ever being activated when you don't want it to be.

The final comment I'd like to make is to mention that attribute modification makes no attempts to limit the user to sane inputs.  If you run Attribute Range Set: IC-Basic[10,000,000] = 0 the code will gladly attempt to 0 out the 5 kilobytes of memory you told it to zero out, probably crashing your game.  At the same time, if you happen to know where some relevant piece of information occurs relative to the fighter's attribute table you may be able to use attribute modification to write to that value.  Also, I suspect that the way attribute modification is written may remove certain safeguards on bad PSA commands, specifically 12 type commands with a subtype of 14-1F (commands which do not exist) may attempt to branch into random memory crashing the game.  This is very easily avoidable though, since you shouldn't be using non-existent commands in the first place.


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: Mr. AI | Sluigi123 on February 06, 2016, 09:40:43 AM
This is so hype.

But maybe too little too late v:
Still Super hype though!


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: Droid15.24.3 [DELTA] on March 05, 2016, 11:41:59 AM
I never used Brawl Minus before so please excuse my question if it seems like the answer is obvious. Would I be able to have another action take place, be it a completely different move or a damage penalty (over exertion) for example?

Honestly, I have little experience when it comes to modding Brawl, I have messed with textures, attributes, and effects mostly. I haven't had the time to dive in and try out my ideas, assuming they would work.


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: KingJigglypuff on March 05, 2016, 03:04:13 PM
You should have made a post in A/A Help, but to answer your question, if what you want is the character to go into a different Action upon spamming the same move over and over, then it can be possible. For damage reduction, there's already a mechanic in the game that stales the damage of moves if used over and over.


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: LJSTAR on March 09, 2016, 02:47:40 PM
Wait. "Character Attributes on the fly" ? Basically, making a character heavier and such on the fly, via PSA command instead of messing around with momentum ?

... This is beautiful. (and also, exactly what was needed for Shulk's PSA, lol)


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: KingJigglypuff on March 09, 2016, 03:00:10 PM
That's correct.


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: CaliKingz01 on March 23, 2016, 03:35:28 PM
So question, would I need to use the GCT codes provided below or can I use subroutines and such in the PSA to actually edit the attributes? Need to know because I'm helping KTH and LJSTAR with the Shulk PSA which is coming along really nice I might say. :)


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: KingJigglypuff on March 23, 2016, 04:17:03 PM
You need to use the gct codes.


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: JokerPTOH on March 22, 2017, 09:48:07 AM
Does this code work with Project M?


Title: Re: Limited Specials, Independent Sub Routines, and On the Fly Attribute Switching
Post by: KingJigglypuff on July 20, 2018, 01:33:31 PM
This is gonna be a huge-ass necro, I know, but it's important.

Codes (also known as TheGag96) made a fix for the Attribute Modification code so it no longer breaks Rolling Crates, Lip's Stick, Springs, and Soccer Balls. The OP has been updated to use this fixed code.

Does this code work with Project M?
Yes.