Author Topic: Question about doors  (Read 598 times)

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
Question about doors
« on: January 25, 2015, 05:04:28 am »


               

I have a question about doors. This should be rather simple but I can’t figure it for the life of me. How do I get a PC to open a locked door based on one of their stats. As an example I would like the door to unlock and open based on their strength. Is this even possible and if so how do I go about doing this?



               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Question about doors
« Reply #1 on: January 25, 2015, 07:35:39 am »


               

Make sure your door is checked "locked" and "requires a key to unlock". Then in the door's "OnFailToOpen" event you could put something like this:


 


 


void main()

{

    object oPC = GetClickingObject();

    int iStrength = GetAbilityScore(oPC, ABILITY_STRENGTH, FALSE);


    if (iStrength >= 18)

    {

        ActionUnlockObject(OBJECT_SELF);

        ActionOpenDoor(OBJECT_SELF);

        FloatingTextStringOnCreature("You force the door open with your buff muscles.", oPC);

    }


    else

    {

        FloatingTextStringOnCreature("You are too whimpy to open this door.", oPC);

    }

}


 


 


Hope it helps. Good Luck!



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Question about doors
« Reply #2 on: January 25, 2015, 07:36:36 am »


               

I made a custom script that emulates PHB object breaking and door bashing. It uses the FORT save parameter to determine the DC and accounts for the PC's size and strength modifier. The script goes in the OnPhysicalAttacked script slot of a door or placeable. While not exactly what you're looking for, it could be easily altered.


 



   Spoiler
   



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Question about doors
« Reply #3 on: January 25, 2015, 09:29:43 am »


               


I made a custom script that emulates PHB object breaking and door bashing. It uses the FORT save parameter to determine the DC and accounts for the PC's size and strength modifier. The script goes in the OnPhysicalAttacked script slot of a door or placeable. While not exactly what you're looking for, it could be easily altered.


 



   Spoiler
   




 


 


Looks good.  The only problem I can see is that a single arrow can utterly decimate a wooden door, or any other placeable.  Perhaps a melee check?


               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Question about doors
« Reply #4 on: January 25, 2015, 09:43:37 am »


               

I overlooked that...thanks.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Question about doors
« Reply #5 on: January 25, 2015, 08:21:12 pm »


               

Nice script Pstemarie, I was using something similar for my module but I found several problems during playtesting.


 


1) Ranged weapons, had to disable them for this as it makes no sense that you could use them to break doors.


2) The more attacks per round player has the easier is to break doors by brute force, take 2 weapons, enable flurry of blows and just wait soon you roll 20 and its done. I havent been able to solve this issue in any good way so far...



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Question about doors
« Reply #6 on: January 25, 2015, 08:32:10 pm »


               

I'm not too concerned about the flurry of blows. I mainly use this script on doors which I want to be more of a nuisance rather than an obstacle to overcome. More for flavoring than anything else.


 


I've also got some other tweaks I'm working on that will alert nearby monsters when a door gets bashed open - all that breaking and splintering of wood, metal, or stone makes a racket that's hard to ignore.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Question about doors
« Reply #7 on: January 26, 2015, 01:39:38 am »


               


2) The more attacks per round player has the easier is to break doors by brute force, take 2 weapons, enable flurry of blows and just wait soon you roll 20 and its done. I havent been able to solve this issue in any good way so far...




 


This is a non-issue as you are simulating saving throws rather than actually making them (no auto-success on 20).  So if the fortitude save is set high enough, then a character with low strength may be unable to break it no matter how many attacks per round he has.


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Question about doors
« Reply #8 on: January 26, 2015, 03:48:51 pm »


               

I see how to disable this in the on attack type scripts. I have doors that allow damage but I would like to undo that damage if caused by a ranged weapon or otherwise disallow damaging by ranged weapons. Anyone know how to do that? Does GetLastWeaponUsed() work still in the onDamaged event?  Is there a better way than healing the damage dealt to do this?



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Question about doors
« Reply #9 on: January 26, 2015, 05:41:01 pm »


               

This is what I did to take of care ranged physical attacks...


 



   Spoiler
   


 


For the OnDamagedEvent, you'd have to give the HP back, which I don't think is possible because AFAIK healing doesn't work on placeables.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Question about doors
« Reply #10 on: January 26, 2015, 06:47:13 pm »


               

Thanks, Pstemarie.


 


Yeah, that's about what I did in the on attack event, but that only works for plot doors which are being bashed by strength check as in your code above.


 


I'll test the GetLastWeaponUsed from OnDamaged when I get back into the toolset later. Healing does work at least on real doors. There's a cool respawning mechanism you can use that uses the ability to heal the door.


 


I just want to keep people with bows from being able to destroy such doors '<img'>


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Question about doors
« Reply #11 on: January 27, 2015, 03:01:31 am »


               

I'll test the GetLastWeaponUsed from OnDamaged when I get back into the toolset later. Healing does work at least on real doors.


Fwiw, it seems GetLastWeaponUsed on the LastDamager works okay in OnDamaged event. You can then heal the non-plot door and as long as there's no instant death it should catch these cases.


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Question about doors
« Reply #12 on: January 27, 2015, 03:19:49 am »


               

If you are using only the OnDamaged event, then you have to account for other sources of damage (e.g. spells, grenades), in which case the last used weapon could be anything as it is unrelated.


 


An alternative is to do a delayed command off of the OnPhysicalAttacked event.  For example, get the current hit points during this event and pass that parameter so that the door is healed up to this amount 0.5 seconds later.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Question about doors
« Reply #13 on: January 27, 2015, 04:03:45 am »


               

Good point WhiZard...  The delay could work but in multiplayer could end up healing more than it should pretty easily.  Maybe the damage type could be used to weed out spells and other things... I'll have to poke at it some more.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Question about doors
« Reply #14 on: January 28, 2015, 03:58:47 pm »


               

Not meaning to completely hijack this thread, but it seems relevant to the original post.


 


Does anyone know if the ondamaged event for a successful attack immediately follows the onattacked event for that attack or could some other event get in between? Like some other creature's on attack event against the same object.


 


Edit: nevermind... I was storing the tracking variable on the wrong object (the attackee) when it makes more sense and removes the issue of interleaving to store it on the attaker. In the on attacked handler set a variable on the attacker when detecting a ranged


attack (clear it if not ranged). Then on damaged can tell if the attacker used a real ranged weapon or not and heal as appropriate.