Author Topic: Death System  (Read 451 times)

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Death System
« on: October 30, 2010, 03:20:48 pm »


               Ok more help needed,

i am using this script to drop equiped items to a placable corpse on death and works just fine problem is i dont want it to check for creature items skins etc, as is every now and then it drops creature skin etc to corpse

#include "color_include"

void main()
{
object oPC = GetLastPlayerDied();
if (!GetIsPC(oPC)) return;
int xCount, xGold;
  object xPC, xCorpse, xItem;
  location xLoc;
  //Get player and find locations
  xPC = GetLastPlayerDied();
  xLoc = GetLocation(xPC);
  //Create corpse at player's feet
  xCorpse = CreateObject(OBJECT_TYPE_PLACEABLE,"sc_corpse",xLoc);
  //Drop equipment on corpse
  for (xCount = 0; xCount < NUM_INVENTORY_SLOTS; xCount++)
  {
  xItem=GetItemInSlot(xCount, xPC);
  AssignCommand(xCorpse,ActionTakeItem(xItem,xPC));
  }
/////Now drop player's gold.//////
  // xGold = (GetGold(xPC));
  //  AssignCommand(xCorpse, TakeGoldFromCreature(xGold,xPC,TRUE));
  // CreateItemOnObject ("nw_it_gold001", xCorpse, xGold);
//////////////////////////////////
DelayCommand(2.0,  FloatingTextStringOnCreature(PALEBLUE+"You have died. You're belongings have been dropped on the floor.", oPC));
DelayCommand(4.0,  FloatingTextStringOnCreature(PALEBLUE+"you can either respawn or wait to bo rescued from another player.", oPC));

DelayCommand(8.0, PopUpGUIPanel(oPC,GUI_PANEL_PLAYER_DEATH));
}


I found this in my loot system and prevents this happening when loot is droped to pc inventory but dont know how to merge these

//Get items in slots
    for (nCounter = 0; nCounter <= NUM_INVENTORY_SLOTS; nCounter++)
        {
        //Skip creature items
        if(nCounter != INVENTORY_SLOT_CARMOUR &&
           nCounter != INVENTORY_SLOT_CWEAPON_B &&
           nCounter != INVENTORY_SLOT_CWEAPON_L &&
           nCounter != INVENTORY_SLOT_CWEAPON_R)
           {
            oItem = GetItemInSlot(nCounter, OBJECT_SELF);
            if(GetIsObjectValid(oItem))
 
                {
                ActionGiveItem(oItem, oPC);
                }


thanks in advance
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Death System
« Reply #1 on: October 30, 2010, 03:28:49 pm »


               Make the skin plot and have it only drop items that are nonplot.
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Death System
« Reply #2 on: October 30, 2010, 03:31:40 pm »


               i was hoping to be able to merge these two, as players may be using plot items, and would not be dropped.
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Death System
« Reply #3 on: October 30, 2010, 03:57:46 pm »


               All i need is ondeath create a placable, stip all equiped items from dead players inventory except creature items, delay abit, float some txt, delay again then pop the death gui.  I know what i need but suck at scripting '<img'>
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Death System
« Reply #4 on: October 30, 2010, 05:42:32 pm »


               Give this a try. It should do the trick. The posted script was a bit confusing to read(all ints, objects and locs used an "x" naming convention. Should do something specific for each one to recognize what it is. Most people use "o" for object, "l" for location and "n" or "i" for integers.) so I altered for the purpose of this post. Also took out a bit of redundancy. You were defining the player who died twice.


#include "color_include"

void main()
{
    //Get the player
    object oPC = GetLastPlayerDied();
    //Make sure the object that died is actually a player character. If not,
    //reutrn.
    if (!GetIsPC(oPC)) return;
    int nCount, nGold;
    object oCorpse, oItem;
    location lLoc = GetLocation(oPC);
    //Create corpse at player's feet
    oCorpse = CreateObject(OBJECT_TYPE_PLACEABLE,"sc_corpse",lLoc);
    //Drop equipment on corpse
    for (nCount = 0; nCount < NUM_INVENTORY_SLOTS; nCount++)
    {
    //Skip creature items
        if(nCount != INVENTORY_SLOT_CARMOUR &&
           nCount != INVENTORY_SLOT_CWEAPON_B &&
           nCount != INVENTORY_SLOT_CWEAPON_L &&
           nCount != INVENTORY_SLOT_CWEAPON_R)
        {
            oItem = GetItemInSlot(nCount, oPC);
            if(GetIsObjectValid(oItem))
                {
                AssignCommand(oCorpse,ActionTakeItem(oItem,oPC));
                }
        }
    }
    /////Now drop player's gold.//////
    //nGold = (GetGold(oPC));
    //AssignCommand(oCorpse, TakeGoldFromCreature(nGold,oPC,TRUE));
    //CreateItemOnObject ("nw_it_gold001", oCorpse, nGold);
    //////////////////////////////////
    DelayCommand(2.0, FloatingTextStringOnCreature(PALEBLUE+"You have died. You're belongings have been dropped on the floor.", oPC));
    DelayCommand(4.0, FloatingTextStringOnCreature(PALEBLUE+"you can either respawn or wait to bo rescued from another player.", oPC));
    DelayCommand(8.0, PopUpGUIPanel(oPC,GUI_PANEL_PLAYER_DEATH));
}

Hope that works for ya. Good luck.
               
               

               


                     Modifié par GhostOfGod, 30 octobre 2010 - 05:03 .
                     
                  


            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Death System
« Reply #5 on: October 30, 2010, 06:11:05 pm »


               i have just tested this and it dont drop anything to corpse, dead player still has all gear.



This script works but sometime you get pc properties etc in corpse and cannot remove it



#include "color_include"





void main()

{

object oPC = GetLastPlayerDied();



if (!GetIsPC(oPC)) return;



int xCount, xGold;

 object xPC, xCorpse, xItem;

 location xLoc;

 //Get player and find locations

 xPC = GetLastPlayerDied();

 xLoc = GetLocation(xPC);

 //Create corpse at player's feet

 xCorpse = CreateObject(OBJECT_TYPE_PLACEABLE,"sc_corpse",xLoc);

 //Drop equipment on corpse

 for (xCount = 0; xCount < NUM_INVENTORY_SLOTS; xCount++)

 {

 xItem=GetItemInSlot(xCount, xPC);

 AssignCommand(xCorpse,ActionTakeItem(xItem,xPC));

 }



/////Now drop player's gold.//////

 // xGold = (GetGold(xPC));

 //  AssignCommand(xCorpse, TakeGoldFromCreature(xGold,xPC,TRUE));

 // CreateItemOnObject ("nw_it_gold001", xCorpse, xGold);

//////////////////////////////////



DelayCommand(2.0,  FloatingTextStringOnCreature(PALEBLUE+"You have died. You're belongings have been dropped on the floor.", oPC));

DelayCommand(4.0,  FloatingTextStringOnCreature(PALEBLUE+"you can either respawn or wait to bo rescued from another player.", oPC));





DelayCommand(8.0, PopUpGUIPanel(oPC,GUI_PANEL_PLAYER_DEATH));



}



               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Death System
« Reply #6 on: October 30, 2010, 06:18:24 pm »


               ok it works, for some reason the line AssignCommand(oCorpse,ActionTakeItem(oItem,oPC)); was commented out.... so thanks for all your help and i will test some more '<img'>