| Author: | Volsys |
| Author Website/Email: | Volsys@hotmail.com |
| Script Name: | EZ Skill Checks |
| Description: | This script is meant to be re-usable on many different events with ease of use in mind. Primarily skill and ability or feat checks but can be adapted for anything. Nice for me as I have all the types in commented sections so I can quickly change my criteria. Probably not perfect, but was a great learning experience. |
| Instructions on Use: | Slap it on something's (OnUse) and watch those PC's pay a bit more attention... |
Script 1:
| // EZ Check // //This is an update to the EZ Checks script. //It adds the appropriate ability modifier to the SKILL_ check, and verifies //the PC has the Skill/Feat/etc itself, or fails to run for them. //Looks a bit cleaner, and added extra comments. //All the comments above the code is the explanation. //Below the code is the to change the check criteria fast. //Have fun! Tie this to any object, trigger, pc, conversations, etc to run any kind of skill check. // This example rewards a dagger "hidden and wedged beneath some leg shackles" to the PC //who checks(clicks) the item and makes a successful search roll. // //I wrote simply because I use many easy checks in my PnP, and wanted //to make a script that was easily adaptable to OnEnter, OnOpen, OnClose, OnUnlock, etc. //It simply does a skill/ability/feat/whatever check... //Maybe a hidden item, a path based on alignment, secret doors, monster weakness messages, //information messages, magic-mouths, lots of various things. // //I did me best to explain it but I'm no master at programming, this is just something //fun for me to experiment with for now. // //Default use is OnUse, but easily adapted to anything. Good luck and have fun. //I use this script often, hopefully will get revised and optomized. //Sorry if my formatting and everything is not perfect. //The code starts... //Tell me if my secret was already found. set to 0. When the secret is found, will set to 1. //This is a local variable. Something that can get changed anywhere in the module and //does get changed in this example int found_secret = 0; //You've seent his before... void main() { //Who is OnUsing me? or OnEntering me, or OnOpening me. object oPC = GetLastUsedBy(); //Special item check. If you have this item it sends an additional message //or whatever you like, cast a spell on him, create an object, etc. object oTorch = GetItemPossessedBy(oPC,"EnhancedTorch"); //this is the secret item to be "discovered". I made a dagger called RustyDagger. string sItem = "RustyDagger"; //string diety_name = GetDeity(oPC); Not used. //Get the PC skill SKILL_WHATEVER plus any ability modifiers. //All Skills are listed below the command, SKILL_SEARCH is my default. You can //replace everything from Equal on with the extra code following the skills below. int pc_search_score = ((GetSkillRank(SKILL_SEARCH, oPC)) + (GetAbilityModifier(ABILITY_INTELLIGENCE,oPC))); // SKILL_ANIMAL_EMPATHY ((GetSkillRank(SKILL_ANIMAL_EMPATHY, oPC)) + (GetAbilityModifier(ABILITY_INTELLIGENCE,oPC))); // SKILL_CONCENTRATION ((GetSkillRank(SKILL_CONCENTRATION, oPC)) + (GetAbilityModifier(ABILITY_CONSTITUTION,oPC))); // SKILL_DISABLE_TRAP ((GetSkillRank(SKILL_DISABLE_TRAP, oPC)) + (GetAbilityModifier(ABILITY_INTELLIGENCE,oPC))); // SKILL_DISCIPLINE ((GetSkillRank(SKILL_DISCIPLINE, oPC)) + (GetAbilityModifier(ABILITY_STRENGTH,oPC))); // SKILL_HEAL ((GetSkillRank(SKILL_HEAL, oPC)) + (GetAbilityModifier(ABILITY_WISDOM,oPC))); // SKILL_HIDE ((GetSkillRank(SKILL_HIDE, oPC)) + (GetAbilityModifier(ABILITY_DEXTERITY,oPC))); // SKILL_LISTEN ((GetSkillRank(SKILL_LISTEN, oPC)) + (GetAbilityModifier(ABILITY_WISDOM,oPC))); // SKILL_LORE ((GetSkillRank(SKILL_LORE, oPC)) + (GetAbilityModifier(ABILITY_INTELLIGENCE,oPC))); // SKILL_MOVE_SILENTLY ((GetSkillRank(SKILL_MOVE_SILENTLY, oPC)) + (GetAbilityModifier(ABILITY_DEXTERITY,oPC))); // SKILL_OPEN_LOCK ((GetSkillRank(SKILL_OPEN_LOCK, oPC)) + (GetAbilityModifier(ABILITY_DEXTERITY,oPC))); // SKILL_PARRY ((GetSkillRank(SKILL_PARRY, oPC)) + (GetAbilityModifier(ABILITY_DEXTERITY,oPC))); // SKILL_PERFORM ((GetSkillRank(SKILL_PERFORM, oPC)) + (GetAbilityModifier(ABILITY_CHARISMA,oPC))); // SKILL_PERSUADE ((GetSkillRank(SKILL_PERSUADE, oPC)) + (GetAbilityModifier(ABILITY_CHARISMA,oPC))); // SKILL_PICK_POCKET ((GetSkillRank(SKILL_PICK_POCKET, oPC)) + (GetAbilityModifier(ABILITY_DEXTERITY,oPC))); // SKILL_SEARCH ((GetSkillRank(SKILL_SEARCH, oPC)) + (GetAbilityModifier(ABILITY_INTELLIGENCE,oPC))); // SKILL_SET_TRAP ((GetSkillRank(SKILL_SET_TRAP, oPC)) + (GetAbilityModifier(ABILITY_DEXTERITY,oPC))); // SKILL_SPELLCRAFT ((GetSkillRank(SKILL_SPELLCRAFT, oPC)) + (GetAbilityModifier(ABILITY_INTELLIGENCE,oPC))); // SKILL_SPOT ((GetSkillRank(SKILL_SPOT, oPC)) + (GetAbilityModifier(ABILITY_WISDOM,oPC))); // SKILL_TAUNT ((GetSkillRank(SKILL_TAUNT, oPC)) + (GetAbilityModifier(ABILITY_CHARISMA,oPC))); // SKILL_USE_MAGIC_DEVICE ((GetSkillRank(SKILL_USE_MAGIC_DEVICE, oPC)) + (GetAbilityModifier(ABILITY_CHARISMA,oPC))); // Get the PC ability score ABILITY_WHATEVER. Abilities also listed below. int pc_ability_score = GetAbilityScore(oPC, ABILITY_STRENGTH); //ABILITY_STRENGTH ABILITY_CONSTITUTION ABILITY_DEXTERITY ABILITY_WISDOM ABILITY_INTELLIGENCE //ABILITY_CHARISMA // Get the PC Race. The races below are the values it will assign based on PC Race int pc_char_race = GetRacialType(oPC); // RACIAL_TYPE_DWARF RACIAL_TYPE_ELF RACIAL_TYPE_GNOME RACIAL_TYPE_HALFELF // RACIAL_TYPE_HALFLING RACIAL_TYPE_HALFORC RACIAL_TYPE_HUMAN RACIAL_TYPE_HALFORC //Get the PC Gender. Same with Gender int pc_gender = GetGender(oPC); // GENDER_BOTH GENDER_FEMALE GENDER_MALE GENDER_NONE GENDER_OTHER //Get the PC Size. And with Size. int pc_size = GetCreatureSize(oPC); // CREATURE_SIZE_HUGE CREATURE_SIZE_LARGE CREATURE_SIZE_MEDIUM // CREATURE_SIZE_SMALL CREATURE_SIZE_TINY CREATURE_SIZE_INVALID //Get PC Alignment. I only really care about good or evil for the most part. int pc_alignment = GetAlignmentGoodEvil(oPC); // ALIGNMENT_EVIL ALIGNMENT_GOOD //Get the current amount of Hitpoints int pc_hit_points = GetCurrentHitPoints(oPC); // if (pc_hit_points < 4) { //The three types of saving throws. Get the PC's numbers. int pc_fortitude_save = GetReflexSavingThrow(oPC); int pc_reflex_save = GetWillSavingThrow(oPC); int pc_willpower_save = GetFortitudeSavingThrow(oPC); //This is a generic message sent to the PC OnUsing this script OnUsing this object. I //have this on a placeable Floor Shackles. SendMessageToPC(oPC, "The shackles are rusted."); //TOPTEST - if the PC already found the secret, break from the script. This is put here //first so that we can stop the next part from running if it already sucessfully ran. if (GetLocalInt(GetModule(),"found_secret")) { return; } //MiIDDLETEST - This says if the PC does not have the skill AND does not have the second //criteria (bardic knowledge), then stop running because not only does the PC //not have the skill, he also does not have the feat - so dont give him a //chance to find the secret. if ( (GetSkillRank(SKILL_SEARCH,oPC)) == (-1) && (GetHasFeat(FEAT_BARDIC_KNOWLEDGE, oPC)) != TRUE) { return; } //This part checks a skill or feat or anything that is listed above. If sucessful checks //are made it performs your actions. In this case it gives a "hidden" item, and sends an appropriate //message to the pc. This is where all the action of the ability checks, or skill checks, or //feats, or race or alignment, etc, or a combination can be checked to see if the character //is able to discover... //In this case, I'm saying. If on a d20 roll + the Pc's search score is greater than 10. AND (&&) //on another d20 roll + the PC's ability score of Strength is higher than 10. Then you can //go ahead and send the message and give the item to the pc. But you also see || (GetHasFeat( //This means that if the PC failed the 1'st check BUT has the Bardic Knowledge feat, then you can //go ahead and send the message and give the item to the PC. || means "OR". if ( (d20(1) + pc_search_score > 10) && ( d20(1)+ pc_ability_score > 20) || (GetHasFeat(FEAT_BARDIC_KNOWLEDGE, oPC))) { // Send the PC the message telling him how skillful he is. SendMessageToPC(oPC, "You notice a small dagger wedged beneath the rusted shackles. With some strength you manage to pull it out."); // Give him this reward for being so skillful. CreateItemOnObject(sItem, oPC); //Now that the PC found the item, set found_secret to 1 so that this
part wont run again. |