Hello,
I have a custom skill placed in my skills.2da file. I need to call this skill in a script and was planning on representing it by its name in an include file when I realized I had no idea how to find the strref of a skill. Would anyone be able to point me in the right direction or tell me what number I should start with?
Thanks!
Custom Skill Question
Débuté par
Ralthis
, juin 17 2011 11:18
#1
Posté 17 juin 2011 - 11:18
#2
Posté 17 juin 2011 - 11:53
Somewhere (probably skills.2da) Every skill will have a number, and probably a strref in a name column, that will go to dialog.tlk or if the row number is high enough into a custom tlk table to fetch the name.
2DA V2.0
Label Name Description Icon Untrained KeyAbility ArmorCheckPenalty AllclassesCanUse Category MaxCR Constant HostileSkill
0 AnimalEmpathy 269 344 isk_aniemp 0 CHA 0 0 **** 1 SKILL_ANIMAL_EMPATHY 1
1 Concentration 270 345 isk_concen 1 CON 0 1 **** **** SKILL_CONCENTRATION 0
2 DisableTrap 271 346 isk_distrap 0 INT 0 1 **** **** SKILL_DISABLE_TRAP 0
3 Discipline 343 347 isk_discipline 1 STR 0 1 **** **** SKILL_DISCIPLINE 0
4 Heal 273 349 isk_heal 1 WIS 0 1 **** 1 SKILL_HEAL 0
5 Hide 274 350 isk_hide 1 DEX 1 1 **** **** SKILL_HIDE 0
6 Listen 275 351 isk_listen 1 WIS 0 1 **** **** SKILL_LISTEN 0
7 Lore 276 352 isk_lore 1 INT 0 1 **** **** SKILL_LORE 0
8 MoveSilently 277 353 isk_movsilent 1 DEX 1 1 **** **** SKILL_MOVE_SILENTLY 0
9 OpenLock 278 354 isk_olock 0 DEX 0 1 **** **** SKILL_OPEN_LOCK 0
10 Parry 279 355 isk_parry 1 DEX 1 1 **** 1 SKILL_PARRY 0
11 Perform 280 356 isk_perform 1 CHA 0 0 **** **** SKILL_PERFORM 0
12 Persuade 281 357 isk_persuade 1 CHA 0 1 **** **** SKILL_PERSUADE 0
13 PickPocket 282 358 isk_pocket 0 DEX 1 1 **** **** SKILL_PICK_POCKET 1
14 Search 284 360 isk_search 1 INT 0 1 **** **** SKILL_SEARCH 0
15 SetTrap 285 361 isk_settrap 0 DEX 1 1 **** **** SKILL_SET_TRAP 0
16 Spellcraft 286 362 isk_spellcraft 0 INT 0 1 **** **** SKILL_SPELLCRAFT 0
17 Spot 287 364 isk_spot 1 WIS 0 1 **** **** SKILL_SPOT 0
18 Taunt 342 366 isk_taunt 1 CHA 0 1 **** 1 SKILL_TAUNT 1
19 UseMagicDevice 288 367 isk_magicdev 0 CHA 0 0 **** **** SKILL_USE_MAGIC_DEVICE 0
20 Appraise 2693 2694 ife_X1App 1 INT 0 1 **** **** SKILL_APPRAISE 0
21 Tumble 2695 2696 ife_X1Tum 0 DEX 1 1 **** **** SKILL_TUMBLE 0
22 CraftTrap 2697 2698 ife_X1CrTrap 1 INT 0 1 **** **** SKILL_CRAFT_TRAP 0
23 Bluff 8746 8757 isk_X2bluff 1 CHA 0 1 **** **** SKILL_BLUFF 0
24 Intimidate 8756 8786 isk_X2Inti 1 CHA 0 1 **** **** SKILL_INTIMIDATE 0
25 CraftArmor 8787 8788 isk_X2CArm 1 INT 0 1 **** **** SKILL_CRAFT_ARMOR 0
26 CraftWeapon 8789 8790 isk_X2CWeap 1 INT 0 1 **** **** SKILL_CRAFT_WEAPON 0
27 Ride 111889 111890 isk_x3_ride 1 DEX 0 1 **** **** SKILL_RIDE 0
#3
Posté 17 juin 2011 - 11:56
Bleh it's messy sorry... but the 2nd and 3rd columns are Name and Description.
They contain strrefs that refer to the actual text in dialog.tlk (they can also point to a custom tlk table if one is associated with a module).
Not sure why you wouldn't call the skill by number in the scripts though, unless you're sending feedback to your player.
They contain strrefs that refer to the actual text in dialog.tlk (they can also point to a custom tlk table if one is associated with a module).
Not sure why you wouldn't call the skill by number in the scripts though, unless you're sending feedback to your player.
#4
Posté 18 juin 2011 - 12:22
I'm trying to use an include file to represent the skill so that I can use it in a script. I figured that custom skills were like custom feats where you can call the feat by the number in the first column and represent them by a new name, like
const int FEAT_CUSTOM = 1094;
for example. Am I going about it the wrong way? It's the first time I've made a custom skill, so I'm still learning,
.
const int FEAT_CUSTOM = 1094;
for example. Am I going about it the wrong way? It's the first time I've made a custom skill, so I'm still learning,
#5
Posté 18 juin 2011 - 12:54
No, I think what you are doing is fine. So you could call your skill:
const int SKILL_CUSTOM = 28; (if it's on line 28 right after Ride, which I would recommend)
Doing this helps prevent you from using "magic numbers"; so that if you need to change that number in the future, you only have to do it in one place rather than littered throughout your scripts.
const int SKILL_CUSTOM = 28; (if it's on line 28 right after Ride, which I would recommend)
Doing this helps prevent you from using "magic numbers"; so that if you need to change that number in the future, you only have to do it in one place rather than littered throughout your scripts.
#6
Posté 18 juin 2011 - 01:25
Oh, ok. I was worried that if I did that, it would refer to the feat at line 28. Thanks Kuzadrepa!
#7
Posté 18 juin 2011 - 02:30
I tried to use the number in the first column as the name for my skill, but it defaulted to the Feat,
. Which column should I use: the Name column or Description column?
#8
Posté 18 juin 2011 - 02:59
I'm sorry, I guess I'm not entirely following what you are doing. Where are you trying to name your skill?
What I described above is called a constant. It's only useful in programming (ie scripting.)
If you want the name of the skill to appear in game, you have to reference an entry in the .tlk file (also referred to as strref which is short for string reference.) What is the name of the new skill you want to use? Where do you want the name to appear? The number under the Name column of the skills.2da is the one that shows the name of the skill in game.
Give some more detail about what you want to do, and I'll try to help guide you from there.
What I described above is called a constant. It's only useful in programming (ie scripting.)
If you want the name of the skill to appear in game, you have to reference an entry in the .tlk file (also referred to as strref which is short for string reference.) What is the name of the new skill you want to use? Where do you want the name to appear? The number under the Name column of the skills.2da is the one that shows the name of the skill in game.
Give some more detail about what you want to do, and I'll try to help guide you from there.
Modifié par Khuzadrepa, 18 juin 2011 - 02:59 .
#9
Posté 18 juin 2011 - 03:05
Here's the line from my skills.2da:
28 SpeakLanguage 16777233 16777255 isk_persuade 1 INT 0 1 **** **** SKILL_SPEAK_LANGUAGE 0
I've already edited my tlk file so that the name and description appear for the players. What I'm trying to do is check the ranks that a PC has in this skill using a script. I figured it was easier to save the skill as a const int, but when I used number 28 it thought I was referencing feat.2da and not skills.2da. In a script, should I use the number 16777233 or 16777255 in my script?
Thanks for the help Khuzadrepa!
28 SpeakLanguage 16777233 16777255 isk_persuade 1 INT 0 1 **** **** SKILL_SPEAK_LANGUAGE 0
I've already edited my tlk file so that the name and description appear for the players. What I'm trying to do is check the ranks that a PC has in this skill using a script. I figured it was easier to save the skill as a const int, but when I used number 28 it thought I was referencing feat.2da and not skills.2da. In a script, should I use the number 16777233 or 16777255 in my script?
Thanks for the help Khuzadrepa!
#10
Posté 18 juin 2011 - 03:06
Neither, you can't use the STRREF, you'd have to use the skill value, what scripting function are you using to try and reference your skill?
#11
Posté 18 juin 2011 - 03:13
As an aside this function is probably what you want to use.....
http://www.nwnlexico...tskillrank.html
So you wind up with something like:
If you have doubts it's pulling the right values, simply use a SendMessage to help yourself debug the code.
http://www.nwnlexico...tskillrank.html
So you wind up with something like:
// This script would be placed in a conversation
// where the player challenges the Master Bard to
// a performance duel.
void main()
{
// Initialize Objects
object oPlayer = GetPCSpeaker();
// Determine skill checks
int iPPerCheck = d20(1) + GetSkillRank(28, oPlayer);
int iMPerCheck = d20(1) + GetSkillRank(28, OBJECT_SELF);
// Compare the two skill checks
if (iPPerCheck > iMPerCheck)
{
// Player wins perform duel
// Place reward code here
}
else
{
//Player looses perform duel
//Place failure code here
}
}
If you have doubts it's pulling the right values, simply use a SendMessage to help yourself debug the code.
Modifié par Calvinthesneak, 18 juin 2011 - 03:15 .
#12
Posté 18 juin 2011 - 03:39
Ahh, thanks Calvin! That looks about right. I'll give it a shot and see how it goes.
UPDATE: It works like a charm! Thanks again!
UPDATE: It works like a charm! Thanks again!
Modifié par Ralthis, 18 juin 2011 - 06:49 .
#13
Posté 18 juin 2011 - 11:58
I really like your example, Calvin!
And then in your include file, you can declare the constant like this:
const int SKILL_SPEAK_LANGUAGE = 28;
and then replace those 28s in the code with SKILL_SPEAK_LANGUAGE, which is more descriptive and also advantageous for the reason I noted before.
And then in your include file, you can declare the constant like this:
const int SKILL_SPEAK_LANGUAGE = 28;
and then replace those 28s in the code with SKILL_SPEAK_LANGUAGE, which is more descriptive and also advantageous for the reason I noted before.
Modifié par Khuzadrepa, 18 juin 2011 - 11:59 .
#14
Posté 18 juin 2011 - 04:31
lol it's just the code from the lexicon. I didn't even edit it properly, just was a brief example for him. And yeah, assigning a constant to the value is a good idea too.
I spose I did too much of this in the past.
I spose I did too much of this in the past.





Retour en haut






