kupo15
Member
I'm about ready to look into strucs and want to theorize a better way to code this existing system I have. It seems like converting it to structs away from arrays might be a good choice but I don't know enough about struc to know for sure.
Each character has their own script of move hitboxes that is one long 2D array for each move they have. Here is a snippet of one move's hitbox attributes (out of 30 moves so each script is 30x longer than what you see here)
Takeaways in understanding this are the following:
1) the (b) array slot is the sprite number for the animation (62 is spr_attack0 so move[62,10] is attack0's hitbox 1 frame start)
2) I allotted for each move to have up to 5 hitbox data (so one move could hit 5 times with different properties or 1 hitbox can change values throughout the animation 5 times for example)
3) index[b,0-9]] are general hitbox attributes (not relevant to this thread, really)
4) Each group of 10 numbers aligns with the same hitbox. ie:
[10] hitbox 1 frame start
[20] hitbox 1 frame end
[30] hitbox 1 damage
[40] hitbox 1 strength
etc....
[11] hitbox 2 frame start
[21] hitbox 2 frame end
[31] hitbox 2 damage
[41] hitbox 2 strength
etc....
The reason I did this with arrays was so I could easily loop through arrays to copy data, also bc the first array is the player's sprite index, I can use that to pull correct hitbox data as needed and link it to the player (ie if move[sprite,10] == w/e). If you have any questions on how other systems use this data to understand why I initially did this to better understand feel free to ask. I didn't want to overload with too much front information. I built this system 6 years ago when none of these strucs were available and I wasn't as good a programmer. Its obvious now this whole system feels like spaghetti code that works somehow. It would be a huge overhaul to change but if it makes sleep better at night knowing its consolidated and solid its something I'm interested in doing haha
TLDR:
Would this be a good candidate to use strucs instead of arrays? If you make suggestions on how to change this into strucs, be prepared for me to tell you the potential problems I see with how it interacts with other systems. I will do this not to push back against you but it seems like the easiest way to give you the fuller picture of how everything connects together
@GMWolf this is what we briefly talked about in one of my recent status updates, obviously the status wasn't the place to go into full depth compared to here haha
Each character has their own script of move hitboxes that is one long 2D array for each move they have. Here is a snippet of one move's hitbox attributes (out of 30 moves so each script is 30x longer than what you see here)
GML:
// ATTACK 0: UPPERCUT //
var b = charAnimation.attack0;
move[b][0] = b;
move[b][1] = 0; // if 0 single hit; 1 is multiple active hitboxes
move[b][2] = 34; // IASA
move[b][3] = 3; // charge frame
move[b][4] = 0; // 0 if melee move, 1 if projectile
// FRAME STARTS
move[b][10] = 4; // frame hitbox 1 starts
move[b][11] = noone; // frame hitbox 2 starts
move[b][12] = noone; // frame hitbox 3 starts
move[b][13] = noone; // frame hitbox 4 starts
move[b][14] = noone; // frame hitbox 5 starts
// FRAME ENDS
move[b][20] = 11; // last frame of hitbox 1
move[b][21] = noone; // last frame hitbox 2
move[b][22] = noone; // last frame hitbox 3
move[b][23] = noone; // last frame hitbox 4
move[b][24] = noone; // last frame hitbox 5
// DAMAGE
move[b][30] = 16; // hitbox 1 damage
move[b][31] = noone; // hitbox 2 damage
move[b][32] = noone; // hitbox 3 damage
move[b][33] = noone; // hitbox 4 damage
move[b][34] = noone; // hitbox 5 damage
// KNOCKBACK STRENGTH
move[b][40] = 8.1; // hitbox 1 knockback strength
move[b][41] = noone; // hitbox 2 knockback strength
move[b][42] = noone; // hitbox 3 knockback strength
move[b][43] = noone; // hitbox 4 knockback strength
move[b][44] = noone; // hitbox 5 knockback strength
// KNOCKBACK ANGLE
move[b][50] = 10; // hitbox 1 knockback angle + 90
move[b][51] = noone; // hitbox 2 knockback angle + 90
move[b][52] = noone; // hitbox 3 knockback angle + 90
move[b][53] = noone; // hitbox 4 knockback angle + 90
move[b][54] = noone; // hitbox 5 knockback angle + 90
move[b][55] = 5; // hitbox 1 angle scaling
// KNOCKBACK STUN TYPE
/* 0 is grab; 10 is random flinch; 11-19 is specific flinch;
20/25 is random back/front knockdown; 21-24/26-29 is specific back/front knockdown */
move[b][60] = 20; // knockback type
move[b][61] = noone; // knockback type
move[b][62] = noone; // knockback type
move[b][63] = noone; // knockback type
move[b][64] = noone; // knockback type
// ELEMENT SFX
move[b][70] = noone; // 0 normal element; 1 fire; 2 electric; 3 ice
move[b][71] = noone; // element
move[b][72] = noone; // element
move[b][73] = noone; // element
move[b][74] = noone; // element
// HIT SFX
move[b][80] = 5; // hit sfx type
move[b][81] = noone; // hit sfx type
move[b][82] = noone; // hit sfx type
move[b][83] = noone; // hit sfx type
move[b][84] = noone; // hit sfx type
// WHIFF SFX
move[b][90] = 3; // whiff sfx type
move[b][91] = noone; // whiff sfx type
move[b][92] = noone; // whiff sfx type
move[b][93] = noone; // whiff sfx type
move[b][94] = noone; // whiff sfx type
// HURT SFX
move[b][100] = 2.5; // hurt sfx type
move[b][101] = noone; // hurt sfx type
move[b][102] = noone; // hurt sfx type
move[b][103] = noone; // hurt sfx type
move[b][104] = noone; // hurt sfx type
// GRUNT SFX
move[b][110] = noone; // grunt sfx type
move[b][111] = noone; // grunt sfx type
move[b][112] = noone; // grunt sfx type
move[b][113] = noone; // grunt sfx type
move[b][114] = noone; // grunt sfx type
// SHIELD STUN
move[b][120] = noone; // shield stun
move[b][121] = noone; // shield stun
move[b][122] = noone; // shield stun
move[b][123] = noone; // shield stun
move[b][124] = noone; // shield stun
// SHIELD KNOCKBACK
move[b][130] = noone; // shield knockback
move[b][131] = noone; // shield knockback
move[b][132] = noone; // shield knockback
move[b][133] = noone; // shield knockback
move[b][134] = noone; // shield knockback
// HIT STUN
move[b][140] = noone; // hit stun
move[b][141] = noone; // hit stun
move[b][142] = noone; // hit stun
move[b][143] = noone; // hit stun
move[b][144] = noone; // hit stun
// HITLAG
move[b][150] = noone; // hitlag
move[b][151] = noone; // hitlag
move[b][152] = noone; // hitlag
move[b][153] = noone; // hitlag
move[b][154] = noone; // hitlag
// CAMERA SHAKE MULTIPLIER
move[b][160] = 1; // camera shake
move[b][161] = 1; // camera shake
move[b][162] = 1; // camera shake
move[b][163] = 1; // camera shake
move[b][164] = 1; // camera shake
1) the (b) array slot is the sprite number for the animation (62 is spr_attack0 so move[62,10] is attack0's hitbox 1 frame start)
2) I allotted for each move to have up to 5 hitbox data (so one move could hit 5 times with different properties or 1 hitbox can change values throughout the animation 5 times for example)
3) index[b,0-9]] are general hitbox attributes (not relevant to this thread, really)
4) Each group of 10 numbers aligns with the same hitbox. ie:
[10] hitbox 1 frame start
[20] hitbox 1 frame end
[30] hitbox 1 damage
[40] hitbox 1 strength
etc....
[11] hitbox 2 frame start
[21] hitbox 2 frame end
[31] hitbox 2 damage
[41] hitbox 2 strength
etc....
The reason I did this with arrays was so I could easily loop through arrays to copy data, also bc the first array is the player's sprite index, I can use that to pull correct hitbox data as needed and link it to the player (ie if move[sprite,10] == w/e). If you have any questions on how other systems use this data to understand why I initially did this to better understand feel free to ask. I didn't want to overload with too much front information. I built this system 6 years ago when none of these strucs were available and I wasn't as good a programmer. Its obvious now this whole system feels like spaghetti code that works somehow. It would be a huge overhaul to change but if it makes sleep better at night knowing its consolidated and solid its something I'm interested in doing haha
TLDR:
Would this be a good candidate to use strucs instead of arrays? If you make suggestions on how to change this into strucs, be prepared for me to tell you the potential problems I see with how it interacts with other systems. I will do this not to push back against you but it seems like the easiest way to give you the fuller picture of how everything connects together
@GMWolf this is what we briefly talked about in one of my recent status updates, obviously the status wasn't the place to go into full depth compared to here haha