Armor

Armor

There is an easy way to create a simple shield/armor system without using gml.

1. Create an invisible object with no sprite. Name this something like obj_armorcontrol.
2. Create the object and sprite that you want to give your character armor. Name this obj_getarmor
3. Create a collision with obj_getarmor in your character's properties. In the actions for this event, make a create instance action and tell it to create an instance of obj_armorcontrol at a point in the corner of your screen.
4. Go to wherever you have the settings for your character's health loss. (see health) Make a "test instance count" an set it to 1 instance of obj_armorcontrol then tell it to subtact health by however much less than normal. (ex. if you normally lose 10 health, then lose 5 health with armor)
5. Then put an else statement and then your normal health loss (ex. 10 health)

You now have a simple armor system.

Timed Armor

  • Armor that will wear off after a certain amount of time.

Ad this:

In the create event for obj_armorcontrol, create an action that sets a timer. You can either set it for steps, using the action buttons to set it to go off after a number of steps, or you can set it to go off after a number of seconds using room_speed. Please note that the latter option requires gml,
but to make it easy, just paste this code and change the 1's to however many seconds you would like your armor to last.

alarm[0] = room_speed * 1; // 1 seconds

Multiple Level Armor System

  • An armor system that lets you gain or lose armor strength during your game. (ex. the defense stat in the pokemon games). Again, there is a fairly simple way to do this.

1. Start with the armor system outlined above.
2. Place more than 1 of obj_getarmor in your room, wherever you want your character to get their armor levelup.
3. Decide how many armor levels you would like. (How strong you want your armor to get.) We will use a 3 level armor system for this example.
4. In front of the other "test instance count" in your health, put as many as the amount of armor levels you have (ex. 3), and put an "else" command after each one.
5. For the first one, put the amount of obj_getarmor control that you have for your character to get. (ex. 3) Then tell it to subtract health by the least amount you want in your game. (Rermember that your character loses the least health when best protected by armor, which is what you are setting now, the maximum armor protection.)
6. Repeat step 5 for every armor level down to level 1, which is already there.

Important!
It is very important to remember to put an "else" command after each "test instance count" and to have your armor level settings going in descending order, or this won't work.

Armor Damage / Destruction[pro]

  • Armor that keeps track of damage and the armor is eventually destroyed. This is done using variables.

1. Right under your test instance count, post this code, replacing 10 with the strength of your armor:

chardamage_var = 10; //sets armor strength

chardamage_var = chardamage_var - 1; //damages armor

Then in the step event for your character, put this code:

if chardamage_var = 0;
{
obj_delete(obj_armorcontrol) //destroys armor
}

Shields

To make a shield that totally protects your character, follow steps 1-3 in the simple armor system section. Naming your objects obj_getshield and obj_shieldcontrol.
Then, create a "test instant count" action, also like before. Now you do something different. Instead of setting the amage at less, set the damage taken to 0. If you want a shield that wears off or gets destroyed, follow the steps above.