Author Topic: N help with thief style guards  (Read 499 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
N help with thief style guards
« on: July 04, 2013, 12:17:01 am »


               I want to make a thief-style guards and have no clue how.

Need hints and snippets to make possible the cone-vision, aka that they see only in a certain angle cone in their facing. Normally every npc can see behind too, so I need to bypass it somehow.

Also seeking ideas how to make shadows more properly. Atm I set up interior as an exterior so shadows dont moves but i would like to control shadows, be able to pain them via script so if player put out a candle there will spawn new shadows, anyone seen a placeable that might work for this? Tried to modify darkness vfx but its over my possibilities.
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
N help with thief style guards
« Reply #1 on: July 04, 2013, 01:13:02 am »


               I thought about this before going the route of a class specific Wizard/Sorcerer series, and had a few ideas.

As you mention, shadows that are preset via a tileset can easily be manipulated with triggers on their very edge, with OnEnter and OnExit scripts that fire to check if the PC is in the shadows or not, and if it is GetIsNight() for additional bonuses.

A cone effect might not be possible without scripting assistance, and even so, my knowledge is nothing like what some of the old folks had back on the old forum when it was full of action and awsome scripts. The legacy forum is something I miss a lot for script knowledge.

Anyhow, checking the relation of the player to the guard using a vector could return a placement result. You could play around with this and see what you can come up with.

#include "nw_i0_tool"
#include "x2_inc_switches"

object oPC = GetFirstPC();
object oTarget = OBJECT_SELF; // GUARD/NPC/ETC...

//  Returns a string telling oPlayer where they are in relation to oTarget's position.
string GetDirection(object oTarget, object oPC);

string GetDirection(object oTarget, object oPC)
{
   vector vPlayer = GetPosition(oPC);
   vector vTarget = GetPosition(oTarget);
   float fDist = GetDistanceBetween(oTarget, oPC);
   float fCosine = (vTarget.x - vPlayer.x) / fDist;
   float fDeltaY = vTarget.y - vPlayer.y;
   if(fCosine > 0.7071)
       return "DEBUG: Player is east of OBJECT_SELF";
   else if(fCosine < -0.7071)
       return "DEBUG: Player is west of OBJECT_SELF";
   else if(fDeltaY > 0.0)
       return "DEBUG: Player is north of OBJECT_SELF";
   return "DEBUG: Player is south of OBJECT_SELF";
}

void main()
{
string sMsg = GetDirection(oTarget, oPC);


//Let's see if player is inside OBJECT_SELF personal space bubble!
float fMinDistanceToGuide = 5.0f;
vector vPCPosition = GetPosition(oPC);
vector vGuideLocation = GetPosition(OBJECT_SELF, oPC));
vector vDistance = vPCPosition - vGuideLocation;
float fDistance = VectorMagnitude(vDistance);

if (fDistance <= fMinDistanceToGuide)
{

    AssignCommand(oPC, SpeakString("DEBUG: Inside of OBJECT_SELF personal space bubble!"));
    return;
}
}


The torch bracket from 1.69 pulses and creates a light source radius around itself. When extinguished, the source of light vanishes returning the shadows around it.

x3_plc_torch001

Placeables -> Building Adornments -> Torch Bracket (first in the list of three).

FP!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
N help with thief style guards
« Reply #2 on: July 04, 2013, 02:55:28 am »


               int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc);
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc)
{
   location lSelf = GetLocation(oSelf);
   location lTarget = GetLocation(oTarget);


   float AngleOffset = VectorToAngle( GetPosition(oTarget) - GetPosition(oSelf)) - GetFacing(oSelf) ;


   //float  fViewArc = 180.0;
   return (abs(FloatToInt(AngleOffset)) <  nViewArc/2);
}
 
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
N help with thief style guards
« Reply #3 on: July 04, 2013, 03:36:16 am »


               thanks for functions im really not good with vectors, but now different problem how to maintaing a realtime cone of view since guards are moving? a 0.X sec pseudo hb? ugh would prefer different method if someone knows, cos i have like 8 guards in area and this should be for PW not SP.

most guards are walking on waypoints, few is only changing facing
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
N help with thief style guards
« Reply #4 on: July 04, 2013, 04:51:16 am »


               some random ideas i have many of which probably won't work but might lead some where

what tools do you have available to solve this problem?

NWNX?
is there a way to clear the perception state of an NPC with NWNX? If so you could tweak the guards' perception event. If the PC enter's a guards "visible" list, and is about to go hostile, you could check vectors at that point. If the Guard is not facing the PC, then don't send the guard after PC, and clear the PC from the guards "seen" list after a certain delay. As soon as you clear the PC from the list I imagine the guard would probably get another perception check... but that would have to be verified.

Get object in shape?
Is it possible to create a cone shaped AOE on the NPC guard?

Triggers? grid of AOE's?
Is this for specific areas that these particular guards are in? If so you could lay down a bunch of triggers along the guards' route and into which the guards would see if a PC enters them. On each on enter or on exit event you can tag the pc as being in that zone and run an artificial perception event with nearby guards
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
N help with thief style guards
« Reply #5 on: July 04, 2013, 05:19:41 am »


               Can you use a cone aoe? or a circle AOE that check facing in on enter? oops missed the other post sorry.
               
               

               


                     Modifié par ShadowM, 04 juillet 2013 - 04:21 .
                     
                  


            

Legacy_kamal_

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
N help with thief style guards
« Reply #6 on: July 04, 2013, 03:08:59 pm »


               

Fester Pot wrote...

I thought about this before going the route of a class specific Wizard/Sorcerer series, and had a few ideas.

As you mention, shadows that are preset via a tileset can easily be manipulated with triggers on their very edge, with OnEnter and OnExit scripts that fire to check if the PC is in the shadows or not, and if it is GetIsNight() for additional bonuses.

I made a thief campaign for nwn2 (Crimmor, in signature) that did shadow based triggers to do hide bonuses for the pc. While it worked in general, the trigger would fail on rare occaisions. Over the course of the module, the adjustments to the hide skill sharply altered the player's hide skill. The code and triggers for it are still in the module, just the code is commented out because it never worked 100% reliably. Day versus night adjustments worked fine.

I also set things up so that guards and such "own" things and would notice if they were in the "wrong" state, such as a door being open or a torch not being lit.

Not sure how much of the code in my campaign would directly port to nwn1 because of different functions, but I'd imagine someone could get it to work without too much trouble.
               
               

               


                     Modifié par kamal_, 04 juillet 2013 - 02:09 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
N help with thief style guards
« Reply #7 on: July 05, 2013, 12:17:51 am »


               

henesua wrote...

some random ideas i have many of which probably won't work but might lead some where

what tools do you have available to solve this problem?

NWNX?
is there a way to clear the perception state of an NPC with NWNX? If so you could tweak the guards' perception event. If the PC enter's a guards "visible" list, and is about to go hostile, you could check vectors at that point. If the Guard is not facing the PC, then don't send the guard after PC, and clear the PC from the guards "seen" list after a certain delay. As soon as you clear the PC from the list I imagine the guard would probably get another perception check... but that would have to be verified.

i dont know if the visibility plugin from virusman allows this, not sure its even public too, and this is for linux so i cant digg into nwnx myself but yers in theory this should work

Get object in shape?
Is it possible to create a cone shaped AOE on the NPC guard?

AOE cant be that shape afaik

Triggers? grid of AOE's?
Is this for specific areas that these particular guards are in? If so you could lay down a bunch of triggers along the guards' route and into which the guards would see if a PC enters them. On each on enter or on exit event you can tag the pc as being in that zone and run an artificial perception event with nearby guards

hmm this might work, will think about it though the pseudo hb doesnt sound that bad to me now '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
N help with thief style guards
« Reply #8 on: July 05, 2013, 12:21:57 am »


               

kamal_ wrote...

I made a thief campaign for nwn2 (Crimmor, in signature) that did shadow based triggers to do hide bonuses for the pc.

yea that was my first thought too, but then realized the hide skill is quite weird for this so i reworked it so guards have true seeing and simply ignores pc if he stands in shadow trigger

yet this method has big flaw of that onperception event doesnt fire later since they already seen you, so it must be paired with pseudohb or triffer exit or pc will be able to run around guard without problems

the biggest problem is however to paint shadows where toolset doesnt make them and to change built in interior light source state, im open to custom content but what i would need is no small project
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
N help with thief style guards
« Reply #9 on: July 07, 2013, 11:57:58 pm »


               ok im still not sure about my take on walking in shadows, does anyone have a modified darkness visual effect that makes a brighter/smaller area? Or can anyone do it?
A cast shadows (opposite of the cast sun lights like in forest tileset) placeable would be best if anyone seen something like that already '<img'>
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
N help with thief style guards
« Reply #10 on: July 08, 2013, 11:31:02 am »


               for windows nwnx uses, in nwnx_funcs.

//**** Original work by virusman ****

const int VISIBILITY_TYPE_DEFAULT = 0;
const int VISIBILITY_TYPE_VISIBLE = 1;
const int VISIBILITY_TYPE_INVISIBLE = 2;

// Sets the visibility of oObject for everybody
void NWNXFuncs_SetVisibilityOverride(object oObject, int nVisibilityType);

// Sets whether oObject2 can see oObject1
void NWNXFuncs_SetVisibility(object oObject1, object oObject2, int nVisibility);

// Gets the visibility of oObject
int NWNXFuncs_GetVisibilityOverride(object oObject);

// Gets whether oObject2 can see oObject1
int NWNXFuncs_GetVisibility(object oObject1, object oObject2);

//**************************************


There's also an anti-light vfx that might work for you, I think it might have been in cep, I know I've used it before.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
N help with thief style guards
« Reply #11 on: July 20, 2013, 06:48:08 pm »


               

There's also an anti-light vfx that might work for you, I think it might have been in cep, I know I've used it before.

can you tell me number? checked whole cep2.4 and there is nothing like that, i mean yes there is PRCVFX_DUR_SHADOWS_ANTILIGHT but thats black shield around character, i want to simulate shadows in area