Author Topic: Changing a datablock on the Client Side?  (Read 880 times)

I'm trying to create a system where a player's health and speed go up depending on their %Variable. I'm not sure if this is possible without multiple Datablocks (One Assigned to each %Variable), but if it I can I would love to know how.

Higher max healths can be simulated through damage reduction. For example, reducing all damage by 50% would be the equivalent of having 200% health.
Hey it's like a repeat of this thread. I'll just have you look here for the code snippet instead of reposting it


For player speeds, how many speeds are you looking for? If it's not a ton, just make multiple datablocks
« Last Edit: October 27, 2012, 01:04:54 PM by Headcrab Zombie »

Oh I remember that topic lol. I need ~15 or maybe even more speeds

15 is a decent number of datablocks to make, as long as you don't mind making them. I wouldn't recommend releasing a mod like this with 15 datablocks though

Oh. I did some reading up and found out I only need 4 per %Variable in this case. New problem is increasing weapon damage per %Variable.

New problem is increasing weapon damage per %Variable.
In your damage reduction function, multiply the damage at the end by (1+%variable) assuming your variable is a percentage to increase the damage by.

In your damage reduction function, multiply the damage at the end by (1+%variable) assuming your variable is a percentage to increase the damage by.
Then which % argument allows you to retrieve the %variable.damage from the attacker. %this is the client having reduced damage, so which is the one that has the attacker?
« Last Edit: October 27, 2012, 03:46:43 PM by Alphadin »

Then which % argument allows you to retrieve the %variable.damage from the attacker. %this is the client having reduced damage, so which is the one that has the attacker?
There isn't one. You'll have to change your code to something like this:

Code: [Select]
package damageModPkg
{
function Player::damage(this,%obj,%pos,%damage,%damageType)
{
%damage = %damage / (%this.fakeMaxHP / 100);
if(%obj.damageBuff != 0)
{
%damage = %damage * (1+%obj.damageBuff);
%obj.damageBuff = 0;
}
Parent::damage(%this,%obj,%pos,%damage,%damageType);
}
function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
%col.damageBuff = %this.sourceClient.damage;
parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}
};
ActivatePackage(damageModPkg);

The variables I need are stored in the client side. How can I send them to the player (I'm still very new at coding).

An easier but extremely hacky way of doing this is by setting the datablock health to a high level, and then appropriately deducting/upping the player's health to the desired health level.

Code: (RP Powers: override.cs) [Select]
//////////////////////////////////
// hacky way of changing health //
//////////////////////////////////

echo("This add-on will overwrite RP Core Player");

datablock PlayerData(RP_Player : PlayerStandardArmor)
{
minJetEnergy = ($RP::pref::canJet) ? $RP::pref::minJetEnergy : 0;
jetEnergyDrain = ($RP::pref::canJet) ? $RP::pref::jetEnergyDrain : 0;
canJet = ($RP::pref::canJet) ? 1 : 0;

maxHealth = 100000; //OPed health level, but it'll be deducted to a level-appropriate health
maxTools = $RP::pref::user::amountTools;
maxWeapons = $RP::pref::user::amountTools;

uiName = "RP Player";

rechargeRate = 0.25;
showEnergyBar = true;
isMage = true;
};

///////////////////////////////////
// torque overrides a la package //
///////////////////////////////////

package RP_Powers_Overrides
{
function gameConnection::SpawnPlayer(%client)
{
%level = RPDB.get(%client.getSaveKey(), "powerlvl");

if(isObject(%client.player)) //angus ghost
%client.player.delete();
parent::SpawnPlayer(%client);

//%client.player.sethealth(90 + (%level * 10));
%client.player.health = 90 + (%level * 10) - %this.getDamageLevel(); //debug crap in case torquescript disbehaves

}

function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
  if(%this.directDamage <= 0)
     return;

  %level = RPDB.get(%obj.client.getSaveKey(), "powerlvl");
  %directDamage = %this.directDamage + (%level-- * (%this.directDamage / 10));

  parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}

function ProjectileData::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt)
{
  %level = RPDB.get(%obj.client.getSaveKey(), "powerlvl");
  %DamageAmt2 = %damageAmt + (%level-- * (%damageAmt / 10));

  parent::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt2);
}
};

RPRegPackage(RP_Powers_Overrides);
« Last Edit: October 28, 2012, 11:16:57 PM by Axolotl2 »

doesn't sound really hacky

doesn't sound really hacky
An OCD coder like Port would probably kick someone's ass if they used my hacky override.

FOR THE LOVE OF GOD CHANGE THE GODDAMN TITLE
THIS IS SERVER SIDED! SERVER SIDED!!!!
* Xalos weeps in a corner.