Home Gallery Resources The Team Rules chat Login Register
  Show Topics
Pages: [1]
1  Super Smash Bros. Brawl Hacking / Programming / SDHC Extension 1.1[Reinsertion support] on: January 11, 2014, 09:17:59 AM
Now Project M 3.01 is out, so I release this:
Code:
SDHC Extension 1.1[Bero]
* C23CB3D8 00000004
* 546302D7 41820014
* 38600001 3C808058
* 60840300 90640000
* 2C1D0000 00000000
* C23EEE18 00000007
* 80610014 54630253
* 41820028 38000009
* 8061000C 5463C43E
* 38630001 1CC30400
* 3C60803E 6063EE58
* 7C6903A6 4E800420
* 80A1000C 00000000
* C23CB620 00000008
* 3D60805A 616B9350
* 816B0000 2C0B0000
* 41820024 2C040040
* 4182001C 39600001
* 91610008 3D60803C
* 616BB410 7D6903A6
* 4E800420 9421FFC0
* 60000000 00000000
* C23CB4AC 00000003
* 38C00000 2C160000
* 41820008 38C00001
* 60000000 00000000
* C23CB5D4 00000009
* 807C001C 2C030001
* 806DCE1C 41820034
* 80030000 90190000
* 80030004 90190004
* 80030008 90190008
* 8003000C 9019000C
* 3C60803C 6063B5E0
* 7C6903A6 4E800420
* 60000000 00000000
* 043EEA20 48191905
* 043EEC1C 48191709
* 06580324 00000028
* 3F008058 63180300
* 83180000 2C180000
* 4182000C 7CB92B78
* 48000008 7F2531D6
* 548006FF 4E800020
* 043EEB6C 481917E1
* 043EED68 481915E5
* 0658034C 00000028
* 3C608058 60630300
* 80630000 2C030000
* 4182000C 3B390001
* 48000008 7F39BA14
* 4E800020 00000000
* 043CBA24 481B48E1
* 043CBD60 481B45A5
* 06580304 00000020
* 3EC08058 62D60300
* 82D60000 2C160000
* 41820008 7C802378
* 7C040040 4E800020
* C23EE0BC 00000003
* 38000000 3C60805A
* 60639350 90030000
* 3C60805A 00000000

This code allows you to use SDHC cards with FPC 3.5.1.
Gecko speed+Riivolution SDHC support=SDHC extension

Requirement:
*SD or SDHC cards(SDXC cards don't work)
*System menu above 4.1(if you have IOS58 installed, it's OK)
*Project M Launcher

Usage:
1. Make GCT with FPC3.5.1 and this code
2. Run Project M Launcher
3. Enjoy!

NOTE:
If you experience freeze when you try to reinsert SDHC, please try to return to main menu before you reinsert SDHC, and then enter CSS.

Mmm... It works while the game is loaded with a proper IOS, no need to use the Project M launcher specifically...

I mean, Bero, you've said this doesn't support USB devices, but I'm using it on a USB device since the day you created it. Both "USB Loader CFG" and "USB Loader GX" work for me, with either the hermes cIOS based in IOS 57 (on IOS 222/223) or the d2x cIOS (on IOS 249/250).

Just in case somebody cares, Project M includes this code since version 3.0. That's why some people were able to run Project M from USB loaders with a SDHC. It'd had been impossible without this code.

The new Project M laucher is the easiest way to use the SDHC card with an actual Brawl disc though.
2  Super Smash Bros. Brawl Hacking / Programming / [AI coding]AIScriptpad2.0 Support Thread on: September 11, 2013, 08:43:46 AM
    Hello, I'm Bero, author of AIScriptpad.
    Have you ever been interested in AI coding? AIScriptpad is a program for making AI. I developed version 1 two years ago. And this time, AIScriptpad evolved drastically including new coding language, which was developed only for AI. The syntax of this language is so simple that you can learn it within 2 days. Graphical tutorial is included in the program, but I write them down here. In the program this tutorial is a lot easier to read.



Introduction
    AIScriptpad is a program for making artificial intelligence(AI) in Super Smash Brothers Brawl.
    AI should essentially play an important role in SSBB. Though this game was made to play with friends, many people spend time playing with CPU. So CPU's quality directly affects the game's quality. It goes without saying that the original AI is optimized for original game and AI doesn't work fine on modded characters. Using this program, you can fix things like your character cannot recover, use weapons, etc. Some may try to make ultimate AI which does techniques perfectly. Let's make smart AI with this.

Creating project
    What you do first is to make a "project". Project manages resources which are needed to make AI. You can create a project from Menu->File->New->Project. When you click it, a window called ProjectManager will appear. In this window, you fill these informations:Project name, Pac file to develop, Working folder in which scripts and built node will be saved. Pac file can be "FitCharMotionEtc" or "common3". The former holds AI scripts of one character in binary format and the latter holds shared AI scripts. You can mark "Use absolute" checkbox. When you create working folder in other drive, mark this checkbox. After you filled these informations, press "Create project".

Building pac file
    After you wrote scripts, you can compile into pac. Click Tool->Full rebuild and the pac file will appear in WorkingFolder/Build. You will be already able to use this pac in the game. There are other options. "Rebuild AIMain" will rebuild only AIMain scripts. The same thing can be said about "Rebuild AIPD", "Rebuild ATKD". "Full rebuild all projects" will compile all the projects in your "solution",which will be mentioned in the next page. "Build and distribute" will build pac file and copies to the place in which original pac file was stored.

Creating solution
    When you make some projects, you may want to access them and switch them at once. Solution makes it possible. Solution is a unit which manages many projects. You can regard it as a shortcut for each projects. To create solution, click File->New->Solution. After you click, a window titled "SolutionWizard" will appear. You decide the name of the solution, a place where the solution file will go, and optionally you can select projects that already exist. You can mark "Use absolute path". Then click "Create solution" and the solution will be created. You can add projects after making a solution by clicking "Add projects".

Miscellaneous features
    Find/Replace offers a function by which you can search particular texts and replace them. You can also use this function by using "ctrl+F","ctrl+H".
    In "Property", you can change some settings of the program ,project and solution. By checking"Emit command lists",the program emits raw command calls after you build a project. These command calls will be shown in LogWindow.  You can associate file formats used by AIScriptpad to AIScriptpad by selecting one of them in "Associate".
    In "Reference", you can see the usage of commands, functions, requirements, events, modules and subactions. The information are gathered from header file which defines them.
    In "Help" you can see this help or this program's description.

AIMain introduction
    AIMain is a main file which describes most of CPU's behavior. In this file you make decision and decide stick input direction and buttons to be pressed.
    You use "commands" to request the system to do some work. There are many commands but the number of really useful commands is small. Let's see from very easy example.

Stick input
    First example is "AbsStick". This command controls CPU's stick input. "AbsStick 1" moves the character to right. "AbsStick -1" moves left. The digit means how you input stick horizontally. So "AbsStick 0.5" inputs stick right with 50% power. You can specify vertical input strength. "AbsStick 0 1" inputs stick up and "AbsStick 0 -1" inputs stick down.
    There is another similar command, "Stick". The difference is that Stick takes the character's facing direction into account. Let's see an example. "Stick 1" inputs stick to the direction of the character's front. "Stick -1" inputs stick to the back. Vertical input is the same as that of AbsStick. You may wonder why we didn't name "AbsStick" as "Stick" and "Stick" as something because AbsStick seems to be standard stick input method. It's because Stick was found first and AbsStick next. At first they couldn't see difference between them and named Stick and "TargetStick".

Buttons
    After you learned stick inputs you may well wonder how to input buttons.
    To input buttons you can simply write "Button A". This inputs A button. You can specify multiple buttons writing like "Button A | R".

Input examples
    At this point, we could already write the CPU's behavior.
    A combination of "Button R" and "AbsStick 1" will have the CPU roll right. "AbsStick 0 -1","Button A" will produce DTilt. "AbsStick 0.5" will make CPU walk right and "Stick -1" will cause constant dashdance.

Variables
    To make better decision, some calculation is necessary. For example, if you would like to know if the opponent is in front of the character, you have to take the character's facing direction and the opponent's position(left or right) into consideration. You use "variables" to do this. Variables are something like boxes which contain values. There are 24 variables that can be used. To use variables, you can simply write "var0=1". This code assigns 1 to var0. "var0=var1" will copy the value of var1 to var0. You can do some calculations and assign the result using this syntax:"var0=var1+var2".
    You can get information of the environment using "Functions". Functions can be used like variables and normal values. For example, "XCoord" is a function which returns the character's x coordinate. You can use this by "var0=XCoord". Of course you can do calculations "var0=XCoord-10".
    Following code is a more advanced example. "var0=OPos*Direction" OPos is a function which returns 1 if the opponent is right and -1 if is left. Direction is a function which returns 1 if the character is facing right and -1 if facing left. So if the result of this code is positive, the opponent is in front of the character. Otherwise the opponent is in back of the character.

If sentences
    If you couldn't switch the behavior of the character depending on situations, the character would do the same thing constantly. Of course you can switch moves of CPU. "if" sentences enable it. To use if sentences, write "if var0 > 0". This code means if var0 is positive, the system will execute following codes. if sentences must be closed by "endif". After writing some lines after if sentence, write "endif" to close if block. You may want to do something if the requirement is false. In such situation, write "if !(var0>0)". If var0 is lower or equal to 0, following codes are executed.
    You may want to do something when the requirement is met and also when the requirement is not met. In such case, write "else".
if ...
    ...
else
    ...
endif
is a standard syntax of if block.
    When you want to evaluate additional requirement, you can write "elif". With elif, you can evaluate requirements if previous requirements are all false. Example:
if ...
    ...
elif ...
    ...
endif
    Please note that you cannot write "if" right after an "else" because the count of "endif" becomes wrong. Use "elif" instead.
    There are many cases that you want to evaluate multiple requirements at one time. In such cases, write "&&" "||". "&&" means "and" requirement and "||" means "or" requirement. Let's see an example. "if var0 > 0 && var0 < 10" means "if var0 is in between 0 and 10, execute following codes". "if var0 < 0 || var0 > 10" means "if var0 is negative or greater than 10, execute following codes". Finally, I show you a big example.
if XCoord > 10
    AbsStick 1
elif XCoord > 0
    Button X
else
    Stick 1
endif
    With this code, the character goes right if the X coordinate is larger than 10. Otherwise, if X coordinate is positive, presses x button. Otherwise, the character goes front.

Labels and seek
    We have looked important parts of AIMain and we have learned 70% of it. The las 30% is control flow syntax. The match lasts more than 1 frame of course. To deal with situations more than 1 frame, it is necessary to write loop. To write loop, you use these commands:"label","Return". It's a little difficult to explain in words, let me explain using an example.
label
...(Do something. Call this part A)
Return
    This code executes A and when the execution reaches "Return", the system stops execution for 1 frame. After 1 frame passed, the system resumes from the position of "label" and executes A, reaches "Return",... When you want to finish loop, there are two options. One is that you stop the execution of the routine. You can simply do this by writing "Finish". This is the example:
label
...
if var0 > 0
    Finish
endif
Return
    The other is to go other label block. You can do this by a command "Seek". By simply writing "Seek", the system searches next "label" in the code. And if it could find one, the system remember the position of it. The execution from next frame will resume from the point. This is the example:
label
...
if var0 > 0
    Seek
endif
Return

label
...
    Seek can have an argument, which refers to names of labels.
label
...
if var0 > 0
    Seek _foo
else
    Seek
endif
Return

label
...
Return

label _foo
...
Return
    In first loop,if var0 is positive, goes to _foo after 1 frame. if var0 is 0 or negative, goes to next label.

Jump and Goto
    We go on seeing execution flow. You may want to jump to next label immediately. In such case, write "Jump". With this command, the system immediately goes to a label which was saught before.
    There is a useful command named "Goto". This command resembles to Seek, but you can immediately jump to a label and you can go back to previous position. This is the example:
...
Goto _subroutine
...(A)

label _subroutine
...
Return    //go back to (A)

Routines
    AIMain codes are separated into "routines", which have their own roles. For example, routine 6031 deals with ground jab, and routine 70 deals with roll. You can call routines from AIMain script. "Call 0x6031" will call routine 6031. I have already named some routines and you can use the names as an argument. So this is valid command call:"Call Jab123". (Jab123 is the name of routine 6031). Don't forget prefix "0x" when you use raw routine names, otherwise AIScriptpad recognizes the value as normal value like "var0=1".
    Sometimes you may want to add routines. To add routines, you can do it by simply adding scripts into "Scripts" folder in the project directory.

Coding idioms
   We have aquired basic knowledge of AIMain. Now I'll explain coding idioms that are often used in binary and actual coding.
    To know whether the opponent is in front or not, write this:
var0=OPos*Direction
if var0 > 0
    //code when the opponent is in front of the character
else
   //code when the opponent is in behind of the character
endif
    When coding, we often want to wait for the character to finish current action. In such case, write this:
if !Dashing && !Idling
    Return
endif
    If you want to fast fall in air, write this code:
if InAir && YSpeed < 0
    AbsStick 0 -1 //this can be substituted with Stick 0 -1
endif
   
Coding miscs
    It is highly recommended to write comments in your source code. It's common that you cannot understand what you wrote yesterday. You can write comment by "//comment".
   
    When the compiler compiles scripts, it expands expressions into raw command calls. For example, it will expand "var0=OXCoord-XCoord" to "SetVar var0 OXCoord" and "Sub var0 XCoord". Sometimes it allocates temporary memory from var23. So usage of high number memories like var23,var22 may sometimes cause some troubles. You should avoid using such memories.
   
    When you compile, you may get some error messages. Sometimes line number in the message may be pointing odd place. In this case, the error is in header file. Check your header file or those in "Include" folder.
   
    When you are coding AI, you may discover new function, requirement, routine usage, etc. In such case you can define your findings in header file. For example, if you find a new function, you can write like this:
func MyFunc : 0x50
    This defines function number 0x50 as MyFunc. You can use this name in AIMain scripts. This is a list of definition syntaxes:
*Command---cmd CmdName : 0x(number) argument1 argument2 ...
*Function---func FuncName : 0x(number)
*Requirement---req RequirementName : 0x(number) argument1 argument2...
*Routine--- act RoutineName : 0x(number)
*AIPD requirement(situation)---event ReqName : 0x(number)
*Subaction---sact SubactionName : 0x(number)
    You can add explanation for each definitions. Write "///" just before these definitions and after ///, write explanation. It will show up in FunctionWindow,which you can open from Reference->Command,etc.

AIPD
    I will explain how to code AIPD.
   AIPD defines largely two things. Attack dice roll definitions and AIMain call definitions. Generally you don't have to edit the former. The latter defines when each AI script is called. The latter has sets of  entries which have following things: AIMain routine name,high frequency value,low frequency value,max level, min level. I explain from head. AIMain routine name is what you use as "Call" argument in AIMain. They are such as RollF, Jab123. How frequent the routine will be called is calculated by following expression: (levelvalue-min)/(max-min)*low+(max-levelvalue)/(max-min)*high. If levelvalue > max, (max-levelvalue)/(max-min) will be 1. If levelvalue < min, (levelvalue-min)/(max-min) will be 1. Levelvalue is a value which changes depending on the CPU level. This is a list of levelvalue.
Level1---0
Level2---15
Level3---21
Level4---31
Level5---42
Level6---48
Level7---60
Level8---75
Level9---100
    Each set has requirement and if the requirement is met, one of the entries in the set will be called after dice roll considering the frequency value. You can specify two requirements but you can omit one of them. This is the example:
fXClose{
    Jab123 100,0,75,21
   FTilt 30,25,100,0
}
    In this example, Jab123 and FTilt will be called when the opponent is in front of the character and they are close together. High value of Jab123 is 100,low is 0,max is 75,min is 21. High value of FTilt is 30,low is 25,max is 100,min is 0. So Jab is likely to be called in this situation.
    To specify multiple requirements to one set, you can do it by writing "&&" and "||". The role of these is the same as that in AIMain so I skip the explanation. You can also negate a requirement using "!". Usage is the same as that in AIMain.
    Sometimes you may want to set a requirement which is applied to multiple sets. In such case, write "if ..." before the head of the sets. This is the example:
if SamePlane

fXClose{
    ...
}

...
endif


ATKD
    ATKD means "Attack definition" and it defines the attacks of the character. There are entries for each subaction and each entry defines following things:
*Start frame
*End frame
*Offensive collision minimum x length
*Offensive collision maximum x length
*Offensive collision minimum y length
*Offensive collision maximum y length
Start frame and end frame are integer values and the rest can be any value. There is also a value called "unk" but it's always 0 so you don't have to be aware of it.

Debugging
    After you build pac file, you have to debug it on Wii. There are two useful codes which help you debug. Dantarion's routine visualizer code visualizes running routine in training mode. To use it, create GCT file with the code and go to training mode, turn on information, and running routine will be displayed in one of the information windows. My force code with button activation will force the system to run specified routine. While you are pressing a button, the system constantly runs the spesified routine.


    Please feel free asking me any questions about AI coding here. Also, when you find some bugs in this program, I'll be grad if you tell me how it occurred.

Screen shots:
Script

Interface

Tutorial window

Pages: [1]