Player Resource Consortium

 

Author Topic: Shadow Discorporation  (Read 3477 times)

0 Members and 1 Guest are viewing this topic.

October 26, 2013, 03:30:08 AM
  • Adept
  • *
  • Posts: 27
  • Karma: +2/-0
  • New Member
    • View Profile

So, Shadow Discorporation (on Telflammar Shadowlord) acquires a random location (GetRandomLocation function from X0_i0_position.nss) 30 feet from the PC. Unfortunately, this does not take into account that players might be jumped behind locked doors or into secret/restricted areas.

Now, I know of the LineOfSightVector function, I could compare the PC's location and the random location and make sure they are in line of sight, however, the NWN Lexicon warns that the LineOfSightVector function is an "expensive function", so I'm afraid to heavily loop a line of sight check with it.

Do you have any suggestions on efficient script logic for this? Maybe I should let it try to gain line of sight via LineOfSightVector something like 5-10 times maximum? Maybe a few times and then try 15 feet a few times, and if it can't find a legal destination it fails?

Just looking for an opinion on what the most efficient means of eliminating or minimizing the (maybe even accidentally) exploitive potential Shadow Discorporation has.


October 26, 2013, 09:10:03 AM
Reply #1
  • Jr. Associate
  • **
  • Posts: 56
  • Karma: +1/-0
  • New Member
    • View Profile

I couldn't get shadow discorporation to work at all.

The problem with doing that is that getting a random location could well turn up inside a wall - in which case GetLineOfSightVector will presumably always return False. So the chances of it actually landing on a walkable place that's within line of sight will be pretty small, which might well cause problems.

One solution could be to try testing LOS say five times and if that fails then give up and just pick anywhere. Not ideal, but I can't see any way around it.


October 26, 2013, 01:43:51 PM
Reply #2
  • Adept
  • *
  • Posts: 27
  • Karma: +2/-0
  • New Member
    • View Profile

It wasn't working for me right away either, but I noticed that my OnPlayerDying event was still calling "nw_o0_dying" as well as "prc_ondying",  which was basically just EffectDeath and done, which would kill PCs before Shadow Discorporation even had a chance to fire. After that, it started working just fine, though I spruced it up with a little bit of VFX, which was when I came across the GetRandomLocation dilemma. It seems to do a pretty good job of getting valid locations, I just don't want valid locations behind locked doors, haha.


October 28, 2013, 09:53:32 AM
Reply #3
  • Jr. Associate
  • **
  • Posts: 56
  • Karma: +1/-0
  • New Member
    • View Profile

I don't think you can tell if it's giving you invalid locations as the JumpToLocation functions will put a creature as close to the location as is possible.

Easy test would be to make it tell you if the location it picked was in your line of sight or not.