Author Topic: impactImpulse Not Working + Weird GUI Position Issue [Solved]  (Read 1337 times)

I have a projectile that is supposed to push the player back, but it won't work no matter what I set verticalImpulse and impactImpulse to. Also, I have a couple sounds that won't work in game, and I can't figure out why.
Code: [Select]
datablock ProjectileData(FLUDDProjectile)
{
directDamage = 0.5;
directDamageType = $DamageType::FLUDD;
explosion = FLUDDExplosion;

verticalImpulse = 1000;
impactImpulse = 1000;

muzzleVelocity = 25;
velInheritFactor = 1;

armingDelay = 0;
lifetime = 300;
fadeDelay = 0;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = false;
gravityMod = 0;

uiName = "FLUDD Squirt";
};

Also, I have this weird GUI position issue. I have a HUD that displays how much water you have left:

Below is what I use to calculate the position and extent of the water tank. The problem is, instead of the extent going down and the position going up by the amount that the extent went down, the extent goes down and the position goes up and then it goes down back down, lower than it was before.
Code: [Select]
function clientCmdSetFLUDDWater(%num)
{
FLUDD_TankTop.setVisible(0);

if(%num <= 0)
{
FLUDD_TankLeft.setVisible(0);
FLUDD_TankRight.setVisible(0);

return;
}

FLUDD_TankLeft.setVisible(1);
FLUDD_TankRight.setVisible(1);

if(%num >= $MaxFLUDDWater)
{
FLUDD_TankTop.setVisible(1);

FLUDD_TankLeft.position = "29 38";
FLUDD_TankRight.position = "47 40";
FLUDD_TankTop.position = "26 30";

FLUDD_TankLeft.extent = "22 61";
FLUDD_TankRight.extent = "24 59";
FLUDD_TankTop.extent = "49 22";

return;
}

%prevLeftTankExtent = restWords(FLUDD_TankLeft.getExtent());
%prevRightTankExtent = restWords(FLUDD_TankRight.getExtent());

%leftTankExtent = mFloor((getSubStr(%num / $MaxFLUDDWater, 0, 4) * 61) + 0.5);
%rightTankExtent = mFloor((getSubStr(%num / $MaxFLUDDWater, 0, 4) * 59) + 0.5);

echo(%prevLeftTankExtent SPC "-" SPC %leftTankExtent);
echo(%prevLeftTankExtent - %leftTankExtent);

%leftTankPos = %prevLeftTankExtent - %leftTankExtent;
%leftTankPos = restWords(FLUDD_TankLeft.getExtent()) + %leftTankPos;
%rightTankPos = %prevRightTankExtent - %rightTankExtent;
%rightTankPos = restWords(FLUDD_TankRight.getExtent()) + %rightTankPos;

FLUDD_TankLeft.extent = "22" SPC %leftTankExtent;
FLUDD_TankRight.extent = "24" SPC %rightTankExtent;

FLUDD_TankLeft.position = "29" SPC %leftTankPos;
FLUDD_TankRight.position = "47" SPC %rightTankPos;

echo("New left tank pos:" SPC FLUDD_TankLeft.position);
}
« Last Edit: January 29, 2014, 08:10:25 AM by jes00 »

Found out why verticalImpulse wasn't working, I spelt it wrong. But that still does not explain why impactImpulse won't work.

Strange... the sounds randomly started to work.
« Last Edit: January 27, 2014, 11:28:48 AM by jes00 »

Looks fine to me. Have you tried testing it with only the default add-ons?

Looks fine to me. Have you tried testing it with only the default add-ons?
Yes. impactImpulse is the only thing I can't get to work now.

Did you try setting isballistic to true?

Did you try setting isballistic to true?
No effect.

A strange thing I just discovered. verticalImpulse seems to only take effect when the target is moving or something like that. Or at least that's how it is when you do it on bots.

Perhaps I should just manually do it in onDamage? But I don't know the math to get the X and Y velocity.

Where have I seen that bottle before..

Take a look at the TF2 Butterfly Knife. It has what you want for the x and y velocity


Super Mario Sunshine



Right now I can only make the squirt nozzle because Demian is too busy to model.

Are you doing anything with the projectile's onCollision or onDamage?

Are you doing anything with the projectile's onCollision or onDamage?
Code: [Select]
function FLUDDProjectile::onCollision(%data, %player, %col, %fade, %pos, %normal)
{
if(%col.getClassName() $= "fxDTSBrick")
{
$InputTarget_["Self"] = %col;
$InputTarget_["Player"] = %player;
$InputTarget_["Client"] = %player.client;

if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%player.client);
}

else
{
if(getMiniGameFromObject(%col) == getMiniGameFromObject(%player.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%col);
}

else
{
$InputTarget_["MiniGame"] = 0;
}
}

%col.processInputEvent("onFLUDDHit", %player.client);
}

else
{
if(isFunction(%col, "getDataBlock"))
{
if(isFunction(%col.getDataBlock().getName(), "onFLUDDHit"))
{
%col.getDataBlock().onFLUDDHit(%player, %col, %pos);
}
}

if(isFunction(%col.getClassName(), "onFLUDDHit"))
{
%col.onFLUDDHit(%player, %col, %pos);
}
}

parent::onCollision(%data, %player, %col, %fade, %pos, %normal);
}

EDIT: I think I'm just going to do the impulse manually in armor::damage. Now I just need help with the GUI...

DOUBLE EDIT: Figured the problem out.
Code: [Select]
%leftTankPos = restWords(FLUDD_TankLeft.getExtent()) + %leftTankPos;
%rightTankPos = restWords(FLUDD_TankRight.getExtent()) + %rightTankPos;
Should have been:
Code: [Select]
%leftTankPos = restWords(FLUDD_TankLeft.position) + %leftTankPos;
%rightTankPos = restWords(FLUDD_TankRight.position) + %rightTankPos;
« Last Edit: January 29, 2014, 08:10:09 AM by jes00 »