Author Topic: Could someone edit the Proto-17's projectile to do damage and push back?  (Read 2415 times)


It actually flings them in the direction opposite to where they are aimed
hm well for me it either pushes them NW and SE, or NE and SW for some reason

I think the only reason why you weren't getting your desired result to begin with was simply because the projectile's arming delay was set to 1 second. I removed that, it should work just fine without any extra code.

I think the only reason why you weren't getting your desired result to begin with was simply because the projectile's arming delay was set to 1 second. I removed that, it should work just fine without any extra code.
That's not why. The arming delay effects the time in milliseconds before the projectile will cause damage or explode on impact

The issue is that the projectile gets the eye vector of the player it hits, and pushes them in the opposite direction.
Hence, if a person if running at you, it shoves them back when hit, and vise versa

It's a simple bug in the code I gave earlier.

That's not why. The arming delay effects the time in milliseconds before the projectile will cause damage or explode on impact

The issue is that the projectile gets the eye vector of the player it hits, and pushes them in the opposite direction.
Hence, if a person if running at you, it shoves them back when hit, and vise versa

It's a simple bug in the code I gave earlier.
I didn't base this off your code. Projectiles already handle impact impulse by default, the only reason it wouldn't have worked before was because of the arming delay.

Just copy/pasted the server.cs you attached, Pecon. It does not move the player the projectile hits.

Replace the current projectile collision function with
Code: [Select]
function Proto17Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal,%velocity)
{
serverPlay3D(Proto17BounceSound,%pos);

       if(%col.getClassName() $= "Player" || %col.getClassName() $= "AIPlayer")
               %col.setVelocity(VectorAdd(%col.getVelocity(),VectorScale(%velocity,"4")));

return Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
tested and works

Nevermind, I see why it never worked in the first place. The onCollision function needed to be packaged and parented.

Tested and works.
http://justfilehosting.space/download.php?f=plzzq&name=Weapon_Proto17.zip

Goth, there isn't any reason to handle this through custom code, using the engine-generated impulse will work much more smoothly in multiplayer.
« Last Edit: February 07, 2016, 09:22:05 PM by Pecon »

Just tested, it doesn't do the same thing, it only bumps the player up a bit. There is a lack of horizontal push back



Really?

That's a rhetorical question. I'm just pointing out that the values are there, just waiting to be tweaked to your desires. Stop nitpicking.

Yes, really. lol.

Actually go in-game, make a minigame, get the gun, plant down a standard hole bot, then shoot it.

edit: read ye small text. not trying to nit pick, I'm only saying the file you uploaded doesn't work for me, that is all.
« Last Edit: February 07, 2016, 09:10:30 PM by Goth77 »

So I was wrong at first. Turns out that packaging the onCollision function makes torque hiccup and ignore the impulse on the projectile. I fixed the code again, and now it really does work.... without having to apply velocity to the target.

http://justfilehosting.space/download.php?f=spbjt&name=2016-02-07_22-19-30.mp4

This is the correct way to do it regardless. Impulse is handled automatically by the engine and therefore will network and predict more properly than arbitrary velocity. I updated the link in my post up higher. I blame all our roadblocks along the way to the fact that this weapon was really badly made to begin with.

Ahh, I see. That's a useful thing to know! I guess the only real benefit over the projectile collision method is that you could make the push-back distance a changeable in-game pref.

I blame all our roadblocks along the way to the fact that this weapon was really badly made to begin with.
lol. It could have been better. Thanks for your time and sorting this out.

ALMOST exactly what I wanted, but I still wanted it to bounce since that's how I came up with my idea in the first place of a bouncing pushing laser

So I was wrong at first. Turns out that packaging the onCollision function makes torque hiccup and ignore the impulse on the projectile. I fixed the code again, and now it really does work.... without having to apply velocity to the target.

http://justfilehosting.space/download.php?f=spbjt&name=2016-02-07_22-19-30.mp4

This is the correct way to do it regardless. Impulse is handled automatically by the engine and therefore will network and predict more properly than arbitrary velocity. I updated the link in my post up higher. I blame all our roadblocks along the way to the fact that this weapon was really badly made to begin with.
Ahh, I see. That's a useful thing to know! I guess the only real benefit over the projectile collision method is that you could make the push-back distance a changeable in-game pref.
lol. It could have been better. Thanks for your time and sorting this out.

So I only looked at it briefly but I'm gonna wager that the heart of this mystery is that everyone was either leaving the last argument off the onCollision definition, or left it off when calling the parent, like here

function Proto17Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal,%velocity) <--
{
   serverPlay3D(Proto17BounceSound,%pos);

       if(%col.getClassName() $= "Player" || %col.getClassName() $= "AIPlayer")
               %col.setVelocity(VectorAdd(%col.getVelocity(),VectorScale(%velocity,"4")));

   return Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal); <--
}

Incidentally, the projectile has to be within its arming delay to bounce without exploding.


ALMOST exactly what I wanted, but I still wanted it to bounce since that's how I came up with my idea in the first place of a bouncing pushing laser

Bump up the arming delay in the projectile to match the lifetime. Looks like the bounce elasticity and friction are set right. Need to flag "explodeOnPlayerImpact" for it to hit players properly. You'll also probably want to set "bounceExplosion" to the one that's currently playing the bounce sound for that to work properly.

perfect, that worked! thanks
I also upped the damage from 5 to 10 since I realized 20 hits to kill was way too much
https://www.dropbox.com/s/g8s99w0do2dwmg8/Weapon_Proto17.zip?dl=1