Thread: Naked Corpses
View Single Post
  #4  
Old 10-12-2006, 06:21 AM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

I've been bouncing back to this concept between server explosions, and wanted to pose a quick concept to get feedback from devs or others on a possible way to make this work. In attack.cpp, there is a section of code regarding client death that checks the value of variables "leavecorpses". If it's set to any positive value, a corpse is generated and items are moved to the corpse, etc.

I was thinking of changing this to a switch (leavecorpses) which will check for a default case, then 1 or 2 for values which cause the corpse generation to behave differently. 1 = normal, drop corpse, move items to corpse. 2 = drop corpse, leave items on player, allow corpse rez to recover xp like normal.

Current code:
Code:
// check db variable 'leavecorpses'
char tmp[20] = {0};
database.GetVariable("leavecorpses", tmp, 20);
int leavecorpses = atoi(tmp);
if(leavecorpses)
{
  // creating the corpse takes the cash/items off the player too
			Corpse *new_corpse = new Corpse(this, exploss);
Concept code:
Code:
// check db variable 'leavecorpses'
char tmp[20] = {0};
database.GetVariable("leavecorpses", tmp, 20);
int leavecorpses = atoi(tmp);
switch (leavecorpses)
{
  case 1:
    // creating the corpse takes the cash/items off the player too
    Corpse *new_corpse = new Corpse(this, exploss);
    break;
  case 2:
    // creating the corpse leaving the cash/items on the player
    Corpse *new_naked_corpse = new Corpse(this, exploss);  // or whatever
    break;
  default:
    // just to normal, no corpse death routine
}
(I haven't verified the syntax of the switch/case yet, so forgive if it's wrong)

Does this make sense? And, are there any long-term issues you might see with adding this functionality? I've grep'd the code for where the database lookup occurs, and it only seems to be in attack.cpp. I realize a new routine would probably also need to be added like Corpse *new_naked_corpse = new Corpse(this, exploss); or something that will generate the new corpse, naked, and leave you with your gear like leavecorpses = 0 does.

Any advice would be welcome. I am working out the code now and will test it before posting here.

TIA,
J
Reply With Quote