[solved] Slow medkits action
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: 4
- Joined: Tue Aug 21, 2018 4:51 am
[solved] Slow medkits action
Good day! Is there a way to make a medikits stretched over time, for example 1 health per second?
Last edited by azz on Mon Aug 27, 2018 4:15 am, edited 1 time in total.
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: Slow medkits action
Would something like this help? (untested, apologies for typos)
EDIT: changed goawayanddie to destroy
Code: Select all
class LeakyMedikit:Inventory{
int ticker;
override void DoEffect() //this happens every tic while carried
{
if(!owner)return; //null check
if(amount<1) //remove if run out
{
destroy();
return;
}
ticker--; //35 tick = 1 second
if(ticker<1)
{
ticker=35; //reset the counter
amount--; //expend 1 unit of itself
owner.GiveBody(1); //heal owner 1 health
}
}
default
{
inventory.pickupmessage "Picked up a medikit.";
inventory.amount 25;
inventory.maxamount 100;
}
states
{
spawn:
MEDI A -1;
stop;
}
}
Last edited by Matt on Fri Aug 24, 2018 5:24 pm, edited 1 time in total.
-
- Posts: 4
- Joined: Tue Aug 21, 2018 4:51 am
Re: Slow medkits action
Thank's, how i can use it? It must be in file? I am nube in modes dev
-
- Posts: 1562
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Slow medkits action
This is the right place for you:
https://zdoom.org/wiki/Main_Page
https://zdoom.org/wiki/Main_Page
-
- Posts: 412
- Joined: Fri Nov 25, 2016 7:17 am
- Location: some northern german shithole
Re: Slow medkits action
I made this for you, don't know how much you allready know about gzdoom but if you're just getting into modding...
use slade to edit wads and pk3 files and read something about DECORATE.
there's more than just decorate but that's where you should start I guess, if you allready know about everything I just wrote then just read arround the wiki ramon mentioned.
use slade to edit wads and pk3 files and read something about DECORATE.
there's more than just decorate but that's where you should start I guess, if you allready know about everything I just wrote then just read arround the wiki ramon mentioned.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: Slow medkits action
What difference between goawayanddie() and destroy()?
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: Slow medkits action
Destroy() destroys the actor immediately, while GoAwayAndDie() waits at least 1 tick (and does some other stuff too, I assume, but I don't know what that stuff would be).
I only used GoAwayAndDie() here on the assumption that that function does something important that owned inventory actors should be doing before they are destroyed. If I'm wrong, Destroy() would be better since it ends up with less weird side effects when interacting with other inventory manipulation.
I only used GoAwayAndDie() here on the assumption that that function does something important that owned inventory actors should be doing before they are destroyed. If I'm wrong, Destroy() would be better since it ends up with less weird side effects when interacting with other inventory manipulation.
-
- Lead GZDoom+Raze Developer
- Posts: 49188
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Slow medkits action
GoAwayAndDie is meant for removing items during pickup actions because those need to do some checks for item respawning settings. In DoEffect you should use Destroy instead.
-
- Posts: 4
- Joined: Tue Aug 21, 2018 4:51 am
Re: Slow medkits action
Very big thank's! I'll be learn it.Zen3001 wrote:I made this for you, don't know how much you allready know about gzdoom but if you're just getting into modding...
use slade to edit wads and pk3 files and read something about DECORATE.
there's more than just decorate but that's where you should start I guess, if you allready know about everything I just wrote then just read arround the wiki ramon mentioned.
-
- Posts: 4
- Joined: Tue Aug 21, 2018 4:51 am
Re: [solved] Slow medkits action
One problem, stimpak & medikit now is always pickup. I try to add "-INVENTORY.ALWAYSPICKUP" to "default" section, but it isn't work.
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: [solved] Slow medkits action
You need to override trypickup virtual.
Here how it works in regular medikit
But you need something like
And also you must add flag INVENTORY.ISHEALTH into default block, to let gzdoom know that this item is a health item. Its important if you play with cvar "respavn healing item" set to true, so gzdoom can properly respawn this item.
Here how it works in regular medikit
But you need something like
Code: Select all
override bool TryPickup (in out Actor other)
{
int PrevHealth = other.player != NULL ? other.player.health : other.health;
if (other.GiveBody(Amount, MaxAmount))
{
GoAwayAndDie();
return true;
}
return false;
}