Breakable Actor

From EDukeWiki
Revision as of 16:37, 7 January 2013 by High Treason (talk | contribs)
Jump to navigation Jump to search

Breakable actors are objects in the game which break - that is to say, spawn debris and disappear - when hit by a weapon. The debris could be a material, such as glass shards, or it could be gore. Hardcoded examples are sprites like BOTTLE1.

This article assumes that you have already added the art or models you wish to use, if you have not yet done so, see DEF Language. In this example the actor's tile number is 5124, but you should change this as required.


Firstly, you need to define your actor. Add the following to the bottom of user.con;

define BREAKABLE1 5124  // This means Tile 5124 can now be referred to as BREAKABLE1 in your code


Now you need to decide what you want it to do when it is hit by a weapon, if you want it to spawn generic debris then add the following below your define;

useractor notenemy BREAKABLE1  // Your actor's code starts here
  cstat 257  // Makes sure you can hit the actor
  ifhitweapon  // Has a weapon hit the actor?
  {
    sound VENT_BUST  // Makes a noise when you break it
    debris SCRAP1 4  // These determine what type of debris to spawn and how much
    debris SCRAP2 4 
    debris SCRAP3 4 
    debris SCRAP4 4 
    debris SCRAP5 4 
    debris SCRAP6 4 
    killit  // Removes the actor from the map
  }
enda  // Your actor's code ends here


Of course, you can make the actor spawn glass by using lotsofglass instead of the debris command;

useractor notenemy BREAKABLE1
  cstat 257
  ifhitweapon
  {
    sound GLASS_HEAVYBREAK
    lotsofglass 30  // Spawns 30 glass shards
    killit
  }
enda


The other option is to spawn jibs (blood and guts) using the guts command;

useractor notenemy BREAKABLE1
  cstat 257
  ifhitweapon
  {
    sound SQUISHED
    guts JIBS1 3  // Spawns 3 of this type of jib
    guts JIBS2 3
    guts JIBS3 3
    guts JIBS4 3
    guts JIBS5 3
    killit
  }
enda

Notes;

  • You could combine more than one effect, spawning guts and debris at the same time for example, or spawn nothing at all.
  • If you are copying this code, make sure you do not set up your actor more than once, there should be only one useractor notenemy BREAKABLE1 line and a single enda line per actor.
  • A full list of sounds can be found on the infosuite.
  • You may also be interested in the ifwasweapon command to make your actor's behaviour more specific.
  • If you are unsure about what is happening in the code, try typing each command used into the search bar.