Mere_Duke, on 21 February 2018 - 01:44 PM, said:
@Trooper Dan
Nope, it works differenty. I'll try to explain in details. When the actor faces the situation when distance from the floor is more than 320, it starts falling and goes to the 1st frame of DYING animation. It continues to fall (dying anim constantly resets to its start frame), and when floordistance is less than 8, it checks with getzrange if the picnum below is a water. If not, then it "releases" DYING animation, and the actor is dying normally. If it is water below, it changes DYING anim to a "zero ai" or default STANDING action, and actor becomes alive, and behaves normally. Everything is ok except that in the case 2, if I kill that actor after he has fallen and was saved by water, he plays "squish" sound on death in addition to normal dying yell.
And I can't understand how "fall" works. I know of "htcgg", but sometimes actors fall faster or slower, in different situations. For example, my test actor is falling to the ground much slower, than to the water. (Probably smth related to the sectors? Idk)
First, your sound bug: it is likely that the actor is falling on a water
texture, but the sector was not actually lotag 1 (water sector). Thus, as far as the game is concerned, he fell on a regular floor and not water. I don't know where the falling death data is getting saved in the sprite structure, but clearly it is.
Second, your method is very complicated and will probably give you the wrong result in some situations. The easiest way to tell if an actor is falling is to simply check their zvel (positive means falling). I would try something like this:
gamevar falltime 0 2
define FALLDAMAGETIME 24 // number of tics of falling before landing will hurt
define FALLDAMAGEMULT 3
state fallaction
// this is a placeholder state for changing the actor's action appropriately
// you will want to change the action to the falling action when falltime >= FALLDAMAGETIME
ends
state checkfall
ifg sprite[].zvel 0
{
add falltime 1
state fallaction
}
else
{
ifg falltime FALLDAMAGETIME
{
ifonwater
nullop
else
ifinwater
nullop
else
{
sub falltime FALLDAMAGETIME
mul falltime FALLDAMAGEMULT
seta[].htextra falltime
seta[].htpicnum KNEE
seta[].htowner THISACTOR
sound SQUISHED
guts JIBS6 4 // or whatever you want
}
}
set falltime 0
}
ends
The idea is that you want the actor to use the checkfall state whenever he's not already dead. It will determine whether he is falling, count how long he has been falling and apply damage depending on the length of the fall once he hits ground. It will not apply damage if he falls on a water sector.