Aller au contenu

Photo

Starting Level and/or XP


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

#1
Pompeii69

Pompeii69
  • Members
  • 153 messages
I've tried searching for this, here as well as at nwvault site, and I cannot seem to find anything.

When my module starts, I'd like to give the PC either XP points, or more preferably level them up to a speciic level, as well as have starting a few inventory items.

In the area properties, under On PC Load, I tried setting it to ga_give_xp, but this script function takes 2 parameters.  How do I set what those parameters should be>  Where is it called from?

SOrry if this is rather basic...

#2
The Fred

The Fred
  • Members
  • 2 516 messages
Simply use the SetCreatureXP(); function in a custom script. You will want to make sure, though, that this doesn't trigger indiscriminantly, since otherwise your players will be set back to their start XP whenever they load. You could try something like this:

object oPC = GetEnteringObject();
if(GetCurrentXP(oPC) < XXXX)
{
    SetCurrentXP(oPC, XXXX);
}

Modifié par The Fred, 19 juin 2011 - 11:16 .


#3
Pompeii69

Pompeii69
  • Members
  • 153 messages
I realize I probably have not even scratched the surface of what I need to know about this toolset, but I am familiar with programming, using Visual Studio 2010 for C# development.  And in the properties editor, when I wish to assign some code to an event it's usually pretty straight forward.

However, in this On PC Load event, I am given a drop down of avalable functions calls.  I am assuming I should be able to pick one, and it will run that actual function, right?  So if I select ga_give_xp, is this the function that runs when this event fires?  If so, how do those parameters get populated?  If not, what is the point of providing those functions to be called?

I guess I need to find more info to read...

#4
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
ga_* and gc_* type scripts only work when fired from a conversation. You will need to write a custom script and place it in the OnClientEnter of the module properties (that's probably better than OnPCLoad).

If you have experience in script like you say then you should be ok. You can check out the tutorial linked in my signature below to get some basic scripting instructions. Its written for somebody who knows nothing about NWN scripting, but might serve to point you in the right direction as far as how things are set up script-wise.

#5
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
Scripts which start with ga_ are to be called from conversations. Those parameters are filled in via the conversation editor in some capacity.

I wish I could think of a good tutorial to direct you towards. Since you're already familiar with scripting, it sort of becomes difficult to explain the subtleties of the NWN2 interface. That said, these two seem rather helpful:

http://nwvault.ign.c...s.Detail&id=124
http://nwvault.ign.c...s.Detail&id=120

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
A common technique for levelling and equipping at the beginning of a module is to do so through a conversation. That provides events to run scripts and also allows you to provide options about levelling up as well as a chance to introduce the player to your module.

Check out Moonshadows. There is a good example of this in the beginning.

#7
MasterChanger

MasterChanger
  • Members
  • 686 messages
There isn't a way to pass parameters into a script from an event handler (those On__ slots). However, you can set variables on the object (module, area, creature, placeable, etc). If you write your own script, you can instruct it to retrieve these variables and use them for your computations.

#8
The Fred

The Fred
  • Members
  • 2 516 messages
Yes, the dropdown you get allows you to select a script. If you create your own, you can select it there (or just type its name directly in).

For someone with any kind of coding experience (particularly of a C-based language), writing a script like this should not be too hard. The syntax is like this:
void main()
{
    //Your code here.
}

As KM says, check out his tutorial.

#9
Pompeii69

Pompeii69
  • Members
  • 153 messages
Writing the script wasn't so much an issue, as it was in explaining the purpose of having all those available functions directly in the properties box, regardless if they could be directly called or not.  I had assumed that since I could select the ga_give_xp function, that it would be used.  So for my own knowledge now, I know to always write a script and forget those available functions in that drop down, that they are not (or should not be) directly callable from there.

#10
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Pompeii69, also for your own knowledge, those ga_* scripts are not functions, they are full scripts that are pre-written by the game designers. Their purpose is to allow somebody who does not know how to do their own scripts to use them when needed. For the most part they are fairly simple scripts and only useable when fired from a conversation (due to the way they are written).

If you open the script editor in the toolset and choose the "Script Assist" button near the top left, a new window will open on the right that does list the useable functions. Note that not every single function is listed there, some are hidden (but useable) in other include files.

Modifié par _Knightmare_, 20 juin 2011 - 02:45 .


#11
The Fred

The Fred
  • Members
  • 2 516 messages
KM hit it right on the spot. If you go to File -> Open Converstation/Script you can view all those pre-existing scripts - helpful if you need a script which already exists, or for learning how to script.

Those ga_* scripts specifically are by and large designed for conversation, and conversation scripts can take parameters (like command-line arguments, almost). Scripts for most other uses can't, so for what you want to do, one of these won't work.

#12
Pompeii69

Pompeii69
  • Members
  • 153 messages
Once I gave up on the dropdown list, and just started writing my own scripts, things kinda came together quite well. Thanx for all the responses here though!! I've still got a long way to go tho.

#13
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
It's a learning process, yes, and comes in time; glad that things have mostly worked out for you. If you have any further questions, we'll do our best to help you out. :)

#14
Dann-J

Dann-J
  • Members
  • 3 161 messages
This is a very simple level-up script I wrote that fires from a conversation node, where you specify the target level (iLevel) you want:

void main(int iLevel)
{
object oPC = GetFirstPC();
int iCurrentXP = GetXP(oPC);
int iPosition = ((iLevel - 1)*3);
string sXPArray = "000001003006010015021028036045055066078091105120136153171190210231253276300325351378406435";
string sNextXP = GetSubString(sXPArray, iPosition, 3);
int iNextXP = StringToInt(sNextXP)*1000;
int iXP = iNextXP - iCurrentXP;

if (iXP <= 0)// If PC level is equal to or higher than iLevel, do nothing
return;

GiveXPToCreature(oPC, iXP);// Otherwise, give enough XP to reach iLevel from current level
}

Modifié par DannJ, 20 juin 2011 - 10:57 .