I’m not advanced enough yet to make quests etc but i’d love a placeable onused that rewards exp to the player but only works once… Unless the server is reset!
Would be cool if i could assign a variable to each crystal that rewards exp too, for the number of exp given, or maybe an area variable… I wish i can learn faster
hmm! I’ve no PW experience, so I don’t know about checking for a server reset, but far as the awarding exp on placeable use once goes, you could set an integer on the user’s creature skin. AFAIK that’s persistent past character export, too.
OK, building blocks unassembled for learning purposes, but in order.
These are the functions you need for this:
GetLastUsedBy()
<- In an OnUsed event, returns the last user.
GetItemInSlot()
<- Gets an item by a specific slot, in this case INVENTORY_SLOT_CARMOUR
GetLocalInt()
<- Use this to check for the presence of the integer you set, so you can abort the script (return;
) if it’s present.
SetLocalInt()
<- Use this to set an integer on the item in the CARMOUR slot of the user.
GiveXPToCreature()
<- Use this to give XP to the user.
DeleteLocalInt()
<- Remove a stored integer from something.
If you want something to only happen once, you can do something like this:
if (GetLocalInt(oTarget, "ONCE_ONLY"))
return;
SetLocalInt(oTarget, "ONCE_ONLY", 1);
You can store variables and check them again from anywhere you like, you just need to be able to target the object that has the variable set on it again.
Lexicon link for the functions list:
https://nwnlexicon.com/index.php?title=Category:Functions
I think you could also store the character on the module as a local object using GetModule() and SetLocalObject(); I doubt the module would “respawn” with the variable set on it if the server gets rebooted. If you want to store something on the area, same deal, but with GetArea().
Set an integer on the crystal and retrieve it with GetLocalInt(), then apply that integer with GiveXPToCreature(), for making the amount of XP given dependent on the placeable.
Thanks a lot i will try my best!
If you are using the skin it’s best to use the x3_inc_skin routines rather than doing it directly. I think you will have less chance of messing up other systems (like horses) that also use the skin.
However, if you want it to clear on server reset you can just set the variable on the PC. No need to deal with persistence. Scripted placeable variables and PC variables will not survive the server reset. Variables on items (crystals, skin etc) that are exported on the character will.
There are at least a couple of nice scripting tutorials around that cover a lot of this kind of thing which are worth looking at. I bet someone will have links handy…
Thanks much love from me and i’m actually using the easy script generator it’s a great learning tool i think im manageing something i’ll show you guys :)
Did it guys:
/* Script generated by
Lilac Soul’s NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */
//Put this script OnUsed
#include “nw_i0_tool”
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
int DoTwice = GetLocalInt(oPC, GetTag(OBJECT_SELF));
if (DoTwice==TRUE) return;
SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);
RewardPartyXP(500, oPC, FALSE);
FloatingTextStringOnCreature(“500 XP!!!”, oPC);
object oTarget;
oTarget = oPC;
//Visual effects can’t be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP’s location instead
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_SUNSTRIKE), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_SUNSTRIKE), GetLocation(oTarget));
}