| Author: | Danmar |
| Author Website: | Lands of Kray |
| Script Name: | Retrieve Ammunition |
| Description: | This script allows a PC to retrieve ammunition fired at a creature (assuming the creature is killed). |
| Instructions on Use: | As is the script has a 100% chance of every item that hits of being on
the body. You can fairly easily change that according to your ideas of how
many a player should be getting back by putting a simple change like so
around each create statement: if (d6()<=3) { Create statement } |
Script 1 (OnUserDefined):
//:://///////////////////////////////////////////// //:: Name: Missile weapon respawn //:: NW_C2_DEFAULTD replacement //:: Copyright 2002 Dennis Dollins - www.landsofkray.com //::////////////////////////////////////////////// /* Purpose: Uses the On damaged user event to respawn missile weapons in the inventory of the attackee. Rationale: I dislike the fact that an arrow, bolt, bullet throwing axe (?!) crumbles and distenigrates after a single use. Bullets are simple chunks of stone and/or metal for goodness sake. Code: Pretty simple. Each time an object is damaged we find out what weapon type damaged it. If its a ranged weapon we check that the object has an inventory and then we create an object of the type that damaged it in that inventory. To avoid increasing the code I did not include having bullets bounce off and be created on the ground nearby or at the objects feet. The risk of an invalid location and such outweighed the vermislitude in that instance. As is this code spawns in a generic aka BW standard ammo replacement. To code the replacement of a precise ammo type would require too much specialized checking in my opinion increasing the performance hit for this addition. Your opinion may differ and you can see an example at the bottom of the script as to how you might do exact replacements. How to use aka what files to edit: 1)Put this script in place of the UserEvent script on the NPC's you wish to collect an inventory. You could replace/edit the standard user event script and then all the npc's including standard ones would collect arrows. 2)Uncomment the signal damaged event in the onspawn script for your npcs. Again you can do this for all the standard npc's by editing the standard on spawn script. Change this: //SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT); to this: SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT); */ //::////////////////////////////////////////////// //:: Created By: Dennis Dollins //:: Created On: July 10, 2002 //:: Last Revised: July 11,2002 //::////////////////////////////////////////////// void main() { // Okay let's get the event that brought us here. int nUser = GetUserDefinedEventNumber(); if(nUser == 1001) //HEARTBEAT { } else if(nUser == 1002) // PERCEIVE { } else if(nUser == 1003) // END OF COMBAT { } else if(nUser == 1004) // ON DIALOGUE { } else if(nUser == 1005) // ATTACKED { } else if(nUser == 1006) // DAMAGED { // Who did the attacking? object Attacker = GetLastDamager(); // What did they do it with? object Weapon = GetLastWeaponUsed(Attacker); // What's the base type of the weapon? int BaseType = GetBaseItemType(Weapon); // If the weapon was ranged and we have an inventory // I know most things that get hit should have an inventory // but let's check anyway to avoid trying to create // something in nothing. Bag of holding inside portable hole = bad. if (GetWeaponRanged(Weapon)&&GetHasInventory(OBJECT_SELF)) { switch (BaseType) { //Not going to comment these as they should be //pretty self evident what each case does. case BASE_ITEM_SHORTBOW: CreateItemOnObject("nw_wamar001",OBJECT_SELF,1); break; case BASE_ITEM_LONGBOW: CreateItemOnObject("nw_wamar001",OBJECT_SELF,1); break; case BASE_ITEM_LIGHTCROSSBOW: CreateItemOnObject("nw_wambo001",OBJECT_SELF,1); break; case BASE_ITEM_HEAVYCROSSBOW: CreateItemOnObject("nw_wambo001",OBJECT_SELF,1); break; case BASE_ITEM_DART: CreateItemOnObject("nw_wthdt001",OBJECT_SELF,1); break; case BASE_ITEM_SLING: CreateItemOnObject("nw_wambu001",OBJECT_SELF,1); break; case BASE_ITEM_SHURIKEN: CreateItemOnObject("nw_wthsh001",OBJECT_SELF,1); break; case BASE_ITEM_THROWINGAXE: CreateItemOnObject("nw_wthax001",OBJECT_SELF,1); break; /* Below this find example of how to do a little more involved bit of check and replacment but you'll have to supply the blueprints that pertain to your module and items. */ /* case BASE_ITEM_SHORTBOW: object CurrentAmmo = GetItemInSlot(INVENTORY_SLOT_ARROWS,OBJECT_SELF); string AmmoTag = GetTag(CurrentAmmo); //I think switch works with strings if not you'll need //to do a buttload of if statements switch (AmmoTag) { // Example tag, your tag would be different case "Arrows_Plus_1" // Example blueprint ref name, yours would be different. CreateItemOnObject("nw_wamar003",OBJECT_SELF,1) break; } */ } } } else if(nUser == 1007) // DEATH { } else if(nUser == 1008) // DISTURBED { } return; } |