I was trying to make a potion that only one person can drink by using the class restrictions but they’re not on the potion options. So I tried a wand which had the restrictions but they weigh too much and have a different animation. I then used a scroll and changed it into a potion in the properties, the animation was fine but the restriction was gone because it was a potion again.
Is it possible to restrict a potion or am I trying to go against the way the game works ? In which case I’ll just make them as potions and leave it up to the player to role play it. These are healing potions so nothing fancy or vital to the plot that can’t have anybody drinking them.
There has to be a way to do this by scripting. I don’t think it’s impossible at all. However, I have to go to sleep now, but I can see if I can help you tomorrow if somebody else doesn’t beat me to it.
That’s an interesting idea but it’s not a one off thing, it’s something there’ll be a lot of that you can collect so anybody can pick it up just like normal healing potions. I just wanted to make some blueprints then scatter them about as loot and when anybody but the intended person has them in their inventory they come up red and unusable.
Excellent so it is possible and that way I can restrict it to the character I want with it still being a potion ! Thank you, I will investigate this later and see what happens.
Thinking about your problem Tsongo when I went to sleep, my first thought was something along these lines too.
Perhaps use the i_itemtag_ac template, and do something with the script that checks the character’s tag that you want to be able to use the potion. If it’s not that character that has the item he/she won’t be able to use it.
I think I have a solution now. Create a new item, under Item Properties select Cast Spell: Unique Power Self Only [- Unlimited Uses] . Under Base Item choose Miscellaneous Small Object (or use Potion, but the drinking animation will run even for the character that can’t use the item)
Then use this script:
// i_temp_ac
/*
Template for an Activate item script.
This script will run each time an item's "custom activation" is used.
How to use this script:
Item needs an item property that will cause a custom activation such as Cast Spell:Unique Power
Replace the word "temp" (in line 1) with the tag of the item. Rename the script with this name.
Additional Info:
In general, all the item "tag-based" scripts will be named as follows:
- a prefix ("i_" by defualt)
- the tag of the item
- a postfix indicating the item event.
This script will be called automatically (by defualt) whether it exists or not. If if does not exist, nothing happens.
Note: this script runs on the module object, an important consideration for assigning actions.
-ChazM
*/
// Name_Date
void PrepForDestruction(object oTarget)
{
SetPlotFlag(oTarget,FALSE);
SetImmortal(oTarget,FALSE);
AssignCommand(oTarget,SetIsDestroyable(TRUE,FALSE,FALSE));
}
void main()
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oCharacter = GetObjectByTag("charactertag");
effect eVisual = EffectNWN2SpecialEffectFile("sp_cure_light");
if(oPC != oCharacter)
{
FloatingTextStringOnCreature("You can't use this item.", oPC, FALSE);
return;
}
else
{
effect eHeal = EffectHeal(15);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPC);
PrepForDestruction(oItem);
DestroyObject(oItem);
}
}
andgalf… That is totally awesome it works perfectly. Much better than my copy and pasting which involved me getting carried away and copying half the page in my excitement and pasting all the suggested topics and the rest of this forum page on to a blank script then wondering what happened !
It is now immortalised with your name on it in my mod and will definitely be heading into the templates.
I’m going to make the item icon and description look like it’s supposed to and at least now the PC will not be drinking something awful !
Many many thanks if I could like your post a load more times I would and I apologise for keeping you awake last night thinking about it !
ps. I’ve never seen prep for destruction in a script before and found that highly amusing as it seems like you’ve just set off the timer on a bomb !
LOL! No, no, it didn’t keep me awake at all. I just thought about it a bit as I went to bed, then I fell asleep.
Hehe. Yeah, it’s maybe not necessary, but I always use that function to be on the safe side. Almost all this code you see in the script I copied from stock scripts like ga_heal and ga_destroy. The Prepfordestruction is from ga_destroy.
Edit: Maybe there is a way to prevent the animation from happening if your character isn’t suppose to be able to drink it, but that’s above my knowledge, I’m afraid. I’m sure kevL_s, travus and Lance_Botelle could do a way more advanced script for you, that maybe will get it to look even more cool ingame but…well, if you think it works now, then I’m glad. And of course, I’m sure you understand this, you can change the amount of points the potion is supposed to heal by changing the number in EffectHeal.
Could you copy and edit the itemprops.2da, and for column 8-potions, change the value **** to a 1 on Use_Limitation_Class.
What that achieves is making that property available when editing items in your module, and then you can set a class use limitation in your custom item’s properties
andgalf… I’m going to have to investigate healing spells and find out how much they heal so I can make up a full set with the scripts altered to match. As for more advanced scripts your one definitely does the job and the “you can’t use this” is a bonus so I’m very happy.
THughes281… Excellent idea and what I was aiming for to start with, I’m going to keep it in mind for other things I might require that have to be restricted. I can think of one already and that’s a hood. Thank you.
Yes. I have many items that are “restricted” one way or another, including potions.
I see that @andgalf has written a script for you, so I won’t repeat. I would only add a couple of other pointers …
You can also use the “single use” property if you ensure your script replaces any potion used “in error”. i.e. This way the potion will say “Single Use” only rather than “Unlimited Uses”, which may mislead the player if it is not unlimited in uses. I do it this way to ensure the description is correct, but may not be required for you.
You only need a single script for multiple items! i.e. Differentiate usage of the script via resref (or variable association) detection. I have a single script that handles all my items like this, which makes editing and adding much easier.
Lance_Botelle… Thanks for the info and I can see that unlimited uses could be confusing so to save that I could put a line in the description explaining it or be brave and write a create item line in the script under the FloatingTextStringOnCreature line, cross my fingers and press compile !
As for the single script for many items it would be good but I’ll keep it simple, one item one script , I can handle that and know where it’s gone wrong if it does.
I will investigate the functions in the script maker later.
I actually tried that first, but I thought it looked odd when the game says to the player that he/she can’t consume the potion and then does so anyway, only for a new one to appear. So I guess it’s up to what you prefer. None of the options are ideal but both are acceptable, I guess.