Discuss all aspects related to modding Zandronum here.
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#1
Post
by Monkeybtm6 » Sun Mar 13, 2016 12:27 am
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.
Last edited by
Monkeybtm6 on Sun Mar 13, 2016 3:09 am, edited 1 time in total.
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2568
- Joined: Sat Jun 02, 2012 2:44 am
#2
Post
by Catastrophe » Sun Mar 13, 2016 1:07 am
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?
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#3
Post
by Monkeybtm6 » Sun Mar 13, 2016 1:15 am
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.
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2568
- Joined: Sat Jun 02, 2012 2:44 am
#4
Post
by Catastrophe » Sun Mar 13, 2016 1:17 am
Uhm health doesnt cap at 999, if you go on fullscreen hud you'll see it goes well beyond that.
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#5
Post
by Monkeybtm6 » Sun Mar 13, 2016 1:24 am
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.
-
Lakai
- New User
- Posts: 7
- Joined: Tue Feb 19, 2013 12:00 am
#6
Post
by Lakai » Sun Mar 13, 2016 6:51 pm
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);
}
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#7
Post
by Monkeybtm6 » Sun Mar 13, 2016 8:13 pm
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
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2568
- Joined: Sat Jun 02, 2012 2:44 am
#8
Post
by Catastrophe » Sun Mar 13, 2016 8:20 pm
Have you tried just downright adding giveinventory("maxhealthbonus", 1000) to see if that even works?
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#9
Post
by Monkeybtm6 » Sun Mar 13, 2016 8:43 pm
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?
-
Lakai
- New User
- Posts: 7
- Joined: Tue Feb 19, 2013 12:00 am
#10
Post
by Lakai » Sun Mar 13, 2016 8:46 pm
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);
}
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#11
Post
by Monkeybtm6 » Sun Mar 13, 2016 8:55 pm
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...
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#12
Post
by Monkeybtm6 » Sun Mar 13, 2016 9:00 pm
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);
}
-
Lakai
- New User
- Posts: 7
- Joined: Tue Feb 19, 2013 12:00 am
#13
Post
by Lakai » Sun Mar 13, 2016 9:25 pm
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);
}
-
Monkeybtm6
-
- Posts: 38
- Joined: Tue Dec 16, 2014 11:59 pm
#14
Post
by Monkeybtm6 » Sun Mar 13, 2016 9:37 pm
yeah i had tried that and it wasnt giving the item. Tried it with GiveActorInventory too, giving it the player tid