Sign in with
Sign up | Sign in
Your question

[Toolset] One Time Use Item

Last response: in Video Games
Share
Anonymous
December 15, 2004 9:12:38 AM

Archived from groups: alt.games.neverwinter-nights (More info?)

I have a 1 time use item that I want to only operate under certain
conditions. The thing is, I don't want the item to be consumed if the
conditions aren't right.

I've tried making it a 1 time use Unique Power and also a charged item
with 1 charge. I've tried:

(1) Use CopyItem to make a new copy of the item to replace the one being
consumed if the conditions aren't right. The CopyItem returns an Invalid
object - it must be being consumed before my ItemActivated code runs.

(2) For the charged item scenario, I've tried setting the charges back
to 1. This does nothing as well, probably for the same reason.

Suggestions?
--
My NWN Work So Far: http://tinyurl.com/6xy2f
"Pits of red smoke and fog are usually bad."
- Tip from Doom3 Manual

More about : toolset time item

Anonymous
December 15, 2004 1:09:40 PM

Archived from groups: alt.games.neverwinter-nights (More info?)

everlast wrote:
> I have a 1 time use item that I want to only operate under certain
> conditions. The thing is, I don't want the item to be consumed if the
> conditions aren't right.
>
> I've tried making it a 1 time use Unique Power and also a charged item
> with 1 charge. I've tried:
>
> (1) Use CopyItem to make a new copy of the item to replace the one
> being consumed if the conditions aren't right. The CopyItem returns
> an Invalid object - it must be being consumed before my ItemActivated
> code runs.
>
> (2) For the charged item scenario, I've tried setting the charges back
> to 1. This does nothing as well, probably for the same reason.
>
> Suggestions?

Maybe the function GetItemActivatedTarget() will help. When you activate the
item, the OnActivateItem() script of the module is triggered. This script
may look like this:

void main()
{
object oItem = GetItemActivated();
string sTag = GetTag(oItem);
object oPC = GetItemActivator();
object oTarget = GetItemActivatedTarget();

//Then the function:

if (sTag == "MyItem" && GetTag(oTarget) == "MyTarget")
{
ExecuteScript("MyItemActivated", oTarget);
}
}

The executed script handles the action on the target (e.g. destroying or
opening it) and finally destroys the item in the player's inventory.

HTH
Hans
Anonymous
December 15, 2004 10:41:37 PM

Archived from groups: alt.games.neverwinter-nights (More info?)

>I have a 1 time use item that I want to only operate under certain
>conditions. The thing is, I don't want the item to be consumed if the
>conditions aren't right.

I assume that the one use effect is scripted i nwhich case the solution is
fairly simple.

Create the item required give it the UniquePower or UniquePowerSelfOnly
depending on preferences. Make sure it has unlimited uses per day.

Give the item a good description so its possible to work out where to use
it.

I use the modules OnActivate item script hook and don't use the single
script per item method that HotU allows (Its just to keep all my code in one
place)

Heres the code I used to allow a grenade item (Fire Capsules) to destroy a
monster (Treeman) in the PC is in the correct area and within a distance of
20.0 (metres / feet? who knows):

void main()
{
object oUser = GetItemActivator();
object oUsed = GetItemActivated();
string sItemTag = GetTag(oUsed);

if (sItemTag == "FireCapsules")
{
object oTree = GetObjectByTag("TreeMan");

if ( GetDistanceBetween(oTree, oUser) < 20.0 )
{
effect eFire = EffectVisualEffect(VFX_FNF_FIREBALL);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eFire, oTree);
effect eEffect = EffectDeath(TRUE, TRUE);
object oItem = GetItemPossessedBy(oUser, "FireCapsules");
DestroyObject(oItem, 0.0);
}
else
{
AssignCommand(oUser, SpeakString("I do not want to use those right
now."));
}
}
}

If the item is used in the incorrect place the PC gets floating text saying
its not the correct time to use it. When its used in the correct place then
the special effects happen (have edited code for simplicity) and the item is
then destroyed from the inventory.

Any criteria for the correct usage of the item could be coded into the
script.
Related resources
Anonymous
December 15, 2004 11:13:34 PM

Archived from groups: alt.games.neverwinter-nights (More info?)

everlast wrote:
> I have a 1 time use item that I want to only operate under certain
> conditions. The thing is, I don't want the item to be consumed if the
> conditions aren't right.
>
> I've tried making it a 1 time use Unique Power and also a charged item
> with 1 charge. I've tried:
>
> (1) Use CopyItem to make a new copy of the item to replace the one being
> consumed if the conditions aren't right. The CopyItem returns an Invalid
> object - it must be being consumed before my ItemActivated code runs.
>
> (2) For the charged item scenario, I've tried setting the charges back
> to 1. This does nothing as well, probably for the same reason.

Thanks to those who replied.

It turns out that it is in fact the case that the item is consumed
before any of the scripts run, so it can't be made into a "true" 1-use
item. It can only be made, as 1 reply suggested, a many-use item that I
then manually destroy if used in the correct fashion. This is what I
was trying to avoid, as to avoid any confusion on the part of the player
when the 'Properties' section would seem to indicate that item can be
used repeatedly yet my description is telling them it can only be used
once. But there is no way around it.
--
My NWN Work So Far: http://tinyurl.com/6xy2f
"Pits of red smoke and fog are usually bad."
- Tip from Doom3 Manual
Anonymous
December 15, 2004 11:17:20 PM

Archived from groups: alt.games.neverwinter-nights (More info?)

On Wed, 15 Dec 2004 06:12:38 GMT, everlast <everlast@jmjservices.com>
wrote:

>I have a 1 time use item that I want to only operate under certain
>conditions. The thing is, I don't want the item to be consumed if the
>conditions aren't right.
>
>I've tried making it a 1 time use Unique Power and also a charged item
>with 1 charge. I've tried:
>
>(1) Use CopyItem to make a new copy of the item to replace the one being
>consumed if the conditions aren't right. The CopyItem returns an Invalid
>object - it must be being consumed before my ItemActivated code runs.
>
>(2) For the charged item scenario, I've tried setting the charges back
>to 1. This does nothing as well, probably for the same reason.
>
>Suggestions?

It seems to me that the designers made such items infinite use
but when they are activated for real the script destroys the item.
December 16, 2004 1:22:18 PM

Archived from groups: alt.games.neverwinter-nights (More info?)

"everlast" <everlast@jmjservices.com> wrote in message
news:qBQvd.42331$4m5.28569@fe1.columbus.rr.com...
>I have a 1 time use item that I want to only operate under certain
>conditions. The thing is, I don't want the item to be consumed if the
>conditions aren't right.
>
> I've tried making it a 1 time use Unique Power and also a charged item
> with 1 charge. I've tried:
>
> (1) Use CopyItem to make a new copy of the item to replace the one being
> consumed if the conditions aren't right. The CopyItem returns an Invalid
> object - it must be being consumed before my ItemActivated code runs.
>
> (2) For the charged item scenario, I've tried setting the charges back to
> 1. This does nothing as well, probably for the same reason.
>
> Suggestions?

On use, create a second one, which is then destroyed if the use works
correctly, else it is the one that stays in inventory. Not perfect, but may
do what you are looking for.

David

--
CaissaWas__SPAMHater__INTP@adelphia__ANTIV__.net without the block
> --
> My NWN Work So Far: http://tinyurl.com/6xy2f
> "Pits of red smoke and fog are usually bad."
> - Tip from Doom3 Manual
>
!