Aller au contenu

Photo

NWN2 Door Scripting Question


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

#1
ApocalypsePiggy

ApocalypsePiggy
  • Members
  • 5 messages

Hi All,

I had an idea to create respawning doors to prevent the eventual all doors in the module being destroyed by players either purposely or accidentally.  After many hours or trying different things without success, I eventually gave up the idea of respawning the doors, and tried instead to pretend they were destroyed by making them invisible or something ... but this didnt seem to work either as it appears effects cannot be applied to doors (or at least I couldn't find a way).  

Then I though maybe I could change their appearance - if the 'Appearance' is set to NONE, or the 'Door State' is set to 'Destroyed' in the Toolset the door is invisible, but I cant find any way to set either of these parameters via a script.  I also tried changing the size using the SetScale command to scale the door to 0.01, 0.01, 0.01 ... which in the Toolset using the Scale parameter makes the door small enough to be nigh invisible, but the SetScale command in scripting seems only to act on monsters or placeables :(  ...

Finally I gave up on trying to hide the door or make it appear to be destroyed, and just let it open after being bashed and then the PC can't interact with it anymore - it would give a message like "This door is broken" for some period of time until it closes and resets itself."  Yet the lack of abilities to script doors still confronts me - all I want now is the door to open from the opposite direction it was bashed from (since it looks pretty stupid if you Critical it with a greataxe and it opens towards you) ... but it doesnt seem to accept the SetFacing command to change its direction.  I'm getting very frustrated with this and any help would be greatly appreciated :)  

Below is my current OnDamaged script that attempts to make the door open from the opposite direction it was bashed from.  I eventually want to add some code to restore its hit points but given the difficulties I've faced so far i wonder if its even possible to heal a door ...

 

void main()
{
  int iHP=GetCurrentHitPoints(OBJECT_SELF);
  int iMaxHP=GetLocalInt(OBJECT_SELF,"J_DOOR_HP");  //door is set to 1000 HP & this variable gives its "real" HP
 
 
  if (iHP<(1000-iMaxHP)) 
  {
    if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0) return;
    SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
    float fDir=GetFacing(OBJECT_SELF);
    object oAttacker=GetLastAttacker(OBJECT_SELF);
    location lAttackerLoc=GetLocation(oAttacker);
    float fFacingAttackerLoc=GetFacingFromLocation(lAttackerLoc);
    if (fabs(fDir-fFacingAttackerLoc)<180.0) {
      fDir=fDir+180;
      fDir=asin(sin(fDir));
      SetFacing(fDir);
      }
    ExecuteScript("x2_door_death",OBJECT_SELF);
    ActionOpenDoor(OBJECT_SELF);
    AssignCommand(oAttacker,ClearAllActions());
   } 
 
}

 

 



#2
bealzebub

bealzebub
  • Members
  • 352 messages

why not just set important doors to plot so they can't be destroyed?



#3
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
It never occurred to me that someone might want to go through my campaign and bash all of the doors. I didn't realize that was even a temptation for folks. Funny.

#4
ApocalypsePiggy

ApocalypsePiggy
  • Members
  • 5 messages

I got the idea when making a sort of 'door maze' area with a bunch of locked doors where an appropriate level rogue would be able to unlock many but not all of them, and bashing a door - which sometimes would be required - would create noise which alerted enemies and was part of the essential challenge in the area.  If I could get the doors to respawn I'd extend the ability to all the doors in the campaign, though you are probably right that the number of players tempted to smash everything just because is probably low :)



#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

I've been out of the NWN2 loop for quite awhile now but as far as the opening of the door towards or away from you, in NWN1 you would use ActionPlayAnimation(); function and use the ANIMATION_DOOR_OPEN1 or ANIMATION_DOOR_OPEN2 constants. Might want to play around with that. Unless it's one of those broken functions.



#6
ApocalypsePiggy

ApocalypsePiggy
  • Members
  • 5 messages

A good idea - thanks!  I'll try fiddling around with that



#7
Dann-J

Dann-J
  • Members
  • 3 161 messages

I think there's only one door opening animation in NWN2. Doors always seem to open towards the creature that activated them, so perhaps spawning a temporary ipoint on the other side and assigning ActionOpenDoor() to it might open it away from the player.



#8
Dann-J

Dann-J
  • Members
  • 3 161 messages

It never occurred to me that someone might want to go through my campaign and bash all of the doors. I didn't realize that was even a temptation for folks. Funny.

 

I seem to recall that the default OnDeath script for doors checks for a variable (either on the door or on the module) and spawns wooden planks for crafting if it finds it. Someone looking to craft something from wood might have a good reason to bash doors.



#9
Tchos

Tchos
  • Members
  • 5 054 messages

Actually, I've encountered some doors that opened away from me into the black transition clicker, essentially making the door disappear.  Seems rare, though.



#10
4760

4760
  • Members
  • 1 207 messages

Two animation files are expected (..._OPEN1.gr2 and ..._OPEN2.gr2): one for opening towards the character, the other one for opening away from him/her. Maybe one of the files is missing in the case of the few doors you mention?



#11
ApocalypsePiggy

ApocalypsePiggy
  • Members
  • 5 messages

I think there's only one door opening animation in NWN2. Doors always seem to open towards the creature that activated them, so perhaps spawning a temporary ipoint on the other side and assigning ActionOpenDoor() to it might open it away from the player.

 

Thanks!  This does work - I had an invisible, uninteractable creature spawn the opposite side from where the door is being attacked to open it and it's worked in every test to open the door away from the player.  I'll need to fiddle a bit with the timing to make it appear as smooth an action as possible but in general I think that is the golden ticket