Player Resource Consortium

 

Author Topic: Need little help/suggestion - Ita Admin  (Read 2958 times)

0 Members and 1 Guest are viewing this topic.

January 01, 2018, 10:01:06 PM
  • Adept
  • *
  • Posts: 16
  • Karma: +0/-0
  • New Member
    • View Profile

Good Morning!
Just a suggestion. I'm sure someone of you can know the way to help me.

I use prc from several years on my shard and i've completely translated all prc in Italian, adapting something specific for my world.

No problem with scripts, no problem with classes, no problem with nothing.

I've just a problem that i've tried to solve by myself for months, without finding a solution.
It's not a bug.

I would like to edit some strings of codes, some spell scripts to have them behave slightly different but i can't make it work.

Example: Fireball script; i would like to set the caster level cap to 24 instead of 10 and so on with some other spell scripts.

Now, i know that these scripts are in prcspells.hak and i've exported to edit them.
I can edit the nss but until i can't make a ncs of the script, also re-importing into the hak and using the new hak modified, the fireball will continue to do the same things as before.

The PRC compiler does not work on my windows 7. No compiler for nwn seems to work. It starts for a blink of an eye and then shuts down.
I have not an old machine on which i could make it work the compiler.

The first question: is it right? This is the way to edit that spell scripts or are there other ways?
I would like to touch only spell scripts of original nwn spells and not every spell, just a few; then some epic spells.

1- i open the hak
2- i export the spell script (nss and ncs)
3?
4- i re-import into the hak
5- i use the new hak.

Am i missing something?
Do you have a compiler version that works with windows 7 that i can use to produce an ncs?
Are there other ways to do this?


January 02, 2018, 10:24:28 AM
Reply #1
  • Hero Member
  • *****
  • Posts: 1439
  • Karma: +27/-0
  • Gender: Male
    • View Profile

I use nwnnsscomp.exe to compile scripts. You can find it in PRC SVN repo or on the Vault:
PRC Neverwinter Script Compiler v2.0

You can find usage example in this post:
http://prc.athasreborn.com/index.php?topic=1661.msg7540#msg7540

I'm sure you will find more if you search the forum for 'nwnnsscomp'

Good luck!


January 02, 2018, 12:53:33 PM
Reply #2
  • Adept
  • *
  • Posts: 16
  • Karma: +0/-0
  • New Member
    • View Profile

Thank you xwarren. I'm very sorry for make you waste time! I've searched forums before writing but i've used wrong keywords.

Thanks again for your amazing work and all prc team. Your work is the best add to nwn ever made and me and my players are very grateful to this masterpiece.
I will follow the instructions in the compiler usage post :) :) :)


January 05, 2018, 08:03:04 AM
Reply #3
  • Adept
  • *
  • Posts: 16
  • Karma: +0/-0
  • New Member
    • View Profile

Ok, i've done what we said. I've used the compiler with all prc scripts (inc and all the others) in a folder.
It compiles the script but it finds errors.

Is there a pious soul that explains me how to use the spellhooking function that the prc staff has gently included in their scripts?

This is what i know:
1 - this is a part of the code in the x2_inc_spellhook
it seems to say that if you want you can tell it to execute a script that you create instead of an original script:


Code: [Select]
//------------------------------------------------------------------------------
// Execute a user overridden spell script.
//------------------------------------------------------------------------------
int X2RunUserDefinedSpellScript()
{
    // See x2_inc_switches for details on this code
    string sScript =  GetModuleOverrideSpellscript();
    if (sScript != "")
    {
        ExecuteScript(sScript,OBJECT_SELF);
        if (GetModuleOverrideSpellScriptFinished() == TRUE)
        {
            return FALSE;
        }
    }
    return TRUE;
}

//------------------------------------------------------------------------------
// Set the user-specific spell script
//------------------------------------------------------------------------------
void PRCSetUserSpecificSpellScript(string sScript)
{
    SetLocalString(OBJECT_SELF, "PRC_OVERRIDE_SPELLSCRIPT", sScript);
}

//------------------------------------------------------------------------------
// Get the user-specific spell script
//------------------------------------------------------------------------------
string PRCGetUserSpecificSpellScript()
{
    return GetLocalString(OBJECT_SELF, "PRC_OVERRIDE_SPELLSCRIPT");
}

2 - part of the code of nw_s0_fireball (fireball original prc script) for example
it says something about spellhook

Code: [Select]
/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook


3 - the most important: it explains how to use the spellhook function i think
(x2_inc_switches - part of the code about spellhooking)

Code: [Select]
//------------------------------------------------------------------------------
//                          S P E L L S C R I P T S
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Allows the module creator to specify a script that will be run before any spellscript is run
// You can call SetModuleOverrideSpellscript() at the end of the script specified by
// sScriptName. If you call this function this will prevent the original spellscript
// (and all craft item code) from being executed.
// If you do not add this line, the original spellscript and/or crafting code will
// run in addition to your script
//------------------------------------------------------------------------------
void SetModuleOverrideSpellscript(string sScriptName);

Can someone make me an example of how to use that function with prc, without touching the original spell scripts of prc?
I think it's possible but i can't solve by myself


January 26, 2018, 06:22:53 PM
Reply #4
  • Jr. Associate
  • **
  • Posts: 60
  • Karma: +5/-0
  • New Member
    • View Profile

As a recap: the Spellhook script fires before the bulk of the spell script; if the Spellhook script returns false in the X2PreSpellCastCode function, then the origional script will not fire. In this way, you can 'intercept' a spell, do something else with it, and tell the original spell not to fire.

You have to define what script (what name your script will have) to fire for spellhooking, that is where setting the module variable via SetModuleOverrideSpellscript(string sScriptName) comes in. Pick a name like "my_spell_hook" and then use that name when you create your spellhook script. I don't remember off hand if the PRC has a default value set for a spellhooking script name that you can just use without the need to set anything.


I think you know this, and that you just need helm with how the spellhook sript works. If that's not it, then let me know.


Here is an example from my own spellhook script; however, my script compiles the PRC items in it using the NWNTX Loader.exe updated toolset you can find on the NWN vault. Without that you wont' be able to use any PRC includes or functions.

Here is a partial spellhook file example for simply disabling the Continual Flame spell:

Code: [Select]
//::///////////////////////////////////////////////
//:: Name: Spellhook script
//:://////////////////////////////////////////////
/*
Description:

This script handles all the spellhooking for various spells

*/
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////

#include "x2_inc_switches"
// allows the use of:
// SetModuleOverrideSpellScriptFinished();
// which will kill the origional spell, if we need it not to run

// Include file for PCR Spell constants
#include "prc_spell_const"

// Include file for PCR Psionic Power constants
#include "psi_power_const"



//:://////////////////////////////////////////////
//:: Functions
//:://////////////////////////////////////////////

void main()
{

// Gather all useful info about the spell
    object oCaster =  OBJECT_SELF;                  // The caster of the spell is OBJECT_SELF
    object oMagicItem = GetSpellCastItem();         // if an item cast the spell, this function gets that item
    object oTarget =  GetSpellTargetObject();       // returns the targeted object of the spell, if valid
    location locTarget = GetSpellTargetLocation();  // returns the targeted location of the spell, if valid
    int iCasterClass = GetLastSpellCastClass();     // gets the class the PC cast the spell as
    int iCastLevel = GetCasterLevel(OBJECT_SELF);   // gets the level the PC cast the spell as
    int iSpellDC = GetSpellSaveDC();                // gets the DC required to save against the effects of the spell
    int iCasterAlignment = GetAlignmentGoodEvil(OBJECT_SELF);  // Returns the good/neutral/evil constant for the caster

    int iSpell = GetSpellId();                      // returns the SPELL_* constant of the spell cast



    switch (iSpell)
    {
//:://////////////////////////////////////////////
//:: Spells Section
//:://////////////////////////////////////////////


        case SPELL_CONTINUAL_FLAME:
                FloatingTextStringOnCreature(ColorString(C_RED, "The Continual Flame spell is currently disabled."), oCaster, FALSE);
                SetModuleOverrideSpellScriptFinished();
        break;


Basically, in the spellhook file you want to
1) Identify the spell via spell ID (GetSpellId())
2) Do something with the spell (script your own spell, call another script, whatever); in my example I play some floating text in the caster.
3) Tell the original spell NOT to fire (via SetModuleOverrideSpellScriptFinished() call)



My example just ends the spell, and doesn't do #2, but for a different fireball you could do this:


        case SPELL_FIREBALL:
                ExecuteScript("my_cust_fireball", OBJECT_SELF);
                SetModuleOverrideSpellScriptFinished();
        break;


And then you can write up your own fireball script in the "my_cust_fireball" scritp file.
« Last Edit: January 26, 2018, 06:29:08 PM by Atalsen »