Aller au contenu

Photo

Item Stripping Script Not Working As It Should


  • Veuillez vous connecter pour répondre
14 réponses à ce sujet

#1
MokahTGS

MokahTGS
  • Members
  • 946 messages

//***************************************************************************//
//                         ITEM STRIPPER                                     //
//                                                                           //
//                  created by Darkleaf/Philip                               //
//                  philip_schouten@hotmail.com                              //
//***************************************************************************//
//                                                                           //
//              Comment in and out what you need.                            //
//      Don't change anything unless you know what you're doing.             //
//                                                                           //
//***************************************************************************//

void main()
{
object oPC = GetEnteringObject();
int nStripped = GetLocalInt(oPC, "stripped");

if ((GetIsPC(oPC))&&(nStripped!=1))
    {
    // Set the integer for stripping once
    SetLocalInt(oPC, "stripped", 1);

    /*Remove Gold   -   Default at destroy all*/

    TakeGoldFromCreature(GetGold(oPC), oPC, TRUE);
    GiveGoldToCreature(oPC, 500);

    /*Remove XP or give XP  -Default at 0
    To give XP: levels are the following:
    LVL 1:  0           LVL 11: 55000       LVL 21: 210000
    LVL 2:  1000        LVL 12: 66000       LVL 22: 231000
    LVL 3:  3000        LVL 13: 78000       LVL 23: 253000
    LVL 4:  6000        LVL 14: 91000       LVL 24: 276000
    LVL 5:  10000       LVL 15: 105000      LVL 25: 300000
    LVL 6:  15000       LVL 16: 120000      LVL 26: 325000
    LVL 7:  21000       LVL 17: 136000      LVL 27: 351000
    LVL 8:  28000       LVL 18: 153000      LVL 28: 378000
    LVL 9:  36000       LVL 19: 171000      LVL 29: 406000
    LVL 10: 45000       LVL 20: 190000      LVL 30: 435000*/
    //Change the 0 in anything

    //if(GetXP(oPC) < 10000) SetXP(oPC, 10000);
    SetXP(oPC, 10000);

    /*Destroy all items on the PC   -   Default destroys everything*/

    //Chest item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC), 0.0);
    //Creature armor item. Might not be necesarry but is possibly equiped.
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC), 0.0);
    //Arms item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_ARMS, oPC), 0.0);
    //Left hand item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC), 0.0);
    //Lef hand ring item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_LEFTRING, oPC), 0.0);
    //Right hand item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC), 0.0);
    //Right hand ring item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oPC), 0.0);
    //Neck item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_NECK, oPC), 0.0);
    //Head item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_HEAD, oPC), 0.0);
    //Creaure weapon item bite. Might not be necesarry but is possibly equiped.
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oPC), 0.0);
    //Creaure weapon item left hand. Might not be necesarry but is possibly equiped.
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_CWEAPON_L, oPC), 0.0);
    //Creaure weapon item right hand. Might not be necesarry but is possibly equiped.
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_CWEAPON_R, oPC), 0.0);
    //Cloak item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC), 0.0);
    //Belt item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_BELT, oPC), 0.0);
    //Arrows item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_ARROWS, oPC), 0.0);
    //Bolts item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_BOLTS, oPC), 0.0);
    //Bullets item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_BULLETS, oPC), 0.0);
    //Boots item
    DestroyObject(GetItemInSlot(INVENTORY_SLOT_BOOTS, oPC), 0.0);

    /*Create items on the PC. Put the resref in the commands.*/

    //Chest item
    object oChest = CreateItemOnObject("jw_travelers_armor", oPC, 1);
    //Arms item
    object oArms = CreateItemOnObject("resref", oPC, 1);
    //Right hand item
    object oRightHand = CreateItemOnObject("resref", oPC, 1);
    //Right hand ring item
    object oRightRing = CreateItemOnObject("resref", oPC, 1);
    //Left hand item
    object oLeftHand = CreateItemOnObject("resref", oPC, 1);
    //Left hand ring item
    object oLeftRing = CreateItemOnObject("resref", oPC, 1);
    //Cloak item
    object oCloak = CreateItemOnObject("resref", oPC, 1);
    //Neck item
    object oNeck = CreateItemOnObject("resref", oPC, 1);
    //Head item
    object oHead = CreateItemOnObject("resref", oPC, 1);
    //Boots item
    object oBoots = CreateItemOnObject("resref", oPC, 1);
    //Arrows item
    object oArrows = CreateItemOnObject("resref", oPC, 99);
    //Bolts item
    object oBolts = CreateItemOnObject("resref", oPC, 99);
    //Bullets item
    object oBullets = CreateItemOnObject("resref", oPC, 99);
    //Creature bite item
    object oCBite = CreateItemOnObject("resref", oPC, 1);
    //Creature left hand item
    object oCLeft = CreateItemOnObject("resref", oPC, 1);
    //Creature right hand item
    object oCRight = CreateItemOnObject("resref", oPC, 1);
    //Creatue armour
    object oCArmour = CreateItemOnObject("resref", oPC, 1);
    //Belt item
    object oBelt = CreateItemOnObject("resref", oPC, 1);

    /* Equip items on the PC */

    //Equip chest item
    AssignCommand(oPC, ActionEquipItem(oChest, INVENTORY_SLOT_CHEST));
    //Equip arms item
    AssignCommand(oPC, ActionEquipItem(oArms, INVENTORY_SLOT_ARMS));
    //Equip right hand item
    AssignCommand(oPC, ActionEquipItem(oRightHand, INVENTORY_SLOT_RIGHTHAND));
    //Equip right hand ring item
    AssignCommand(oPC, ActionEquipItem(oRightRing, INVENTORY_SLOT_RIGHTRING));
    //Equip left hand item
    AssignCommand(oPC, ActionEquipItem(oLeftHand, INVENTORY_SLOT_LEFTHAND));
    //Equip left hand ring item
    AssignCommand(oPC, ActionEquipItem(oLeftRing, INVENTORY_SLOT_LEFTRING));
    //Equip cloak item
    AssignCommand(oPC, ActionEquipItem(oCloak, INVENTORY_SLOT_CLOAK));
    //Equip neck item
    AssignCommand(oPC, ActionEquipItem(oNeck, INVENTORY_SLOT_NECK));
    //Equip head item
    AssignCommand(oPC, ActionEquipItem(oHead, INVENTORY_SLOT_HEAD));
    //Equip boots item
    AssignCommand(oPC, ActionEquipItem(oBoots, INVENTORY_SLOT_BOOTS));
    //Equip arrows
    AssignCommand(oPC, ActionEquipItem(oArrows, INVENTORY_SLOT_ARROWS));
    //Equip bolts
    AssignCommand(oPC, ActionEquipItem(oBolts, INVENTORY_SLOT_BOLTS));
    //Equip bullets
    AssignCommand(oPC, ActionEquipItem(oBullets, INVENTORY_SLOT_BULLETS));
    //Equip creature bite item
    AssignCommand(oPC, ActionEquipItem(oCBite, INVENTORY_SLOT_CWEAPON_B));
    //Equip creature left hand item
    AssignCommand(oPC, ActionEquipItem(oCLeft,INVENTORY_SLOT_CWEAPON_L));
    //Equip creature right hand item
    AssignCommand(oPC, ActionEquipItem(oCRight, INVENTORY_SLOT_CWEAPON_R));
    //Equip creature armour item
    AssignCommand(oPC, ActionEquipItem(oCArmour, INVENTORY_SLOT_CARMOUR));
    //Equip belt item
    AssignCommand(oPC, ActionEquipItem(oBelt, INVENTORY_SLOT_BELT));

    /* Destroy all inventory items */

    object oDestroy = GetFirstItemInInventory(oPC);

    while (oDestroy != OBJECT_INVALID)
        {
        DestroyObject(oDestroy, 0.0);

        oDestroy = GetNextItemInInventory(oPC);
        }

    /* Give new items to the PC. Put the resref between quotation marks.
       Uncomment and copy new lines if needed.                           */
    //object oItem = CreateItemOnObject("resref", oPC, 1);
    }
   
    //Start the Libray Into Conversation
    ActionStartConversation(oPC, "jw2_lib_intro");
   
}


I'm having issues with this script not actually creating and equiping the jw_travelers_armor.  Everything else seems to be working, but my inventory remains empty instead of getting the starting armor.

Anyone have any ideas why?

#2
MokahTGS

MokahTGS
  • Members
  • 946 messages
Ok, it also looks like the leveling bit is not functioning either.

#3
rjshae

rjshae
  • Members
  • 4 485 messages
I don't see anything obviously wrong, except for all the "resref"s not being set to a value.

#4
MokahTGS

MokahTGS
  • Members
  • 946 messages
Maybe that's it. I'll comment out those lines and see if it does what it should.

#5
MokahTGS

MokahTGS
  • Members
  • 946 messages
I also said that the level adjustment part was not working. Not sure why.

#6
Orion7486

Orion7486
  • Members
  • 161 messages
Where is this script being triggered. If in an onenter of area, try oncliententer. Try putting a delay in the actionequip. Then put a longer delay in the destroyobject stuff.

What I'm thinking is maybe the armor is being created, but not equipping, thus as you're looping thru the inventory items, it's destroying the armor.

#7
MokahTGS

MokahTGS
  • Members
  • 946 messages
So I moved a bit of the script around and now things work, but only sporadically.



/* Destroy all inventory items */



object oDestroy = GetFirstItemInInventory(oPC);



while (oDestroy != OBJECT_INVALID)

{

DestroyObject(oDestroy, 0.0);



oDestroy = GetNextItemInInventory(oPC);

}



/* Give new items to the PC. Put the resref between quotation marks.

Uncomment and copy new lines if needed. */

//object oItem = CreateItemOnObject("resref", oPC, 1);




The script is on a trigger and fires correctly for the player, but it is hit or miss with spawned in party members using the party creation system. The first party member I brought in didn't get stripped when spawned. The second, got stripped after I changed control to that member. The third didn't get stripped until I exited the trigger and re-entered



Is there a rock solid way of stripping the player when they first log in and then making sure that party members brought in are also stripped?

#8
Orion7486

Orion7486
  • Members
  • 161 messages
When first log in, you can use the mod's onclient enter. Or I use the onclient enter in the first area.

To strip the player, you can loop the destroyobject stuff within another loop using GetFirstEnteringPC, and GetNextEnteringPC.

There might be a better way to script it rather than doing a loop within a loop.

#9
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Here's a section of the script I use when the player adds a new party member (SoZ style). I stripped out some of it that won't matter to you. Also, it may be a bit easier for me as I have specific areas where the player can add members (from a convo with a "recruiter" type NPC):

//Put this script OnEnter for areas where PC can add new members to party, fired upon something entering the area
void main()
{
object oPC = GetEnteringObject();
object oMainPC = GetFirstPC(TRUE);
object oPartyMember = GetFirstFactionMember(oMainPC, FALSE);
object oDoor = GetNearestObjectByTag("Door_Recruiter", oPC, 1);
int nPlayerXP;
int nCohortXP = GetXP(oPC);
object oSkin;
// Exclude any human soldiers and the orc trader NPCs
if((GetRacialType(oPC) == RACIAL_TYPE_HUMAN) || (GetTag(oPC) == "c_orc_recruiter"))
 {
 SetLocalInt(oPC, "Creature_Skin_Applied", 1);
 }
 
// Check to make sure the object is a player made/controlled character
if (GetIsOwnedByPlayer(oPartyMember) || GetIsPlayerCreated(oPartyMember) || GetIsRosterMember(oPartyMember))
  {
  while (GetIsObjectValid(oPartyMember))
   {
 // Make sure the player is not bringing in a duplicate of their Main PC
   if((GetFirstName(oPC) == GetFirstName(oMainPC)) && (oPC != oMainPC))
     {
  // If so, prevent from use
     effect ePoly = EffectPolymorph(POLYMORPH_TYPE_COW, TRUE, FALSE);
     ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoly, oPC);
     SetLocalInt(oPC, "Illegal", 1);
     return;
     }
 // Make sure player is not bringing in a duplicate of some other party member
   if((GetFirstName(oPC) == GetFirstName(oPartyMember)) && (oPartyMember != oPC))
     {
   // If so, prevent from use
     effect ePoly = EffectPolymorph(POLYMORPH_TYPE_COW, TRUE, FALSE);
     ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoly, oPC);
     SetLocalInt(oPC, "Illegal", 1);
     return;
     }
    
  // Check to see if the character already has a creature skin, has skin = 1
  if (GetLocalInt(oPartyMember, "Creature_Skin_Applied") < 1)
     {
     // Set the new companions XP equal to the main PCs if it is lower
     nPlayerXP = GetXP(oMainPC);
     if (nCohortXP < nPlayerXP)
       {
       SetXP(oPC, nPlayerXP);
       }
  }
    oPartyMember = GetNextFactionMember(oMainPC, FALSE);
   }
  }
}


 

#10
MokahTGS

MokahTGS
  • Members
  • 946 messages
Knightmare,

Basically I'm looking to do the following to the player on entering the module:
  • Strip the main player's character of all inventory items and equipped items and gold.
  • Give the player a set of clothes and equip that set into the chest slot (resref=jw_travelers_armor)
  • Give the player 500 gold.
  • Check the entering character's level for level 5.
  • If the player is under level 5, give them enough exp to reach level 5.
  • If they are level 6 and above, delevel them so that they are level 5.
This process should be repeated for each character the player creates via the party registration book that is available in the first room.  The player currently can create 4 characters in a party as per the SoZ system.

So can someone make a script for this little ole' strumpet that does that?

#11
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Here's an updated script for you. I tested it in game and it seemed to work, however, I only tested it with a single PC (not with a whole party but it should work). For my testing I have it set as the OnEnter of a trigger to fire it, you may need to edit a bit to fit it in to where you want the script fired from.

void main()
{
object oPC = GetEnteringObject();
object oMainPC = GetFirstPC(TRUE);
object oPartyMember = GetFirstFactionMember(oMainPC, FALSE);

// Check to make sure the object is a player made/controlled character
if (GetIsOwnedByPlayer(oPartyMember) || GetIsPlayerCreated(oPartyMember) || GetIsRosterMember(oPartyMember))
 {
   while (GetIsObjectValid(oPartyMember))
     {
   // Make sure the player is not bringing in a duplicate of their Main PC
     if((GetFirstName(oPC) == GetFirstName(oMainPC)) && (oPC != oMainPC))
       {
     // If so, prevent from use
       effect ePoly = EffectPolymorph(POLYMORPH_TYPE_COW, TRUE, FALSE);
       ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoly, oPC);
       SetLocalInt(oPC, "Illegal", 1);
       return;
       }
   
   // Make sure player is not bringing in a duplicate of some other party member
     if((GetFirstName(oPC) == GetFirstName(oPartyMember)) && (oPartyMember != oPC))
       {
      // If so, prevent from use
       effect ePoly = EffectPolymorph(POLYMORPH_TYPE_COW, TRUE, FALSE);
       ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoly, oPC);
       SetLocalInt(oPC, "Illegal", 1);
       return;
       }
   
  // Check to see if the character already has had this script run on them
  // If so, skip to next party member
  // If not then continue script
  if (GetLocalInt(oPartyMember, "Level_Up_Applied") != 1)
       {
   // Cycle through equiped items, remove and destroy
   object oItem;
   int nSlot;
   for(nSlot = 0; nSlot < 18; nSlot ++)
    {
    oItem = GetItemInSlot(nSlot, oPartyMember);
    SetPlotFlag(oItem, FALSE);
    AssignCommand(oPartyMember, ActionUnequipItem(oItem));
    DestroyObject(oItem, 0.0f);
    }
    
   // Cycle through general inventory, destroy items
   oItem = GetFirstItemInInventory(oPartyMember);
   while(GetIsObjectValid(oItem))
    {
    SetPlotFlag(oItem, FALSE);
    DestroyObject(oItem, 0.0f);
    oItem = GetNextItemInInventory(oPartyMember);
    }
    
   // Set the new companions XP equal to level 5 (10001 XP)
   // Delay Commands to prevent killing PC if they have a Constitution or HP bonus item equiped
   DelayCommand(0.5, SetXP(oPartyMember, 1)); // First set XP to 1 to prevent killing the PC
   DelayCommand(0.6, SetXP(oPartyMember, 10001));
   
   // Heal the PC back to full level 1 HPs
   int nHP = GetMaxHitPoints(oPartyMember);
   effect eHeal= EffectHeal(nHP);
   DelayCommand(0.8, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPartyMember));
   
   // Remove gold from PC and give 500 gold
   int nGold = GetGold(oPartyMember);
   TakeGoldFromCreature(nGold, oPartyMember, TRUE, FALSE);
   GiveGoldToCreature(oPartyMember, 500, FALSE);
   
   // Give the PC starting clothing and equip it
   object oClothes = CreateItemOnObject("jw_travelers_armor", oPartyMember, 1, "", FALSE);
   SetIdentified(oClothes, TRUE);
   AssignCommand(oPartyMember, ActionEquipItem(oClothes, INVENTORY_SLOT_CHEST));
   
   // Set variable on party member so they are ignored next time this script is run
   SetLocalInt(oPartyMember, "Level_Up_Applied", 1);
     }
     oPartyMember = GetNextFactionMember(oMainPC, FALSE);
  }
 }
}


Modifié par _Knightmare_, 22 août 2010 - 02:51 .


#12
MokahTGS

MokahTGS
  • Members
  • 946 messages
So I tested this script in my module and it worked like a charm for my first character, except that it did not remove levels from my character.  It changed the exp my character had to 10000, but I still had 15 levels of ranger and 1 level of rogue.  The script does work correctly if I bring a lvl 1 character in.  It's going backwards that is the issue.

Also, when bringing a party in, it only runs the script when you take control of the character.   I can run my party through the trigger all I like, but nothing happens to the following party members until I switch to them.

#13
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

MokahTGS wrote...

So I tested this script in my module and it worked like a charm for my first character, except that it did not remove levels from my character.  It changed the exp my character had to 10000, but I still had 15 levels of ranger and 1 level of rogue.  The script does work correctly if I bring a lvl 1 character in.  It's going backwards that is the issue.


I just tested it again in game with a level 20 Fighter. For me it did reset the PC to level 1 (with 10000 XP so able to level up to 5), it also took away the appropriate skill ranks and feats. No idea why it did not work for you, though I was testing with a single classed character.

Also, when bringing a party in, it only runs the script when you take control of the character.   I can run my party through the trigger all I like, but nothing happens to the following party members until I switch to them.


Also just tried it with a 4 character party (SoZ style party) and all characters had the script fire on them at once when only my currently controlled PC walked through the trigger. In other words this part did what it should do.

XP/Level Up and giving the 500 gold each worked fine. However, it did seem to have trouble stripping all the gear off the the individual PCs. It removed most of their gear, but left some of the equiped gear in tact (did take all in general inventory). One of the party did not equip their starting armor we are trying to give them but they did receive it in inventory. Perhaps you can re-iterate through their gear a second time and try to catch what may have been missed?

Guess some tweaking will be required here for you. Sorry it did not work as it should as is, but hopefully I've helped you move in the right direction. Posted Image

#14
MokahTGS

MokahTGS
  • Members
  • 946 messages
Yeah, not sure what to do about the multi-classed PCs. I'll test tonight with a single classed PC and see if I can replicate this.



Not sure what to do about the party issue though...maybe it'll run fine when I get it setup in the right spot.



Could the script be rewritten for the ClientOnEnter handle? Would that make a difference?

#15
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
The scipt can be used in the OnClientEnter slot of the area. Not sure if the secondary party members entering the module when "recruited" will cause this event to fire or not though (or if it only fires when the main PC enters). Like I said before, I have mine firing from the area OnEnter, but there are only a few areas where the player can add new members, so its easy for me to control the situation better than if they could add new PCs anywhere (not sure of yourown restrictions to this).