03-06-2007, 12:52 AM | #1 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
|
//::///////////////////////////////////////////////
//:: Name: returnweapon //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /*This script is supposed to simulate returning throwing weapons by keeping a constant stack of 1. */ //::////////////////////////////////////////////// //:: Created By: Robert the Bard //:: Created On: 05, March, 2007 //::////////////////////////////////////////////// #include "x2_inc_switches" void main() { object oReturn = GetPCItemLastUnequipped(); object oPC = GetPCItemLastUnequippedBy(); int nStack = (GetItemStackSize(oReturn)); if (GetBaseItemType(oReturn)== BASE_ITEM_DART || BASE_ITEM_THROWINGAXE) GetTag(oReturn); { if (GetTag(oReturn)!="returnweapon") return; else (GetNumStackedItems(oReturn)); if (nStack ==2) CreateItemOnObject("returnweapon", oPC, 1); } } This is a compiled script, but it doesn't function correctly. If you unequip the weapon with 1 or 2 in the right hand slot, it will create another. However, trying to run it on equip froze up my test server. I have tried to run it off of OnEquip, OnUnequip, and OnInventoryDisturb, but it won't do what I'm looking to do. Perhaps somebody can see a flaw in my logic, which seems to have snuck past the compiler...
__________________
To those we have lost; May your spirits fly free. Good Music: Here. Interesting read, one of my blogs. |
03-06-2007, 03:27 AM | #2 |
Jack Burton
Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 39
Posts: 5,459
|
My initial thought would be that you want this in the OnUnequip slot, if that's indeed what fires when a player loses the last of his ammo. Give the object a stack size of 1, and when it's being unequipped, check the player's inventory for an item with the tag (GetItemPossessedBy). If it returns OBJECT_INVALID, you know the throwing weapon has been thrown instead of simply unequipped and you can create a new one on the player.
|
03-06-2007, 09:03 AM | #3 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
|
I'll give that a shot. I'm not sure what fires when you run out of arrows/bolts that automatically re-equips them, but what ever that is would be what I'd need.
__________________
To those we have lost; May your spirits fly free. Good Music: Here. Interesting read, one of my blogs. |
03-06-2007, 10:00 AM | #4 |
Jack Burton
Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 39
Posts: 5,459
|
As it turns out, three scripts fire at the point you get rid of your last throwing weapon. These are the target's OnPhysicalAttacked, the module event OnPlayerUnEquipItem and the module event OnUnAcquireItem.
The first of the three is impractical to use because you'd need to stick the script to every creature and placeable and door in the game to make sure the dart/axe/whatever always returns. The other two should both do the job, but I'd suggest the OnUnAcquireItem because that one's last to fire and so you can be sure the item is truely gone. Mind you, throwing weapons aren't automatically re-equipped the way bullets, bolts and arrows are. You'll have to do that manually, and that may result in the 'thrower' resorting to a fistfight, being busy with a 'combat' action and therefore ignoring the 'equip' action which comes later in the action queue. Clearing the combat action first would work, but it also messes up things like attacks per round and sneak attack vulnerability. You can of course clear the action the moment the dart is unacquired to prevent the character rushing forward and claim a throwing weapon can only be used once per round - or tie the number of darts to the user's attacks per round as modified by haste, rapid shot mode etc.. In which case you assume a character always spends all of a round's worth of darts on a target. A problem there is that it becomes all too easy to separate the stack and replenish all of the new mini stacks to generate more throwing weapons. Splitting stacks isn't captured by any script hooks you can apply to a PC. So, in summary, returning throwing weapons aren't likely to be very user-friendly or rapid-firing unless you can think of some tidy solution. On the other hand, you can probably off-set some of the discomfort by accepting they are a bit slow and clumsy, and compensating for that with relatively powerful enchantments. |
03-06-2007, 12:11 PM | #5 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
|
code://::///////////////////////////////////////////////[/QUOTE]This script works as intended, but on module heartbeat. I really hate that, but since I really hate that, I have no other heartbeat scripts in my modules. I ran the gambit of acquire, unacquire, equip, unequip, and put the script in every event I could think of, including the OnCombatRoundEnd User defined event. If it's got to be a heartbeat to work, then I'll use it that way, and limit item availability.
__________________
To those we have lost; May your spirits fly free. Good Music: Here. Interesting read, one of my blogs. |
03-06-2007, 01:02 PM | #6 |
Jack Burton
Join Date: March 31, 2001
Location: The zephyr lands beneath the brine.
Age: 39
Posts: 5,459
|
But what happens when player X has a stack of five darts in his inventory, splits them into five individual darts and equips them all in turn, waiting for the heartbeat to fire? In this case, the script would fill the 'depleted' stacks to their full size of five, giving the player 25 darts. With a bit of repetition players generate some 4 darts per heartbeat, and there's no telling if they disappeared into monsters, the inventory, stores, other players, or were left somewhere on the ground.
I imagine you'll need another check to see if they're the only returning darts in the player's inventory, and if not, you'll have to destroy all the others. Likewise, you need a check on unacquire to make sure any darts not dropped by the player are demolished. Lastly, though it's not essential, I'd suggest making sure the stack size doesn't become greater than 5 as well; a sure sign that something's wrong. Of course, making sure you have more darts than you can get rid of in a round is indeed the only way to create 'unlimited' throwing weapons without disturbing a player's attack or bash sequences, you're right about that. |
03-06-2007, 01:47 PM | #7 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
|
Right now, the important thing was getting the script to actually work. I'd love to get it off the heartbeat event, if possible. The problem is that while it worked when I unequipped the item, it wouldn't work in combat. Now that I have a working script, I can start trying to cover up the exploits, but as a long time player, I know that players will find exploits, and use them, if they can.
I'm not sure how to go about destroying any items over the max stack yet, without destroying all of them. I only started on this in earnest yesterday though, and it's a generator free script, so working out the apparent bugs will take a little while to figure out. However, for a basic idea, it's ready for use. Improvements will be forthcoming, as I figure out how to go about it. I couldn't get your earlier suggestion to compile, and so went this route to see where I could get.
__________________
To those we have lost; May your spirits fly free. Good Music: Here. Interesting read, one of my blogs. |
03-06-2007, 01:51 PM | #8 |
Mephistopheles
Join Date: August 30, 2001
Location: deep within the sylvan splendor....
Age: 60
Posts: 1,443
|
You guys make my eyes cross and my head hurt with all this gibberish.
........goes back to happily smiting Evil with acknowledged ignorance of the scripting that makes it all possible........
__________________
"Nature tells every secret once." Ralph Waldo Emerson |
03-06-2007, 02:19 PM | #9 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
|
Awwwww, poor G is all fuzzled...Think how I felt trying to think through a major headache, and scripter headache, until I actually managed to maintain a constant stack of five darts.
One way to overcome the split dilemma is to make it non profitable to do so. If the items are flagged as plot, they can be used, but not sold. I can set them to non droppable too, but I'm not sure I'd really want to.
__________________
To those we have lost; May your spirits fly free. Good Music: Here. Interesting read, one of my blogs. |
03-06-2007, 04:23 PM | #10 |
Xanathar Thieves Guild
Join Date: March 17, 2001
Location: Wichita, KS USA
Age: 60
Posts: 4,537
|
code://::///////////////////////////////////////////////[/QUOTE]Hopefully it works here, but this will sort of overcome the issue of getting too many, and stacking of items, to some extent.
__________________
To those we have lost; May your spirits fly free. Good Music: Here. Interesting read, one of my blogs. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hello scripters...Why isn't this working? | robertthebard | Neverwinter Nights 1 & 2 Also SoU & HotU Forum | 6 | 08-17-2006 12:02 PM |
For your own health: chew your food properly! | uss | General Discussion | 8 | 03-18-2006 03:02 PM |
another question for builders and scripters (mainly)... | Mozenwrathe | Neverwinter Nights 1 & 2 Also SoU & HotU Forum | 0 | 02-01-2006 02:52 PM |
question for builders and scripters... | Mozenwrathe | Neverwinter Nights 1 & 2 Also SoU & HotU Forum | 0 | 02-01-2006 02:39 PM |
Do You Chew Gum? | Ladyzekke | General Conversation Archives (11/2000 - 01/2005) | 25 | 03-05-2004 08:15 PM |