Stamina bar

Discuss all aspects related to modding Zandronum here.
Post Reply
HellDoomSpawn
New User
Posts: 2
Joined: Sat Oct 13, 2012 5:02 am
Location: Mexico

Stamina bar

#1

Post by HellDoomSpawn » Sat Oct 13, 2012 6:52 am

How can I make a special button (Like in the case of a sprint button) show a stamina bar for the players current energy, such as so make the player stop running when the bar is done, and after time the bar should go filling itself until it gets full.

ps: sorry for my bad english

User avatar
someoneelse
Forum Regular
Posts: 338
Joined: Sat Aug 18, 2012 10:53 am
Location: Poland

RE: Stamina bar

#2

Post by someoneelse » Sat Oct 13, 2012 2:16 pm

Button? It seems you want to make a mod with Doom3-like stamina variable, yes? Such mod would pretty much suck in classic Doom, where the speed is one of the things player like the most, so I doubt it has been done... And since I suspect you have problems with knowing what you're talking about, I doubt you'd be able to make a mod yourself. (If you're a coder, but with really bad English, sorry!)
Last edited by someoneelse on Sat Oct 13, 2012 2:18 pm, edited 1 time in total.
Shared keys will now be in Zandro! Thanks devs for their work, and users for the support!
<AlienOverlord> Do you have any friends at all
<AlienOverlord> You play Doom

one_Two
Addicted to Zandronum
Posts: 1753
Joined: Thu Jun 07, 2012 4:47 pm

RE: Stamina bar

#3

Post by one_Two » Sat Oct 13, 2012 3:00 pm

Well your best bet would be a while loop run while movement keys are down (dunno how you would differentiate between run and walk if you have auto run on) and then using getactorproperty you can adjust the player speed. Having said that the Zdoom wiki suggests using: "Player.ForwardMove value[, value-run]" to adjust the speed and it includes a running state. It shouldn't be too hard to achieve imo.

EDIT:

And then the bar can be achieved by using a hudmessage image, and maybe perctage the stamina and show it out of 100 (maybe have 10 bars that fade away) a bit like the boss bars in Armageddon invasion. It's all there on the zdoom wiki.
Last edited by one_Two on Sat Oct 13, 2012 3:01 pm, edited 1 time in total.

XutaWoo
Forum Regular
Posts: 113
Joined: Mon Jun 04, 2012 7:04 am

RE: Stamina bar

#4

Post by XutaWoo » Tue Oct 23, 2012 2:52 am

Or you could just use SBARINFO which has native support for showing bars that are full when you have a maximum of an item and empty when you have none.

It's not actually all that hard, actually. Just make a sprint function, make it drain an item while in use, and prevent the player from sprinting for a while if he runs out. Then use DrawBar to draw the amount of the item he has.
[spoiler]Image[/spoiler]
Image

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Stamina bar

#5

Post by ZzZombo » Tue Nov 27, 2012 3:58 am

Spoiler: Example (Open)

Code: Select all

actor FailItem:CustomInventory
{
	Inventory.Amount	1
	States
	{
		Spawn:
		TNT1 A 0
		stop
		Failed:
		TNT1 A 0
		fail
	}
}

actor SprintAbility:FailItem
{
	+INVENTORY.UNDROPPABLE
	States
	{
		Pickup:
		TNT1 A 0 A_GiveInventory("SprintAbilityCancel")
		stop
		Use:
		TNT1 A 0 A_JumpIfInventory("Sprint",1,"Failed")
		TNT1 A 0 A_JumpIfInventory("SprintPenalty",9800,"Failed")
		TNT1 A 0 A_GiveInventory("Sprint")
		TNT1 A 0 A_PlaySound("human/sprint")
		fail
	}
}

actor SprintAbilityCancel:CustomInventory
{
	+INVENTORY.UNDROPPABLE
	States
	{
		Use:
		TNT1 A 0 A_TakeInventory("Sprint")
		fail
	}
}

actor Sprint:PowerSpeed
{
	Speed				1.5
	//Inventory.Icon		"SPBOOT0"
	Powerup.Duration	-15
	+INVENTORY.INTERHUBSTRIP
//so players have at least 15 secs of sprint until they run out of stamina AND release their sprint key
}

actor marker:Inventory
{
	Inventory.Amount	1
	Inventory.MaxAmount	1
	+INVENTORY.UNDROPPABLE
	States
	{
		Spawn:
		TNT1 A 0
		stop
	}
}

actor SprintPenalty:marker
{
	//Inventory.InterHubAmount	0//:(
	Inventory.MaxAmount			10000
	+INVENTORY.INTERHUBSTRIP//deprecated in ZDoom, but still usable in ST
}
[/spolier]
Now in your DECORATE definition of the player class you alter See and Missile states:

Code: Select all

		See/Missile:
		TNT1 A 0 A_JumpIfInventory("Sprint",1,2)
		TNT1 A 0 A_Jump(255,2)
		TNT1 A 0 A_GiveInventory("SprintPenalty",50)
and Spawn state too:

Code: Select all

		Spawn:
		TNT1 A 0 A_TakeInventory("SprintPenalty",10)
How it works: you need to define an alias in the KEYCONF lump to use your SprintAbility item, i. e.:

Code: Select all

addmenukey "Sprint" +sprint
...
alias +sprint "use SprintAbility"
alias -sprint "use SprintAbilityCancel"
When a player presses his sprint key he just uses the inventory item that in its turn will actually give the player sprint speed. Of course, you have to give the SprintAbility item in order to work correctly. When activated it will automatically give the player the "cancel" item so the player can stop running at any given time when he releases his sprint key. To draw the stamina bar you have to use SBARINFO and place this command somewhere:

Code: Select all

DrawBar "STAMBARA","STAMBARB",SprintPenalty,vertical,0,0;
of course you have to supply the appropriate graphics to draw. If your bar is horizontal then change the word "vertical" to "horizontal".
You also need to adjust the coordinates of the bar.

This code uses SprintPenalty item's count to determine how tired the player is due to sprinting. Use can alter its maximum amount in order to raise or lower the maximum duration of sprinting. The player slowly loses his tiredness when standing still. Using this method you can change almost everything in your stamina system without ACS coding.

Cheers.

Post Reply