Aller au contenu

Photo

Changing core stats via nwscript


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

#1
MrWakka

MrWakka
  • Members
  • 147 messages

So I recently felt a wave of nostalgia, and thought about doing a little nwn work. I had an idea for some custom systems, and it has been so long I only vaguely remember what is possible with nwscript. At the time I played nwn I didn't know much of anything of scripting, so I only have a few memories of what I had seen done to go on.

 

Is it possible to have a script alter, permanently, a characters BAB, either in vanilla nwn, or through the use of NWNX, which I seem to recall opened up some additional script functions. And for the same reason, would it be possible to alter character attributes and hp in a similar fashion?

 

Why? Well, for some reason after reading an old wiki for a pw project I was a builder on I kind of got the urge to take a stab at creating a custom system that would apply permanent bonuses. If a character took damage, add that to a variable, and at certain milestones he might gain a permanent bonus +2 hp or the like.

 

But before I get into digging out my old disks and reinstalling I wanted to check if anyone could tell me if I would just be wasting my time on the matter.



#2
Shadooow

Shadooow
  • Members
  • 4 470 messages

check this



#3
Thayan

Thayan
  • Members
  • 244 messages

If you just need the functions to change BAB, hit points, abilities scores, skills, etc - the nwn_funcs provides that. Here's the BAB function, for example:

 

// Sets the Base Attack Bonus Override of oObject to iBaB
// If BAB Override is greater than zero GetBaseAttackBonus will return this instead
// The original BAB can be restored by setting the BAB Override to zero
// The range of iBab is 0 to 254
// Unfortunately this is not a permanent setting as the game calculates the BaB every time a player logs in
void NWNXFuncs_SetBaseAttackBonusOverride(object oCreature, int iBaB)


#4
MrWakka

MrWakka
  • Members
  • 147 messages

Using those, would either of them grant the additional attacks from bab, or is that hard coded?



#5
WhiZard

WhiZard
  • Members
  • 1 204 messages

The APR for BAB is the command SetBaseAttackBonus() (oddly it sets the APR, not the attack bonus).  See also, RestoreBaseAttackBonus() for restoring the APR back to normal.



#6
MrWakka

MrWakka
  • Members
  • 147 messages

So would you set it to 6 for two, or would that result in 6 attacks per round?



#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

Setting SetBaseAttackBonus() to 6 is 6 APR.


  • MrWakka aime ceci

#8
MrWakka

MrWakka
  • Members
  • 147 messages

Thanks, I hope to report back some success eventually, it has been very illuminating.



#9
MrWakka

MrWakka
  • Members
  • 147 messages

Alright, I got things reinstalled and started typing away, and quickly hit my first stumbling block, and it is probably simple, but I am so out of practice I am not sure what the issue is.

if (GetIsPC(oPC)&&!GetLocalInt(oPC, "UMBRAL_NEW"))
    {
        NWNXFuncs_SetAbilityScore(oPC, int ABILITY_STRENGTH, int 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, int ABILITY_DEXTERITY, int 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, int ABILITY_CONSTITUTION, int 10, TRUE);
        NWNXFuncs_SetAbilityScore(oPC, int ABILITY_INTELLIGENCE, int 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, int ABILITY_WISDOM, int 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, int ABILITY_CHARISMA, int 10, FALSE);
        NWNXFuncs_ModSavingThrowBonus(oPC, SAVING_THROW_ALL, int 0);
        NWNXFuncs_SetMaxHitPoints(oPC, int 10);
        NWNXFuncs_RemoveAllFeats(oPC, TRUE);
        NWNXFuncs_SetBaseAttackBonusOverride(oPC, int 0);
        SetLocalInt(oPC, "BAB", 0)
        NWNXFuncs_RemoveAllSpells(oPC, CLASS_TYPE_SORCERER, int 0, int 9, FALSE);
        SetLocalInt(oPC, "UMBRAL_NEW", 1);
    }

oPC is defined earlier in the script, but NWNXFuncs_SetAbilityScore(oPC, int ABILITY_STRENGTH, int 10, FALSE); is returning an error of unknown state in the compiler.

Anyone able to let me know how I screwed up?

 

And as an aside, is there anyway for a creature to tell what it died from? Physical vs spell?



#10
meaglyn

meaglyn
  • Members
  • 808 messages

You need to take out all those "int" keywords in your calls to those functions.


  • MrWakka aime ceci

#11
MrWakka

MrWakka
  • Members
  • 147 messages

Now I feel silly, thank you for the help!



#12
MrWakka

MrWakka
  • Members
  • 147 messages

Back again, and everything is mostly working, except my attempts to set a new max HP. The script compiles, and everything seems to work as it should at the moment when I log in, except for the hit points.

 

This is my oncliententer event script:

#include "nwnx_funcs"

void main()
{
    object oPC=GetEnteringObject(); 
    if (GetIsPC(oPC)&&!GetLocalInt(oPC, "UMBRAL_NEW"))
    {
        NWNXFuncs_SetAbilityScore(oPC, ABILITY_STRENGTH, 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, ABILITY_DEXTERITY, 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, ABILITY_CONSTITUTION, 10, TRUE);
        NWNXFuncs_SetAbilityScore(oPC, ABILITY_INTELLIGENCE, 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, ABILITY_WISDOM, 10, FALSE);
        NWNXFuncs_SetAbilityScore(oPC, ABILITY_CHARISMA, 10, FALSE);
        NWNXFuncs_ModSavingThrowBonus(oPC, SAVING_THROW_ALL, 1);
        NWNXFuncs_SetCurrentHitPoints(oPC, 10);
        NWNXFuncs_SetMaxHitPoints(oPC, 10);
        NWNXFuncs_RemoveAllFeats(oPC, TRUE);
        NWNXFuncs_SetAllSkillsToZero(oPC);
        NWNXFuncs_SetBaseAttackBonusOverride(oPC, 1);
        SetLocalInt(oPC, "BAB", 1);
        NWNXFuncs_RemoveAllSpells(oPC, CLASS_TYPE_SORCERER, 0, 9, FALSE);
        SetLocalInt(oPC, "UMBRAL_NEW", 1);
    }
    else
    {
        int Current_BAB = GetLocalInt(oPC, "BAB");
        NWNXFuncs_SetBaseAttackBonusOverride(oPC, Current_BAB);
    }
}

It will set current hp to 10, even if that is above the current 'max', but the max doesn't seem to change. Am I using the function wrong? And if this one won't work, is there an alternative?

Ideally i'd like to be able to set it up so the user gains to their max HP over time by performing certain actions, though obviously this is just the initial script to make the player character a blank canvas that can then be expanded upon.



#13
MrWakka

MrWakka
  • Members
  • 147 messages

Not sure if anyone is interested, but I figured i'd share my findings as I went. Since I couldn't get the set max HP function to work I instead switched to a set HP by level function, which after some issues, namely that even if set to 0 you always get at least 1 hp per level, I got it to work.

NWNXFuncs_ModSavingThrowBonus(oPC, SAVING_THROW_ALL, 1); works to increase, but the Set function doesn't seem to eliminate gains from class levels. This should be somewhat solved once I edit the classes 2da, which was always my original intent anyway, though I was starting to hope I could avoid having an extra hak.

 

Overall progress continues, albeit it a bit slower rate than I hoped. Just got the system in to gain stat xp and increase BAB in. once I get it refined a bit and working how I want the other stats should be fairly easy, the biggest ones likely in terms of time will be the spell hooking for caster level XP. Then it is just creating the tasks and mini-games that will allow for increases in things like skills, and certain feats.



#14
henesua

henesua
  • Members
  • 3 863 messages

there is a server setting for setting max HP. not sure if that will help you, but you should be aware of it.



#15
MrWakka

MrWakka
  • Members
  • 147 messages

Yeah, that just sets the hp on level up from random to max. My goal was to alter a persons HP permanently. So for example a level 10 sorcerer might have 50 odd hp. The script would then change that, in this instance I was trying to set it to be 10 instead.

As it stands currently when a player logs in to my module they are checked to see if they are new, then if they are a sorcerer, and then leveled to 20, and a number of local variables are stored on the character for tracking a individualized xp on a stat by stat basis.

When they level, and then take a portal, they are then stripped to 20hp, their ability scores are each set to 10, BAB to 1, and all feats, spells and skill points are removed. (The leveling is required for the spell slots, should a player pursue a spellcasting career.)

 

From there forward certain actions earn them experience to specific things. Currently only melee and ranged combat are implemented, but whenever they inflict damage a variable is increased, representing experience towards a BAB increase. When the variable reaches a target number they are then granted a +1 to their current bab, and the total they need to reach the next stat increase is doubled. Certain stats will be tied together, such as 'combat' stats, so that by increasing one the cost to raise all of them goes up at the same time.

In this manner a person can increase BAB, or Caster Level, but an increase to either increases the cost for both to be advanced going forward. Example: It takes 100 xp for BAB 2, or CL 2, if you raise your BAB to 2, it will cost 200xp for BAB 3 or CL 2. You can choose to raise both slowly, or specialize in one.

 

Once the system is done a character could in theory, given enough time, max everything, but the increasing costs make that unlikely. All the stats will be increased through a relevant activity, spending time in a library might increase your lore skill, whereas collecting lumber might increase your strength and fortitude saves. Ideally I'll have enough activities to keep it interesting and varied.

Ultimately it replaces the class based system inherent in NWN, and instead turns it into something resembling a skill based system like you might find in morrowind, and for it to work being able to adjust a characters hit points is required, but i found a way around the issue i was having.



#16
WhiZard

WhiZard
  • Members
  • 1 204 messages

You might also want to keep an eye out for constitution reducing effects.  If the character is already at 1 HP per level (or two for toughness), decreasing constitution will have no affect on hit points.


  • MrWakka aime ceci

#17
MrWakka

MrWakka
  • Members
  • 147 messages

Good point, something I had not considered. Though it should only affect new PC's, anyone who has advanced their HP will have more to work with. 



#18
MrWakka

MrWakka
  • Members
  • 147 messages

I could have sworn NWNX has a set caster level function, but apparently I was mistaken.

Anyone know of a way to reduce caster level? Without also reducing other stats, such a the way level drain works.

 

I suppose I could modify the spells to do a custom caster level, but seems a fairly time consuming method.



#19
Baaleos

Baaleos
  • Members
  • 1 330 messages
nwnx_cool has an onSpellCast hook.
You are able to change the caster level in that event.

//Spellcast
if( nEvent == 1 ){

//Can override casterlevel for the comming spellscript
if(GetIsAGod(oPC)){
WriteTimestampedLogEntry("God casting spell: Override CasterLevel to 9000");
SetLocalInt( oPC, "cstrlvl", 9000 );
}

}


As for the nwnx_funcs - SetMaxHP.

I think that it works primarilly for NPC's
For PC's you can use
SetMaxHPPerLevel - or whatever it is called
You can provide I believe up to 254 hp per hitdice (level)

And combined with nwnx_cool - with its levelup capabillities that allow leveling up beyond level 40 - you can in theory have an uncapped HP Limit.
Assuming that the levels continue to accept 254 hp per level

Eg: 80 Levels x 254 = 20320 Max HP (Theoretical)
Thats actually higher than the HP you can set for a NPC in toolset
  • MrWakka aime ceci

#20
MrWakka

MrWakka
  • Members
  • 147 messages

Sounds good, found the windows thread for it, and that should save me a lot of time.



#21
DoomsDay1000

DoomsDay1000
  • Members
  • 9 messages

Hope someone still comes to these. I was wondering how i can get the nwnX functions installed but i only can find these.

 

file:///C:/NeverwinterNights/NWN/nwnx_functions.html

 

I don't see a list of the functions that get used in this thread.