Cuberite Forum
Destructionless Explosions? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Destructionless Explosions? (/thread-1637.html)



Destructionless Explosions? - DiamondToaster - 10-27-2014

Hi, I'm a bit of a noob here, but I'm attempting to make a rocket jump plugin (Search TF2 rocketjump if you don't know what I mean). I have everything working perfectly, except the terrain being destroyed. Is there a way to create an explosion that still has significant knockback, but doesn't alter terrain? The only way i could think of doing this is spawning a primed TNT, reading the block type of a 3x3x3 cube around the TNT, setting that as water, then afterwards set those blocks back. Unfortunately, I found this to be incredibly unreliable and only works about 30% of the time. I would HIGHLY appreciate any suggestions.


RE: Destructionless Explosions? - NiLSPACE - 10-27-2014

You can use the OnExploding hook to stop explosions. You just have to check if you're stopping the correct explosion.


RE: Destructionless Explosions? - DiamondToaster - 10-27-2014

The problem is that I want the explosion because they cause a large amount of player knockback. The player is able to throw snowballs and use them as "rockets" to hurt others or to propel himself in the air. I just can't find a way to make an explosion that still hurts the player and sends him flying, but Don't damage the terrain. I tried to use the OnExploding hook to restore that segment of the terrain but it turned out to be unreliable.


RE: Destructionless Explosions? - NiLSPACE - 10-27-2014

Oh I forgot that the knockback would be gone as well. Sorry Wink.

You can use cPlayer:SetSpeed to make a player move somewhere. You could (if you want) use cWorld:BroadcastSoundEffect("random.explode", PosX, PosY, PosZ, 1, 1) to make the particles and explosion noise appear as well.


RE: Destructionless Explosions? - DiamondToaster - 10-27-2014

No problem. Tongue

That sounds like a pretty good idea. So what I would do is essentially create a speed vector using the Player position and the explosion site?


RE: Destructionless Explosions? - xoft - 10-27-2014

I'd go about it that way as well - do not actually use explosions, but simulate them by setting the nearby players' speed and perhaps sending the particles. There is currently no way to stop an explosion from destructing terrain, other than removing the explosion altogether.


RE: Destructionless Explosions? - DiamondToaster - 10-27-2014

Ok, I'll do that and see how it turns out. Thanks for the replys. Smile


RE: Destructionless Explosions? - NiLSPACE - 10-27-2014

No you could do it like this:
Player:SetSpeedY(5) -- 5 might not be a good number to use here. You probably have to play around with it for a bit.
local Pos = Player:GetPosition()
Player:GetWorld:BroadcastSoundEffect("random.explode", Pos.x, Pos.y, Pos.z, 1, 1)
Now the server says: "Jump 5 blocks up and create some particles + sounds", but the physics for players isn't properly handled for players yet. That's why you have to play around with the SetSpeedY parameter Smile


RE: Destructionless Explosions? - DiamondToaster - 10-27-2014

Finally finished it, it turned out pretty good. Big Grin
I even got the particles and sounds to work. I might post it in Plugin Releases.