The below script is from Witches Wake, used in conversations to cast spells.
Two test characters are used and are generating different results and I don't understand why or where the difference in value is coming from.
Character 1
Level 6 Dwarf Pure Wizard with 16 Intelligence
Character 2
Level 6 Dwarf Pure Wizard with 19 Intelligence
When casting the same spell, Acid Splash - or any spell for that matter using these scripts - the value that is added to the d20 roll is different, which I expect based on the +3 difference in the intelligence between the two characters.
The problem, or perhaps it's not a problem, I just can't figure out how the value is being determined, is that Character 1 has a higher value added to the d20 roll vs. Character 2, even though the latter has the higher intelligence.
Character 1 always receives a 9 (sSkill) bonus when casting spells, added to the d20 roll.
Character 2 always receives a 5 (sSkill) bonus when casting spells, added to the d20 roll.
I can't figure out why.
All test characters were naked when casting these spells and all intelligence stats posted above are their stock INT scores with no modifiers.
Here's the script.
//::///////////////////////////////////////////////
//:: Witchwork Conversation System: Cast Acid Splash Check
//:: WW_Abil_AcidSp.nss
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Does a Cast Acid Splash check and broadcasts a
feedback string.
*/
//:://////////////////////////////////////////////
//:: Created By: Rob Bartel
//:: Created On: August 30, 2002
//:://////////////////////////////////////////////
void main()
{
object oPC = GetPCSpeaker();
int bHasSpell1 = GetHasSpell(SPELL_ACID_SPLASH, oPC);
//If PC is unable to cast Acid Splash, do nothing...
if (bHasSpell1 == FALSE)
{
return;
}
object oNPC = OBJECT_SELF;
int iAbilityType;
int iSpell;
//Get the PC's individual class levels for calculating their total
//character level.
int iclass1Level = GetLevelByPosition(1, oPC);
int iclass2Level = GetLevelByPosition(2, oPC);
int iclass3Level = GetLevelByPosition(3, oPC);
//Determine what those three classes are.
int iclass1 = GetclassByPosition(1, oPC);
int iclass2 = GetclassByPosition(2, oPC);
int iclass3 = GetclassByPosition(3, oPC);
//Make an educated guess as to whether they used Acid Splash
if (GetHasSpell(SPELL_ACID_SPLASH, oPC))
iSpell = SPELL_ACID_SPLASH;
//Otherwise start doing some educated guessing as to what class they might
//be casting from so you can use the appropriate ability score modifier.
//class 1:
else if (iclass1 == class_TYPE_WIZARD)
iAbilityType = ABILITY_INTELLIGENCE;
else if (iclass1 == class_TYPE_SORCERER ||
(iclass1 == class_TYPE_BARD &&
iclass1Level >= 2))
iAbilityType = ABILITY_CHARISMA;
//class 2:
else if (iclass2 == class_TYPE_WIZARD)
iAbilityType = ABILITY_INTELLIGENCE;
else if (iclass2 == class_TYPE_SORCERER ||
(iclass2 == class_TYPE_BARD &&
iclass1Level >= 2))
iAbilityType = ABILITY_CHARISMA;
//class 3:
else if (iclass3 == class_TYPE_WIZARD)
iAbilityType = ABILITY_INTELLIGENCE;
else if (iclass3 == class_TYPE_SORCERER ||
(iclass3 == class_TYPE_BARD &&
iclass1Level >= 2))
iAbilityType = ABILITY_CHARISMA;
//For Special Abilities, use intelligence:
else
iAbilityType = ABILITY_INTELLIGENCE;
//Decrement the spell & cast a fake one
AssignCommand(oPC, ActionPauseConversation());
DecrementRemainingSpellUses(oPC, iSpell);
AssignCommand(oPC, ActionCastFakeSpellAtObject(iSpell, oNPC));
AssignCommand(oPC, ActionResumeConversation());
//Declare the values used in the Ability Check
int iDC = GetLocalInt(OBJECT_SELF, "iWW_AbilityDC");
int iD20 = Random(20)+1;
int iAbilMod = GetAbilityModifier(iAbilityType, oPC);
int iCharLevel = iclass1Level + iclass2Level + iclass3Level;
//Create the final Check calculation.
int iCheck = iD20 + iAbilMod + iCharLevel;
int iSkill = iAbilMod + iCharLevel;
//Convert the above Ints to Strings in preparation for broadcast.
// DEBUG
string sDC = IntToString(iDC); // DONE
string sRoll = IntToString(iD20); // DONE
string sSkill = IntToString(iSkill); // DONE
string sCheck = IntToString(iCheck); // DONE
// DEBUG
//If the PC's Check >= DC, they succeed.
if (iCheck >= iDC)
{
SetLocalString(OBJECT_SELF, "sWW_AbilityResult", "Success");
// PASS ROLL
string sBroadcast = "<c þþ>Acid Splash</c> <cþþ >:</c> <cþþþ>"+sRoll+"</c> <cþþ >+</c> <cþþþ>"+sSkill+"</c> <cþþ >=</c> <c þ >"+sCheck+"</c> <cþþ >vs.</c> <cþþþ>DC</c> <c þþ>"+sDC+".</c>";
SendMessageToPC(oPC, sBroadcast);
}
//If not, they fail.
else
{
SetLocalString(OBJECT_SELF, "sWW_AbilityResult", "Failure");
// FAIL ROLL
string sBroadcast = "<c þþ>Acid Splash</c> <cþþ >:</c> <cþþþ>"+sRoll+"</c> <cþþ >+</c> <cþþþ>"+sSkill+"</c> <cþþ >=</c> <cþ >"+sCheck+"</c> <cþþ >vs.</c> <cþþþ>DC</c> <c þþ>"+sDC+".</c>";
SendMessageToPC(oPC, sBroadcast);
}
}
Just a clean crop of the colour codes regarding the broadcast message of the variables.
Acid Splash : "+sRoll+" + "+sSkill+" = "+sCheck+" vs. DC "+sDC+".
FP!
Modifié par Fester Pot, 05 novembre 2011 - 10:22 .