Custom item of returning
+3
RustyDios
The Amethyst Dragon
half_evil_333
7 posters
Page 1 of 1
Custom item of returning
Say, would there be a way to make a script for a "returning" property for throwing weapons? I really would love to make my next custom item a throwing dagger, but as it is that would be quite useless . I mean it's kinda unfair: there is an "unlimited ammo" property for bows, crossbows and slings but no such thing for throwing weapons afaik (at least it doesn't show up on the toolset).
I would come up with a script myself (or at least try it) if not for my scripting skills being, well... pretty much non-existent .
I would come up with a script myself (or at least try it) if not for my scripting skills being, well... pretty much non-existent .
half_evil_333- Adventurer
- Number of posts : 27
Age : 39
Location : some fictional realm within the dnd multiverse
Main Character : Tarn Moondusk
NWN Username : Half3vil333
Time Zone : \GMT +1:00\
Registration date : 2010-03-17
Re: Custom item of returning
It's a cool idea, but there isn't currently a way to do a returning weapon without some custom scripting specific to your weapon, and new scripting is something I don't do for PC's custom items (due to resources it adds to the game and time needed).
Re: Custom item of returning
How hard would it be to add a base item type (of returning) piggybacking off the (unlimited ammo) thingi ?... How does the unlimited arrow property work ?.. does it just reset the stack count to 99 at 0 ?.. or does it give it an "infinite" number ?.... .. what would happen if the propety was opened for other types of weapon/ammo in the 2da's and applied ?
I found the following on the vault that looked interesting:
here
To bad one cannot add new ranged weapons into the game it seems (freaky out of ammo bug). So one needs to replace an existing ranged weapon, shuriken OR the dart.
here
Not satisfied with tossing axes and lobbing darts at Dungeon scum? How about adding daggers, clubs, hammers, javelins, spears, and (when they're added), nets & rocks ? With this system, you can also create 'returning' weapons that come back like a boomerang or add all sorts of magical properties.
.. a quick glance around the lexicon I came up with a generic idea for what could be possible using a gettag(object_self) and copyobject idea on a stack of 1 throwing dagger to the auto-equip to the PC's slot "onhit" of a creature.. but that would involve scripting, the idea of using object_self and copy item is so that it could be applied to any weapon....I think it's doable, but I'm not sure if thinks it's particularly worth it for one or two items... it would just use more resources .... ....
You could try asking if maybe you could have a "Flying scimitar of Tusmit" property added to a normal weapon (not sure if that's doable either or particularly what your after... )....
I found the following on the vault that looked interesting:
here
To bad one cannot add new ranged weapons into the game it seems (freaky out of ammo bug). So one needs to replace an existing ranged weapon, shuriken OR the dart.
here
Not satisfied with tossing axes and lobbing darts at Dungeon scum? How about adding daggers, clubs, hammers, javelins, spears, and (when they're added), nets & rocks ? With this system, you can also create 'returning' weapons that come back like a boomerang or add all sorts of magical properties.
.. a quick glance around the lexicon I came up with a generic idea for what could be possible using a gettag(object_self) and copyobject idea on a stack of 1 throwing dagger to the auto-equip to the PC's slot "onhit" of a creature.. but that would involve scripting, the idea of using object_self and copy item is so that it could be applied to any weapon....I think it's doable, but I'm not sure if thinks it's particularly worth it for one or two items... it would just use more resources .... ....
You could try asking if maybe you could have a "Flying scimitar of Tusmit" property added to a normal weapon (not sure if that's doable either or particularly what your after... )....
RustyDios- High Epic Level
- Number of posts : 2271
Age : 40
Location : England // Getting lost in Aenea
Main Character : Jay Braysin, The Wandering Shadow, Protector of Nektaria, Talon's Eternal Foe
Other Character : Shouri Braysin, The Shimmerstar's Moonlight Sorceress
Other Character. : Grace Fularras, Walking Library , Cleric of Mystara
Other Character.. : See my sig ... And here too ...
NWN Username : RustyDios
Time Zone : GMT (England, DST)
. :
Registration date : 2008-07-28
Re: Custom item of returning
He would have to add manually to the script for each and every custom item that wanted this feature. Too much hassle on his part.
Though It may be possible to have a VC command using the select tool to select an ammo type and that ammo will auto-replenish (Also checking if they have the item to allow it in their Inventory). It could use the existing script and it wouldn't have to keep track of every ResRef.
If the Everfull items were made this way it would open up the use of players using Vouchers to make custom ammo. Or keep the existing ones and make new items that do this but make them rare and hard to find with an epic level restriction.
Though It may be possible to have a VC command using the select tool to select an ammo type and that ammo will auto-replenish (Also checking if they have the item to allow it in their Inventory). It could use the existing script and it wouldn't have to keep track of every ResRef.
If the Everfull items were made this way it would open up the use of players using Vouchers to make custom ammo. Or keep the existing ones and make new items that do this but make them rare and hard to find with an epic level restriction.
Alundaio- Aenean Scholar
- Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. :
Registration date : 2009-09-14
Re: Custom item of returning
Alundaio wrote:He would have to add manually to the script for each and every custom item that wanted this feature. Too much hassle on his part.
.
.. I don't think this is entirely true... the item would just need a unique tag (common to all items with this property) that would fire off the same tag-based script each time. If the script is made generic enough (to pull information from the player using it) with no "hard set varibles" specific to each weapon it would only require one additional script (or one entry in a massive "tohit" script that triggers if GetTag(oItem) == "blahtag" )... ... .. ... the feature is possible... but I'm just not sure it's worth it.... .... ..
RustyDios- High Epic Level
- Number of posts : 2271
Age : 40
Location : England // Getting lost in Aenea
Main Character : Jay Braysin, The Wandering Shadow, Protector of Nektaria, Talon's Eternal Foe
Other Character : Shouri Braysin, The Shimmerstar's Moonlight Sorceress
Other Character. : Grace Fularras, Walking Library , Cleric of Mystara
Other Character.. : See my sig ... And here too ...
NWN Username : RustyDios
Time Zone : GMT (England, DST)
. :
Registration date : 2008-07-28
Re: Custom item of returning
Not to mention the lag that such a script might cause with how often it would be running.
evilkittenofdoom- Epic Level
- Number of posts : 1217
Age : 124
Location : Ready to Pounce at the Least Suspected Moment...
Main Character : Aseph, the NOT old sorcerer
Other Character : Analo, professional Dracolich (and other undead) hunter
Other Character. : Sivoran, the PC Demilich
Other Character.. : Imyna, Drow Priestess of Sorgath
NWN Username : evilkittenofdoom
Time Zone : EST (GMT-5)
Registration date : 2009-02-26
Re: Custom item of returning
You don't need to create an OnHit script. An on-unequip script could just create a new item and re-equip it when used.
But either way. Like Kitten says would most likely cause some serious lag. The on-hit would cause lag and if you made the item use a similar script to the Everfull items it would probably also cause lag because it would call the function to create the item on the player every single time you used it. Unless of course you made the boomarang a stack of 99. But then that just defeats the purpose.
This is the function you need to use to create items on a player: CreateItemOnObject( Resref, PC, StackSize, Tag)
As you see it requires both the Resref and the Tag. Now unless you pass on the Tag and Resref from using the select tool or something, the script would have to be edited for each individual item.
If a new everfull item was made using a method like that it would open up the possibility for custom ammo. Seeing as how melee types can put a crap load of things on their custom weapon and ranged players can't, I think it would be a cool idea. Because the only thing you can put on a ranged weapon (Bow/Crossbow/Sling) is Attack bonus and Massive Criticals. Extra damage from elemental types isn't available. Though the Everfull items help some with the 1d4 elemental damage.
But either way. Like Kitten says would most likely cause some serious lag. The on-hit would cause lag and if you made the item use a similar script to the Everfull items it would probably also cause lag because it would call the function to create the item on the player every single time you used it. Unless of course you made the boomarang a stack of 99. But then that just defeats the purpose.
This is the function you need to use to create items on a player: CreateItemOnObject( Resref, PC, StackSize, Tag)
As you see it requires both the Resref and the Tag. Now unless you pass on the Tag and Resref from using the select tool or something, the script would have to be edited for each individual item.
If a new everfull item was made using a method like that it would open up the possibility for custom ammo. Seeing as how melee types can put a crap load of things on their custom weapon and ranged players can't, I think it would be a cool idea. Because the only thing you can put on a ranged weapon (Bow/Crossbow/Sling) is Attack bonus and Massive Criticals. Extra damage from elemental types isn't available. Though the Everfull items help some with the 1d4 elemental damage.
Alundaio- Aenean Scholar
- Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. :
Registration date : 2009-09-14
Re: Custom item of returning
Yeah.. I just had a play around in the toolset... I came up with a working script.. however for it to work it needs to use the "OnHit:CastSpell(UniquePower[onhit]:Level x" item property.....
It does however work for ANY item that can have a stack size, if the stack size is set to 2 (and the tag set to dios_it_w_return[or whatever the script is saved as], resref can be whatever)
... and there it is for anybody here that might be interested in it.... ...
EDIT EDIT EDIT :: Make that ANY thrown weapon type... it's not working for ammo... though I'm sure I could get that sorted with a little more digging/scripting....
EDIT EDIT EDIT EDIT :: Further testing shows it screws up if you *miss* the target........ oh well... nothing ever works correctly on a first attempt.. but hey, at least it is a good starting ground....
It does however work for ANY item that can have a stack size, if the stack size is set to 2 (and the tag set to dios_it_w_return[or whatever the script is saved as], resref can be whatever)
//::///////////////////////////////////////////////
//:: Name dios_it_w_return
//:: FileName dios_it_w_return
//:://////////////////////////////////////////////
/*
This script is my attempt as making a returning thrown weapon
*/
//:://////////////////////////////////////////////
//:: Created By: RustyDios
//:: Created On: 24/03/10
//:://////////////////////////////////////////////
#include "x2_inc_switches"
//:///////////////////////////////////////////////
//:///////////////////////////////////////////////
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
//SendMessageToPC(GetFirstPC(),IntToString(nEvent));
// * This code runs when the item has the OnHitCastSpell: Unique power property
// * and it hits a target(weapon) or is being hit (armor)
// * Note that this event fires for non PC creatures as well. !!!!
if (nEvent == X2_ITEM_EVENT_ONHITCAST)
{
object oItem = GetSpellCastItem(); // The item casting triggering this spellscript (the thrown weapon)
object oSpellOrigin = OBJECT_SELF ; //The PC throwing the weapon
object oSpellTarget = GetSpellTargetObject();// the person hit
object oPC = OBJECT_SELF; //The PC throwing the weapon
object oINew = CopyItem(oItem,oPC,TRUE);// copy the old weapon
SetIdentified(oINew,TRUE); // set to Identified
SetItemStackSize(oINew,1);
ClearAllActions(); // clear action que
AssignCommand(oPC,ActionEquipItem(oINew,INVENTORY_SLOT_RIGHTHAND));// equip weapon
AssignCommand(oPC,ActionAttack(oSpellTarget)); // continue combat
}
}
... and there it is for anybody here that might be interested in it.... ...
EDIT EDIT EDIT :: Make that ANY thrown weapon type... it's not working for ammo... though I'm sure I could get that sorted with a little more digging/scripting....
EDIT EDIT EDIT EDIT :: Further testing shows it screws up if you *miss* the target........ oh well... nothing ever works correctly on a first attempt.. but hey, at least it is a good starting ground....
Last edited by RustyDios on Wed Mar 24, 2010 7:03 pm; edited 1 time in total
RustyDios- High Epic Level
- Number of posts : 2271
Age : 40
Location : England // Getting lost in Aenea
Main Character : Jay Braysin, The Wandering Shadow, Protector of Nektaria, Talon's Eternal Foe
Other Character : Shouri Braysin, The Shimmerstar's Moonlight Sorceress
Other Character. : Grace Fularras, Walking Library , Cleric of Mystara
Other Character.. : See my sig ... And here too ...
NWN Username : RustyDios
Time Zone : GMT (England, DST)
. :
Registration date : 2008-07-28
Re: Custom item of returning
Nice. That would cause little (If any) lag, unless everyone on the server was using it.
The main problem with On-hit:Cast Spell is that if someone with ton attacks uses an item with it, it will get called tons of times every round; If the spell is one that has to calculate damage it will cause massive lag.
So that should be fine to use. Worth a try.
The main problem with On-hit:Cast Spell is that if someone with ton attacks uses an item with it, it will get called tons of times every round; If the spell is one that has to calculate damage it will cause massive lag.
So that should be fine to use. Worth a try.
Alundaio- Aenean Scholar
- Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. :
Registration date : 2009-09-14
Re: Custom item of returning
From the testing with it I've just been doing (and some more toying with an attempt for ammo replen) using my test ftr/rog (4 attacks round), it seems to only be one attack per round.. I think this is due to the call for ClearAllActions "pausing combat" on each hit.. ((time for said weapon to return)).... .... see also the edit notice above about *misses* !
RustyDios- High Epic Level
- Number of posts : 2271
Age : 40
Location : England // Getting lost in Aenea
Main Character : Jay Braysin, The Wandering Shadow, Protector of Nektaria, Talon's Eternal Foe
Other Character : Shouri Braysin, The Shimmerstar's Moonlight Sorceress
Other Character. : Grace Fularras, Walking Library , Cleric of Mystara
Other Character.. : See my sig ... And here too ...
NWN Username : RustyDios
Time Zone : GMT (England, DST)
. :
Registration date : 2008-07-28
Re: Custom item of returning
And an even easier way that works for ammo too...
//::///////////////////////////////////////////////
//:: Name dios_it_w_return
//:: FileName dios_it_w_return
//:://////////////////////////////////////////////
/*
This script is my attempt as making a returning thrown weapon
The item must have the same tag as this this scripts saved title
The item must have the OnHit:CastSpell(UniquePower[OnHit](level x)) item prop
... this goes for ammo too (not the actual bow, x-bow, sling)
*/
//:://////////////////////////////////////////////
//:: Created By: RustyDios
//:: Created On: 24/03/10
//:://////////////////////////////////////////////
#include "x2_inc_switches"
//:///////////////////////////////////////////////
//:///////////////////////////////////////////////
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
object oItem;
// * This code runs when the item has the OnHitCastSpell: Unique power property
// * and it hits a target(weapon) or is being hit (armor)
// * Note that this event fires for non PC creatures as well.
if (nEvent == X2_ITEM_EVENT_ONHITCAST)
{
oItem = GetSpellCastItem(); // The item casting triggering this spellscript (the thrown weapon)
SetItemStackSize(oItem,50);
// with the item stack always replenishing to 50 it very unlikely to get 50 misses in a row....
// .. well I think it's unlikely....
}
// * This code runs when the item is equipped
// * Note that this event fires PCs only
else if (nEvent ==X2_ITEM_EVENT_EQUIP)
{
oItem = GetPCItemLastEquipped();
SetItemStackSize(oItem,50); // on equip from inventory boost stack to 50 for firing
}
// * This code runs when the item is unequipped
// * Note that this event fires PCs only
else if (nEvent ==X2_ITEM_EVENT_UNEQUIP)
{
oItem = GetPCItemLastUnequipped();
SetItemStackSize(oItem,1); // on unequip drop stack to 1 for buying selling....
}
}
RustyDios- High Epic Level
- Number of posts : 2271
Age : 40
Location : England // Getting lost in Aenea
Main Character : Jay Braysin, The Wandering Shadow, Protector of Nektaria, Talon's Eternal Foe
Other Character : Shouri Braysin, The Shimmerstar's Moonlight Sorceress
Other Character. : Grace Fularras, Walking Library , Cleric of Mystara
Other Character.. : See my sig ... And here too ...
NWN Username : RustyDios
Time Zone : GMT (England, DST)
. :
Registration date : 2008-07-28
Re: Custom item of returning
What happens if you miss on your first hit and you only have 1 ammo/thrown weapon?
Alundaio- Aenean Scholar
- Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. :
Registration date : 2009-09-14
Re: Custom item of returning
Heya ... shouldn't this thread, or at least parts of it, be moved to the scripting sub-forum?
Eric of Atrophy- Ludicrous Level
- . :
Number of posts : 4113
Age : 51
Location : Kea'au, HI, USA
Main Character : The Vault of Atrophy
NWN Username : atrophied_eric
DM Name : Dungeon Mistress Anaurra Lide
Time Zone : GMT - 10:00 EST (We have our own time zone!)
Registration date : 2008-06-06
Re: Custom item of returning
You don't/won't .... ..
... the second it gets equipped the stack size bumps to 50....
....it's a bit misleading on the script layout...
... but the item gets equipped first (second item-event from script fires.. stack from 1 to 50, your first shot takes it to 49),
....then used (first item event fires. stack continuously replenished to 50 on each and any hit),
....then unequipped when your finished with it (third item event fires, stack size reset to 1)... ...
... trust me this works very well for all the play testing situations I could think of... .... .... ...
... the second it gets equipped the stack size bumps to 50....
....it's a bit misleading on the script layout...
... but the item gets equipped first (second item-event from script fires.. stack from 1 to 50, your first shot takes it to 49),
....then used (first item event fires. stack continuously replenished to 50 on each and any hit),
....then unequipped when your finished with it (third item event fires, stack size reset to 1)... ...
... trust me this works very well for all the play testing situations I could think of... .... .... ...
RustyDios- High Epic Level
- Number of posts : 2271
Age : 40
Location : England // Getting lost in Aenea
Main Character : Jay Braysin, The Wandering Shadow, Protector of Nektaria, Talon's Eternal Foe
Other Character : Shouri Braysin, The Shimmerstar's Moonlight Sorceress
Other Character. : Grace Fularras, Walking Library , Cleric of Mystara
Other Character.. : See my sig ... And here too ...
NWN Username : RustyDios
Time Zone : GMT (England, DST)
. :
Registration date : 2008-07-28
Re: Custom item of returning
erm, ok, I admit I don't understand most of the above , but for now I take 's reply simply as a "No" and think about which weapon to take instead for my rogue, and if RustyDios can make a working script for returning items and decides to implement it I will rejoice when it's done .
Nonetheless thanks for giving it a thought everyone .
Nonetheless thanks for giving it a thought everyone .
half_evil_333- Adventurer
- Number of posts : 27
Age : 39
Location : some fictional realm within the dnd multiverse
Main Character : Tarn Moondusk
NWN Username : Half3vil333
Time Zone : \GMT +1:00\
Registration date : 2010-03-17
Re: Custom item of returning
I enjoyed looking at the scripts above.
I'm unfamiliar with NWN code, and am wondering if there is a list of NWN function definitions, etc somewhere I might be able to look at.
I'm unfamiliar with NWN code, and am wondering if there is a list of NWN function definitions, etc somewhere I might be able to look at.
Svair- Epic Level
- Number of posts : 1178
Age : 52
Location : Seattle, WA
Main Character : Karamip Ningle
Other Character : Phyllick Delucian
NWN Username : S'Vair
. :
Registration date : 2008-06-03
Re: Custom item of returning
Holy crap! I thought I would have to chew through a bunch of header files. That's awesome, thanks!
Svair- Epic Level
- Number of posts : 1178
Age : 52
Location : Seattle, WA
Main Character : Karamip Ningle
Other Character : Phyllick Delucian
NWN Username : S'Vair
. :
Registration date : 2008-06-03
Similar topics
» Custom Item property
» Custom Item Properties
» Creating my first custom item...
» Custom item question.
» Custom item redesign
» Custom Item Properties
» Creating my first custom item...
» Custom item question.
» Custom item redesign
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum