Author Topic: Adding Max Health or Setting Max Health On A Datablock  (Read 906 times)

I have found out how to set, and add the fake max health like the TF2 Medigun, but it seems the variables are not working...What is the problem?

Code: [Select]
package setMaxDamageEvent
{
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
if(%obj.OverHealth > 0)
{
if(%damage > %obj.OverHealth)
{
%damage = %damage - %obj.OverHealth;
%obj.OverHealth = 0;
}
else
{
%obj.OverHealth = %obj.OverHealth - %damage;
%damage = 0;
}
}
Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
}
};
activatepackage(setMaxDamageEvent);

package SetMaxDamageMain
{
 function Player::AddMaxHealth(%this,%AddMax)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = (%brickuser.OverHealth+%AddMax);
 }
 
 function Player::SetMaxHealth(%this,%SetMax)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = %SetMax;
 }

 function Player::SetMaxHealthByNoP(%this,%SetNoP)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = (clientgroup.getCount() * %SetNoP);
 }
 
  function Player::AddMaxHealthByNoP(%this,%AddNoP)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = ((clientgroup.getCount() * %AddNoP) + %brickuser.OverHealth);
 }
};

registerOutputEvent("player", "AddMaxHealth" ,"string 4 40");
registerOutputEvent("player", "SetMaxHealthByNoP" ,"string 4 40");
registerOutputEvent("player", "AddMaxHealthByNoP" ,"string 4 40");
registerOutputEvent("player", "SetMaxHealth" ,"string 4 40");
« Last Edit: April 07, 2013, 11:27:44 PM by Advanced Bot »

For one, your not activating the SetMaxDamageMain package (and that package does not even need to exist).
Code: [Select]
function Player::AddMaxHealth(%this,%AddMax)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = (%brickuser.OverHealth+%AddMax);
 }
 
 function Player::SetMaxHealth(%this,%SetMax)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = %SetMax;
 }

 function Player::SetMaxHealthByNoP(%this,%SetNoP)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = (clientgroup.getCount() * %SetNoP);
 }
 
  function Player::AddMaxHealthByNoP(%this,%AddNoP)
 {
 %brickuser = %this.client.player;
 %brickuser.OverHealth = ((clientgroup.getCount() * %AddNoP) + %brickuser.OverHealth);
 }
Don't do %brickuser = %this.client.player; because %this is the player. Just do %this.OverHealth = stuff;

I modified all of that. But I also forgot to package it, it works now, thanks though. I also had to edit the medigun for this to work too lol (It seems I did all of the other edits for nothing)
« Last Edit: April 09, 2013, 02:23:48 PM by Advanced Bot »

Every time I see a topic like this I feel like releasing my script for fully dynamic health, max health, damage reduction and invulnerability. But I still need to fix it up a bit and give it a better API.