Aller au contenu

Photo

trapped door script problem


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Calgacus

Calgacus
  • Members
  • 122 messages
Apparently my script traps the door but the trap then seems to disappear off the door when a PC tries to open the door.
Here is my first script:
void createDoorTrap(object oDoor, object oPC ){
    FloatingTextStringOnCreature(" trap door", oPC, FALSE);
    if (GetIsTrapped(oDoor)!=TRUE){
        CreateTrapOnObject(TRAP_BASE_TYPE_AVERAGE_ACID, oDoor, STANDARD_FACTION_HOSTILE, "empty_trap", "empty_trap");
    }
    if (GetIsTrapped(oDoor)==TRUE){
          FloatingTextStringOnCreature(" trap IS on door", oPC, FALSE);
    }else{
          FloatingTextStringOnCreature(" trap ISNOT door", oPC, FALSE);
    }
    SetTrapDisabled(oDoor);
    if (GetIsTrapped(oDoor)==TRUE){
          FloatingTextStringOnCreature(" trap IS STILL on door", oPC, FALSE);
    }else{
          FloatingTextStringOnCreature(" trap IS NO LONGER on door", oPC, FALSE);
    }
    SetTrapDetectable(oDoor, FALSE);
    SetTrapDetectedBy(oDoor, oPC, FALSE);
    SetTrapDetectDC(oDoor, 250);
    SetTrapDisarmable(oDoor, FALSE);
}
and here is the script that fires when the PC tries to open a locked door:
void main(){
    oPC = GetClickingObject();
    oArea = GetArea(oPC);
    //FloatingTextStringOnCreature("Your turn is over.", oPC, FALSE);
    endTurn();
    //

    if( GetLocalInt(oArea, "REMINDER") == TRUE && GetLocalInt(oArea, "DOORS") == TRUE){
        FloatingTextStringOnCreature(" door should be trapped", oPC, FALSE);
        if (GetIsTrapped(OBJECT_SELF)==TRUE){
            FloatingTextStringOnCreature(" door is trapped", oPC, FALSE);
        }else{
            FloatingTextStringOnCreature(" door is NOT trapped", oPC, FALSE);
        }
        //set trap on door detected by oPC
        SetTrapDetectable(OBJECT_SELF, TRUE);
        SetTrapDetectedBy(OBJECT_SELF, oPC, TRUE);
      //  SetTrapDetectable(OBJECT_SELF, FALSE);
    }
    //
    SoundObjectPlay(GetObjectByTag(GetLocalString(oArea, snd_HITWALL)));
    DragonsTurn();
}
The following messages get output:
trap IS on door
trap IS STILL on door
....and later.....
door should be trapped
door is NOT trapped


So is there something wrong with these scripts?  Maybe the trap is getting removed elsewhere but this part of my script is very new so I doubt I've had a chance yet to include some such code - how would I have removed a trap from a door anyway?
BTW, i am only useing the trap on the door to cause the door to glow red after someone tries and fails to open it to serve as a reminder that they already tried to open that door.

Thanks.

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
A couple errors with the second script.

These two lines:

oPC = GetClickingObject();
oArea = GetArea(oPC);

Should be:

object oPC = GetClickingObject();
object oArea = GetArea(oPC);

And this line:

SoundObjectPlay(GetObjectByTag(GetLocalString(oArea, snd_HITWALL)));

Should be:

SoundObjectPlay(GetObjectByTag(GetLocalString(oArea, "snd_HITWALL")));

Hope that helps.

Modifié par GhostOfGod, 29 septembre 2010 - 02:50 .


#3
Calgacus

Calgacus
  • Members
  • 122 messages
Thanks but those variables were declared in another included file.

PS: The scripts compile and run but the trap is missing in action.  Does OBJECT_SELF not support this usage? GetIsTrapped(OBJECT_SELF)

Modifié par Calgacus, 29 septembre 2010 - 03:09 .


#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
OBJECT_SELF should work fine. Is the "One Shot" box checked on your "empty trap" blueprint? If it is, that might be your problem right there. Once it's triggered it's gone.

And according to the Lexicon:

All traps set by PCs, NPCs during game are automatically set as 'one-shot'.


So you may need to use the function "SetTrapOneShot" at it's creation.
These are just guesses. Haven't fiddled around with traps much.

Modifié par GhostOfGod, 29 septembre 2010 - 03:54 .


#5
Calgacus

Calgacus
  • Members
  • 122 messages
added the one shot call, but I still have the same problem.

#6
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Ok. Instead of just making guesses I just decided to go into the toolset and try this myself.

First off just wondering if there is any particular reason why you don't just set the door trap on the door in the toolset ahead of time instead of creating one in game. It is just a bit easier.

But for testing I made a placeable useable to create a trap on the door like so(This works just fine):

void main()
{
object oDoor = GetNearestObjectByTag("TRAP_DOOR_1");
CreateTrapOnObject(TRAP_BASE_TYPE_AVERAGE_ACID, oDoor, STANDARD_FACTION_HOSTILE, "", "");
SetTrapOneShot(oDoor, FALSE);
SetTrapDetectable(oDoor, FALSE);
SetTrapDisarmable(oDoor, FALSE);
}

Then I just put this in the doors "OnFailToOpen" event:

void main()
{
object oPC = GetClickingObject();
SetTrapDetectedBy(OBJECT_SELF, oPC, TRUE);
}

If the door is locked then the door turns red and stays red for the player who tried to open it.

Hope this helps.

#7
Calgacus

Calgacus
  • Members
  • 122 messages

GhostOfGod wrote...



Ok. Instead of just making guesses I just decided to go into the toolset and try this myself.



First off just wondering if there is any particular reason why you don't just set the door trap on the door in the toolset ahead of time instead of creating one in game. It is just a bit easier.




I didn't think of it when I first made the area and since there are now 112 doors it seemed like a pain.



But for testing I made a placeable useable to create a trap on the door like so(This works just fine):



void main()

{

object oDoor = GetNearestObjectByTag("TRAP_DOOR_1");

CreateTrapOnObject(TRAP_BASE_TYPE_AVERAGE_ACID, oDoor, STANDARD_FACTION_HOSTILE, "", "");

SetTrapOneShot(oDoor, FALSE);

SetTrapDetectable(oDoor, FALSE);

SetTrapDisarmable(oDoor, FALSE);

}



Then I just put this in the doors "OnFailToOpen" event:



void main()

{

object oPC = GetClickingObject();

SetTrapDetectedBy(OBJECT_SELF, oPC, TRUE);

}



If the door is locked then the door turns red and stays red for the player who tried to open it.



Hope this helps.




Thanks for the effort but I just found the problem - I used SetTrapDisabled(oDoor);

when I should have used SetTrapActive(...FALSE...) like I did in a previous script for doing something similar - DOH!!