Aller au contenu

Photo

Starting player gold?


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
Hi guys. Can somebody tell me how you set the gold the player gets when starting a new game in your module? I guess it's necessarily going to be a level 1 character. What about starting equipment? Thanks!

#2
kevL

kevL
  • Members
  • 4 056 messages
how's yer scripting-fu


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
Claudius33

Claudius33
  • Members
  • 256 messages

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
Groove Widdit

Groove Widdit
  • Members
  • 378 messages

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
Tchos

Tchos
  • Members
  • 5 042 messages

Silly question: Did you enclose that code within the braces of the following?:

void main()
{
   //code goes here
}


#6
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
Oh sorry. That was stupid of me. Okay, now it's saying: "UNKNOWN STATE IN COMPILER" in the GiveGoldToCreature(oPC, 150) line.

#7
kevL

kevL
  • Members
  • 4 056 messages
it could be that period at the end of the line

if not, post script ...

#8
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
Yeah that was it. Sorry, I'm screwing up a lot today. Happening at work, too. It worked!

#9
kevL

kevL
  • Members
  • 4 056 messages
[examples] from Claudius' script

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 hat
object 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
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
Sweet! I bookmarked both of them.

#11
bealzebub

bealzebub
  • Members
  • 352 messages

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
kamal_

kamal_
  • Members
  • 5 240 messages

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.