Advertisement
Guest User

Untitled

a guest
May 26th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. if (!bIsAmmoOrThrowing) return; //Check nBaseItemType to see if it's a projectile
  2. {
  3. SendMessageToPC(oPC, "Test");
  4. string sName = GetName(oItem); //Get the name of the depleted ammunition.
  5. int nDepletedProjectileType = GetBaseItemType(oItem);
  6. object oNewProjectile = GetFirstItemInInventory(oPC); //The start of finding a similar item.
  7.  
  8. while(oNewProjectile != OBJECT_INVALID)
  9. {
  10. if(!bIsAmmoOrThrowing) return; //Same as above, making sure we've found a projectile before proceeding.
  11. {
  12. int nNewProjectileType = GetBaseItemType(oNewProjectile); //Declare new projectile type for comparison against depleted projectile type.
  13.  
  14. if(nNewProjectileType == nDepletedProjectileType) //If projectile types match
  15. {
  16. string sNextItemName = GetName(oNewProjectile); //Get the name of projectile stack.
  17. SendMessageToPC(oPC, "Base Item Types Match.");
  18.  
  19. if(TestStringAgainstPattern(sName, sNextItemName) == 1) //Compare names, if match:
  20. {
  21. switch(nNewProjectileType) //Switch/case statement to determine what slot to equip the projectile match.
  22. {
  23. case 20: //Arrows
  24. {
  25. SendMessageToPC(oPC, "Equip new arrows.");
  26. ActionEquipItem(oNewProjectile, INVENTORY_SLOT_ARROWS);
  27. break;
  28. }
  29. case 25: //Bolts
  30. {
  31. SendMessageToPC(oPC, "Equip new bolts.");
  32. ActionEquipItem(oNewProjectile, INVENTORY_SLOT_BOLTS);
  33. break;
  34. }
  35. case 27: //Bullets
  36. {
  37. SendMessageToPC(oPC, "Equip new bullets.");
  38. ActionEquipItem(oNewProjectile, INVENTORY_SLOT_BULLETS);
  39. break;
  40. }
  41. case 31: //Darts
  42. case 59: //Shuriken
  43. case 63: //Throwing Axe
  44. {
  45. SendMessageToPC(oPC, "Equip new throwing weapon.");
  46. ClearAllActions(TRUE);
  47. ActionEquipItem(oNewProjectile, INVENTORY_SLOT_RIGHTHAND);
  48. break;
  49. }
  50. default: SendMessageToPC(oPC, "You have found a bug in the projectile auto-equip script! Please report to the devs.");
  51. break; //If for some reason nNewProjectileType is not one of the projectiles, we'll find out about it.
  52. }
  53. }
  54. }
  55. }
  56. oNewProjectile = GetNextItemInInventory(oPC); //Otherwise, continue the search. This function will also search "nested" inventory for Bags of Holding/Magic Bags/Boxes automatically.
  57. }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement