Page 1 of 1
Stamina bar
Posted: Sat Oct 13, 2012 6:52 am
by HellDoomSpawn
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
RE: Stamina bar
Posted: Sat Oct 13, 2012 2:16 pm
by someoneelse
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!)
RE: Stamina bar
Posted: Sat Oct 13, 2012 3:00 pm
by one_Two
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.
RE: Stamina bar
Posted: Tue Oct 23, 2012 2:52 am
by XutaWoo
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.
RE: Stamina bar
Posted: Tue Nov 27, 2012 3:58 am
by ZzZombo
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.