Breaking stuff when you fall on them
#1 Posted 23 October 2017 - 10:38 AM
An example:
When the player falls into a Vent, i want the Vent to Break once the Player falls onto it
#2 Posted 23 October 2017 - 10:58 AM
I Never tried it but I believe it should work.
When player impact when he falls he make sound of boots hitting ground when you fall from a certain height.
Let say
-----------
useractor notenemy BREAKABLE_VENT
getactor[THISACTOR].sectnum temp
getplayer[THISACTOR].cursectnum temp2
ifvarvare temp temp2
{
ifpdistl 700
{
ifsound DUKE_LAND
{
sound VENT_BUST
debris SCRAP1 3
debris SCRAP2 2
killit
}
}
}
ifhitweapon
{
sound VENT_BUST
debris SCRAP1 3
debris SCRAP2 2
killit
}
enda
---------------
ifpdist is vital so if you're far from it and you fall it doesn't break it.
if the distance 700 is too low, rise it a bit.
*
getactor[THISACTOR].sectnum temp
getplayer[THISACTOR].cursectnum temp2
ifvarvare temp temp2 { othercodes inside }
*Code is to make that it only works if the player is in the same sector as the sprite.
PS
My mod has a scene you carry hydrazine hydrate.
Stuff is soo sensitive that if you fall and impact, it blows the player to pieces.
uses the ifsound PLAYERIMPACTSOUND { *explosion event code* }
This post has been edited by Zaxtor: 23 October 2017 - 11:00 AM
#3 Posted 23 October 2017 - 11:02 AM
Someone else might be able to chime in with a good way to detect when the player hits the ground.
#4 Posted 23 October 2017 - 11:06 AM
There is a thing that works on sprites when it falls to the floor "Iffloordistl xx { killit }" thing like my mod has some tiles that falls and break.
And the thing if a player falls from a great height it hurts him/her.
But I dunno if there's code to work the other way around.
if a player falls a certain height on a sprite it will break it.
This post has been edited by Zaxtor: 23 October 2017 - 11:07 AM
#5 Posted 23 October 2017 - 11:19 AM
#6 Posted 23 October 2017 - 11:36 AM
You can use this to get the sprite id of whatever the player is standing on; in this case, you can check to see if it's the grate actor and then manually try damaging it. don't have time to try it myself at this moment but I'll give it an attempt if you can't figure it out tomorrow.
#7 Posted 23 October 2017 - 11:39 AM
cus at 8 it will do some dmg.
This post has been edited by Zaxtor: 23 October 2017 - 11:40 AM
#8 Posted 23 October 2017 - 12:20 PM
Jblade, on 23 October 2017 - 11:36 AM, said:
You can use this to get the sprite id of whatever the player is standing on; in this case, you can check to see if it's the grate actor and then manually try damaging it. don't have time to try it myself at this moment but I'll give it an attempt if you can't figure it out tomorrow.
Yeah you could have the player save his poszv from the previous tic, if that value is > a certain number and he is currently on a sprite bridge, then apply damage to the sprite bridge. The downside is that he won't retain any momentum, he will stop on the sprite, then it will break. To sustain momentum you have to detect the sprite below the player before he lands on it and break it right before he lands.
#9 Posted 23 October 2017 - 11:46 PM
Might have a go at this later, can't right now, but I've got a few ideas.
Hendricks266, on 23 October 2017 - 11:02 AM, said:
Ah... right...
Walks away whistling suspiciously. To be fair, I'd never use this method in serious code, I'd probably come up with something worse instead.
Edit: Working on an attempt using "falling_counter" and some simple math.
This post has been edited by High Treason: 24 October 2017 - 12:10 AM
#10 Posted 24 October 2017 - 12:53 AM
EDUKE.CON (2.06K)
Number of downloads: 143
Here, this uses player position and falling_counter structure members to do it's thing. It assumes the sprite you're hitting has blocking on and turns it off (it will mess up if you don't have the sprite set to blocking) and it only works for PANEL1, but it should give you an idea of what's going on. A fall slightly from higher than a normal jump from the sprite will break it, see "ifvarg PL_FC 4" in the code and increase it to set a longer fall. You could probably make my state more flexible and improve it in a number of ways, we already know how flaky my coding is, but this proves it is at least possible.
As a testament to my incompetence, most of my time was taken trying to figure out why nothing was working, even deliberate errors caused no effect... I was working in a file called "EDUKE.CIN" and had not noticed... could have been worse I suppose, at least I didn't break anything too badly.
This post has been edited by High Treason: 24 October 2017 - 01:05 AM
#11 Posted 24 October 2017 - 03:23 PM
High Treason, on 24 October 2017 - 12:53 AM, said:
EDUKE.CON
Here, this uses player position and falling_counter structure members to do it's thing. It assumes the sprite you're hitting has blocking on and turns it off (it will mess up if you don't have the sprite set to blocking) and it only works for PANEL1, but it should give you an idea of what's going on. A fall slightly from higher than a normal jump from the sprite will break it, see "ifvarg PL_FC 4" in the code and increase it to set a longer fall. You could probably make my state more flexible and improve it in a number of ways, we already know how flaky my coding is, but this proves it is at least possible.
As a testament to my incompetence, most of my time was taken trying to figure out why nothing was working, even deliberate errors caused no effect... I was working in a file called "EDUKE.CIN" and had not noticed... could have been worse I suppose, at least I didn't break anything too badly.
Gonna try this and probably make some modifications, i couldn't make it work on my own so the script was a big mess that i assure you, you don't want to see it.