So, for example, you know how in Doom it says "Picked up a Medkit you REALLY need!" when you have lower than 26 health?
I will show you how to do this, among other things in Wolf4SDL.
YOU NEED WSJ's INGAME MESSAGES ADDED TO YOUR CODE FOR THIS TO WORK!
All the changes are in WL_AGENT.CPP, and written by me without me following any tutorials, so report any bugs.
("Picked up a Medkit you REALLY need!")
The reason it is 51, rather than 26, is because of a logic error that happens in the Doom code, and would be in this code too if not corrected, despite being new code.
The error is that since it is when your health is below 26, and a medkit gives you 25 health, your health will be at a minimum 26, due to your minimum health to be alive is 1, thus meaning since it uses less than for the medkit you really need string.
So, why the number 51? Because I am using the logic error to my advantage.
Basically, If you look back to the logic error, and make it 51 instead of 26, the minimum health for displaying the string is when your health is under 26.
The reason for this involves some basic knowledge, but maybe advanced if you do not know how integers, and less than and more than work.
Basically, Due to the fact that you gain 25 health from a medkit, and 51-25=26. Due to the fact the message will display as only "picked up a medkit" rather than "picked up a medkit you REALLY need" if after you gain 25 health, your health is equal to or more than 26 when you have minimum 1 hp, meaning when set to 26, it is impossible to see the message when set to 26. However, since it is set to 51, if you get 25 hp when you are at 26 hp, you will be at 51, meaning you will not see the message. If you are at 1 hp, and get 25 health, you will see the message, due to it being in the range now. Clever, huh?
If you walk over ammo with your ammo full, it will say ammo full.
Picked up a gold key or silver key.
Since the block of code for the keys looks like this, when you put a message for the keys, (i put a getmessage in there to demonstrate, if you want to see what I mean)
it only says one thing for all the keys.
To make it say picked up a gold key, and picked up a silver key, for the gold and silver key change it to say this.
This would work too.
Leave any of your ideas for things like these and I can do them.
I will update this with more code as I do more.
I will show you how to do this, among other things in Wolf4SDL.
YOU NEED WSJ's INGAME MESSAGES ADDED TO YOUR CODE FOR THIS TO WORK!
All the changes are in WL_AGENT.CPP, and written by me without me following any tutorials, so report any bugs.
("Picked up a Medkit you REALLY need!")
- Code:
case bo_firstaid:
if (gamestate.health == 100)
return;
SD_PlaySound (HEALTH2SND);
HealSelf (25);
if (gamestate.health <= 51)
{
GetMessage("Picked up a medkit you REALLY need.");
}
else if (gamestate.health >= 51)
{
GetMessage("Picked up a medkit.");
}
break;
The reason it is 51, rather than 26, is because of a logic error that happens in the Doom code, and would be in this code too if not corrected, despite being new code.
The error is that since it is when your health is below 26, and a medkit gives you 25 health, your health will be at a minimum 26, due to your minimum health to be alive is 1, thus meaning since it uses less than for the medkit you really need string.
So, why the number 51? Because I am using the logic error to my advantage.
Basically, If you look back to the logic error, and make it 51 instead of 26, the minimum health for displaying the string is when your health is under 26.
The reason for this involves some basic knowledge, but maybe advanced if you do not know how integers, and less than and more than work.
Basically, Due to the fact that you gain 25 health from a medkit, and 51-25=26. Due to the fact the message will display as only "picked up a medkit" rather than "picked up a medkit you REALLY need" if after you gain 25 health, your health is equal to or more than 26 when you have minimum 1 hp, meaning when set to 26, it is impossible to see the message when set to 26. However, since it is set to 51, if you get 25 hp when you are at 26 hp, you will be at 51, meaning you will not see the message. If you are at 1 hp, and get 25 health, you will see the message, due to it being in the range now. Clever, huh?
If you walk over ammo with your ammo full, it will say ammo full.
- Code:
case bo_clip:
if (gamestate.ammo == 99)
{
GetMessage("Can't pick up the ammo, your ammo is full!"
}
return;
SD_PlaySound (GETAMMOSND);
GiveAmmo (8);
GetMessage("Picked up a clip.")
break;
Picked up a gold key or silver key.
Since the block of code for the keys looks like this, when you put a message for the keys, (i put a getmessage in there to demonstrate, if you want to see what I mean)
it only says one thing for all the keys.
- Code:
case bo_key1:
case bo_key2:
case bo_key3:
case bo_key4:
GiveKey (check->itemnumber - bo_key1);
SD_PlaySound (GETKEYSND);
GetMessage("Picked up a key.");
break;
To make it say picked up a gold key, and picked up a silver key, for the gold and silver key change it to say this.
- Code:
case bo_key1:
GetMessage("Picked up a gold key.");
case bo_key2:
GetMessage("Picked up a silver key.");
case bo_key3:
case bo_key4:
GiveKey (check->itemnumber - bo_key1);
SD_PlaySound (GETKEYSND);
break;
This would work too.
- Code:
case bo_key1:
case bo_key2:
case bo_key3:
case bo_key4:
GiveKey (check->itemnumber - bo_key1);
SD_PlaySound (GETKEYSND);
if(bo_key1)
{
GetMessage("Picked up a gold key.");
}
else if(bo_key2)
{
GetMessage("Picked up a silver key.");
}
break;
Leave any of your ideas for things like these and I can do them.
I will update this with more code as I do more.