Page 1 of 1
Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 12:27 am
by Monkeybtm6
Trying to write a ACS script that restores the players max health on respawn for co-op. But im completely clueless and have no idea what im doing.
This script i did write wont work and im stumped.
Code: Select all
#include "zcommon.acs"
#define PLAYER_TID_START 500
#define PLAYER_MAX_HEALTH_ADD 4
script 91 RESPAWN
{
Thing_ChangeTID(PLAYER_TID_START+PlayerNumber(),0);
Thing_ChangeTID(0,PLAYER_TID_START+PlayerNumber());
delay(1);
int Player_Max_Health = PLAYER_MAX_HEALTH_ADD * CheckInventory("PlayerLevel");
GiveActorInventory(PLAYER_TID_START+PlayerNumber(),"MaxhealthGiver",Player_Max_Health);
}
im not very good with ACS and try to do as much as possible within decorate, but in some instances you don't have a choice.
Re: Restoring items on player Respawn [ACS].
Posted: Sun Mar 13, 2016 1:07 am
by Catastrophe
Print out what the value of Player_Max_Health is and also give yourself "MaxhealthGiver" on the console to check if that item actually works. Btw, most mods start off their playerTid's at 1000, why not use that instead?
Re: Restoring items on player Respawn [ACS].
Posted: Sun Mar 13, 2016 1:15 am
by Monkeybtm6
Maxhealthgiver works fine, its basically just my mods maxhealth bonus, caps at 999, but since your max health gets reset on death im trying to find a sort of workaround. otherwise id just give the player maxhealthgiver upon level increase and call it done.
and ill change the playertid range...figured what number id set didnt really matter.
Re: Restoring items on player Respawn [ACS].
Posted: Sun Mar 13, 2016 1:17 am
by Catastrophe
Uhm health doesnt cap at 999, if you go on fullscreen hud you'll see it goes well beyond that.
Re: Restoring items on player Respawn [ACS].
Posted: Sun Mar 13, 2016 1:24 am
by Monkeybtm6
i know it goes higher. original plan was to cap it at 9999 but, ive not edited my hud yet to make room for the additional digit. but that's besides the problem, the issue is when i respawn on a co-op test my healths back to being capped to 100. want it to give me the right max health back when i respawn but its not.
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 6:51 pm
by Lakai
Try this:
Code: Select all
script 91 RESPAWN
{
Thing_ChangeTID(PLAYER_TID_START+PlayerNumber(),0);
Thing_ChangeTID(0,PLAYER_TID_START+PlayerNumber());
delay(1);
int Player_Max_Health = PLAYER_MAX_HEALTH_ADD * CheckInventory("PlayerLevel");
SetActorProperty(PLAYER_TID_START+PlayerNumber(), APROP_HEALTH, Player_Max_Health);
}
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 8:13 pm
by Monkeybtm6
that does set the health but it still isnt setting the max health, once it drops below 100, medkits only heal it up to 100. still its progress
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 8:20 pm
by Catastrophe
Have you tried just downright adding giveinventory("maxhealthbonus", 1000) to see if that even works?
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 8:43 pm
by Monkeybtm6
yeah weird....even just giving it a set number it still wont give it to me on respawn.. does the giveinventory and giveactorinventory functions not work on respawn?
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 8:46 pm
by Lakai
Monkeybtm6 wrote:that does set the health but it still isnt setting the max health, once it drops below 100, medkits only heal it up to 100. still its progress
Code: Select all
script 91 RESPAWN
{
Thing_ChangeTID(PLAYER_TID_START+PlayerNumber(),0);
Thing_ChangeTID(0,PLAYER_TID_START+PlayerNumber());
delay(1);
int Player_Max_Health = PLAYER_MAX_HEALTH_ADD * CheckInventory("PlayerLevel");
SetActorProperty(PLAYER_TID_START+PlayerNumber(), APROP_SPAWNHEALTH, Player_Max_Health);
SetActorProperty(PLAYER_TID_START+PlayerNumber(), APROP_HEALTH, Player_Max_Health);
}
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 8:55 pm
by Monkeybtm6
well look at that...it worked...but i tried it before with APROP_HEALTH and APROP_SPAWNHEALTH and it didnt do anything....but never tried them both at the same time.
still curious though if the giveinventory commands really dont work on respawn...
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 9:00 pm
by Monkeybtm6
had to edit the code a bit though
Code: Select all
script 91 RESPAWN
{
Thing_ChangeTID(PLAYER_TID_START+PlayerNumber(),0);
Thing_ChangeTID(0,PLAYER_TID_START+PlayerNumber());
delay(1);
int Player_Max_Health_in = PLAYER_MAX_HEALTH_ADD * CheckInventory("PlayerLevel");
int Player_Max_Health_Out = (PLAYER_MAX_HEALTH_in + 100);
SetActorProperty(PLAYER_TID_START+PlayerNumber(), APROP_SPAWNHEALTH, Player_Max_Health_Out);
SetActorProperty(PLAYER_TID_START+PlayerNumber(), APROP_HEALTH, Player_Max_Health_out);
}
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 9:25 pm
by Lakai
Monkeybtm6 wrote:still curious though if the giveinventory commands really dont work on respawn...
Code: Select all
script 91 RESPAWN
{
int Player_Max_Health = PLAYER_MAX_HEALTH_ADD * CheckInventory("PlayerLevel");
GiveInventory("MaxhealthGiver", Player_Max_Health);
}
Re: Restoring Max Health on player Respawn [ACS].
Posted: Sun Mar 13, 2016 9:37 pm
by Monkeybtm6
yeah i had tried that and it wasnt giving the item. Tried it with GiveActorInventory too, giving it the player tid