Difference between revisions of "Compatible Companion Mod Creation/Joining The Party"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (Created)
 
m (The joining script: indented main)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The '''Joining The Party''' step describes how to handle add your custom companion to the party.
+
The '''Joining The Party''' step describes how to handle adding your custom companion to the party.
  
 
In this step Valeria is allowed to have a class chosen the first time you meet her. So create in VALERIA_NPC_HIRE the flags ISMAGE, ISROGUE, ISWARRIOR and ISROGUEWARRIOR, if you want to do that, otherwise delete all the references to those flags. One of these is set to TRUE through dialog with Valeria. At the end of the dialog this script is called.
 
In this step Valeria is allowed to have a class chosen the first time you meet her. So create in VALERIA_NPC_HIRE the flags ISMAGE, ISROGUE, ISWARRIOR and ISROGUEWARRIOR, if you want to do that, otherwise delete all the references to those flags. One of these is set to TRUE through dialog with Valeria. At the end of the dialog this script is called.
Line 8: Line 8:
 
This script contains EVERYTHING you need to properly hire a follower without leveling him/her automatically.
 
This script contains EVERYTHING you need to properly hire a follower without leveling him/her automatically.
  
Valeria in my mod is allowed to choose her class to Warrior, Rogue, Mage or Rogue-Warrior.
+
Valeria in my mod is allowed to choose her class to Warrior, Rogue, Mage or Multiclass (here I show you only the case Rogue-Warrior).
  
 
<dascript>
 
<dascript>
Line 21: Line 21:
 
void main()
 
void main()
 
{
 
{
 +
    object oPC=GetHero();
 +
    object me=OBJECT_SELF;
  
object oPC=GetHero(), me=OBJECT_SELF;
+
    WR_SetPlotFlag(PLT_VALERIA_NPC_HIRE, PARTY_VALERIA_JOINED, TRUE);
WR_SetPlotFlag(PLT_VALERIA_NPC_HIRE, PARTY_VALERIA_JOINED, TRUE);
+
   
 +
    basic_blank_char(me);
 +
    //select race, otherwise skills tree wont show
 +
   
 +
    Chargen_SelectRace(me,RACE_HUMAN);
 +
    int nClass;
 +
    //remove the rogue defaults, valeria's char is rogue when created
 +
   
 +
    CharGen_ClearAbilityList(me,1);//remove talents
 +
    //CharGen_ClearAbilityList(me,2);//remove spells
 +
    //CharGen_ClearAbilityList(me,3);//remove skills
 +
   
 +
    RemoveAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
 +
    RemoveAbility(me, ABILITY_SKILL_POISON_1);
 +
    //depending on which flags you set in the dialog that lead to this script, choose the appropriate class
 +
   
 +
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISMAGE)==TRUE)
 +
    {
 +
        nClass=CLASS_WIZARD;
 +
        _AddAbility(me, ABILITY_SPELL_ARCANE_BOLT);
 +
    }
 +
   
 +
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUE)==TRUE)
 +
    {
 +
        nClass=CLASS_ROGUE;
 +
        _AddAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
 +
        _AddAbility(me, ABILITY_SKILL_POISON_1);
 +
    }
 +
   
 +
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISWARRIOR)==TRUE)
 +
    {
 +
        nClass=CLASS_WARRIOR;
 +
        _AddAbility(me, ABILITY_TALENT_POWERFUL);
 +
    }
 +
   
 +
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUEWARRIOR)==TRUE)
 +
    {nClass=CLASS_ROGUE;}
 +
   
 +
    //apply attributes, abilities and stats for the core class
 +
    //SetCreatureProperty(me,PROPERTY_SIMPLE_CURRENT_CLASS, n1-3.0,PROPERTY_VALUE_BASE);
 +
   
 +
    Chargen_SelectCoreClass(me,nClass);
  
basic_blank_char(me);
+
    //add mage spells
//select race, otherwise skills tree wont show
+
    //_AddAbility(me, ABILITY_TALENT_HIDDEN_ASSASSIN);//this works if it's available on the core class
 +
   
 +
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUEWARRIOR)==TRUE)
 +
    {
 +
        _AddAbility(me, ABILITY_TALENT_HIDDEN_WARRIOR);
 +
        _AddAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
 +
        _AddAbility(me, ABILITY_SKILL_POISON_1);
 +
    }
  
Chargen_SelectRace(me,RACE_HUMAN);
+
    //tactics
int nClass;
+
   
//remove the rogue defaults, valeria's char is rogue when created
+
    Chargen_SetNumTactics(me);
 +
    Chargen_EnableTacticsPresets(me);
 +
 +
    //level needed for scaling
 +
   
 +
    int nPackage = GetPackage(me);
 +
    int nTargetLevel;
 +
   
 +
    int nPlayerLevel = GetLevel(oPC);
 +
    if(nPlayerLevel >= 13 || nPlayerLevel == 1 )
 +
      nTargetLevel = nPlayerLevel;
 +
    else
 +
      nTargetLevel = nPlayerLevel + 1;
  
CharGen_ClearAbilityList(me,1);//remove talents
+
     int nMinLevel = GetM2DAInt(TABLE_PACKAGES, "MinLevel", nPackage);
//CharGen_ClearAbilityList(me,2);//remove spells
+
   
//CharGen_ClearAbilityList(me,3);//remove skills
+
    if(nMinLevel > 0 && nMinLevel > nTargetLevel)
 
+
      nTargetLevel = nMinLevel;
RemoveAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
+
   
RemoveAbility(me, ABILITY_SKILL_POISON_1);
+
    //xp until hero level
//depending on which flags you set in the dialog that lead to this script, choose the appropriate class
+
   
 
+
    int nXp = RW_GetXPNeededForLevel(Max(nTargetLevel, 1));
if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISMAGE)==TRUE)
+
    RewardXP(me, nXp, TRUE, FALSE);
{
+
   
     nClass=CLASS_WIZARD;
+
    //add specialization
    _AddAbility(me, ABILITY_SPELL_ARCANE_BOLT);
+
   
}
+
    float count=1.0;
 
+
    if(GetLevel(GetHero())>=7)
if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUE)==TRUE)
+
    {
{
+
        SetCreatureProperty(me, 38, count);  // 38 is the spec point ID
    nClass=CLASS_ROGUE;
+
        count=count+1.;
    _AddAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
+
    }
    _AddAbility(me, ABILITY_SKILL_POISON_1);
+
    if(GetLevel(GetHero())>=14)
}
+
        SetCreatureProperty(me, 38, count);  // 38 is the spec point ID
 
+
   
if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISWARRIOR)==TRUE)
+
    //make available in party picker
{
+
   
    nClass=CLASS_WARRIOR;
+
    SetFollowerState(me, FOLLOWER_STATE_ACTIVE);
    _AddAbility(me, ABILITY_TALENT_POWERFUL);
+
    SetFollowerState(me, FOLLOWER_STATE_AVAILABLE);
}
+
   
 
+
    //dont fire player_core scaling
if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUEWARRIOR)==TRUE)
+
   
{nClass=CLASS_ROGUE;}
+
    SetLocalInt(me, FOLLOWER_SCALED, 1);
 
+
    SetLocalInt(me, AI_FLAG_STATIONARY, 0);
//apply attributes, abilities and stats for the core class
+
    SetLocalInt(me, AMBIENT_SYSTEM_STATE, 0);
//SetCreatureProperty(me,PROPERTY_SIMPLE_CURRENT_CLASS, n1-3.0,PROPERTY_VALUE_BASE);
+
    SetLocalInt(me, CREATURE_REWARD_FLAGS, 0);
 
+
   
Chargen_SelectCoreClass(me,nClass);
+
    //change script to player and send hire event
//add mage spells
+
   
//_AddAbility(me, ABILITY_TALENT_HIDDEN_ASSASSIN);//this works if it's available on the core class
+
    SetEventScript(me, RESOURCE_SCRIPT_PLAYER_CORE);
 
+
    InitHeartbeat(me, CONFIG_CONSTANT_HEARTBEAT_RATE);
if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUEWARRIOR)==TRUE)
+
    SendPartyMemberHiredEvent(me, FALSE);
{
+
    SetFollowerApprovalEnabled(me,TRUE);
    _AddAbility(me, ABILITY_TALENT_HIDDEN_WARRIOR);
+
   
    _AddAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
+
    //open up party picker to allow Valeria to join in the active party
    _AddAbility(me, ABILITY_SKILL_POISON_1);
+
    SetPartyPickerGUIStatus(2);
}
+
    ShowPartyPickerGUI();   
//tactics
+
 
+
Chargen_SetNumTactics(me);
+
Chargen_EnableTacticsPresets(me);
+
//SetFollowPartyLeader(me, TRUE);
+
//level needed for scaling
+
 
+
int nPackage = GetPackage(me);
+
int nTargetLevel;
+
 
+
int nPlayerLevel = GetLevel(oPC);
+
if(nPlayerLevel >= 13 || nPlayerLevel == 1 )
+
  nTargetLevel = nPlayerLevel;
+
else
+
  nTargetLevel = nPlayerLevel + 1;
+
int nMinLevel = GetM2DAInt(TABLE_PACKAGES, "MinLevel", nPackage);
+
 
+
if(nMinLevel > 0 && nMinLevel > nTargetLevel)
+
  nTargetLevel = nMinLevel;
+
 
+
//xp until hero level
+
 
+
int nXp = RW_GetXPNeededForLevel(Max(nTargetLevel, 1));
+
RewardXP(me, nXp, TRUE, FALSE);
+
 
+
//add specialization
+
 
+
float count=1.;
+
if(GetLevel(GetHero())>=7)
+
{
+
    SetCreatureProperty(me, 38, count);  // 38 is the spec point ID
+
    count=count+1.;
+
}
+
if(GetLevel(GetHero())>=14)
+
    SetCreatureProperty(me, 38, count);  // 38 is the spec point ID
+
 
+
//make available in party picker
+
 
+
SetFollowerState(me, FOLLOWER_STATE_ACTIVE);
+
SetFollowerState(me, FOLLOWER_STATE_AVAILABLE);
+
 
+
//dont fire player_core scaling
+
 
+
SetLocalInt(me, FOLLOWER_SCALED, 1);
+
SetLocalInt(me, AI_FLAG_STATIONARY, 0);
+
SetLocalInt(me, AMBIENT_SYSTEM_STATE, 0);
+
SetLocalInt(me, CREATURE_REWARD_FLAGS, 0);
+
 
+
//change script to player and send hire event
+
 
+
SetEventScript(me, RESOURCE_SCRIPT_PLAYER_CORE);
+
InitHeartbeat(me, CONFIG_CONSTANT_HEARTBEAT_RATE);
+
SendPartyMemberHiredEvent(me, FALSE);
+
SetFollowerApprovalEnabled(me,TRUE);
+
 
+
//open up party picker
+
 
+
SetPartyPickerGUIStatus(2);
+
ShowPartyPickerGUI();  //to allow Valeria to join in the active party
+
 
}
 
}
  
Line 170: Line 173:
 
</dascript>
 
</dascript>
  
{{TutorialNavBar|The Fade|Handling Gifts}}
+
{{TutorialNavBar|The Fade|Gifts And Approval}}

Latest revision as of 13:35, 11 July 2011

The Joining The Party step describes how to handle adding your custom companion to the party.

In this step Valeria is allowed to have a class chosen the first time you meet her. So create in VALERIA_NPC_HIRE the flags ISMAGE, ISROGUE, ISWARRIOR and ISROGUEWARRIOR, if you want to do that, otherwise delete all the references to those flags. One of these is set to TRUE through dialog with Valeria. At the end of the dialog this script is called.

The joining script

Create the following script. I call it valeria_valjoin.nss This script contains EVERYTHING you need to properly hire a follower without leveling him/her automatically.

Valeria in my mod is allowed to choose her class to Warrior, Rogue, Mage or Multiclass (here I show you only the case Rogue-Warrior).

#include "sys_chargen_h"
#include "sys_rewards_h"
 
#include "plt_valeria_npc_hire"
 
//this function resets an NPC
void basic_blank_char(object oChar);
 
void main()
{
    object oPC=GetHero();
    object me=OBJECT_SELF;
 
    WR_SetPlotFlag(PLT_VALERIA_NPC_HIRE, PARTY_VALERIA_JOINED, TRUE);
 
    basic_blank_char(me);
    //select race, otherwise skills tree wont show
 
    Chargen_SelectRace(me,RACE_HUMAN);
    int nClass;
    //remove the rogue defaults, valeria's char is rogue when created
 
    CharGen_ClearAbilityList(me,1);//remove talents
    //CharGen_ClearAbilityList(me,2);//remove spells
    //CharGen_ClearAbilityList(me,3);//remove skills
 
    RemoveAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
    RemoveAbility(me, ABILITY_SKILL_POISON_1);
    //depending on which flags you set in the dialog that lead to this script, choose the appropriate class
 
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISMAGE)==TRUE)
    {
        nClass=CLASS_WIZARD;
        _AddAbility(me, ABILITY_SPELL_ARCANE_BOLT);
    }
 
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUE)==TRUE)
    {
        nClass=CLASS_ROGUE;
        _AddAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
        _AddAbility(me, ABILITY_SKILL_POISON_1);
    }
 
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISWARRIOR)==TRUE)
    {
        nClass=CLASS_WARRIOR;
        _AddAbility(me, ABILITY_TALENT_POWERFUL);
    }
 
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUEWARRIOR)==TRUE)
    {nClass=CLASS_ROGUE;}
 
    //apply attributes, abilities and stats for the core class
    //SetCreatureProperty(me,PROPERTY_SIMPLE_CURRENT_CLASS, n1-3.0,PROPERTY_VALUE_BASE);
 
    Chargen_SelectCoreClass(me,nClass);
 
    //add mage spells
    //_AddAbility(me, ABILITY_TALENT_HIDDEN_ASSASSIN);//this works if it's available on the core class
 
    if(WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE,ISROGUEWARRIOR)==TRUE)
    {
        _AddAbility(me, ABILITY_TALENT_HIDDEN_WARRIOR);
        _AddAbility(me, ABILITY_TALENT_DIRTY_FIGHTING);
        _AddAbility(me, ABILITY_SKILL_POISON_1);
    }
 
    //tactics
 
    Chargen_SetNumTactics(me);
    Chargen_EnableTacticsPresets(me);
 
    //level needed for scaling
 
    int nPackage = GetPackage(me);
    int nTargetLevel;
 
    int nPlayerLevel = GetLevel(oPC);
    if(nPlayerLevel >= 13 || nPlayerLevel == 1 )
       nTargetLevel = nPlayerLevel;
    else
       nTargetLevel = nPlayerLevel + 1;
 
    int nMinLevel = GetM2DAInt(TABLE_PACKAGES, "MinLevel", nPackage);
 
    if(nMinLevel > 0 && nMinLevel > nTargetLevel)
       nTargetLevel = nMinLevel;
 
    //xp until hero level
 
    int nXp = RW_GetXPNeededForLevel(Max(nTargetLevel, 1));
    RewardXP(me, nXp, TRUE, FALSE);
 
    //add specialization
 
    float count=1.0;
    if(GetLevel(GetHero())>=7)
    {
        SetCreatureProperty(me, 38, count);  // 38 is the spec point ID
        count=count+1.;
    }
    if(GetLevel(GetHero())>=14)
        SetCreatureProperty(me, 38, count);  // 38 is the spec point ID
 
    //make available in party picker
 
    SetFollowerState(me, FOLLOWER_STATE_ACTIVE);
    SetFollowerState(me, FOLLOWER_STATE_AVAILABLE);
 
    //dont fire player_core scaling
 
    SetLocalInt(me, FOLLOWER_SCALED, 1);
    SetLocalInt(me, AI_FLAG_STATIONARY, 0);
    SetLocalInt(me, AMBIENT_SYSTEM_STATE, 0);
    SetLocalInt(me, CREATURE_REWARD_FLAGS, 0);
 
    //change script to player and send hire event
 
    SetEventScript(me, RESOURCE_SCRIPT_PLAYER_CORE);
    InitHeartbeat(me, CONFIG_CONSTANT_HEARTBEAT_RATE);
    SendPartyMemberHiredEvent(me, FALSE);
    SetFollowerApprovalEnabled(me,TRUE);
 
    //open up party picker to allow Valeria to join in the active party
    SetPartyPickerGUIStatus(2);
    ShowPartyPickerGUI();  
}
 
 
void basic_blank_char(object oChar)
{
// Initialize all creature properties to default value
 
    SetCreatureProperty(oChar,PROPERTY_SIMPLE_LEVEL,1.0f,PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_SIMPLE_EXPERIENCE,0.0f,PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_STRENGTH,      CHARGEN_BASE_ATTRIBUTE_VALUE, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_DEXTERITY,     CHARGEN_BASE_ATTRIBUTE_VALUE, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_CONSTITUTION,  CHARGEN_BASE_ATTRIBUTE_VALUE, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_WILLPOWER,     CHARGEN_BASE_ATTRIBUTE_VALUE, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_INTELLIGENCE,  CHARGEN_BASE_ATTRIBUTE_VALUE, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_MAGIC,         CHARGEN_BASE_ATTRIBUTE_VALUE, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_ATTACK_SPEED_MODIFIER,     1.0f);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_DAMAGE_SCALE,       1.0f);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_RESISTANCE_MENTAL,         0.0f);
    SetCreatureProperty(oChar,PROPERTY_ATTRIBUTE_RESISTANCE_PHYSICAL,       0.0f);
    SetCreatureProperty(oChar,51,       1.0f);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_REGENERATION_HEALTH_COMBAT,  REGENERATION_HEALTH_COMBAT_DEFAULT);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_REGENERATION_STAMINA_COMBAT, REGENERATION_STAMINA_COMBAT_DEFAULT);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_REGENERATION_HEALTH,REGENERATION_HEALTH_EXPLORE_DEFAULT, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_REGENERATION_STAMINA, REGENERATION_STAMINA_EXPLORE_DEFAULT, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_MISSILE_SHIELD,0.0);
    SetCreatureProperty(oChar, 38,0.0);
    SetCreatureProperty(oChar, PROPERTY_DEPLETABLE_HEALTH ,          1.0f, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_DEPLETABLE_MANA_STAMINA ,    0.0f, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_DEFENSE ,          0.0f, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_ATTACK,            0.0f, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_DAMAGE_BONUS,      0.0f, PROPERTY_VALUE_BASE);
    SetCreatureProperty(oChar, PROPERTY_ATTRIBUTE_FLANKING_ANGLE,  60.0f, PROPERTY_VALUE_BASE);
 
}
The Fade Compatible Companion Mod Creation Gifts And Approval