Author Topic: Detecting which action can be executed.  (Read 415 times)

Legacy_Pixelord

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Detecting which action can be executed.
« on: July 17, 2013, 06:51:53 am »


               Hi,

I am working on an AI project and using NeverWinter Nights as my sandbox.
I am trying to detect if a player can perfom an action in any object like door, placable, etc.
For example, I need to write a scripr that will determine if a player can perform the action on teh door.
Like when player click on a door, the script will check if player can open, bash, knock or unlock the door.

I am not quite sure how to do that. I tried to use GetIsDoorActionPossible in case fo Door, but this script is not working as I was expecting.

Morever, I have another question about the game rule,
Like how the game determine if a player has the ability to perform certain action.
For example, a player cannot bash a door, because of the current weapon class and player ability score.
But same player can bash teh door later gaining more ability score and better weapon.

Where can I find these rule? Is there any way to write my own script tahtw ill use the same game rule and will feedback the outcome of the action to the AI system?

Thanks in advance.
               
               

               
            

Legacy_painofdungeoneternal

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #1 on: July 17, 2013, 07:07:50 am »


               Take a look at the script NW_C2_DEFAULTE.nss  ( which is in the AI for the game in the on blocked event )

I imagine this will have examples of what you need in it. It handles the game logic when a NPC encounters a closed or locked door.
               
               

               


                     Modifié par painofdungeoneternal, 17 juillet 2013 - 06:09 .
                     
                  


            

Legacy_Pixelord

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #2 on: July 17, 2013, 07:17:38 am »


               Thanks! I'll have a look.
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #3 on: July 17, 2013, 09:03:16 am »


               All those actions you listed can always be executed. So your hypothetical function would simply always return TRUE in every situation. If you want to detect ahead of time if the action will succeed or not, and call that your "possibility" function, then that can be done but could get complicated. For instance if you were to accept the proposition that a locked door can never be opened and an unlocked one always can be, then you can simply check to see if the door is locked or not. The bash would be much harder because whether or not a bash will succeed is dependent on the weapon used, hardness settings of the door, etc. such that one player might have the ability to succeed while another may not dependent on both the door's properties and the player's. Or it could be possible eventually, but takes several bashes to get in (you must weaken the door over several rounds), and so on one round it would be impossible but on the next round maybe possible and eventually assurred iff you choose to start bashing now. Knock requires a spell or an item. Unlocking sometimes requires a key, sometimes you can't pick the lock because you're lacking skill or class requirements, etc. Items give bonuses that increase ability and/or skills thereby affecting the probability of succeeding at particular actions.

You ought to be able to encode some propositions into your KB to simplify the problem some (i.e. Locked doors can't be opened, Unlocked doors can be opened but not unlocked, Open doors can only be closed. Key is needed to unlock, Lock can be picked when class is Thief and skill > x, if it's unlocked there is no need to bash it or pick it, etc) and then use more fundamental and specific functions like GetIsLocked, GetLockKeyRequired, GetSkill, GetClassByPosition, GetIsOpen, etc to determine the predicates instead of just one big one.

Another thing that will be difficult to work with is combat. When there is no combat going on, all the probability involved in actions like pick lock is effectively disabled. When there is combat, even though you might have the ability to succeed at picking the lock, it might take several attempts to do so because you only have a probable chance of doing it. You have to roll a dice to see. And it's random so it is nondeterministic. When there is no combat the game assumes you're going to stand there and roll until you get the best roll possible, so rather than simulating that, it simply gives you the best roll right off to save time which removes all the randomness. Bashing is the same way. So you might be able to say it's possible to succeed in executing that action but not that it will succeed. If there isn't to be any combat then it won't be a problem...in that case if you can possibly succeed, you can conclude that you will succeed though sometimes only eventually.

To make it simple you will probably need to come up with some big assumptions you can use. Like no items, no combat, no trapped doors, all agents are the same class & level & maybe just clones, bashable doors always have hardness = x, Pick lock DC is always 20, etc. Depends on what you're trying to do overall really. For example, you could eliminate the need to know if bashing is possible by working into your system a frustration factor that increases on each attempted bash and causes your agent to stop trying after some frustration threshold, then assume bashing is always possible.
               
               

               


                     Modifié par Axe_Murderer, 17 juillet 2013 - 01:44 .
                     
                  


            

Legacy_Pixelord

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #4 on: July 18, 2013, 03:50:06 am »


               Great details there!

" The bash would be much harder because whether or not a bash will succeed is dependent on the weapon used, hardness settings of the door, etc. such that one player might have the ability to succeed while another may not dependent on both the door's properties and the player's."

How the game determines this? Is there any existing script that actually determines this outcome?

"be picked when class is Thief and skill > x"

ow can i get these game rules, like which class and skill and score will be able successful in which action ?
               
               

               
            

Legacy_painofdungeoneternal

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #5 on: July 18, 2013, 05:18:25 am »


               rules for nwn are at http://nwn.wikia.com/wiki/Main_Page

rules for 3.0 SRD http://www.opengamin...on.org/srd.html

Actual books http://en.wikipedia....dition_and_v3.5

( NWN1 is 3.0 edition, NWN2 is 3.5 )

or google for "Dungeons and Dragons"
               
               

               


                     Modifié par painofdungeoneternal, 18 juillet 2013 - 04:18 .
                     
                  


            

Legacy_Pixelord

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #6 on: July 18, 2013, 05:22:58 am »


               Thanks a lot!
               
               

               
            

Legacy_Pixelord

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #7 on: July 19, 2013, 01:02:43 am »


               When trying to Open a Lock, i saw that it is calculated as

Open Lock 20+22=42 vs DC 18
I am assuming that D20 got value 20 and the Open Lock skill score is 22 for the player.
Where as DC was 18 so it succeeded.

Now I am not quite sure what are other basic criteria a player need to be able to use this skill.
For example, have to have Open Lock skill for obvious.
What are other basic prerequisites, like class, intelligence level etc?

Any help?
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Detecting which action can be executed.
« Reply #8 on: July 19, 2013, 05:29:20 pm »


               That calculation is saying you rolled a 20, or got a "Take 20" (i.e. are given the best roll of 20 outside combat), and then 22 bonus points (wow that's a lot) were added due to skill, item, race, class, level, feat and ability adjustments resulting in an "effective" or "adjusted" dice roll of 42. And that the difficulty to pick that particular lock is 18, meaning you must have effective roll of 18 or higher to be successful (with +22 bonus it is virtually assured of being successful in that example case, even during combat, cuz even if you get the worst roll possible of 1, you'll still beat an 18 difficulty class having an effective roll of 23).

If you look up the skills table in the appendix of the manual or look at the skills dialog box in game, you will see skills are listed as either "Requires Training" or "Unskilled". If a skill requires training (like OpenLock does) this means that no matter what you roll or what bonuses you have that add bonus points to it, you will always fail unless you have gained at least one skill level in it. Untrained skills mean that you can potentially succeed even without any skill levels devoted to it. Whenever you level up, you get some skill points to distribute among the available skills. So if you assign one or more of them to OpenLock you will gain skill level and get the possibility of opening locks since you are now trained in that area.

You can also get skill levels awarded by items. So you can get training in that skill by wearing a belt, for instance, which awards magical OpenLock skill level(s). Even if you have no training in the OpenLock skill itself, the belt will give you the training while you are wearing it. And, naturally, the more skill levels you have, the bigger the bonus added to your dice roll will be (as I recall it's a one-to-one relationship between skill level achieved and bonus amount awarded due to skill level).

Also on the skills table you will see associated with each one is a "Key Ability" -- one of the six ability scores available. This is the ability which affects the bonus awarded when attempting that skill. There is exactly one associated with each skill, and it never changes. For Open Lock, for example, the key is Dexterity ability. So having a higher Dex means you may get a larger bonus when you attempt to pick locks, but Intelligence and Strength and the rest of them have no effect on lock picking. Key ability does not, however, allow you to bypass the training requirement like items do -- they affect the dice roll bonus only. Thus, for Open Lock, if you have no skill levels you will always fail even on a DC 1 lock regardless of how dexterous you have become. When you look at your character sheet, you will see a +X (or a -X) listed after your ability scores if the ability is high enough (or low enough) to earn a bonus (or a penalty). This will be the bonus amount you get for any skill attempts where that ability is key. So if your Dex score says 16+1 that means you get +1 bonus added to your dice roll when trying to pick locks due to your above average dexterity ability. And, since items can grant Dex ability, you can increase your bonus by also wearing item(s) that grant Dex points. Unfortunately, the +X you get on your abilities is not a strictly linear function of the ability level achieved (IIRC) so you'll probably have to create a lookup table to compute what ability you will have to have in order to get a specific amount of bonus. There is a function you can call that tells you what bonus you are getting right now, but if you want to compute what ability you will need in order to get a given bonus amount, it isn't especially straight forward to compute. For example, if you want to know what your Dex bonus will increase to, if at all, should you choose to put on some +1 Boots of Dex you happen to have in your inventory, before you actually strap them on to find out the effect... There may exist a formula, but a table lookup will probably be easier and faster.

Another thing you'll see in the skills table are "Class Skills", "Cross Class Skills", and "Exclusive Class Skills" -- a classification of the skill dependent on class. This affects how expensive it is, measured in skill points, to gain levels in that skill. When you level up in some class, say Thief, you get some skill points which you can "spend" to gain skill levels. If the skill you want to purchase levels in is a Class Skill for Thieves, it will cost one skill point to gain one skill level. If it is a Cross Class Skill for Thieves, like Concentration is, it will cost two skill points to gain one skill level. And if it is an Exclusive skill, this means for that skill, only a particular class(es) can gain skill levels in it by whatever means. An example is Animal Empathy which can only be purchased by characters who are leveling up their Druid or Ranger class. Also items will only grant exclusive skill levels to agents having levels in those classes capable of gaining them. The number of skill points you are given to "spend" when you level up is determined by your Class, Race, and Intelligence ability. There is a table called Skill Points Per Class in the appendix which tells you how to compute it.

It's important to understand the difference between skill points and skill levels. Items grant skill levels not skill points. Skill points have no effect on your ability to succeed in a skill action attempt (only skill levels affect the roll bonus). You only get skill points when you level up, and to permanently increase a skill level, the only way to achieve it is to spend skill points on it at level up time. Skill points not spent at level up time are retained until you spend them, but you can only spend them when you level up. Which class you choose to level up in determines which skills will be cheap to buy, expensive to buy, or excluded from purchase. Theives get much more flexibility in that regard than any other class -- significantly more flexibility in fact, because almost every skill is categorized as a Class Skill for them and on top of that they get far more skill points to spend at level up time than do the other classes (I've been calling them Thief but they are actually called Rogue by the game). Skill points are like skill scholarships, and skill levels are like diplomas in skill learning. Unlike real life, only the diplomas matter in regards to your performance when you venture out into the world and attempt to employ your skills. In real life neither a scholarship nor a diploma has any effective meaning as to whether or not you are able perform some skill successfully, and in the game you aren't able to get a diploma unless you have a scholarship first, so perhaps that isn't the best analogy to use.

If you read the sections detailing Classes and Races, you can also sometimes find things about skills and abilities specific to each class or race which could affect your computations of bonuses. There are also Feats which you get to choose from at level up, dependent on class level and race, some of which affect abilities and skills and therefore bonuses. They are sort of similar to skills and items. Race is an interesting thing, sometimes you get bonuses in some abilities or skills and penalties (a negative bonus) for others. Spells also affect abilities and skills and the bonuses you get, often by penalizing you while you are under their effect. And it isn't always an enemy agent that casts Spells on you, very often it is the world itself or an item (such as a potion) which does it. Penalties include, by the way, lowering of skill levels! But you cannot lose your training requirement via penalty -- once you are trained you can't lose that. Everything is very intertwined, which is why it becomes so complex to compute things especially when you don't make any assumptions to simplify the problem somehow.
               
               

               


                     Modifié par Axe_Murderer, 19 juillet 2013 - 06:22 .