Would you like to react to this message? Create an account in a few clicks or log in to continue.

Custom item of returning

+3
RustyDios
The Amethyst Dragon
half_evil_333
7 posters

Go down

Custom item of returning Empty Custom item of returning

Post by half_evil_333 Wed Mar 24, 2010 11:46 am

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 Custom item of returning Icon_cry. 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 Custom item of returning Icon_neutral.
half_evil_333
half_evil_333
Adventurer
Adventurer

Male Number of posts : 27
Age : 38
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

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by The Amethyst Dragon Wed Mar 24, 2010 12:02 pm

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).
The Amethyst Dragon
The Amethyst Dragon
Ludicrous Level
Ludicrous Level

. : Creator of Aenea / Dungeon Master
Male Number of posts : 7840
Age : 48
Location : probably on the computer or wrangling his offspring
NWN Username : amethystdragon
DM Name : The Amethyst Dragon
Time Zone : GMT - 6:00 (Wisconsin)
Registration date : 2008-06-02

https://www.amethyst-dragon.com

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by RustyDios Wed Mar 24, 2010 1:52 pm

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 The Amethyst Dragon 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
RustyDios
High Epic Level
High Epic Level

Male Number of posts : 2271
Age : 39
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)
. : Custom item of returning Forum_donor
Registration date : 2008-07-28

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Alundaio Wed Mar 24, 2010 2:24 pm

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.
Alundaio
Alundaio
Aenean Scholar
Aenean Scholar

Male Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. : Custom item of returning Forum_donor
Registration date : 2009-09-14

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by RustyDios Wed Mar 24, 2010 5:22 pm

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
RustyDios
High Epic Level
High Epic Level

Male Number of posts : 2271
Age : 39
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)
. : Custom item of returning Forum_donor
Registration date : 2008-07-28

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by evilkittenofdoom Wed Mar 24, 2010 5:47 pm

Not to mention the lag that such a script might cause with how often it would be running.
evilkittenofdoom
evilkittenofdoom
Epic Level
Epic Level

Male 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

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Alundaio Wed Mar 24, 2010 6:06 pm

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.
Alundaio
Alundaio
Aenean Scholar
Aenean Scholar

Male Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. : Custom item of returning Forum_donor
Registration date : 2009-09-14

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by RustyDios Wed Mar 24, 2010 6:08 pm

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)


//::///////////////////////////////////////////////
//:: 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
RustyDios
High Epic Level
High Epic Level

Male Number of posts : 2271
Age : 39
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)
. : Custom item of returning Forum_donor
Registration date : 2008-07-28

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Alundaio Wed Mar 24, 2010 6:36 pm

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.
Alundaio
Alundaio
Aenean Scholar
Aenean Scholar

Male Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. : Custom item of returning Forum_donor
Registration date : 2009-09-14

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by RustyDios Wed Mar 24, 2010 7:07 pm

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
RustyDios
High Epic Level
High Epic Level

Male Number of posts : 2271
Age : 39
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)
. : Custom item of returning Forum_donor
Registration date : 2008-07-28

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by RustyDios Wed Mar 24, 2010 8:23 pm

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
RustyDios
High Epic Level
High Epic Level

Male Number of posts : 2271
Age : 39
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)
. : Custom item of returning Forum_donor
Registration date : 2008-07-28

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Alundaio Wed Mar 24, 2010 8:51 pm

What happens if you miss on your first hit and you only have 1 ammo/thrown weapon?
Alundaio
Alundaio
Aenean Scholar
Aenean Scholar

Male Number of posts : 372
Age : 39
Main Character : Alundaio
Time Zone : GMT-04:00 (EST)
. : Custom item of returning Forum_donor
Registration date : 2009-09-14

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Eric of Atrophy Wed Mar 24, 2010 9:01 pm

Heya ... shouldn't this thread, or at least parts of it, be moved to the scripting sub-forum?
Eric of Atrophy
Eric of Atrophy
Ludicrous Level
Ludicrous Level

. : Dungeon Master
Male Number of posts : 4112
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

http://myanimelist.net/profile/Eric_of_Atrophy

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by RustyDios Wed Mar 24, 2010 9:04 pm

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... .... .... ...
RustyDios
RustyDios
High Epic Level
High Epic Level

Male Number of posts : 2271
Age : 39
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)
. : Custom item of returning Forum_donor
Registration date : 2008-07-28

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by half_evil_333 Thu Mar 25, 2010 4:00 am

erm, ok, I admit I don't understand most of the above Custom item of returning Icon_redface , but for now I take The Amethyst Dragon'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 Custom item of returning 787378 decides to implement it I will rejoice when it's done Custom item of returning Icon_smile.
Nonetheless thanks for giving it a thought everyone Custom item of returning Icon_wink.
half_evil_333
half_evil_333
Adventurer
Adventurer

Male Number of posts : 27
Age : 38
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

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Svair Thu Mar 25, 2010 11:00 am

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.
Svair
Svair
Epic Level
Epic Level

Male Number of posts : 1178
Age : 52
Location : Seattle, WA
Main Character : Karamip Ningle
Other Character : Phyllick Delucian
NWN Username : S'Vair
. : Custom item of returning Forum_donor
Registration date : 2008-06-03

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by The Amethyst Dragon Thu Mar 25, 2010 11:11 am

The Amethyst Dragon
The Amethyst Dragon
Ludicrous Level
Ludicrous Level

. : Creator of Aenea / Dungeon Master
Male Number of posts : 7840
Age : 48
Location : probably on the computer or wrangling his offspring
NWN Username : amethystdragon
DM Name : The Amethyst Dragon
Time Zone : GMT - 6:00 (Wisconsin)
Registration date : 2008-06-02

https://www.amethyst-dragon.com

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Svair Thu Mar 25, 2010 11:28 am

Holy crap! I thought I would have to chew through a bunch of header files. That's awesome, thanks!
Svair
Svair
Epic Level
Epic Level

Male Number of posts : 1178
Age : 52
Location : Seattle, WA
Main Character : Karamip Ningle
Other Character : Phyllick Delucian
NWN Username : S'Vair
. : Custom item of returning Forum_donor
Registration date : 2008-06-03

Back to top Go down

Custom item of returning Empty Re: Custom item of returning

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum