Give the player +1 HP when press USE on Decoration actor?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 188
- Joined: Sun Jun 10, 2018 7:01 pm
Give the player +1 HP when press USE on Decoration actor?
For sure it must be possible, so I'm not asking if, but how to achieve that.
I have a custom actor that I want to be able to heal the player (+1hp per use per 1 sec).
Something like Half-Life HEV station.
I have a custom actor that I want to be able to heal the player (+1hp per use per 1 sec).
Something like Half-Life HEV station.
-
- Posts: 186
- Joined: Tue May 02, 2017 3:54 pm
Re: Give the player +1 HP when press USE on Decoration actor
You could give the actor the `+USESPECIAL`flag to call an ACS script, or you could use ZScript’s `Used` virtual function.
-
- Posts: 188
- Joined: Sun Jun 10, 2018 7:01 pm
Re: Give the player +1 HP when press USE on Decoration actor
Would you mind posting a sample that I could apply to my mod?
https://zdoom.org/wiki/ZScript_actor_fu ... _Functions
I found GiveAmmo function, but what would be most optimal is some kind of "Give Health" but I don't really see something like that here
And if I understand correctly, zscript is prefered than acs? acs needs to be compiled i think, while zscript is just pure text?
https://zdoom.org/wiki/ZScript_actor_fu ... _Functions
I found GiveAmmo function, but what would be most optimal is some kind of "Give Health" but I don't really see something like that here
And if I understand correctly, zscript is prefered than acs? acs needs to be compiled i think, while zscript is just pure text?
-
- Posts: 1562
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Give the player +1 HP when press USE on Decoration actor
use a_giveinventory() and just give player healthbonus, or something like that.
Last edited by ramon.dexter on Wed Aug 22, 2018 11:14 am, edited 1 time in total.
-
- Posts: 188
- Joined: Sun Jun 10, 2018 7:01 pm
Re: Give the player +1 HP when press USE on Decoration actor
Code: Select all
actor Fountain 12620
{
//$Category Duke3D
//$Title "0921 Fountain (anim)"
Height 36
Radius 16
Scale 0.175
-SOLID
-WALLSPRITE
-SPAWNCEILING
+NOGRAVITY
+DONTTHRUST
+USESPECIAL
Activation THINGSPEC_Activate
States
{
Spawn:
TNT1 A 0 A_PlaySound("props/dukewater",4,0.30,1)
0921 A 2
0922 A 2
0923 A 2
0924 A 2
Loop
Active:
TNT1 A 0 A_PlaySound("props/dukewaterdrink",4,0.5,1)
TNT1 A 0 A_GiveInventory("HealthBonus", 1)
Wait
}
}
There are so many different actor flags, states, properties and I'm not even sure if I'm doing this properly. I just want a sound to be played, and given 1 hp per second or two, up to 100 hp.
Maybe i'll have to make a custom actor like healthbonus but with max inventory 100 instead of 200. but the problem is actually being able to execute the script/command
-
- Posts: 1783
- Joined: Wed Jul 23, 2003 9:22 pm
Re: Give the player +1 HP when press USE on Decoration actor
You could have a stationary thing with a linedef box around it, and when you use space near it, it runs whatever script you want. However, I don't know how you can continually gain health by holding down space. I'm sure there's some kind of function that accounts for that. Otherwise, you could make a sector surrounding the thing which will run a script for as long as you're inside the sector (thus being near the thing). You would activate the script by using the space bar, but it will continue to run until you leave the sector.
-
- Posts: 188
- Joined: Sun Jun 10, 2018 7:01 pm
Re: Give the player +1 HP when press USE on Decoration actor
That would work only on my own custom map, but I'm trying to use Replace function to replace another decoration, that's why I need this function independetly from any map linedefs etc.
Another idea that could work is upon pressing space by the actor (which is nonsolid, I don't know if that is an issue) it would spawn a new sprite actor of health thing that is fully transparent. So upon pressing USE by the Fountain, it would actually spawn (DropItem?) 1hp bonus that would be picked up immediatly by the player. Then wait 1 sec before USE can be pressed again to spawn the health.
At least that's how I see it in my head but I have no idea how to tackle this thing on.
Another idea that could work is upon pressing space by the actor (which is nonsolid, I don't know if that is an issue) it would spawn a new sprite actor of health thing that is fully transparent. So upon pressing USE by the Fountain, it would actually spawn (DropItem?) 1hp bonus that would be picked up immediatly by the player. Then wait 1 sec before USE can be pressed again to spawn the health.
At least that's how I see it in my head but I have no idea how to tackle this thing on.
-
- Global Moderator
- Posts: 1116
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
Re: Give the player +1 HP when press USE on Decoration actor
I made this work.
I'm not sure why, but with only THINGSPEC_Activate instead of THINGSPEC_Switch and only Active state, for some reason it'll activate only once and won't work anymore. Not sure why, I'm not great with SwitchableDecorations and it's getting late.
In your case I see several potential issues:
* AFAIK unless it's a SwitchableDecoration, the Active state won't be used
* You're trying to loop a 0-length frame with Wait, which is bad, and not going back to Spawn
* A_GiveInventory is giving healthbonus to the thing, not the player
Code: Select all
Actor HealingBarrel : Switchabledecoration
{
+SOLID
Radius 10
Height 42
+USESPECIAL
Activation THINGSPEC_Switch|THINGSPEC_ThingTargets
states
{
Spawn:
BAR1 AB 6
loop
Inactive:
TNT1 A 0 A_GiveInventory("HealthBonus",1,AAPTR_TARGET)
goto spawn
Active:
TNT1 A 0 A_GiveInventory("HealthBonus",1,AAPTR_TARGET)
goto spawn
}
}
In your case I see several potential issues:
* AFAIK unless it's a SwitchableDecoration, the Active state won't be used
* You're trying to loop a 0-length frame with Wait, which is bad, and not going back to Spawn
* A_GiveInventory is giving healthbonus to the thing, not the player
-
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
Re: Give the player +1 HP when press USE on Decoration actor
Probably because whether or not an actor is activated or not isn't tracked by its state, but by a separate variable. So with THINGSPEC_Activate, you press it once and it become active, then you press it again and it tries to activate it, but since it's already active, nothing happens. THINGSPEC_Switch changes the use action to, well, switch the actor from activated to deactivated and vice-versa ad nauseam, so you can do it repeatedly without getting stuck in either "state."Jekyll Grim Payne wrote:I'm not sure why, but with only THINGSPEC_Activate instead of THINGSPEC_Switch and only Active state, for some reason it'll activate only once and won't work anymore. Not sure why, I'm not great with SwitchableDecorations and it's getting late.
-
- Posts: 188
- Joined: Sun Jun 10, 2018 7:01 pm
Re: Give the player +1 HP when press USE on Decoration actor
Thanks, I'll try to apply it to my mod. Will report back.
-
- Global Moderator
- Posts: 1116
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
Re: Give the player +1 HP when press USE on Decoration actor
Well, that's more or less what I thought, I was just surprised that goto Spawn didn't reset it. But I guess it makes sense. Anyway, the important thing is it worksArctangent wrote: Probably because whether or not an actor is activated or not isn't tracked by its state, but by a separate variable. So with THINGSPEC_Activate, you press it once and it become active, then you press it again and it tries to activate it, but since it's already active, nothing happens. THINGSPEC_Switch changes the use action to, well, switch the actor from activated to deactivated and vice-versa ad nauseam, so you can do it repeatedly without getting stuck in either "state."
-
- Posts: 412
- Joined: Fri Nov 25, 2016 7:17 am
- Location: some northern german shithole
Re: Give the player +1 HP when press USE on Decoration actor
So that's how you do it, I didn't knew you could use multiple values for the "Activation" propertyJekyll Grim Payne wrote:I made this work.
I'm not sure why, but with only THINGSPEC_Activate instead of THINGSPEC_Switch and only Active state, for some reason it'll activate only once and won't work anymore. Not sure why, I'm not great with SwitchableDecorations and it's getting late.Code: Select all
Actor HealingBarrel : Switchabledecoration { +SOLID Radius 10 Height 42 +USESPECIAL Activation THINGSPEC_Switch|THINGSPEC_ThingTargets states { Spawn: BAR1 AB 6 loop Inactive: TNT1 A 0 A_GiveInventory("HealthBonus",1,AAPTR_TARGET) goto spawn Active: TNT1 A 0 A_GiveInventory("HealthBonus",1,AAPTR_TARGET) goto spawn } }
In your case I see several potential issues:
* AFAIK unless it's a SwitchableDecoration, the Active state won't be used
* You're trying to loop a 0-length frame with Wait, which is bad, and not going back to Spawn
* A_GiveInventory is giving healthbonus to the thing, not the player