Duke4.net Forums: Hurt Floors - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Hurt Floors  "Questions on how to make a damaging floor like the FLOORSLIME"

User is offline   HELLMOUSE 

#1

Does anyone know how to make a hurt floor? Something like the FLOORSLIME and then something like the PURPLELAVA. There's nothing in the GAME.CON as an example.

This post has been edited by HELLMOUSE: 28 July 2020 - 06:45 PM

0

User is offline   Jimmy 

  • Let's go Brandon!

#2

It's hardcoded into the game. It can certainly be replicated. Not sure how offhand though.
1

#3

Can't really test this code right now, but stuffing this into a CON file should work;

gamevar PL_TEMP 0 1
gamevar PL_HFTP 0 1

state MYHURTFLOOR
ifrnd 6  // Range 0-255, increase number for more frequent damage, decrease for less frequent damage
{
  addphealth -5  // Removes 5 health

  ifvare PL_HFTP 0  // If electric floor
  {
  palfrom 40 12 12 40  // Flashes screen blue
  sound 21 // Short circuit
  soundonce 211  // Play Duke's gasping pain noise
  }

  ifvare PL_HFTP 1  // If generic floor
  {
  palfrom 40 40 0 0  // Flashes screen red
  soundonce 211  // Play Duke's gasping pain noise
  }

  ifvare PL_HFTP 2  // If alien floor
  {
  palfrom 40 8 40 0  // Flashes screen green
  soundonce 163  // Slimy noises
  soundonce 211  // Play Duke's gasping pain noise
  }

  ifvare PL_HFTP 3  // If burning floor
  {
  palfrom 40 40 32 0  // Flashes screen orange
  soundonce 68  // Burning noises
  soundonce 211  // Play Duke's gasping pain noise
  }

}
ends



onevent EVENT_GAME
ifactor APLAYER
{
  iffloordistl 1 // Is the player on the floor?
  {
  getsector[THISACTOR].floorpicnum PL_TEMP // Get the floor tile number. 
  ifvare PL_TEMP 230 { setvar PL_HFTP 0 state MYHURTFLOOR }  // Use tile 230 as electric hurtfloor
  ifvare PL_TEMP 331 { setvar PL_HFTP 1 state MYHURTFLOOR }  // Use tile 331 as generic hurtfloor
  ifvare PL_TEMP 803 { setvar PL_HFTP 2 state MYHURTFLOOR }  // Use tile 803 as alien hurtfloor
  ifvare PL_TEMP 899 { setvar PL_HFTP 3 state MYHURTFLOOR }  // Use tile 899 as burning hurtfloor
  // Add as many of those as you want...
  }
// ...and you can put some here if you want it to still damage when player is above floor.
// You could also use other things to set PL_TEMP here, like the ceiling or whatever.
}
endevent


Obviously you should probably change the tile numbers (ifvare PL_TEMP ####) to something better.
2

User is online   Danukem 

  • Duke Plus Developer

#4

Ideally you would want it to hurt immediately when the player lands on it, then once per second or so on a timer instead of randomly. You also want to check for whether player has boots and deduct from those instead of hurting player if they are owned, and finally you need to check for whether player is on a sprite bridge, because currently the player will take damage on a sprite bridge that is above the hurt floor.
2

User is offline   HELLMOUSE 

#5

Thanks for the code and advice. :)

getsector[THISACTOR].floorpicnum PL_TEMP is the most important part.

I've been experimenting but I'm not sure what the "event" is about. Does it need to be in an event?

gamevar HURT_FLOOR_TILE 0 1 is outside of the actor somewhere else

Here is a very basic block of code under the APLAYER actor that I made and tested successfully:

ifvare HURT_FLOOR_TILE 5641
  iffloordistl 1
    ifrnd 32
      addphealth -1


How do you account for a sprite bridge anyway?

This post has been edited by HELLMOUSE: 31 July 2020 - 12:05 PM

0

User is online   Danukem 

  • Duke Plus Developer

#6

That code does not need to be in that event, it can be in the player actor instead. The advantage in this case of providing code in the event is it makes the code more portable (especially if appendevent is used instead of onevent).

Also see this for sprite bridge info: https://wiki.eduke32...ki/Spritebridge
1

User is offline   HELLMOUSE 

#7

Thanks for the help. :)
There still is some code that I'll add such as for quotes and screen flashes.

// This goes into names.h
#define KAILK 5641


// This goes into DEFS.CON
define KAILK 5641


// This goes above the APLAYER actor code 
gamevar DUKE_STAT 0 1 			// used to manipulate Duke's struct data

// **** Negative Value Protection (NVP) ****
// what happens if Duke's shield goes negative?  The steriods pop-up in the HUD
// To prevent the computer getting confused, just set the value to 0.

state NVP
  ifvarl DUKE_STAT 0 setvar DUKE_STAT 0
ends


// This goes below the APLAYER actor code
// **** Hurt Floor ****
// Help from High Treason and  Danukem

getsector[].floorpicnum HURT_FLOOR_TILE		 // Under Duke's code this checks to see what floor tile he is on. 
ifvare HURT_FLOOR_TILE 5641			 // If Duke is in a sector with this floor tile then... But if he is not then do nothing
{
  getplayer[].spritebridge IS_ON_SPRITEBRIDGE	 // Is Duke on a Sprite Bridge?
  ifvare IS_ON_SPRITEBRIDGE 0			 // If he is then do nothing.  If he is not (IS_ON_SPRITEBRIDGE = 0)...
    iffloordistl 32				 // Is he too close?  If he is... But if he is not then do nothing
    {
      getplayer[].boot_amount DUKE_STAT		 // Load Boot Amount into DUKE_STAT
      ifvarg DUKE_STAT 0			 // If Duke has Boots then subtract from them at... But if does not then else
      { 
        ifrnd 4 				 // "Frequency" of 4 out of 255 times...    
        { 
           subvar DUKE_STAT 1  			 // subtract 1 from DUKE_STAT (Boots)
           state NVP		 		 // Just in case DUKE_STAT (Boots) goes negative, set to 0
           setplayer[].boot_amount DUKE_STAT     // Set Boot Amount to new value 
        } 
      }  
      else					 // (else) If Duke does not have Boots then subtract from Shield or Health
      {						
        getplayer[].shield_amount DUKE_STAT	 // Load Shield Amount into DUKE_STAT
        ifvarg DUKE_STAT 0 			 // If Duke has a Shield then subtract from it at... But if does not then else
        { 
          ifrnd 4				 // "Frequency" of 4 out of 255 times...
          { 
             subvar DUKE_STAT 1  		 // subtract 1 from DUKE_STAT (Shield)
             state NVP			 	 // Just in case DUKE_STAT (Shield) goes negative, set to 0
             setplayer[].shield_amount DUKE_STAT // Set Shield Amount to new value
          } 
        }
        else 					 // (else) If Duke does not have a Shield then... 
          ifrnd 8				 // "Frequency" of 8 out of 255 times... 
            addphealth -1			 // add a negative to Duke's Health (subtract 1)
      }
    }
}


As for tile 5641 use your imagination.

This post has been edited by HELLMOUSE: 02 August 2020 - 10:56 AM

0

User is online   Danukem 

  • Duke Plus Developer

#8

For comparison, here is code that I currently use in WGR:


switch sector[player[].cursectnum].floorpicnum // check floor type
case 4820
case 4085
ifvarand player[].player_par 1
{
	getflorzofslope player[].cursectnum player[].posx player[].posy z
	subvarvar z player[].posz
	ifvarl z 10240
	{
		ifvarg player[THISACTOR].boot_amount 0
		{
			soundonce ENVSUIT
			getp[].boot_amount temp
			subvar temp 1
			setp[].boot_amount temp
		}
		else
		{
			addphealth -1
			palfrom 40 50 15 15
			state dukepainsounds
			addvar burning 2
		}
	}
}	
break
endswitch



Notice that if you check the real floor height directly with getflorzofslope, then there is no need to check whether the player is on a sprite bridge. Although I suppose if the mapper put the sprite bridge right on the actual floor, then that would cause a problem because you would still take damage if on the bridge. If WG had an area like that I would need to add an extra check. In my code, I have it causing damage every other tic, so you will take 15 damage per second if not protected by boots. If you want to make this slower but not random, you can either add a separate var countdown timer, or you could use modvar #numtics on player_par and then do damage when the remainder is 0. One last thing to note is that typically the player's posz is 8192 build z units above the floor, so while the code above may look like damage ensues when the player is within 10240 of the floor, it's actually the much smaller distance of 2048.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options