Player Resource Consortium

 

Author Topic: activated item ability that grants temporary powerpoints  (Read 363 times)

0 Members and 1 Guest are viewing this topic.

March 10, 2017, 09:09:09 PM

So I am trying to write a script, it's supposed to work from an active item ability. Those are defined in mod_onactivate.nss or executescript link to another file. just including the psi_inc_ppoints just led to the const int BIOWARE_INHIBIT = !!0; error.

So I try the nwnnsscomp.exe like http://prc.athasreborn.com/index.php/topic,933.msg5684.html#msg5684 said

After a bit of troubleshooting, including not realizing that I have to declare the functions from the include before I can use them...



#include "psi_inc_ppoints"

void GainTemporaryPowerPoints(object oChar, int nGain, float fDuration, int bInform = TRUE);

void main()
{

    object oPC = GetItemActivator();
   
    //SendMessageToPC(oPC, "Current powerpoints: " GetCurrentPowerPoints(oPC) " before buffs.");
    GainTemporaryPowerPoints(oPC, 100, 30.0f, TRUE);
    //SendMessageToPC(oPC, "Current powerpoints: " GetCurrentPowerPoints(oPC) " after buffs.");

}




C:\Users\User>D:\compile\nwnnsscomp.exe -o -g -i d:\compile\prc_include d:\compi
le\prc_include\temppowerp.nss @pause
NeverWinter Nights Script Compiler/Decompiler
Copyright 2002-2003, Edward T. Smith
Copyright 2003, The Open Knights Consortium

Compiling: temppowerp.nss
Total Execution time = 312 ms


I arrive at this, it compiles, I put the script in the top hak, load module, use the script:

   if(GetTag(oItem)=="CaptiveRags")
   {
    ExecuteScript("temppowerp", oPC);
   }


I save, load the module, use the item with a psion and nothing happens.

I have very limited experience with coding (i just copy and paste a lot of already working scripts and hope for the best) so please excuse my ineptitude and I would appreciate any help.


March 12, 2017, 08:11:20 PM
Reply #1
  • Jr. Associate
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile

Do you have max pp? I am not sure you can go over your pp maximum.
Ideas are bulletproof.


March 13, 2017, 12:45:56 AM
Reply #2

From psi_inc_ppoints.nss :

 * Gives the character an amount of temporary power points. Temporary power
 * points are always used first and ignore the maximum PP limit.

Adding a sendmessage or using the GetCurrentPowerPoints functions doesn't even cause it to give out, so it seems like the function temppowerp isn't actually activated.



After compiling the temppowerp.nss, I should be able to call it in other scripts, right? Or do I need to compile mod_onactivate.nss the same way in the prc_include folder?


Edit1:
Please disregard the temporary powerpoints part. The GainTemporaryPowerPoints() function isn't actually defined in the include file. As I said, I am not that experienced so I was bound to make elementary mistakes. But that doesn't actually matter because it seems like even the defined functions don't work when I compile the nss with the nwnnsscomp.exe. Even basic functions, like when I reduce the script to a SendMessageToPC() function aren't actually running.



Edit2:
Should the compiler produce an ncs file or something after compiling my plain text file nss script (it doesn't)?


Edit3:
I think I am already failing at creating the batch file. I just put in the script I wanted to compile as %1 and it tried to compile, was that correct? When I make it the nwnnsscomp.exe I get a lot of error messages

nwnnsscomp.exe(75): Warning: Invalid character '$' (0x24) found in source, ignor
ed
nwnnsscomp.exe(75): Warning: Invalid character '$' (0x24) found in source, ignor
ed

And so on.

Compilation aborted with errors
Errors occurred in compiling "d:\compile\prc_include\nwnnsscomp.exe"


Edit4:
Finally got it to work after googling what a batch file even is. I had no idea that you had to save a txt file as .bat to make that (I thought I had to enter all that stuff in the cmd lines). Sorry for the bother and thanks for the response, Shalvan. I hope my shameful display can serve someone in the future at least.
« Last Edit: March 13, 2017, 06:29:51 AM by Mindflayer »


March 13, 2017, 09:26:00 AM
Reply #3
  • Jr. Associate
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile

No problem, I am similarly inexperienced ;) Just recently downloaded the svn repository of PRC and was about to start learning how to compile scripts and the entire PRC - I have some include changes prepared and I want to touch a couple scripts that are currently not functional or broken (for example Epic Eldritch Blast seems to require 20 levels of warlock instead of 9d6 Eldritch Blast, so is unavailable for Eldritch Disciple and Eldritch Theurge, even if total invoker level is equal to 20. Would have to change it to invoker level check, but then if someone in the future adds the Enlightened Spirit, we have another problem as it increases EB damage but does not increase invoker level ;) Other examples include spells like Ring of Blades, Arrow of Bone or psionic power Bolt), it even makes some classes really hard to use - swordsage's maneuver recovery right now doesn't work at all, with conversation appearing, but not recovering maneuvers you chose (not that their mechanism was any good in the first place, but they have to be able to recover maneuvers somehow... Adaptive style would be good here to implement a full-round action recover all maneuvers).

If anything, I will be happy to learn from your mistakes and capitalize on what you learnt. ;) And sorry for offtopic.
« Last Edit: March 13, 2017, 09:36:00 AM by Shalvan »
Ideas are bulletproof.


March 13, 2017, 11:15:45 AM
Reply #4

Some of those I am aware of, too. Wouldn't it be fine if it was something like

 if 9d6 EB || invokerlvl > 20
{}
?

Fun fact: making epic eldritch blast an item feat makes you incapable of leveling without unequipping the item if you don't qualify.

As for bolt, you mean that it switches from +x to d12 etc when you put more than a couple points into it? I don't even remember when that was changed, but I know it used to work correctly.


Ah, so many things I that I also might actually be able to work on myself now. What a liberating and empowering feeling!

I'll try to learn from any mistakes you make public, too!


March 15, 2017, 06:17:16 PM
Reply #5

Oh, I think I have a working version of the psionic power Bolt if anyone is interested: nBonus's value at, say 12, corresponds with 2d4 damage bonus on the constant group, you have to enter nDamageBonusConst variable for that, but you need nBonus for the attack bonus (although I think that AB on ammunition doesn't actually work? Might just be on the character sheet, though.)

/*
   ----------------
   Bolt

   psi_pow_bolt
   ----------------

   29/10/04 by Stratovarius
*/ /** @file

    Bolt

    Metacreativity (Creation)
    Level: Psion/wilder 1
    Manifesting Time: 1 standard action
    Range: 0 ft.
    Effect: A stack of 99 normal bolts, arrows, or sling bullets
    Duration: Instantaneous
    Saving Throw: None
    Power Resistance: No
    Power Points: 1
    Metapsionics: Twin

    You create a stack of arrows, bolts, or sling bullets. Ammunition has a +1 enhancement bonus.
    The type of ammunition created depends on what weapon is equipped. Bows produce arrows, slings bullets,
    and all others create bolts.

    Augment: For every 3 additional power points spent, the enhancement increases by +1.
*/

#include "psi_inc_psifunc"
#include "psi_inc_pwresist"
#include "psi_spellhook"
#include "prc_alterations"

void main()
{
/*
  Spellcast Hook Code
  Added 2004-11-02 by Stratovarius
  If you want to make changes to all powers,
  check psi_spellhook to find out more

*/

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

// End of Spell Cast Hook

    object oManifester = OBJECT_SELF;
    object oTarget     = PRCGetSpellTargetObject();
    struct manifestation manif =
        EvaluateManifestation(oManifester, oTarget,
                              PowerAugmentationProfile(PRC_NO_GENERIC_AUGMENTS,
                                                       3, PRC_UNLIMITED_AUGMENTATION
                                                       ),
                              METAPSIONIC_TWIN
                              );

    if(manif.bCanManifest)
    {
        object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oManifester);
        object oAmmo;
        float fBonusDur = 9999.9;

        // Calculate the enhancement bonus
        int nBonus = 1 + manif.nTimesAugOptUsed_1;
        int nDamageBonusConst;

        if     (nBonus == 1)  nDamageBonusConst = DAMAGE_BONUS_1;  // 1  PP
        else if(nBonus == 2)  nDamageBonusConst = DAMAGE_BONUS_2;  // 4  PP
        else if(nBonus == 3)  nDamageBonusConst = DAMAGE_BONUS_3;  // 7  PP
        else if(nBonus == 4)  nDamageBonusConst = DAMAGE_BONUS_4;  // 10 PP
        else if(nBonus == 5)  nDamageBonusConst = DAMAGE_BONUS_5;  // 13 PP
        else if(nBonus == 6)  nDamageBonusConst = DAMAGE_BONUS_6;  // 16 PP
        else if(nBonus == 7)  nDamageBonusConst = DAMAGE_BONUS_7;  // 19 PP
        else if(nBonus == 8)  nDamageBonusConst = DAMAGE_BONUS_8;  // 22 PP
        else if(nBonus == 9)  nDamageBonusConst = DAMAGE_BONUS_9;  // 25 PP
        else if(nBonus == 10) nDamageBonusConst = DAMAGE_BONUS_10; // 28 PP
        else if(nBonus == 11) nDamageBonusConst = DAMAGE_BONUS_11; // 31 PP
        else if(nBonus == 12) nDamageBonusConst = DAMAGE_BONUS_12; // 34 PP
        else if(nBonus == 13) nDamageBonusConst = DAMAGE_BONUS_13; // 37 PP
        else if(nBonus == 14) nDamageBonusConst = DAMAGE_BONUS_14; // 40 PP
        else if(nBonus == 15) nDamageBonusConst = DAMAGE_BONUS_15; // 43 PP
        else if(nBonus == 16) nDamageBonusConst = DAMAGE_BONUS_16; // 49 PP

        // Handle Twin Power
        int nRepeats = manif.bTwin ? 2 : 1;
        for(; nRepeats > 0; nRepeats--)
        {
            // Create the ammo and apply the bonus
            if(GetBaseItemType(oWeapon) == BASE_ITEM_LONGBOW || GetBaseItemType(oWeapon) == BASE_ITEM_SHORTBOW)
            {
                oAmmo = CreateItemOnObject("NW_WAMAR001", oTarget, 99);
                DelayCommand(1.0, AddItemProperty(DURATION_TYPE_TEMPORARY, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_PIERCING, nDamageBonusConst), oAmmo, fBonusDur));
            }
            else if(GetBaseItemType(oWeapon) == BASE_ITEM_SLING)
            {
                oAmmo = CreateItemOnObject("NW_WAMBU001", oTarget, 99);
                DelayCommand(1.0, AddItemProperty(DURATION_TYPE_TEMPORARY, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_BLUDGEONING, nDamageBonusConst), oAmmo, fBonusDur));
            }
            else // Create crossbow stuff as default, since Psions can always wield one
            {
                oAmmo = CreateItemOnObject("NW_WAMBO001", oTarget, 99);
                DelayCommand(1.0, AddItemProperty(DURATION_TYPE_TEMPORARY, ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_PIERCING, nDamageBonusConst), oAmmo, fBonusDur));
            }

            DelayCommand(1.0, AddItemProperty(DURATION_TYPE_TEMPORARY, ItemPropertyAttackBonus(nBonus), oAmmo, fBonusDur));

            // Identify the ammo
            SetIdentified(oAmmo, TRUE);
        }// end for - Twin Power
    }
}