UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Can't set player.health

broken avatar :(
Created 10 years ago
by Soy-Yo
0 Members and 1 Guest are viewing this topic.
8,041 views
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
Signature
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
I'm making a script where I'm reducing the players health and maxhealth, but none of the things I've tried worked. It seems it only works if I set the number manually.
Code Snippet
Plaintext
// no
self.maxhealth -= damage;
self.health -= damage;
// no
self.maxhealth = self.maxhealth - damage;
self.health = self.health - damage;
// no
newmax = self.maxhealth - damage;
newhealth = self.health - damage;
self.maxhealth = newmax;
self.health = newhealth;
// yes
self.maxhealth = 100;
self.health = 100;
Is it possible to change the value of the players health with a var?
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
are you positive that the variable damage is defined and that its not equal to 0?
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
are you positive that the variable damage is defined and that its not equal to 0?
Yes.
Marked as best answer by Soy-Yo 10 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
If your passing damage over to the function have you tried int(damage);
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
If your passing damage over to the function have you tried int(damage);
Nope, I'm not passing it.
Code Snippet
Plaintext
    time = 90;
    maxdamage = 60;
    steps = 10;
    timewait = time / steps;
    damage = maxdamage / steps;
    for( i = 0; i < steps; i++ ) {
        wait timewait;
        self thread greenScreen();
        newmax = self.maxhealth - damage;
        newhealth = self.health - damage;
        self.maxhealth = newmax;
        self.health = newhealth;
    }
Gonna try it anyway.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Strange, that should be fine. How do you know it isn't working? Maybe there is another function that resets the health, like jug does.

Edit, have you tried setting max health, and then a dodamage the difference of what they have and what you want them to have? Or a radiusdamage so it don't crash the game, just in case.
Last Edit: February 23, 2016, 10:40:55 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 6 months ago
Posts
326
Respect
Forum Rank
Perk Hacker
Primary Group
Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
Signature
My Custom Zombie Maps:

- Nazi zombie Legion
- City of Hell
- The Abandoned Mine
- The Last Undead House (Finished)

more custom zombie maps coming soon
×
gamer9294's Groups
Mapper Has released one or more maps to the UGX-Mods community.
gamer9294's Contact & Social Links
hi man,

I don't know if you have a health counter that you can check if the damage is really taking ?

btw you can try make it iprintln to check what you current health are if you don't have a health counter of course.

also What I also know is that the health restored quickly, example:

health = 100
you being hit by a zombie
your health now is:
health = 40
it takes maybe between 1 or 2 second before the health is back on 100, it is not all the time 1 or 2 second but it is a example. :)


best regards,
Gamer9294
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
I know it isn't working because I have a Health counter, like gamer said. It only changes when I use doDamage() or self.health = <manual value>
I'm not using doDamage() because it doesn't do all the damage sometimes (maybe it's due to the origin argument (?)).
Will test with doDamage() again too.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
instead of using doDamage do like makecents said and use radiusDamage on the player. doDomage on coop will force the game to restart since its a damage of MOD_UNKNOWN
Last Edit: February 23, 2016, 11:01:08 pm by buttkicker845
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
instead of using doDamage do like makecents said and use radiusDamage on the player. doDomage on coop will force the game to restart since its a damage of MOD_UNKNOWN
Can't do it with doDamage() or radiusDamage() because I still have the problem of the maxhealth. By the way, you can set the MOD of the damage on the fifth parameter of doDamage().

---

I've found that this...
Code Snippet
Plaintext
while( 1 ) {
    count++;
    self.health = count;
    self.maxhealth = count;
...does change the health and maxhealth values. I'll try to do something similar. Hope it works.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Can't do it with doDamage() or radiusDamage() because I still have the problem of the maxhealth. By the way, you can set the MOD of the damage on the fifth parameter of doDamage().

---

I've found that this...
Code Snippet
Plaintext
while( 1 ) {
    count++;
    self.health = count;
    self.maxhealth = count;
...does change the health and maxhealth values. I'll try to do something similar. Hope it works.

In the one map intro I did, I had to hurt the player in increments to get it to work right. I never figured out why, cause it worked and I moved on. I ended up damaging the player like half their health over and over. Not sure if it is related, but seeing what you said, makes me feel like it.

Not sure why you have the maxhealth problem. Doesn't make sense unless you need a wait in there....?
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
:poker:
Code Snippet
Plaintext
    time = 90;
    maxdamage = 60;
    steps = 10;
    timewait = time / steps;
    damage = maxdamage / steps;
    for( i = 0; i < steps; i++ ) {
        wait timewait;
        self thread greenScreen();
        newmax = self.maxhealth - damage;
        newhealth = self.health - damage;
        counter = 0;
        while( counter < newmax ) {
            counter++;
        }
        self.maxhealth = counter;
        counter = 0;
        while( counter < newhealth ) {
            counter++;
        }
        self.health = counter;
    }
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 30 December 2012
Last active: 2 years ago
Posts
577
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Signature
My preferred name is "xSanchez78".
Check me out here: www.steamcommunity.com/id/xSanchez78
×
alaurenc9's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
alaurenc9's Contact & Social LinksxSanchez78xSanchez78xSanchez78xSanchez78xSanchez78xSanchez78
:poker:
Code Snippet
Plaintext
    time = 90;
    maxdamage = 60;
    steps = 10;
    timewait = time / steps;
    damage = maxdamage / steps;
    for( i = 0; i < steps; i++ ) {
        wait timewait;
        self thread greenScreen();
        newmax = self.maxhealth - damage;
        newhealth = self.health - damage;
        counter = 0;
        while( counter < newmax ) {
            counter++;
        }
        self.maxhealth = counter;
        counter = 0;
        while( counter < newhealth ) {
            counter++;
        }
        self.health = counter;
    }

Wow that is actually kinda smart. Interesting though, you have to do it that way.
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
If your passing damage over to the function have you tried int(damage);
This works as well. Didn't test it yesterday.
It seems that player.health and player.maxhealth only accept an integer as value. And probably, when you do a division, the game transform it to a double or a float, even though it has no decimals.

But, anyway, it's doing something weird.

Initial health and maxhealth: 300.
The player loses 6 points of health and maxhealth (294). Everything aright.
But if the player is hit by a zombie - health: 240, maxhealth: 300 - and then loses the 6 points of health - health: 234, maxhealth: 234.


If I print the maxhealth instead of the health, it's always 300, until the player loses the 6 points, when it changes to 294. If the player is hit by a zombie, the maxhealth is still 300, until the player loses the 6 points, when it's reduced to 234.

The script is supposed to do:
Code Snippet
Plaintext
damage = int( maxdamage / steps );
self.maxhealth -= damage;
self.health -= damage;

Doesn't make sense. ???
Don't know if I explained myself well. :P

Double Post Merge: February 25, 2016, 02:48:06 pm
Ok, think I've fixed it. I set another variable: self.force_maxhealth and a function that forces the maxhealth:
Code Snippet
Plaintext
forceMaxhealth() {
    self endon( "disconnect" );
    while( isDefined( self ) ) {
        while( isAlive( self ) ) {
            if( self.maxhealth != self.force_maxhealth ) {
                self.maxhealth = self.force_maxhealth;
            }
            wait .1;
        }
        wait .1;
    }
}
I'll mark MakeCents as best answer because it's the simplest.
Last Edit: February 25, 2016, 02:48:06 pm by Soy-Yo

 
Loading ...