Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Zulk RS

How do I implement this armor?

Recommended Posts

I'm trying to make two custom armors; Grand Armor and Dark Armor to add to a wad.

The grand armor is supposed to be a simply stronger version of the Blue armor.

The dark armor is what's causing the problems. I want it work in this way:
-It will give you 50 armor points on top of whatever you have like the armor bonuses.

-If you have 200 armor, it will give you 250 armor. But if you pick it up first and have less than 200 armor, you won't be able to reach over 200 points without picking up another one. Picking up a normal (blue)armor will just get you up to 200.

-It will replace whatever armor you're wearing.

This is the code:

Spoiler

Actor GrandArmor : BlueArmor 20051
{
	Inventory.Pickupmessage "Picked up Grand Armor"
	Armor.SavePercent 70
	Inventory.Icon "GARMA0"
	states
	{
	spawn:
		GARM A 6
		GARM B 6 Bright
		Loop
	}
}

Actor DarkArmor : BasicArmorBonus 20052
{
	Inventory.Pickupmessage "Picked up Dark Armor"
	Armor.MaxSaveAmount 250
	Armor.MaxBonus 50
	Armor.MaxBonusMax 200
	Armor.SavePercent 95
	Armor.SaveAmount 50
	Inventory.Icon "DARMA0"
	states
	{
	spawn:
		DARM A 6
		DARM B 6 Bright
		Loop
	}
}
	

What happens is that when I pick up the dark armor, I can reach 250 by picking up blue armor.

If I'm already wearing armor, the dark armor does not replace it.

Can anyone help me implement this?

Share this post


Link to post

Actor DarkArmor : CustomInventory 20052
{
	Inventory.Pickupmessage "Picked up Dark Armor"
	Inventory.Icon "DARMA0"
	states
	{
	spawn:
		DARM A 6
		DARM B 6 Bright
		Loop
	pickup:
		TNT1 A 0 A_JumpIfInventory("BasicArmor",200,"pickup250")
		TNT1 A 0 A_GiveInventory("DarkArmorBonus")
		stop
	pickup250:
		TNT1 A 0 A_GiveInventory("DarkArmorPickup")
		stop
	}
}
Actor DarkArmorBonus : BasicArmorBonus {
	Armor.SavePercent 95.0
	Armor.SaveAmount 50
	Armor.MaxSaveAmount 200
}
Actor DarkArmorPickup : BasicArmorPickup {
	Armor.SavePercent 95.0
	Armor.SaveAmount 250
}

Share this post


Link to post

What does this part mean?

	pickup:
		TNT1 A 0 A_JumpIfInventory("BasicArmor",200,"pickup250")
		TNT1 A 0 A_GiveInventory("DarkArmorBonus")
		stop
	pickup250:
		TNT1 A 0 A_GiveInventory("DarkArmorPickup")
		stop
	

Share this post


Link to post

Conditional branching, based on the player's current amount of armor points. Either, if the player had less than 200 armor points, the pickup would give him DarkArmorBonus but not DarkArmorPickup, or, if the player had 200 or more armor points, the pickup would give him DarkArmorPickup but not DarkArmorBonus. DarkArmorBonus would give him 50 points of the dark armor up to 200 armor points, and DarkArmorPickup would give him all dark armor up to 250 armor points.

Share this post


Link to post

"TNT1" is a special sprite name such that "TNT1 A" displays no sprite. "TNT1 A 0" displays no sprite for zero duration. The "pickup" states exist only to perform their action functions (A_JumpIfInventory / A_GiveInventory), not to display a visible animation. It's a sort of convention to use "TNT A 0" on such frames, but not a necessity. If a state has duration 0, it never displays any visible sprite anyway (so it doesn't matter which sprite name and letter you use), and the CustomInventory class is hardcoded to ignore state durations in its "pickup" state (behave as if they were 0 even if they're not 0), too.

As I said, it's just a convention that, when a DECORATE modder defines states in which sprite names and letters don't matter, he typically sets the sprite names and letters to "TNT1 A" by default, simply because it's a generic name and possibly also because it makes these states stand out among normal animation frames whose appearance does matter. The engine certainly doesn't require "TNT1 A" to be used on those frames. Whether you use them or not, the actor's behavior in the game will be the same.

Share this post


Link to post

I used the code and two problems occurred:

When I pick it up, it just gives me full 250 instead of (50+whatever I have) dark armor. The sprite, once picked, up shows the blue armor instead of the dark armor

Share this post


Link to post

Make sure to summon / spawn / give the player the item called just "DarkArmor", not DarkArmorBonus or DarkArmorPickup.

Share this post


Link to post

I put the item DarkArmor in a test map. When I picked it up, it gave me 250 Dark Armor (It was working like that) but showed the sprite of the Blue Armor.

It didn't give me (Whatever + 50) Dark Armor but straight up 250 Dark Armor.

How do I do that?

Share this post


Link to post

I've tested my code in both ZDoom and Zandronum and it behaves exactly as you described the intended behavior in the OP. Did you remove your previous definition of DarkArmor before pasting my definition of DarkArmor into your DECORATE? Are you using an up-to-date version of ZDoom?

Share this post


Link to post
scifista42 said:

Did you remove your previous definition of DarkArmor before pasting my definition of DarkArmor into your DECORATE?


Yes.

Share this post


Link to post

Here is my own functional test wad. Start MAP01 and type "summon darkarmor" into the console, pick it up and see what happens. The armor pickup will look like an idling Imp because I didn't have your "DARM" sprites, and the armor icon will also be missing, but otherwise it should behave according to your description - it did so on my side.

Share this post


Link to post

You're wad runs perfectly. I deleted the dark armor decorate and re-wrote it and it behaves properly now.

However, when I pick it up, the inventory icon still looks like a mega armor even though it functions like the dark armor.

Share this post


Link to post

My mistake. Move this line from the definition of DarkArmor:

Inventory.Icon "DARMA0"
Into the definitions of DarkArmorBonus and DarkArmorPickup.

Share this post


Link to post

It now functions almost as it should.

However, picking up the dark armor with armor points less than 200 results in getting more 50 points of existing armor but not dark armor.

Share this post


Link to post

I see, it happens when the player already has another type of armor before picking up the dark armor. Unfortunately, it seems that armor bonuses are unable to replace armor type, and I could not find a way to work around that.

Share this post


Link to post

Interesting.

Maybe I can just make it the most overpowered armor by giving it a fixed 250 armor points. It wasn't supposed to be found by the player outside of secrets. Is this a good idea?

Share this post


Link to post

I think an armor with 250 points of 95% protection probably wouldn't be appropriate as a secret item, as the game's difficulty would change drastically depending on whether the player found it or not. I personally prefer maps with consistent medium difficulty, neither trivial nor impossible. If you could balance the map in such a way that its difficulty would become neither trivial nor impossible no matter if the player found the armor or not, it'd work well, otherwise almost certainly not.

Share this post


Link to post

To that end, how about making the dark armor absorb 66%? That would as much stronger than blue armor (50%) as blue armor is stronger than green armor (33%). The 250 points is fine.

Share this post


Link to post

The grand Armor already does something similar to that. It absorbs 70% damage and has 200 points

What about reducing the dark armor to around 150?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×