Author Sticky: Post Working Scripts Here
j_dunn Posted: Friday, 28 June 04:17AM
-------
Revised Subraces Script
-------

Ok I revised the subraces script so it does not go away after you rest, turned the actual editing command into a function so it is easier to handle in other scripts you may wish to use it in, and provided an example script on attaching it to conversations, doors, and triggers along with the possibility of setting it up to automatically teleport the character to either a general starting point OR a starting point dependent on the subrace (can be changed to race by changing one little line). Here is what you need to do.

1. Set up a Start Room and put your start point there. It can be as big or small as you like as long as it will fit a PC and an NPC, Trigger, or door.

2. Under View, Area Properties make sure it is set to NO REST otherwise it will cause a problem if the PC's rest before updating themselves.

3. Create the base function script which is included in the other 2 scripts necessary for this. I suggest you save the script as "gs_subrace" as that is what I saved mine as and will remove the need to edit the #include statements. There is a template at the end of the script for you to use in adding your own races. The base "gs_subrace" script is as follows:

NWScript:
//::///////////////////////////////////////////////

//:: Sub-Race Functions

//:: gs_subrace.nss

//:: Copyright (c) 2002 J_Dunn

//:://////////////////////////////////////////////

/*

*/

//:://////////////////////////////////////////////

//:: Created By: J_DUNN

//:: Created On: 6/26/02

//:://////////////////////////////////////////////



//DO NOT EDIT THE VARIABLE INIT STRINGS OR THE FUNCTION STRINGS BELOW

object oTarget;

string sSubrace;

int race;

int str;

int dex;

int con;

int intel;

int wis;

int cha;

int empathy;

int conc;

int dtrap;

int disc;

int heal;

int hide;

int list;

int lore;

int silent;

int open;

int parry;

int perf;

int pers;

int pick;

int search;

int strap;

int spell;

int spot;

int taunt;

int magic;



void raisestr() /* Raise Strength */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityIncrease(ABILITY_STRENGTH,str),oTarget);

}

void raisedex() /* Raise Dexterity */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityIncrease(ABILITY_DEXTERITY,dex),oTarget);

}

void raisecon() /* Raise Constitution */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityIncrease(ABILITY_CONSTITUTION,con),oTarget);

}

void raiseint() /* Raise Intelligence */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityIncrease(ABILITY_INTELLIGENCE,intel),oTarget);

}

void raisewis() /* Raise Wisdom */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityIncrease(ABILITY_WISDOM,wis),oTarget);

}

void raisecha() /* Raise Charisma */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityIncrease(ABILITY_CHARISMA,cha),oTarget);

}

void lowerstr() /* Lower Strength */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityDecrease(ABILITY_STRENGTH,str),oTarget);

}

void lowerdex() /* Lower Dexterity */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityDecrease(ABILITY_DEXTERITY,dex),oTarget);

}

void lowercon() /* Lower Constitution */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityDecrease(ABILITY_CONSTITUTION,con),oTarget);

}

void lowerint() /* Lower Intelligence */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityDecrease(ABILITY_INTELLIGENCE,intel),oTarget);

}

void lowerwis() /* Lower Wisdom */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityDecrease(ABILITY_WISDOM,wis),oTarget);

}

void lowercha() /* Lower Charisma */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAbilityDecrease(ABILITY_CHARISMA,cha),oTarget);

}

void raiseempathy() /* Raise Animal Empathy Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_ANIMAL_EMPATHY,empathy),oTarget);

}

void raiseconc() /* Raise Concentration Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_CONCENTRATION,conc),oTarget);

}

void raisedtrap() /* Raise Disable Trap Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_DISABLE_TRAP,dtrap),oTarget);

}

void raisedisc() /* Raise Discipline Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_DISCIPLINE,disc),oTarget);

}

void raiseheal() /* Raise Heal Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_HEAL,heal),oTarget);

}

void raisehide() /* Raise Hide Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_HIDE,hide),oTarget);

}

void raiselist() /* Raise Listen Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_LISTEN,list),oTarget);

}

void raiselore() /* Raise Lore Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_LORE,lore),oTarget);

}

void raisesilent() /* Raise Move Silently Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_MOVE_SILENTLY,silent),oTarget);

}

void raiseopen() /* Raise Open Lock Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_OPEN_LOCK,open),oTarget);

}

void raiseparry() /* Raise Parry Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_PARRY,parry),oTarget);

}

void raiseperf() /* Raise Perform Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_PERFORM,perf),oTarget);

}

void raisepers() /* Raise Persuade Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_PERSUADE,pers),oTarget);

}

void raisepick() /* Raise Pick Pocket Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_PICK_POCKET,pick),oTarget);

}

void raisesearch() /* Raise Search Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_SEARCH,search),oTarget);

}

void raisestrap() /* Raise Set Trap Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_SET_TRAP,strap),oTarget);

}

void raisespell() /* Raise Spellcraft Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_SPELLCRAFT,spell),oTarget);

}

void raisespot() /* Raise Spot Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_SPOT,spot),oTarget);

}

void raisetaunt() /* Raise Taunt Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_TAUNT,taunt),oTarget);

}

void raisemagic() /* Raise Use Magic Device Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillIncrease(SKILL_USE_MAGIC_DEVICE,magic),oTarget);

}

void lowerempathy() /* Lower Animal Empathy Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_ANIMAL_EMPATHY,empathy),oTarget);

}

void lowerconc() /* Lower Concentration Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_CONCENTRATION,conc),oTarget);

}

void lowertrap() /* Lower Disable Trap Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_DISABLE_TRAP,dtrap),oTarget);

}

void lowerdisc() /* Lower Discipline Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_DISCIPLINE,disc),oTarget);

}

void lowerheal() /* Lower Heal Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_HEAL,heal),oTarget);

}

void lowerhide() /* Lower Hide Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_HIDE,hide),oTarget);

}

void lowerlist() /* Lower Listen Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_LISTEN,list),oTarget);

}

void lowerlore() /* Lower Lore Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_LORE,lore),oTarget);

}

void lowersilent() /* Lower Move Silently Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_MOVE_SILENTLY,silent),oTarget);

}

void loweropen() /* Lower Open Lock Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_OPEN_LOCK,open),oTarget);

}

void lowerparry() /* Lower Parry Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_PARRY,parry),oTarget);

}

void lowerperf() /* Lower Perform Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_PERFORM,perf),oTarget);

}

void lowerpers() /* lower Persuade Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_PERSUADE,pers),oTarget);

}

void lowerpick() /* Lower Pick Pocket Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_PICK_POCKET,pick),oTarget);

}

void lowersearch() /* Lower Search Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_SEARCH,search),oTarget);

}

void lowerstrap() /* Lower Set Trap Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_SET_TRAP,strap),oTarget);

}

void lowerspell() /* Lower Spellcraft Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_SPELLCRAFT,spell),oTarget);

}

void lowerspot() /* Lower Spot Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_SPOT,spot),oTarget);

}

void lowertaunt() /* Lower Taunt Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_TAUNT,taunt),oTarget);

}

void lowermagic() /* Lower Use Magic Device Skill */

{

   ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectSkillDecrease(SKILL_USE_MAGIC_DEVICE,magic),oTarget);

}

int subrace() //You May Begin Editing Here

{

 sSubrace = GetSubRace(oTarget);

 race = GetRacialType(oTarget);

 if (race == RACIAL_TYPE_ELF)

  {

   if (sSubrace == "Wood Elf")

    {

      str = 1;

      dex = 0;

      con = 2;

      intel = 1;

      wis = 0;

      cha = 3;

      empathy = 0;

      conc = 0;

      dtrap = 0;

      disc = 0;

      heal = 0;

      hide = 0;

      list = 0;

      lore = 0;

      silent = 0;

      open = 0;

      parry = 0;

      perf = 0;

      pers = 0;

      pick = 0;

      search = 0;

      strap = 0;

      spell = 0;

      spot = 0;

      taunt = 0;

      magic = 0;

     raisestr();

     raisecon();

     lowerint();

     lowercha();

     return 1;

    }

    else

    {

     return 0;

    }

  }

  else

  {

   return 0;

  }

}



 /*

 Subrace Script Template

 if (race == RACIAL_TYPE_<type here>)

  {

   if (sSubrace == "<the subrace, EXACTLY how you want them to type it in, here>")

    {

      str = 0;

      dex = 0;

      con = 0;

      intel = 0;

      wis = 0;

      cha = 0;

      empathy = 0;

      conc = 0;

      dtrap = 0;

      disc = 0;

      heal = 0;

      hide = 0;

      list = 0;

      lore = 0;

      silent = 0;

      open = 0;

      parry = 0;

      perf = 0;

      pers = 0;

      pick = 0;

      search = 0;

      strap = 0;

      spell = 0;

      spot = 0;

      taunt = 0;

      magic = 0;

     //raisestr();

     //raisedex();

     //raisecon();

     //raiseint();

     //raisewis();

     //raisecha();

     //lowerstr();

     //lowerdex();

     //lowercon();

     //lowerint();

     //lowerwis();

     //lowercha();

     //raiseempathy();

     //raiseconc();

     //raisedtrap();

     //raisedisc();

     //raiseheal();

     //raisehide();

     //raiselist();

     //raiselore();

     //raisesilent();

     //raiseopen();

     //raiseparry();

     //raiseperf();

     //raisepers();

     //raisepick();

     //raisesearch();

     //raisestrap();

     //raisespell();

     //raisespot();

     //raisetaunt();

     //raisemagic();

     //lowerempathy();

     //lowerconc();

     //lowerdtrap();

     //lowerdisc();

     //lowerheal();

     //lowerhide();

     //lowerlist();

     //lowerlore();

     //lowersilent();

     //loweropen();

     //lowerparry();

     //lowerperf();

     //lowerpers();

     //lowerpick();

     //lowersearch();

     //lowerstrap();

     //lowerspell();

     //lowerspot();

     //lowertaunt();

     //lowermagic();

     return 1;

    }

  }

  else

  {

   return 0;

  }

} */

{/nwscript]

4. Add this into your module's OnRest script (accessed via View, Module Properties).



#include "gs_subrace"

void main()

{

 oTarget = GetLastPCRested();

 subrace();

}



4. In your module's OnRest script (access via View, Module Properties) add this:

NWScript:
#include "gs_subrace"

void main()

{

 oTarget = GetLastPCRested();

 subrace();

}



5. Finally in your starting area add an NPC, Door, or Trigger. For NPC's attach this script to their conversation. For doors attach it to their OnOpen, and for triggers attach it to OnEnter. Make sure to set up your waypoints for where you want the player to be moved to, and edit the script to change the waypoint tag in it from mine to yours if different. For teleporting based on subrace make sure to add enough if-then-else statements. Also DO NOT set up the door or trigger's area transition, the script does it for you. Oh yeah and unremark the lines you wish to use.

NWScript:
#include "gs_subrace"

void main()

{

//Example of how to use this as a conversation script

/*

 oTarget = GetPCSpeaker();

 if (subrace() == 0)

 {

   SendMessageToPC(oTarget,"You have not created your character properly. Please contact a DM for assistance.");

 }

 else

 {

  AssignCommand(oTarget,ActionJumpToLocation(GetLocation(GetWaypointByTag("wp_start"))));

 }

*/

// Example of how to use this with triggers

/*

 oTarget = GetEnteringObject();

 if (subrace() == 0)

 {

   SendMessageToPC(oTarget,"You have not created your character properly. Please contact a DM for assistance.");

 }

 else

 {

  AssignCommand(oTarget,ActionJumpToLocation(GetLocation(GetWaypointByTag("wp_start"))));

 }

*/

//Example of how to use this with a door

/*

 oTarget = GetLastOpenedBy();

 if (subrace() == 0)

 {

   SendMessageToPC(oTarget,"You have not created your character properly. Please contact a DM for assistance.");

   ActionCloseDoor(OBJECT_SELF);

 }

 else

 {

  AssignCommand(oTarget,ActionJumpToLocation(GetLocation(GetWaypointByTag("wp_start"))));

  ActionCloseDoor(OBJECT_SELF);

 }

*/

//Example of how to use this as a conversation script teleport players to areas specific to race/sub-race

/*

 oTarget = GetPCSpeaker();

 if (subrace() == 0)

 {

   SendMessageToPC(oTarget,"You have not created your character properly. Please contact a DM for assistance.");

 }

 else

 {

  if (sSubrace == "Wood Elf")

  {

   AssignCommand(oTarget,ActionJumpToLocation(GetLocation(GetWaypointByTag("wp_woodelf"))));

  }

 }

// Example of how to use this with triggers to teleport players to areas specific to race/sub-race

/*

 if (subrace() == 0)

 {

   SendMessageToPC(oTarget,"You have not created your character properly. Please contact a DM for assistance.");

 }

 else

 {

  if (sSubrace == "Wood Elf")

  {

   AssignCommand(oTarget,ActionJumpToLocation(GetLocation(GetWaypointByTag("wp_woodelf"))));

  }

 }

*/

//Example of how to use this with doors to teleport players to areas specific to race/sub-race

/*

 oTarget = GetLastOpenedBy();

 if (subrace() == 0)

 {

   SendMessageToPC(oTarget,"You have not created your character properly. Please contact a DM for assistance.");

   ActionCloseDoor(OBJECT_SELF);

 }

 else

 {

  if (sSubrace == "Wood Elf")

  {

   AssignCommand(oTarget,ActionJumpToLocation(GetLocation(GetWaypointByTag("wp_woodelf"))));

   ActionCloseDoor(OBJECT_SELF);

  }

 }

*/

}



That should get you going with sub-races. I could go on and add in the WotC rules for how to balance the sub-races and all that good stuff; however, I really don't feel like typing it all up and violating copyright. I suggest you go out and buy the Dungeon Master's Guide, or just playtest alot, your call.

As always if you have any questions send them my way.

-J