Author Topic: Attacking an Object deactivates Trap  (Read 609 times)

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Attacking an Object deactivates Trap
« Reply #15 on: September 28, 2010, 07:00:37 pm »


               Here it is with the trap set as undetectable:






// "trap1" = trap Tag



// "flame_waypoint = waypoint Tag



// "flamelarge001" = resref of placable



void main()



{

object oPC = GetLastDamager();

if (!GetIsPC(oPC)) return;

object oTrapObject = GetObjectByTag("trap1");
object oArea = GetArea(OBJECT_SELF);
object oDetector;
object oChecker = GetFirstObjectInArea(oArea);



while(GetIsObjectValid(oChecker))
{//determine which pc in this area detected the trap

    if(GetIsPC(oChecker))
    {
        if(GetTrapDetectedBy(oTrapObject, oChecker))
        {
            oDetector = oChecker;
        }
    }
    oChecker = GetNextObjectInArea(oArea);
}


SetTrapDetectedBy(oTrapObject, oDetector, FALSE);
SetTrapActive(oTrapObject, FALSE);
SetTrapDetectable(oTrapObject, FALSE);


int iActiveFlame = GetLocalInt(OBJECT_SELF, "MY_FLAME");
if (iActiveFlame != TRUE)
{
    object oWP = GetWaypointByTag("flame_waypoint");
    location lWP = GetLocation(oWP);
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge001", lWP);
    SetLocalInt(OBJECT_SELF, "MY_FLAME", TRUE);
}

 PlaySound("as_cv_gongring1");
}

               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Attacking an Object deactivates Trap
« Reply #16 on: September 28, 2010, 07:01:46 pm »


               Sorry I seem to have double posted...':mellow:'
               
               

               


                     Modifié par Baragg, 28 septembre 2010 - 06:02 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Attacking an Object deactivates Trap
« Reply #17 on: September 28, 2010, 11:45:10 pm »


               

Lightfoot8 wrote...

No need to reset the DC.  Just set the trap undectable.

SetTrapDetectable(oTrapObject,FALSE);

Then reset it to dectable when you make it active again.  


Oh duh. That one slipped right past me. ':lol:'
               
               

               
            

Legacy_Lethal_Bottle

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Attacking an Object deactivates Trap
« Reply #18 on: September 29, 2010, 12:58:26 am »


                Thanks you three ':wizard:' the script works perfectly now and was everything I needed! ^^ I'm going to try and get my head around how it works too. 

I hope it's useful for other people browsing this thread too, it's a pretty generic dungeon puzzle (as anyone who's played Ocarina of Time and had to shoot the eye over and over will know xD)

Thanks again! You guys are awesome! '<img'>