Starting player gold?
#1
Posté 31 juillet 2015 - 08:04
#2
Posté 31 juillet 2015 - 09:40
you'll want to code into your module's onClientEnter event script.
have a section that runs only once. works like this
object oPC = GetEnteringObject();
if (GetLocalInt(oPC, "I_Have_Started") == FALSE)
{
SetLocalInt(oPC, "I_Have_Started", TRUE);
// do code to give gold, grant starting items, etc etc, here.
}(hopefully someone else has a bit of copy-paste code for gold & equip't -- or you can figure it out or i'll throw in a bit more tomorrow )
#3
Posté 31 juillet 2015 - 09:47
Hello,
Below Sarmates! initialization script as a sample. It is attached to the very first area OnClientEnter.
The first time it removes everything from the PC's inventory (including carried objects such as necklaces), gives an appropriate suit to the PC, gold and med kits, regardless of the PC level.
The function used to give gold is GiveGoldToCreature.
// Init Sarmates, first time : set party limit remove inventory, give "sarmatian" clothes and med kits, launch convo with Hamytz
const string MED_KIT = "nw_it_medkit001";
#include "ginc_misc"
void main()
{
object oPC = GetFirstPC();
if (GetJournalEntry("q_packhorse", oPC) > 10) // spawn the horse if already a companion
SpawnRosterMember("packhorse", GetLocation(GetWaypointByTag("WPS_packhorse_tisza")));
SetGlobalString("LastModule", "Tisza");
if (IsMarkedAsDone()) return;
SetRosterNPCPartyLimit(5); // campaign initialization
int nSlot; // remove inventory
for (nSlot = 0; nSlot < NUM_INVENTORY_SLOTS; nSlot++) DestroyObject(GetItemInSlot(nSlot, oPC));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem);
oItem = GetNextItemInInventory(oPC);
}
string sItem = (GetGender(oPC)==GENDER_MALE) ? "sm_suit_m" : "sm_suit_af";
if (GetGender(oPC)==GENDER_FEMALE)
if ((GetRacialType(oPC)==RACIAL_TYPE_HUMAN) || (GetSubRace(oPC)==RACIAL_SUBTYPE_AASIMAR)) sItem="sm_suit_f";
oItem = CreateItemOnObject(sItem, oPC);
AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_CHEST));
CreateItemOnObject(MED_KIT, oPC, 2);
oItem = CreateItemOnObject("sm_hat", oPC, 1);
GiveGoldToCreature(oPC, 40000);
SetLocalInt(oPC, "GOOD", 0); // set variables attached to the PC
SetLocalInt(oPC, "EVIL", 0);
SetLocalInt(oPC, "LAWFUL", 0);
SetLocalInt(oPC, "CHAOTIC", 0);
object oHamytz = GetObjectByTag("hamytz");
DelayCommand(0.2f, AssignCommand(oPC, ActionStartConversation(oHamytz, "cv_hamytz")));
MarkAsDone();
}
#4
Posté 31 juillet 2015 - 06:57
It is giving me "INVALID DECLARATION TYPE" on line 2 of the below:
object oPC = GetEnteringObject();
if (GetLocalInt(oPC, "I_Have_Started") == FALSE)
{
SetLocalInt(oPC, "I_Have_Started", TRUE);
GiveGoldToCreature(oPC, 150);.
}
#5
Posté 31 juillet 2015 - 07:46
Silly question: Did you enclose that code within the braces of the following?:
void main()
{
//code goes here
}
#6
Posté 31 juillet 2015 - 11:46
#7
Posté 31 juillet 2015 - 11:55
if not, post script ...
#8
Posté 01 août 2015 - 12:26
#9
Posté 01 août 2015 - 01:00
to make sure PC doesn't bring in anything:
int nSlot; // remove inventory
for (nSlot = 0; nSlot < NUM_INVENTORY_SLOTS; nSlot++) DestroyObject(GetItemInSlot(nSlot, oPC));
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem);
oItem = GetNextItemInInventory(oPC);
}to give PC two medikits:CreateItemOnObject("nw_it_medkit001", oPC, 2);to make PC equip a hatobject oItem = CreateItemOnObject("n2_helm_wizhat", oPC, 1);
SetIdentified(oItem, TRUE); // magic item might not equip unless identified.
AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD));for dealing with compiler errors (with the stock compiler)and ... the Lexicon Lyceum (because nothing goes as planned..)
#10
Posté 01 août 2015 - 06:54
#11
Posté 02 août 2015 - 12:40
charlies-scripter-starter-kit has an OnClientEnter script called starter_pc_first_time - It sets the starting gold and xp for PCs.
Also, I have an OnOpen script I got from somewhere called starter_chest. It fills the chest with appropriate equipment according to the PCs class, feats, etc. I can post it if you want.
#12
Posté 02 août 2015 - 01:27
The Forgotten Realms Weave starter module was made specifically for allowing characters to level, get gold, and equip appropriately outside of target modules, iirc it assigns gold and such specifically based on sourcebook rules. You could look at it.





Retour en haut







