ff_u_pc_lvl1_pkg
On first login, replace the inventory based on class and feats.
The first time a PC enters the module, its inventory and its chest and hand items are destroyed, and replaced by a starting package:
Armor: leather armor if the PC has an armor proficiency feat, otherwise clothes chosen by its first class (monk, sorcerer, wizard, or any other).
A light shield, if the PC has the shield proficiency feat.
One weapon for each Weapon Focus feat of the PC, and one weapon for its best weapon proficiency feat (martial: longsword, simple: dagger, rogue: short sword, monk, wizard or druid: quarterstaff).
A club, a torch, 3 potions of Cure Light Wounds and 50 gold.
All items are identified, and the armor, shield and last weapon given are equipped. Item received and lost feedback messages are hidden meanwhile.
Created items are subject to the UTI resource overrides
(eos_uti_ovr.2da and user_uti_ovr.2da).
The best armor given is Leather armor, whatever the armor proficiency;
this is currently hardcoded.
Variables
ENABLE__FF_U_PC_LVL1_PKG: (string) (opt-in) Set to "Y" on module to enable the unit.
Source code
// @code
#include "ff_i_core"
const string ENABLE__FF_U_PC_LVL1_PKG = "ENABLE__FF_U_PC_LVL1_PKG";
const string FF_U_PC_LVL1_PKG = "FF_U_PC_LVL1_PKG";
// -----------------------------------------------------------------------------
//! @brief Show the item received and lost feedback messages to oPC again.
//! @param oPC A player character.
void RestoreMessages(object oPC);
void RestoreMessages(object oPC)
{
NWNX_Feedback_SetFeedbackMessageHidden(NWNX_FEEDBACK_ITEM_RECEIVED, FALSE, oPC);
NWNX_Feedback_SetFeedbackMessageHidden(NWNX_FEEDBACK_ITEM_LOST, FALSE, oPC);
}
// -----------------------------------------------------------------------------
//! @brief Identify and equip the starting armor, weapon and shield of oPC.
//! @param oPC A player character.
//! @param oArmor Armor or clothes, or OBJECT_INVALID.
//! @param oWeapon Weapon for the right hand, or OBJECT_INVALID.
//! @param oShield Shield for the left hand, or OBJECT_INVALID.
void Equip(object oPC, object oArmor, object oWeapon, object oShield)
{
SetIdentified(oArmor, TRUE);
SetIdentified(oShield, TRUE);
SetIdentified(oWeapon, TRUE);
if (GetIsObjectValid(oArmor))
NWNX_Creature_RunEquip(oPC, oArmor, INVENTORY_SLOT_CHEST);
if (GetIsObjectValid(oWeapon))
NWNX_Creature_RunEquip(oPC, oWeapon, INVENTORY_SLOT_RIGHTHAND);
if (GetIsObjectValid(oShield))
NWNX_Creature_RunEquip(oPC, oShield, INVENTORY_SLOT_LEFTHAND);
}
// -----------------------------------------------------------------------------
//! @brief Give the starting package to oPC, if not given yet.
//! @param oPC The entering object.
void OnClientEnter(object oPC)
{
oPC = GetPC(oPC);
if (!GetIsPC(oPC))
return;
if (NWNX_Object_GetInt(oPC, FF_U_PC_LVL1_PKG))
return;
NWNX_Object_SetInt(oPC, FF_U_PC_LVL1_PKG, 1, TRUE);
NWNX_Feedback_SetFeedbackMessageHidden(NWNX_FEEDBACK_ITEM_RECEIVED, TRUE, oPC);
NWNX_Feedback_SetFeedbackMessageHidden(NWNX_FEEDBACK_ITEM_LOST, TRUE, oPC);
DestroyInventory(oPC);
DestroyObject(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC));
DestroyObject(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC));
DestroyObject(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC));
// Armor
object oArmor;
int nClass = GetClassByPosition(1, oPC);
if (FALSE)
{}
else if (GetHasFeat(FEAT_ARMOR_PROFICIENCY_HEAVY, oPC, TRUE))
oArmor = CreateItemOnObject("nw_aarcl001", oPC); // Leather armor, AC 2
else if (GetHasFeat(FEAT_ARMOR_PROFICIENCY_MEDIUM, oPC, TRUE))
oArmor = CreateItemOnObject("nw_aarcl001", oPC); // Leather armor, AC 2
else if (GetHasFeat(FEAT_ARMOR_PROFICIENCY_LIGHT, oPC, TRUE))
oArmor = CreateItemOnObject("nw_aarcl001", oPC); // Leather armor, AC 2
else if (nClass == CLASS_TYPE_MONK)
oArmor = CreateItemOnObject("nw_cloth016", oPC);
else if (nClass == CLASS_TYPE_SORCERER)
oArmor = CreateItemOnObject("nw_cloth008", oPC);
else if (nClass == CLASS_TYPE_WIZARD)
oArmor = CreateItemOnObject("nw_cloth005", oPC);
else
oArmor = CreateItemOnObject("nw_cloth022", oPC);
// Shield
object oShield = OBJECT_INVALID;
if (GetHasFeat(FEAT_SHIELD_PROFICIENCY, oPC, TRUE))
oShield = CreateItemOnObject("nw_ashsw001", oPC); // light shield
// Create as many weapons as the number of FEATS.
// Weapon
object oWeapon = OBJECT_INVALID;
if (GetHasFeat(FEAT_WEAPON_FOCUS_BASTARD_SWORD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswbs001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_BATTLE_AXE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_waxbt001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_CLUB, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblcl001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_DAGGER, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswdg001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_DART, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wthdt001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_DIRE_MACE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbma001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_DOUBLE_AXE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbax001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_DWAXE, oPC, TRUE)) { oWeapon = CreateItemOnObject("x2_wdwraxe001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_GREAT_AXE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_waxgr001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_GREAT_SWORD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswgs001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_HALBERD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wplhb001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_HAND_AXE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_waxhn001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_HEAVY_CROSSBOW, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wbwxh001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_HEAVY_FLAIL, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblfh001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_KAMA, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wspka001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_KATANA, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswka001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_KUKRI, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wspku001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_LIGHT_CROSSBOW, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wbwxl001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_LIGHT_FLAIL, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblfl001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_LIGHT_HAMMER, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblhl001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_LIGHT_MACE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblml001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_LONG_SWORD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswls001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_LONGBOW, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wbwln001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_MORNING_STAR, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblms001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_RAPIER, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswrp001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SCIMITAR, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswsc001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SCYTHE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wplsc001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SHORT_SWORD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswss001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SHORTBOW, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wbwsh001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SHURIKEN, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wthsh001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SICKLE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wspsc001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SLING, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wbwsl001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_SPEAR, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wplss001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_STAFF, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbqs001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_THROWING_AXE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wthax001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_TRIDENT, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wpltr001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_TWO_BLADED_SWORD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbsw001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_WAR_HAMMER, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wblhw001", oPC); } //
if (GetHasFeat(FEAT_WEAPON_FOCUS_WHIP, oPC, TRUE)) { oWeapon = CreateItemOnObject("x2_it_wpwhip", oPC); } //
// ---
if (FALSE) {}
else if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_MARTIAL, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswls001", oPC); } // longsword
else if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_SIMPLE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswdg001", oPC); } // dagger
else if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_MONK, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbqs001", oPC); } // quarterstaff
else if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_ROGUE, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wswss001", oPC); } // shortsword
else if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_WIZARD, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbqs001", oPC); } // quarterstaff
else if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_DRUID, oPC, TRUE)) { oWeapon = CreateItemOnObject("nw_wdbqs001", oPC); } // quarterstaff
// Give everyone a club: it is simple (all classes) and small (all races).
CreateItemOnObject("nw_wblcl001", oPC);
// Equip armor, weapon and shield.
DelayCommand(0.2f, Equip(oPC, oArmor, oWeapon, oShield));
// Torch
CreateItemOnObject("nw_it_torch001", oPC);
// 3 potions of Cure Light Wounds
CreateItemOnObject("nw_it_mpotion001", oPC, 3);
GiveGoldToCreature(oPC, 50);
// Identify all items
object oItem = GetFirstItemInInventory(oPC);
while (oItem != OBJECT_INVALID)
{
SetIdentified(oItem, TRUE);
oItem = GetNextItemInInventory(oPC);
}
LogNotice(__FILE__ + ": " + GetPCInfo(oPC) + " has received the default package");
DelayCommand(0.1f, RestoreMessages(oPC));
}
// =============================================================================
void main()
{
string sEvent = NWNX_Events_GetCurrentEvent();
if (sEvent == ON_REGISTER)
{
if (!GetModuleFlag(ENABLE__FF_U_PC_LVL1_PKG, FALSE))
return;
SubscribeToEvent(ON_DEFAULT_CLIENT_ENTER, __FILE__);
}
else if (sEvent == ON_DEFAULT_CLIENT_ENTER)
DelayCommand(0.0f, OnClientEnter(GetEnteringObject()));
}