Custom Boss Code in Need of Proofreading

Nov 22, 2013 at 5:43 PM
Junior Member
"Wahoo! Upgrade!"
Join Date: May 25, 2011
Location:
Posts: 46
Pronouns: he/him
I've been working on a Cave Story mod, Cave Story: Rising Earth, recently, and I've come across a very difficult problem: coding a custom boss battle. I understand assembly code, but I am fairly new to it, and I still have trouble getting much of anything to actually work. I wrote up some pseudocode for the custom boss, 'Fukuro', but I need someone who is more experienced than me to proofread it and make sure it will work before I actually put it into the game. I would really, really appreciate it if someone would please take the time to help me out here.

Here's the pseudocode (sorry that it isn't more organized, but I can't use the tab button in this thread for some reason. :/ )
//X - EAX
//Y - ECX
//Z - EDX
//Script state 1 - Default behaviour
//Script state 2 - Attack pattern 1
***********************************
[Framerects]
//Beginning of behavior code
Store the object pointer to Z
Store script state to X
Store the value of X (Which is the script state) to local variable A
If script state = 2
Then jump to the code for script state 2
Otherwise
If script state = 3
Then jump to the code for script state 3
If script timer = 200
Then
Store 0 to script timer
Jump to "Determine attack pattern" code
Otherwise
Increase script timer by 1

//Default behaviour code
//Set current frame

Store the object pointer to X
If script timer = 10
Then
Store the object pointer to Y
If frame = 1
Then set frame to 2
Otherwise set frame to 1
Store the object pointer to Y
Set script timer to 0
Otherwise
Store the object pointer to Y
Increase script timer by 1
//Make Fukuro bob up and down
Store the object pointer to X
Store the current Y-position to Z
If script timer = 0
Then add 2 to Z
Otherwise
If script timer = 2
Then add 1 to Z
Otherwise
If script timer = 6
Then subtract 1 from Z
Otherwise
If script timer = 8
Then subtract 2 from Z
Otherwise
If script timer = 10
Then subtract 1 from Z
Otherwise
If script timer = 14
Then add 1 to script timer
If script timer > 14
Then script timer = 0
Otherwise add 1 to script timer
//Attack
//Local variable D - X difference
//Local variable E - Y difference
//Local variable F - speed
//Local variable G - angle
If script timer >= 200
Then
Store the object pointer to X
Store Fukuro's X-position to Y
Store Quote's X-position to Z
Subtract Y from Z (store the result to X)
Store X to local variable D
Store the object pointer to X
Store Fukuro's Y-position to Y
Store Quote's Y-position to Z
Subtract Y from Z (store the result to X)
Store X to local variable E
Push local variable D
Push local variable E
Calculate the arctangent using the FPATAN instruction
Pop ESP (the result of the arctangent, AKA the angle from Fukuro to Quote (in radians), is stored to X)
Divide X by 6.28 (store the result as a number between 0 and 1 to local variable G)
Store the object pointer to X
If local variable F < 10
Then increase local variable F by 2
If local variable F > 10
Then store 10 to local variable F
Store the object pointer to X
Store Fukuro's X-position*local variable G to Y
Store Y*local variable F to Y
Add Y to Fukuro's X-position
Store the object pointer to X
Store 1-local variable G to Z
Store Fukuro's Y-position*Z to Y
Store Y*local variable F to Y
Add Y to Fukuro's Y-position
Store the object pointer to X
Store 0 to script timer
Otherwise
Increase script timer by 1
//Rects (makes the game realize the sprites' borders)
Store the object pointer to X
Add 54 to X
Store the value of the local variable that contains framerect 1 to Y
Store the value of Y into [X] (in brackets)
Store the value of the local variable that contains framerect 2 to Z
Store the value of Z into [X+4] (in brackets)
Store the value of the local variable that contains framerect 3 to Y
Store the value of Y into [X+8] (in brackets)
Store the value of the local variable that contains framerect 4 to Z
Store the value of Z into [X+0C] (in brackets)
//End of code
Store the value of EBP into ESP
Pop EBP
Return

The sprite sheet I have made for the boss is also attached, for reference (note: you can ignore everything except the first nine frames. The rest are all sprites I made for attack patterns that I later decided were too complicated to include right now.)
 

Attachments

Nov 22, 2013 at 8:11 PM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 27
Pronouns: he/him
I probably could look this over.

But If you could post the source code it would be easier to compare directly to your comments you have posted.
 
Back
Top