Author Topic: REQUEST FOR NEW IDEAS TO SCRIPT  (Read 2770 times)

Legacy_Frith5

  • Hero Member
  • *****
  • Posts: 595
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #45 on: November 29, 2010, 01:12:59 am »


               *speechless*

Holy <expletive deleted>!!! Who can port this to Windows, and what do we need to do to make it happen??  That's fantastic stuff!!
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #46 on: November 29, 2010, 04:03:58 am »


               

Frith5 wrote...

*speechless*

Holy !!! Who can port this to Windows, and what do we need to do to make it happen??  That's fantastic stuff!!


I agree  as that is awesome.
               
               

               
            

Legacy_lordofworms

  • Sr. Member
  • ****
  • Posts: 422
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #47 on: November 29, 2010, 09:23:28 pm »


               

Fester Pot wrote...

How about a nice script that will take you from one location to another without having to sit around doing nothing in a wagon for 42 turns?

FP!



absolutely totally spot on!
lol

42 turns? hmmmm...I think I have to check my scripts....

...
...
string sName =  GetPCName(oPC)
if sName == "FesterPot"
{
wait(42 turns);
WaitSomeMore ();
PretendToActuallyDoActions;
NowJumpToOriginalPointHeStartedAtand RepeatProcess;
}
else // For All other players
{
JumpToLocation(iLoc); // immediately go to spot player wants
}
}
'Posted
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #48 on: December 01, 2010, 12:28:43 am »


               I'm still watching and hoping more gems will come down this way soon. So post your thoughts please!



Be well. Game on.

GM_ODA
               
               

               
            

Legacy_Vhaeraun Baenre

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #49 on: December 04, 2010, 08:18:11 pm »


               Well I sent you a pm about it but you never responded....


how about a script to make spell resistance % based instead of DC based like 2nd edition
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #50 on: December 04, 2010, 09:09:29 pm »


               You'd have to rewrite every spell script that used SR - not something easily fit into a neat little package for distribution. Though you might be able to halfass it with a spellhook, if you didn't care about nicities like the 'spell resisted' vfx.

Funky
               
               

               


                     Modifié par FunkySwerve, 04 décembre 2010 - 09:11 .
                     
                  


            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #51 on: December 04, 2010, 09:13:56 pm »


               

Vhaeraun Baenre wrote...
how about a script to make spell resistance % based instead of DC based like 2nd edition

The problem with doing this is that you'd have to alter the scripts for every spell (and possibly spell-like ability) in the game, since spell resistance checks are basically hardcoded.  Trust me, it's not a task to be taken lightly (I'm in the midst of rescripting every spell in my PW right now, and it's a big project).

Edit: And Funky beat me to the reply, I see. '<img'>
               
               

               


                     Modifié par The Amethyst Dragon, 04 décembre 2010 - 09:14 .
                     
                  


            

Legacy_Vhaeraun Baenre

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #52 on: December 05, 2010, 12:54:40 am »


               yes i realize this, i would be willing to do it too if i knew what code to change/add =D
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #53 on: December 05, 2010, 03:07:47 am »


               Well, then, it's fairly straightfoward. Edit an include name of your choosing into all the spell scripts. Do a Find/Replace on all the MyResistSpell instances, replacing them with your custom spell resistance function, named whatever you like. Then, write your custom function in the custom include you've made, keeping the same inputs as the original function:

// * Used to route the resist magic checks into this function to check for spell countering by SR, Globes or Mantles.
//   Return value if oCaster or oTarget is an invalid object: FALSE
//   Return value if spell cast is not a player spell: - 1
//   Return value if spell resisted: 1
//   Return value if spell resisted via magic immunity: 2
//   Return value if spell resisted via spell absorption: 3
int MyResistSpell(object oCaster, object oTarget, float fDelay = 0.0)

There you'll need to calculate the sr and sp of the target and caster, convert them to percentiles in whatever way you like, compare the results, and kick out the appropriate return as indicated in the original function, which you can find in NW_I0_SPELLS. Lastly, you'd probably want to edit the tlk so that item properties on your server show the proper percentile values instead of dc values.

Here's a sample replacement function, though it's still dc-based (no way to convert it without knowing what metric you intend to use). Note that it has an EXTRA input at the end, with a pre-specified default. You can add as many of those as you need to the end of your custom function, as the original functions will just get the default values applied, with you adding different values as needed. It also changed the inputs, however, something I'm not suggesting you do - we did a FAR more extensive rewrite of our spells.

int GetSpellResisted (struct SpellInfo si, object oTarget=OBJECT_INVALID, float fDelay=0.0, int bSROnly=FALSE) {
    int nSR = 0, nResisted = 0, nRoll = 0;

    if (!GetIsObjectValid(oTarget))
        oTarget = si.target;
    if (!GetIsObjectValid(oTarget))
        return 0;

    if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
        nSR = GetSpellResistance(oTarget);
    else
        nSR = GetLocalInt(oTarget, "SR");


    if (nSR > 0 && GetHasSpellImmunity(SPELL_SPELL_RESISTANCE, oTarget)) {
        nSR -= GetLocalInt(oTarget, "TauntResult");
        if (nSR < 1)
            nSR = 1;
    }


    if (nSR > 0 && si.sp >= 0 && !GetFactionEqual(si.caster, oTarget)) {
        nRoll = d20(1);

        if (si.sp + nRoll < nSR)
            nResisted = 1;
    }

    if (nResisted == 0) {
        if (bSROnly) {
            if (bSROnly == 2 && GetHasSpellImmunity(si.id, oTarget))
                nResisted = 2;
        } else {
            switch (ResistSpell(si.caster, oTarget)) {
                case 2:  /* globe or spell immunity */
                    nResisted = 2;
                    break;
                case 3:  /* spell mantle */
                    if (si.sp >= 0)
                        nResisted = 3;
                    break;
            }
        }
    }

    if (!nResisted) {
        if (nRoll > 0)
            SendSpellResistanceMessage(si.caster, oTarget, nRoll, si.sp, nSR, fDelay);

        return 0;
    }

    if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE) {
        effect eVis;

        switch (nResisted) {
            case 2:
                nSR  = -2;
                eVis = EffectVisualEffect(VFX_IMP_GLOBE_USE);
                break;
            case 3:
                nSR  = -3;
                eVis = EffectVisualEffect(VFX_IMP_SPELL_MANTLE_USE);
                break;
            default:
                eVis = EffectVisualEffect(VFX_IMP_MAGIC_RESISTANCE_USE);
                break;
        }

        DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
    }

    if (nRoll > 0 || nSR < -1)
        SendSpellResistanceMessage(si.caster, oTarget, nRoll, si.sp, nSR, fDelay);

    return nResisted;
}

Funky
               
               

               


                     Modifié par FunkySwerve, 05 décembre 2010 - 03:10 .
                     
                  


            

Legacy_cokeCan

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #54 on: December 05, 2010, 05:06:48 am »


               In other lisp like languages I have used a technique called code rewriting. Would that be applicable here?  If you had a set of commands that need to be inserted into every spell, the script would grab the function body, rewrite-it with the extra execution and then execute the modified spell. If spells are similar enough this could save a lot of time.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #55 on: December 05, 2010, 06:27:02 am »


               You aren't inserting so much as replacing, so there isn't extra execution so much as changed. I'm not aware of a faster way than I described, using a text editor like UltraEdit to do mass find/replaces.



Funky
               
               

               
            

Legacy_WebShaman

  • Hero Member
  • *****
  • Posts: 1390
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #56 on: December 05, 2010, 02:49:03 pm »


               The post from worms in response to FP's is definitely the high point of this thread!

ROFL!

And in response to the "who can port this to windows?" - tbh, there are sooooo many NWNx2 scripts that really need porting to windows...*sigh*

So that is my request - please start porting NWNx2 scripts from linux to windows.
               
               

               


                     Modifié par WebShaman, 05 décembre 2010 - 02:49 .
                     
                  


            

Legacy_Mac-Biodiesel

  • Newbie
  • *
  • Posts: 19
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #57 on: December 06, 2010, 06:37:31 pm »


               Maybe this has already been done, but I'd like to control my henchman's leveling up to the same degree as I can control my own PC's.  There is already a way to force a henchie to take a level in a certain class, but I'd like to also control how they spend their skill points, which feats they take, which attributes are increased, etc.  For example, maybe I want my rogue henchie to pump Search, but ignore Spot.



Also, whenever I play a buffing spellcaster, I quickly lose track of what spells I've cast on myself.  The effects are listed on my character sheet, but I'm not always sure what spell produce that effect.
               
               

               
            

Legacy_Avonos the Rogue

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #58 on: December 07, 2010, 07:44:49 am »


               Would it be practice to edit the nw_i0_spells MyResistSpell() directly?  You could probably even fudge a defaulting extra input on a number of spells that didn't use it if so.



Vhaeraun Baenre: check out the spells.2da for HotU or whatever the most recent expansion you're building with using nwnexplorer.  The 'Impact Script' column should tell you what script is associated with the spell being cast in game.  From there as Funky said, trace backwards through the includes and you will find the rest of the spell system.  Make sure you select 'All Resources' when you're specifying file names to open.  You may need to rewrite or come up with your own functions for some of it, but it is entirely do-able.

               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
REQUEST FOR NEW IDEAS TO SCRIPT
« Reply #59 on: December 07, 2010, 08:55:14 am »


               

Avonos the Rogue wrote...

Would it be practice to edit the nw_i0_spells MyResistSpell() directly?  You could probably even fudge a defaulting extra input on a number of spells that didn't use it if so.

Actually, that's probably better still - it didn't occur to me because of my lingering bias against editing bioware includes, however outdated. The only issue I can see is that, without making any edits to the spells themselves, they'll use the default version, instead of compiling using the edited include. So, if you already have spell edits to all the scripts, this will work. Otherwise, you might as well do the mass edits.

Funky