Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!bIsAmmoOrThrowing) return; //Check nBaseItemType to see if it's a projectile
- {
- SendMessageToPC(oPC, "Test");
- string sName = GetName(oItem); //Get the name of the depleted ammunition.
- int nDepletedProjectileType = GetBaseItemType(oItem);
- object oNewProjectile = GetFirstItemInInventory(oPC); //The start of finding a similar item.
- while(oNewProjectile != OBJECT_INVALID)
- {
- if(!bIsAmmoOrThrowing) return; //Same as above, making sure we've found a projectile before proceeding.
- {
- int nNewProjectileType = GetBaseItemType(oNewProjectile); //Declare new projectile type for comparison against depleted projectile type.
- if(nNewProjectileType == nDepletedProjectileType) //If projectile types match
- {
- string sNextItemName = GetName(oNewProjectile); //Get the name of projectile stack.
- SendMessageToPC(oPC, "Base Item Types Match.");
- if(TestStringAgainstPattern(sName, sNextItemName) == 1) //Compare names, if match:
- {
- switch(nNewProjectileType) //Switch/case statement to determine what slot to equip the projectile match.
- {
- case 20: //Arrows
- {
- SendMessageToPC(oPC, "Equip new arrows.");
- ActionEquipItem(oNewProjectile, INVENTORY_SLOT_ARROWS);
- break;
- }
- case 25: //Bolts
- {
- SendMessageToPC(oPC, "Equip new bolts.");
- ActionEquipItem(oNewProjectile, INVENTORY_SLOT_BOLTS);
- break;
- }
- case 27: //Bullets
- {
- SendMessageToPC(oPC, "Equip new bullets.");
- ActionEquipItem(oNewProjectile, INVENTORY_SLOT_BULLETS);
- break;
- }
- case 31: //Darts
- case 59: //Shuriken
- case 63: //Throwing Axe
- {
- SendMessageToPC(oPC, "Equip new throwing weapon.");
- ClearAllActions(TRUE);
- ActionEquipItem(oNewProjectile, INVENTORY_SLOT_RIGHTHAND);
- break;
- }
- default: SendMessageToPC(oPC, "You have found a bug in the projectile auto-equip script! Please report to the devs.");
- break; //If for some reason nNewProjectileType is not one of the projectiles, we'll find out about it.
- }
- }
- }
- }
- oNewProjectile = GetNextItemInInventory(oPC); //Otherwise, continue the search. This function will also search "nested" inventory for Bags of Holding/Magic Bags/Boxes automatically.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement