Several people approached me about working with IB's code, since it can be a little intimidating at first. The organization is a bit non-traditional, since I was relatively new to programming when I started working on it, but I've cleaned up most of the messy portions of the code, so once you understand how it is organized, it should be pretty easy to work with.
Adding CharactersFirst, you'll need to set up the character's stats. This is done in the finish_creation script. Refer to the comments in Naija's portion of this code for a summary of what all these stats mean.
To add the character's portrait, add the sprite to the 'portraits' list in the Create event of the Control object.
We need to make the character selectable, so we need to look in the menu/Character Select folder. We'll need to create a portrait object like the ones already existing, and we'll need to update the step event of the char_select object.
Next, you'll need to add the character's attacks. Each attack involves a number of separate steps. At each step, the character may enter a new animation, change speed or position, or strike an enemy. This can be a little confusing, so here is a summary of how a single attack was programmed - Nikujin's upward slash.
The action script is where each attack begins. To find the attack, you'll need to navigate a nested switch statement - first to the character number (3), then to the attack number (5, for upwards attack). Here's what you'll see:
//This line is normally included. It prevents the attack from being used immediately after another attack in the air.
if(air_attack){
//If airdrift is set to 1, the character will not decelerate naturally during the attack while airborne.
airdrift = 1;
//Set the sprite and animation speed.
current_sprite = s_nikujin_upslash;
sprite_speed = 1;
frame_number = -sprite_speed;
//Set the alarm for the windup portion of the attack. In 6 frames, the next step will execute, and Nikujin will swing his sword.
//In the air, the attack only has 4 frames of windup.
if(onground){
alarm[0] = 6;
}
else{
alarm[0] = 4;
frame_number += 2;
}
//This sets a few common variables for the attack, and should almost always be called.
attack_start();
}
break;
Once that alarm hits 0, the next step of the attack will execute. Let's see what happens then:
//Create the attack itself. We'll get into the attack object a little later.
attack_create (katana_highslash);
//Identify the attack's next step, and the number of frames before that step is reached.
next_step = 2;
alarm [0] = 11;
break;
A lot of attacks will set variables like xmomentum in this step. This is used to modify the character's movement.
Now let's look at step 2, which is the final step for this attack:
//Reset all the variables we changed for the attack
airdrift = 0;
//This script sets a few variables common to most attacks, and should usually be called at an attack's end
attack_end();
break;
Now let's look at the attack itself. The sprite for katana_highslash matches the area covered by Nikujin's sword during the attack. It's parent, attack_template, is common to all melee attacks.
The create event sets some important attack variables:
//Set the duration for the attack. Since this attack is a sword slash, it's hitbox appears very briefly.
alarm[0] = 3;
event_inherited();
//Set the attack's damage, which is only moderate
pow = 5;
//Set the horizontal knockback, which is very low
kbx = .1;
//Set the vertical knockback, which is very high, and aimed upwards
kby = -1.6;
//Set how long the target is stunned for (and unable to attack)
kbtime = 3;
//If two characters hit each other at the same time, the attack with higher priority takes effect. 7 is fairly high.
priority = 7;
//Play the sound for the attack
FMODSoundPlay(Control.sMiss);
Now let's see what happens when the attack hits another character (a collision event)
//We always call this function to make sure the character is a valid target.
//It must be on an opposing team, and not currently immune to the character's attacks.
attack_aim(alarm[0]);
//If the previous function was successful, target will be set to true, otherwise it will be false
if(target){
//Resolve the effect of the attack hitting. The second variable should always be 5 - it's a relic of previous versions of the game
attack_hit(pow,5,kbx,kby,kbtime,unblockable);
//If the attack was a successful hit (it was not blocked), the following code will execute
if(shield_break){
//player_id refers to the character that made the attack. Nikujin's jumps are reset each time he lands an aerial attack.
player_id.doublejump = player_id.maxjumps;
player_id.walljumps = player_id.maxwjumps;
player_id.up_attack = 1;
//Generate sound effects and particles.
FMODSoundPlay(Control.m_sword_hit);
part_particles_create(Control.p_sys,other.x+image_xscale*3,other.y,Control.p_nik_sword,1);
}
}
event_inherited();
Adding ItemsFirst, you need to add the item object. Each item must have a unique item_number, under 100 for thrown items, and over 100 for buffs.
If it's a thrown item, you also need to add the item's attack object. This works just like creating a character attack object. Then, you'll need to add the item's sprite and objects to a few lists in the Create event of the Control object.
If it's not a thrown item, you'll need to add it's effect to the action script. Near the top of the script is a section where it generates different effects for picking up items. For complex item effects, you may need to add additional code for the Character object's creation and step events. Look at how other items are handled for reference.
Of course, you'll also need to make it possible for the game to generate the item. Add it to the create_item script.
Adding StagesWhen placing level terrain, it's important to keep in mind the different types of terrain:
Walls are completely solid, and can't be moved through in any direction.
Characters can jump up through Floors, and drop through them, too.
Semisolids are like Floors, but you can't drop through them. They should be used instead of floors if there's no realistic reason to drop through it.
Each stage needs to have a Control object, which must be placed somewhere in the stage. All this object really needs to do is set character and item spawning locations, but it also usually handles backgrounds and music.
Adding Sounds and ParticlesFor consistency, this is done in the Create Event of the Control object. When you add a new sound, make sure you also remove it in the Game End event of the Control object!