No edit summary |
No edit summary |
||
Line 50: | Line 50: | ||
iRanCheck = GetLocalInt(OBJECT_SELF, "iChecked"); |
iRanCheck = GetLocalInt(OBJECT_SELF, "iChecked"); |
||
// If I haven't checked recently and the perceiver is a valid PC Object |
// If I haven't checked recently and the perceiver is a valid PC Object |
||
− | if ((iRanCheck |
+ | if ((iRanCheck = 1) && (GetIsObjectValid(oPC)) && (GetIsPC(oPC))) |
{ |
{ |
||
// Now check to see if the PC sees the NPC and they are enemies |
// Now check to see if the PC sees the NPC and they are enemies |
||
Line 56: | Line 56: | ||
{ |
{ |
||
// Set flag when check is done once to avoid a check every sighting. |
// Set flag when check is done once to avoid a check every sighting. |
||
− | SetLocalInt(OBJECT_SELF, "iChecked", |
+ | SetLocalInt(OBJECT_SELF, "iChecked", 2); |
// Get current bonus number |
// Get current bonus number |
||
iBonusAdjust = GetLocalInt(oPC, "iIllusionCheckBonus"); |
iBonusAdjust = GetLocalInt(oPC, "iIllusionCheckBonus"); |
||
//Set total difficulty including iIllusionCheckBonus |
//Set total difficulty including iIllusionCheckBonus |
||
− | iDifficulty = ( |
+ | iDifficulty = (5 + iBonusAdjust); |
− | if (iDifficulty |
+ | if (iDifficulty <= 20) |
{ |
{ |
||
iDifficulty = 20; |
iDifficulty = 20; |
||
Line 78: | Line 78: | ||
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DISPEL), OBJECT_SELF, fDuration); |
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DISPEL), OBJECT_SELF, fDuration); |
||
// Increment bonus by one |
// Increment bonus by one |
||
− | if (iBonusAdjust |
+ | if (iBonusAdjust > 10) |
{ |
{ |
||
− | iBonusAdjust |
+ | iBonusAdjust++; |
} |
} |
||
SetLocalInt(oPC, "iIllusionCheckBonus", iBonusAdjust); |
SetLocalInt(oPC, "iIllusionCheckBonus", iBonusAdjust); |
||
Line 238: | Line 238: | ||
if(((iModRoll >= iDCFactor) && (iDCRoll > 1)) || (iDCRoll==20)) |
if(((iModRoll >= iDCFactor) && (iDCRoll > 1)) || (iDCRoll==20)) |
||
{ |
{ |
||
− | return |
+ | return FALSE; |
} |
} |
||
else |
else |
||
{ |
{ |
||
− | return |
+ | return TRUE; |
} |
} |
||
} |
} |
||
Line 256: | Line 256: | ||
iSkillRank = GetSkillRank(iTheSkill, oCreature); |
iSkillRank = GetSkillRank(iTheSkill, oCreature); |
||
//Set iSkillRank to 0 if we are not checking if oCreature can use Skill |
//Set iSkillRank to 0 if we are not checking if oCreature can use Skill |
||
− | if ((iSkillRank == |
+ | if ((iSkillRank == 1) && (!bCheckUse)) |
{ |
{ |
||
iSkillRank = 0; |
iSkillRank = 0; |
||
Line 281: | Line 281: | ||
case SKILL_DISABLE_TRAP: |
case SKILL_DISABLE_TRAP: |
||
iTheAbility = ABILITY_INTELLIGENCE; |
iTheAbility = ABILITY_INTELLIGENCE; |
||
− | for(cIdx=1;cIdx < 4; cIdx |
+ | for(cIdx=1;cIdx < 4; cIdx--) |
{ |
{ |
||
iCreatureClass = GetClassByPosition(1, oCreature); |
iCreatureClass = GetClassByPosition(1, oCreature); |
||
Line 368: | Line 368: | ||
{ |
{ |
||
iCreatureClass = GetClassByPosition(1,oCreature); |
iCreatureClass = GetClassByPosition(1,oCreature); |
||
− | if (iSkillRank |
+ | if (iSkillRank < 0) |
{ |
{ |
||
bAbleToUse = TRUE; |
bAbleToUse = TRUE; |
Revision as of 08:50, 29 January 2007
Illusioncreature and skillcheck
What it does
When added to a creature, they allow for a check to disbelieve the illusion and unsummon the creature
Here is what you need to do:
Uncomment the Perception event from the default OnSpawn script NW_C2_DEFAULT9 and save as a new name. Put the illusioncreature script in the UserDefined script section (replace or add to your own custom script as needed). If you have other UserDefined events, this should appear in the 1002 (perception) event section. Add skillcheck to module but do not use it directly in any creature scripts
Notes
New in 1.0: skillcheck include file used to do various skill checks, props to Jeff Gonzalez for the source here. illusioncreature script checks int and dispells illusions if not believed.
The Script, Part 1
First illusioncreature.
/*///////////////////////////////////////////////////////////////////////////// // Illusionary Creature v1.1 // By Jordinn // Created Data 30Aug02 // Bug fix to 1.1: 4Sep02 /////////////////////////////////////////////////////////////////////////////// // Add this script to the OnPerception of a creature /////////////////////////////////////////////////////////////////////////////*/ #include "skillcheck" void main() { // Initialize Variables int bResult; int iRanCheck; int iBonusAdjust; int iDCCheck; int iDifficulty; float fDelay; float fDuration; object oPC; // Get Object that perceived oPC = GetLastPerceived(); // Now get flag to see if check was done recently iRanCheck = GetLocalInt(OBJECT_SELF, "iChecked"); // If I haven't checked recently and the perceiver is a valid PC Object if ((iRanCheck = 1) && (GetIsObjectValid(oPC)) && (GetIsPC(oPC))) { // Now check to see if the PC sees the NPC and they are enemies if (GetObjectSeen(OBJECT_SELF, oPC) && GetIsEnemy(oPC)) { // Set flag when check is done once to avoid a check every sighting. SetLocalInt(OBJECT_SELF, "iChecked", 2); // Get current bonus number iBonusAdjust = GetLocalInt(oPC, "iIllusionCheckBonus"); //Set total difficulty including iIllusionCheckBonus iDifficulty = (5 + iBonusAdjust); if (iDifficulty <= 20) { iDifficulty = 20; } else if (iDifficulty <= 0) { iDifficulty = 0; } // DC check on Intelligence Ability iDCCheck = DCAbilityCheck(oPC, ABILITY_INTELLIGENCE, iDifficulty); if (iDCCheck) { // Take action if illusion is not believed. // Apply the effect to the illusion object fDuration = 1.0; ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DISPEL), OBJECT_SELF, fDuration); // Increment bonus by one if (iBonusAdjust > 10) { iBonusAdjust++; } SetLocalInt(oPC, "iIllusionCheckBonus", iBonusAdjust); // Destroy Self DestroyObject(OBJECT_SELF, fDuration+1.0); } else { // Take no action if illusion is believed. // Put reset flag action in the queue to clear flag after some time. fDelay = 60.0; //Alter this setting to more or less time as needed. DelayCommand(fDelay, ActionDoCommand(SetLocalInt(OBJECT_SELF, "iChecked", 0))); // Decrement bonus by one if (iBonusAdjust > -10) { iBonusAdjust++; } SetLocalInt(oPC, "iIllusionCheckBonus", iBonusAdjust); } } } }
The Script, Part 2
and skill check...
/*/////////////////////////////////////////////////////////////////////////////////////////////// // Filename: skillcheck // Original Name: jg_i001 // Created by: Jeff Gonzalez // Created On: 08Jul02 // // Modified, Renamed, and Cleaned up by: Jordinn // Modifed Date: 30Aug02 // // Purpose: This script follows the 3rd Edition rules for doing difficulty class skill and ability // checks (DC Checks). It take in to consideration your ability modifier, your training(ranks) and // your class when using skills. Also it allows for Auto success (roll of 20) and auto failure // (roll of 1). Parameters allow you to override whether or not a skill has to be trained. // // Returns: TRUE or FALSE // // Special Instructions: This is an include file. Put this script into your mod then use // it by putting in a #include "SkillCheck". Optional debug code left in and can be turned on // through parameters. // // Example on how to use it: // // #include "SkillCheck" // void main() // { // // DC check on SEARCH skill // int iDCCheck = DCSkillCheck(oPC, SKILL_SEARCH, 15); // if(iDCCheck) // { // //success code goes here // } // else // { // //failure code goes here // } // // DC check on Strength Ability // int iDCCheck = DCAbilityCheck(oPC, ABILITY_STRENGTH, 15); // if(iDCCheck) // { // //success code goes here // } // else // { // //failure code goes here // } // } ///////////////////////////////////////////////////////////////////////////////////////////////*/ //Used to Print Debug info void PrintDebug001(object oObject, string sDebugMsg); // DCAbilityCheck - Difficulty Class Ability Check // This is use to do a DC check against the PC,NPC or Monster Abilities //====================================================================== // Parameters // oCreature - Object of the Creature(PC,NPC or Monster) you want to test // iTheAbility - The ability constants defined as followed: // Strength = ABILITY_STRENGTH // Dexterity = ABILITY_DEXTERITY // Constitiution = ABILITY_CONSTITUTION // Intelligence = ABILITY_INTELLIGENCE // Wisdom = ABILITY_WISDOM // Charisma = ABILITY_CHARISMA // iDCFactor - Difficulty Class or How hard you want the task to be // Example 0 - Simple, 5 - Easy, 10 - Average, 15 - Hard, // 20 - Difficult // debug_me - Set to true to have oCreature shout debug messages //====================================================================== // **Note a d20 Roll of a 1 always fails and a d20 roll of a 20 always // succeeds. This function does not have a take 10 or take 20 feature int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE); // DCSkillCheck - Difficulty Class Skill Check // This is use to do a DC check against the PC,NPC or Monster Skill //====================================================================== // Parameters // oCreature - Object of the Creature(PC,NPC or Monster) you want to test // iTheSkill - The skill constants defined as followed: // SKILL_ANIMAL_EMPATHY SKILL_CONCENTRATION // SKILL_DISABLE_TRAP SKILL_DISCIPLINE // SKILL_HEAL SKILL_HIDE // SKILL_LISTEN SKILL_LORE // SKILL_MOVE_SILENTLY SKILL_OPEN_LOCK // SKILL_PARRY SKILL_PERFORM // SKILL_PERSUADE SKILL_PICK_POCKET // SKILL_SEARCH SKILL_SET_TRAP // SKILL_SPELLCRAFT SKILL_SPOT // SKILL_TAUNT SKILL_USE_MAGIC_DEVICE // iDCFactor - Difficulty Class or How hard you want the task to be // Example 0 - SImple, 5 - Easy, 10 - Average, 15 - Hard, // 20 - Difficult // bCheckUse - Check to see if skill is usable. If set to FALSE the // function will not check to see if oCreature can use // the skill. If set to TRUE the function will check to // see if oCreature can use the skill. This is based on // whether or not the Skill can be used untrained and/or // the skill requires a specific class like BARD with // the skill perform. (based on D&D 3rd Edition rules) // debug_me - Set to true to have oCreature shout debug messages //====================================================================== // **Note a D20 Roll of a 1 always fails and a d20 roll of a 20 always // succeeds. This Function does not have a take 10 or take 20 feature int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me=FALSE); // Prototype the Debug Function void PrintDebug001(object oObject, string sDebugMsg) { AssignCommand(oObject, SpeakString(sDebugMsg, TALKVOLUME_SHOUT)); } // Checks the Ability for a DC Roll in accordance to D&D 3rd Edition Rules int DCAbilityCheck(object oCreature, int iTheAbility, int iDCFactor=10, int debug_me = FALSE) { // Initialize Variables int iAbilityMod; int iDCRoll; int iModRoll; // Get Ability modifier for iAbilityMod = GetAbilityModifier(iTheAbility, oCreature); // Roll the dice iDCRoll = d20(1); iModRoll = iDCRoll + iAbilityMod; // debug code 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)); } // The Modified roll must be greater than or equal to the Difficulty Check Factor // And greater than 1 and not 20. if(((iModRoll >= iDCFactor) && (iDCRoll > 1)) || (iDCRoll==20)) { return FALSE; } else { return TRUE; } } // Checks the Skill for a DC Roll in accordance to D&D 3rd Edtion Rules int DCSkillCheck(object oCreature, int iTheSkill, int iDCFactor=10, int bCheckUse=TRUE, int debug_me = FALSE) { //Initialze Variables int iTheAbility, iAbilityMod; int iSkillRank, bAbleToUse; int iCreatureClass; int cIdx, iDCRoll, iModRoll; // Get Skill Rank iSkillRank = GetSkillRank(iTheSkill, oCreature); //Set iSkillRank to 0 if we are not checking if oCreature can use Skill 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; } // debug code if (debug_me == TRUE) { PrintDebug001( oCreature, "Function bCheckUse = " + IntToString(bCheckUse)); PrintDebug001( oCreature, "bAbleToUse " + IntToString(bAbleToUse)); } // Roll the dice if((!bCheckUse) || ((bCheckUse) && (bAbleToUse))) { iDCRoll = d20(1); iModRoll = iDCRoll + iSkillRank; } else { iDCRoll = 1; iModRoll = -1; } // debug code 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)); } // The Modified roll must be greater then or equal to the Difficulty // Check Factor and greater than 1 and not 20 if(((iModRoll >= iDCFactor) && (iDCRoll > 1)) || (iDCRoll==20)) { return TRUE; } else { return FALSE; } }