//:://///////////////////////////////////////////// //:: gz_inc_onact //:: gz_inc_onact.nss //:: Copyright (c) 2001 Dom Queron //::////////////////////////////////////////////// /* On Activate Scripts... */ //Removes a rope between oTarget and oTarget2 void RemoveRope(object oTarget, object oTarget2); // This should be put in the OnActivate Code of your module it will handle all checks regarding the rope. // If it returns true you can end the OnActivate Script using a return statement - DomQ int CheckRopeTarget(); /*------------------------------------------------------------------*/ void RemoveRope(object oTarget, object oTarget2) { effect eEff = GetFirstEffect(oTarget); while (GetIsEffectValid(eEff)) { if (GetEffectType(eEff) == EFFECT_TYPE_BEAM) RemoveEffect(oTarget,eEff); eEff = GetNextEffect(oTarget); } //CreateObject(OBJECT_TYPE_ITEM,"gz_it_rope", GetLocation(oTarget)); DestroyObject(oTarget2); if (GetLocalInt(oTarget,"T1_OBJECT_KILLSELF") == TRUE) { DestroyObject(oTarget); } else DeleteLocalObject(oTarget,"T1_TARGET_OBJECT"); } int CheckRopeTarget() { /* Rope Config Area - If you change anything, dont forget to BUILD you module!*/ float CFG_ROPE_ATTACH_TIMEOUT = 30.0f; // How much time the rope stays attached default: 30 secs /* End Rope Config */ object oRope = GetItemActivated(); if (GetTag(oRope) != "gz_it_rope" ) return FALSE; object oTarget = GetItemActivatedTarget(); if (oTarget == OBJECT_INVALID) { location lLoc = GetItemActivatedTargetLocation(); oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 5.0f,lLoc,FALSE,OBJECT_TYPE_PLACEABLE); int bFound = FALSE; while (oTarget != OBJECT_INVALID && !bFound) { // our string starts with "gz_rhook_" thus it is a ledge where the rope can be attached if (FindSubString(GetStringLowerCase(GetTag(oTarget)), "gz_rhook_") == 0 ) bFound = TRUE; else oTarget = GetNextObjectInShape(SHAPE_SPHERE, 5.0f,lLoc,FALSE,OBJECT_TYPE_PLACEABLE); } if (!bFound) oTarget =OBJECT_INVALID; else { oTarget = CreateObject(OBJECT_TYPE_PLACEABLE,"gz_obj_ropecont",GetItemActivatedTargetLocation()); SetLocalInt(oTarget,"T1_OBJECT_KILLSELF",TRUE); } } if (GetLocalObject(oTarget,"T1_TARGET_OBJECT") != OBJECT_INVALID) { AssignCommand (GetItemActivator(),ActionSpeakString("I can't have two ropes at the same spot")); } if (oTarget != OBJECT_INVALID && GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE) // we have a target { effect eBeam; /* This branch runs when the rope is not attached somewhere */ if (!FindSubString(GetStringLowerCase(GetTag(oTarget)), "gz_rhook_") == 0) { // we need a valid rope hook to attach the object to! AssignCommand (GetItemActivator(),ActionSpeakString("I cannot attach a rope there!")); return TRUE; } object oTarget2 = CreateObject(OBJECT_TYPE_PLACEABLE,"gz_obj_ropecont",GetLocation(GetItemActivator())); if (oTarget2 != OBJECT_INVALID) { FloatingTextStringOnCreature("Grappling Hook Hit!",GetItemActivator()); eBeam = EffectBeam(VFX_BEAM_MIND,oTarget2,BODY_NODE_CHEST); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eBeam,oTarget); WriteTimestampedLogEntry("Rope attached"); DelayCommand(CFG_ROPE_ATTACH_TIMEOUT,RemoveRope(oTarget,oTarget2)); AssignCommand(oTarget,ActionTakeItem(oRope,GetItemPossessor(oRope) )); SetLocalObject(oTarget2,"T1_TARGET_OBJECT",oTarget); SetLocalObject(oTarget,"T1_TARGET_OBJECT",oTarget2); return TRUE; } else { AssignCommand (GetItemActivator(),ActionSpeakString("The grappling hook won't work there!")); return TRUE; } } else { AssignCommand (GetItemActivator(),ActionSpeakString("The grappling hook won't work there!")); return TRUE; } return TRUE; }