Hall of Traps
Zephirius
Member Posts: 419
I'm trying very hard to create a script that will: when a wand is used it disarms each trap slowly, one by one. There are 10 traps in the hallway...
I've tried to do this but I'm afraid my scripting hasn't caught up with my ambitions.
Any help would be greatly appreciated.
I've tried to do this but I'm afraid my scripting hasn't caught up with my ambitions.
Any help would be greatly appreciated.
0
Comments
void main()
{
object oTrapSeen = GetTrapDetectable();
void main() { // You can set this to get any trap, but calling it this way only gets traps that the user can see. object oTrap = GetNearestTrapToObject(); // This is our escape case. When the user sees no more traps oTrap will return as OBJECT_INVALID. if(GetIsObjectValid(oTrap)) { // This tries to copy the visual display of the knock spell. effect eVis = EffectVisualEffect(VFX_IMP_KNOCK); ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTrap); // This disables the trap and fires the OnDisabled event of the trap. SetTrapDisabled(oTrap); // This waits 2 seconds then calls the script again on the player that originally called it. DelayCommand(2.0, ExecuteScript("trap_wand")); } }I have not compiled this or tested it at all, but it should be a good start, I think.
Let me know if you need help getting the wand to call the script using your module OnItemActivated script.
(Added comments to the code)
Under the edit tab, go to module properties. Under the events tab, edit the second script down (OnActivateItem). Ignore all warnings.
The script should already have Somewhere under that, add:
// This grabs who used the item. object oPC = GetItemActivator(); // This is a fail-safe check if(GetIsObjectValid(oItem)) { // Find the tag of the item that was activated. string sTag = GetTag(oItem); // If it is the trap wand, run the script on the player who activated it. // You will need to replace YourWandTag with the actual tag of the trap wand. if(sTag == "YourWandTag") { ExecuteScript("trap_wand", oPC); } }There may be a if(GetIsObjectValid(oItem)) check in the script already, you can copy what you need.
Thank you for your time and your scripting lesson.