Quote: Posted 07/08/02 21:55:59 (GMT) by Repod
Quote: Posted 07/08/02 20:17:29 (GMT) by Desslok81
Name: jg_i001
Name means: Jeff Gonzalez include file 001
Purpose: This script follows the 3rd Edition rules to doing
difficulty class skill and ability check(DC Check). It take in
to consideration your ability modifier, your training(ranks) and
your class when using skills. The Fool on the Hill
Desslok81
[ Edited By Desslok81: Monday, 08 July 08:44PM (GMT) ]
Do you really need to get the Rank, Ability modifier, Class modifier
and Race modifier (you forgot that one)?
I thought the total that is recorded for the character/NPC/monster
is the total result of ranks, class, ability, race. Also this number
can be negative or 0 and still be usable (IE climb, spot, listen).
You don't have to be trained in some of the skills to user them
either, but you seem to have covered that in your code. A negative
skill just means it's harder to use that skill (some creatures/pc's/npcs
have all the dumb luck...)
Nice Idea though I hope you don't mind If I um plagerize I mean
borrow some of what you've done :shades
-Repod
Yeah I see it now. didn't see it at 3 am this morning but you know us
programmers. Went in and checked it again and your right the SkilRank is
all your mods together. As for Race is Calculated already into your
stats and with Stats modifier already Calulate in the Rank. Just need to
modify it a bit. But the Ability DC check is good. NWN returns a -1 if
you are untrained in that skill. These are change to 0 since according
to D&D rule book a trained skill is on with at least 1 Rank. But that
can easily be modified to your taste. Thanks for pointing this out. Now
how do I get the new code up to that post. BTW take all the code you
want.
3rd Edition Ability and Skill Check Functions
Fixed from a reported Bug
I only change 2 lines and deleted 1 debug line
NWScript:
void PrintDebug001(object oObject, string sDebugMsg);
int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE);
int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE);
int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE)
{
int iAbilityMod;
int iDCRoll;
int iModRoll;
iAbilityMod = GetAbilityModifier(iTheAbility,oCreature);
iDCRoll = d20(1);
iModRoll = iDCRoll + iAbilityMod;
if (debug_me == TRUE)
{
PrintDebug001( oCreature, "My Modifier is " + IntToString(iAbilityMod));
PrintDebug001( oCreature, "My Roll is " + IntToString(iDCRoll));
PrintDebug001( oCreature, "My Modified Roll is " + IntToString(iModRoll));
}
if((iModRoll >= iDCFactor && iDCRoll > 1) || iDCRoll==20)
{
return TRUE;
}
else
{
return FALSE;
}
}
int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE)
{
int iTheAbility, iAbilityMod;
int iSkillRank, bAbleToUse;
int iCreatureClass;
int cIdx, iDCRoll, iModRoll;
iSkillRank = GetSkillRank(iTheSkill,oCreature);
if (iSkillRank == -1 && !bCheckUse)
{
iSkillRank = 0;
}
bAbleToUse=FALSE;
switch(iTheSkill)
{
case SKILL_ANIMAL_EMPATHY:
iTheAbility = ABILITY_CHARISMA;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0
&& (iCreatureClass == CLASS_TYPE_DRUID
|| iCreatureClass == CLASS_TYPE_RANGER))
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_CONCENTRATION:
iTheAbility = ABILITY_CONSTITUTION;
bAbleToUse = TRUE;
break;
case SKILL_DISABLE_TRAP:
iTheAbility = ABILITY_INTELLIGENCE;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0)
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_DISCIPLINE:
iTheAbility = ABILITY_STRENGTH;
bAbleToUse = TRUE;
break;
case SKILL_HEAL:
iTheAbility = ABILITY_WISDOM;
bAbleToUse = TRUE;
break;
case SKILL_HIDE:
iTheAbility = ABILITY_DEXTERITY;
bAbleToUse = TRUE;
break;
case SKILL_LISTEN:
iTheAbility = ABILITY_WISDOM;
bAbleToUse = TRUE;
break;
case SKILL_LORE:
iTheAbility = ABILITY_INTELLIGENCE;
bAbleToUse = TRUE;
break;
case SKILL_MOVE_SILENTLY:
iTheAbility = ABILITY_DEXTERITY;
bAbleToUse = TRUE;
break;
case SKILL_OPEN_LOCK:
iTheAbility = ABILITY_DEXTERITY;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0)
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_PARRY:
iTheAbility = ABILITY_DEXTERITY;
bAbleToUse = TRUE;
break;
case SKILL_PERFORM:ABILITY_CHARISMA;
iTheAbility = ABILITY_CHARISMA;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iCreatureClass == CLASS_TYPE_BARD)
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_PERSUADE:
iTheAbility = ABILITY_CHARISMA;
bAbleToUse = TRUE;
break;
case SKILL_PICK_POCKET:
iTheAbility = ABILITY_DEXTERITY;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0)
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_SEARCH:
iTheAbility = ABILITY_INTELLIGENCE;
bAbleToUse = TRUE;
break;
case SKILL_SET_TRAP:
iTheAbility = ABILITY_DEXTERITY;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0)
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_SPELLCRAFT:
iTheAbility = ABILITY_INTELLIGENCE;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0)
{
bAbleToUse = TRUE;
break;
}
}
break;
case SKILL_SPOT:
iTheAbility = ABILITY_WISDOM;
bAbleToUse = TRUE;
break;
case SKILL_TAUNT:
iTheAbility = ABILITY_CHARISMA;
bAbleToUse = TRUE;
break;
case SKILL_USE_MAGIC_DEVICE:
iTheAbility = ABILITY_CHARISMA;
for(cIdx=1;cIdx < 4; cIdx++)
{
iCreatureClass = GetClassByPosition(1,oCreature);
if (iSkillRank > 0
&& (iCreatureClass == CLASS_TYPE_BARD
|| iCreatureClass == CLASS_TYPE_ROGUE))
{
bAbleToUse = TRUE;
break;
}
}
break;
}
if (debug_me == TRUE)
{
PrintDebug001( oCreature, "Function bCheckUse = " + IntToString(bCheckUse));
PrintDebug001( oCreature, "bAbleToUse " + IntToString(bAbleToUse));
}
if(!bCheckUse
|| (bCheckUse && bAbleToUse))
{
iDCRoll = d20(1);
iModRoll = iDCRoll + iSkillRank;
}
else
{
iDCRoll = 1;
iModRoll = -1;
}
if (debug_me == TRUE)
{
PrintDebug001( oCreature, "My Rank is " + IntToString(iSkillRank));
PrintDebug001( oCreature, "My Roll is " + IntToString(iDCRoll));
PrintDebug001( oCreature, "My Modified Roll is " + IntToString(iModRoll));
}
if((iModRoll >= iDCFactor && iDCRoll > 1) || iDCRoll==20)
{
return TRUE;
}
else
{
return FALSE;
}
}
void PrintDebug001(object oObject, string sDebugMsg)
{
AssignCommand(oObject,SpeakString(sDebugMsg,TALKVOLUME_SHOUT));
}
|