Author Topic: Armor Pickups  (Read 1763 times)


So I know about Perry's doom-armor style pickups, but I was wondering if the effect STACKED. In the topic, it describes each armor pickup as a level of armor. To me, that means that I can't just pickup a bunch of +50 armor until I max it out, which is odd because there's an event that sets the max armor level. Why would that be there if the pickup sets your max armor level automatically? Am I getting the concept of the way it works incorrect or something? I've tried it out, but I'll keep experimenting.

Is there a way I can go in the code to make the pickups stack on what armor the player already has rather than give them an armor level? And is there a way I can make a string appear that tells me how much armor I currently have? I'm willing to listen and do the work. i'm just desperate to get these working the way I need em to give my campaign maps some variance and purpose other than just killing hordes of enemies and searching for the next health powerup and gun.

There's the kevlar add-on, but you need to equip it and use it to put it on, which is just very inconveniencing when you're being ran down by a dozen enemies. "Up! Lemme just put the armor on while their shooting at me!" l:(

Nevermind! It DOES stack! But I still need a way to display the current armor.

the pref for max armor defines the max amount of armor you can hold at once. so say you set the max to 400, that means you can have up to 400 armor at once.

every time you pick up a 50 armor pickup, you get 50 armor added. so it would go 50, 100, 150, 200, 250, 300, 350, 400 and it would stop there because 400 is the max armor you set.

But I still need a way to display the current armor.
the amount of armor a player holds can be accessed by the function Player::getArmorPickupLevel(%this)
use that as you like. if you want to display current armor, make a loop and have it print the player's armor level. i can't make one due to compatibility issues with other mods that bottom or center print, so you'll have to either make one yourself or have someone else make it for you
« Last Edit: July 12, 2017, 06:54:03 AM by PhantOS »

if you wanted you could hide the users shapename and mount a shape onto the users head and label the shapename for how many stacked pieces of armor they have on

the pref for max armor defines the max amount of armor you can hold at once. so say you set the max to 400, that means you can have up to 400 armor at once.

every time you pick up a 50 armor pickup, you get 50 armor added. so it would go 50, 100, 150, 200, 250, 300, 350, 400 and it would stop there because 400 is the max armor you set.
the amount of armor a player holds can be accessed by the function Player::getArmorPickupLevel(%this)
use that as you like. if you want to display current armor, make a loop and have it print the player's armor level. i can't make one due to compatibility issues with other mods that bottom or center print, so you'll have to either make one yourself or have someone else make it for you
Thanks. Not gonna say I totally understand how to do that, but I'm savvy at figuring stuff out when I really want to. But about that loop...how would I do that? I know i'm asking a lot, but it would REALLY put the cherry on top of this build man.

function player::armorloop(%this)
{
      // print code here
      %this.armorloop = %this.schedule(100,armorloop);
}

Thanks bruh. I have no words for your awesomeness.

An alternative to using a schedule would be packaging item::onCollision and player::onDamage. A positive side effect of doing it this way is that you get instant updates.

use them in combination. create a player method that prints it, and call that method both in a loop and whenever you're hit

Hm. Seems like I'd better find an introduction to Torquscript or this will be impossible for me. XD Any...good, FREE places on the net where I can start learning? Like, from ground zero? No experience with anything except a nearly forgotten java class in highschool? l:L

yeah, look at other addons with similar functionality and see how they do it

Ok, I've been looking into the kevlar add-on code and this is what I think I might be able to use to get that client message.
Code: [Select]
function Player::Damage( %this, %obj, %pos, %damage, %damageType )
{
if( %this.armored )
{
%this.armor -= %damage * 0.5;
%damage = %damage * %this.armorDivider;

commandToClient( %this.client, 'bottomprint', "\c6Armor\c3:" SPC MCeil( %this.armor ) @ "\c6.", 3, true );

Unfortunately, I have no freakin' idea what's going on here on so many levels. All I know is that it mentions "bottomprint" and "client" which makes it stand out to me.  I know if i just paste this into the Doom Armor code that it won't do jack because I think there are variables here that aren't created in the Doom Armor to reference to. Like the "c6" and "SPC" thing. What in sam hill IS all that? I can't tell how much of this is general Torquescript language and what's a variable made up by the coder.

Quote
yeah, look at other addons with similar functionality and see how they do it

The kevlar add-on is, so far, the only other armor add-on that I know about and it's the only one that displays how much armor you have whenever you get hit. I DO remember there being another add-on that dispplayed how much armor you had as an energy bar, but I have no idea where it is and, honestly, PhantOS's Doom Armor seems to be the best of them all and perfectly suits the build I've got.

Ok, I've been looking into the kevlar add-on code and this is what I think I might be able to use to get that client message.
Code: [Select]
function Player::Damage( %this, %obj, %pos, %damage, %damageType )
{
if( %this.armored )
{
%this.armor -= %damage * 0.5;
%damage = %damage * %this.armorDivider;

commandToClient( %this.client, 'bottomprint', "\c6Armor\c3:" SPC MCeil( %this.armor ) @ "\c6.", 3, true );

Unfortunately, I have no freakin' idea what's going on here on so many levels. All I know is that it mentions "bottomprint" and "client" which makes it stand out to me.  I know if i just paste this into the Doom Armor code that it won't do jack because I think there are variables here that aren't created in the Doom Armor to reference to. Like the "c6" and "SPC" thing. What in sam hill IS all that? I can't tell how much of this is general Torquescript language and what's a variable made up by the coder.

1) that code is essentially correct. what you have copied there however won't work, you're missing other parts of the function:

       a) two closing brackets } } are needed to end the if() statement and the function.

       b) parent::Damage( %this, %obj, %pos, %damage, %damageType ); needs to be placed there. parent:: ensures that you don't overwrite the damage function. if you leave this out, nobody will ever take damage. you can either put it at the start of the function or the end.

      c) replace (%this.armored) with ( %this.getArmorPickupLevel() != 0 )

      d) remove %this.armor -= %damage and the line after, they are unnecessary





2) \c6 and SPC are formatting codes, they allow you to format string fields.

     a) \c6 is a color code. you put it inside a string to change the color to a set color code. to see what colors are available, go on a singleplayer server and type /colortest in the chat. it will show a bunch of numbers. each number corresponds to the color it represents. so \c6 is white, \c4 is cyan, etc.

     b) SPC, @, TAB and NL can all be used in between strings to connect them or separate them. if you want an example, type in the console:
     
Code: [Select]
echo("hello" @ "these" SPC "are" TAB "string" NL "operations");
      and it should print
     
Code: [Select]
hellothese are            string
              operations


http://docs.garagegames.com/tgea/official/content/documentation/Scripting%20Reference/Introduction/TorqueScript.html#String_Operators:




just as a rule of thumb, variables come in three forms:

%localvariable - a local variable, can only exist in a limited scope. if you put it inside a function, it will exist only inside that function
$globalvariable - a global variable. persists until the game is quit or it is changed.
object.field - a field. is a variable that is attached to an object, kind of like a nametag or something. the armor field used in doom armor pickups is a object field that is attached to players

Dang, man. Thanks again! I'm gonna read the crap out of that guide. I appreciate your "teach a man to fish" mentality. Hopefully i'll be making my own add-ons someday, ones I believe Blockland desperately needs. Shoot, I might even figure out how to stop bots from strafe-ramming everything. XD Seriously though, thanks.

Bruh! Totally got it to work!!! Only had to make one change.

Code: [Select]
commandToClient( %this.client, 'bottomprint', "\c6Armor\c3:" SPC MCeil( %this.armor ) @ "\c6.", 3, true );
Had to change the "%this.armor" to "this.getArmorPickupLevel". You might have wanted me to do that from the get-go, but I thought you meant the one specifically before it and not this one. But yeah! It works! Works like a charm! Thanks man. I'd add sound effects, but the onitempickup add-on doesn't work so there's no way to make the items disappear after pickup, making such efforts void and pointless. That add-on's always been wonky a-h even in the past. I've been forced to use bricks with no collision and the events you incorporated into the add-on to get that down pat.