Aller au contenu

Photo

How do I make ga_ and gc_ scripts?


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

#1
andysks

andysks
  • Members
  • 1 652 messages
Hi all. I wanted to check a saving throw, or better yet make the PC throw a dice for it through a convo. I found out though that there is no saving throw conditional in the stock scripts. Lilacs gives me one, but for a given DC.
I want to be able to use it more times, so I need a gc_ script.
No idea how. Do I have to specify the variables like:

 int StartingConditional(int nSave, int nDC) or something like that, and then the code is what Lilacs gives me?
Quite confused with that, so, some help please :).

#2
Tchos

Tchos
  • Members
  • 5 072 messages
Actually, depending on what kind of saving throw you're looking for, gc_skill_dc might be what you want.  If not, that'll show you how to do it.

Modifié par Tchos, 01 décembre 2013 - 06:06 .


#3
kevL

kevL
  • Members
  • 4 070 messages
saving throws are kinda complicated, and don't fully work as advertised.

i don't wanna get into how some of the automatic fails don't; or how an immunity may result in a failed save so that the hardcoding kicks in...

but this might do in a pinch:


// 'gc_rollsave_kl'
// 2013 dec 1
//
//    iSave:        SAVING_THROW_* as follows
//                        0 = SAVING_THROW_ALL // unhandled. Will return FALSE!
//                        1 = SAVING_THROW_FORT
//                        2 = SAVING_THROW_REFLEX
//                        3 = SAVING_THROW_WILL
//    sTarget:    string of Target. Can use ginc_param_constants ("$PC_SPEAKER")
//                    Defaults to GetPCSpeaker() if blank
//    iDC:        roll required to Save vs.
//    iType:        SAVING_THROW_TYPE_* as follows
//                        0 = SAVING_THROW_TYPE_ALL
//                        0 = SAVING_THROW_TYPE_NONE
//                        1 = SAVING_THROW_TYPE_MIND_SPELLS
//                        2 = SAVING_THROW_TYPE_POISON
//                        3 = SAVING_THROW_TYPE_DISEASE
//                        4 = SAVING_THROW_TYPE_FEAR
//                        5 = SAVING_THROW_TYPE_SONIC
//                        6 = SAVING_THROW_TYPE_ACID
//                        7 = SAVING_THROW_TYPE_FIRE
//                        8 = SAVING_THROW_TYPE_ELECTRICITY
//                        9 = SAVING_THROW_TYPE_POSITIVE
//                        10 = SAVING_THROW_TYPE_NEGATIVE
//                        11 = SAVING_THROW_TYPE_DEATH
//                        12 = SAVING_THROW_TYPE_COLD
//                        13 = SAVING_THROW_TYPE_DIVINE
//                        14 = SAVING_THROW_TYPE_TRAP
//                        15 = SAVING_THROW_TYPE_SPELL
//                        16 = SAVING_THROW_TYPE_GOOD
//                        17 = SAVING_THROW_TYPE_EVIL
//                        18 = SAVING_THROW_TYPE_LAW
//                        19 = SAVING_THROW_TYPE_CHAOS

#include "ginc_param_const"


int StartingConditional(int iSave, int iDC, int iType, string sTarget)
{
    object oTarget = OBJECT_INVALID;

    if (sTarget == "")
    {
        oTarget = GetPCSpeaker();
    }
    else
    {
        oTarget = GetTarget(sTarget);
    }

    if (GetIsObjectValid(oTarget))
    {
        if (iSave == 1)
        {
            return FortitudeSave(oTarget, iDC, iType);
        }
        else if (iSave == 2)
        {
            return ReflexSave(oTarget, iDC, iType);
        }
        else if (iSave == 3)
        {
            return WillSave(oTarget, iDC, iType);
        }
    }
    else SendMessageToPC(GetFirstPC(FALSE), "ERROR : "
            + "gc_rollsave_kl : no Target");

    return FALSE;
}


/untested

#4
andysks

andysks
  • Members
  • 1 652 messages
Date is today. Did you just write this thing on the spot :D !?
I know what you mean with immunities. Let me explain what exactly I want to do maybe.
Encounter a dryad, she wants to save her forest from something. If you accept, is ok. If not, she tries charm person on you. There I wanted to try the save. However, there are so many variables to think of. Perhaps PC has found an immune to charm cloak, or anything like that. What happens then... a mystery before test :).
An easy way, would be to just check for the wisdom of the player, or a charisma depending on the charisma of the dryad. Tweak with the rules or something, to get a result.
The only issue with this, is that my campaign is a little open world. So you could encounter this at level 5 with 16 charisma, or at 15 with 20. But I guess it shouldn't be an issue that much, for if you do the quest so late, you'll also get the same xp. So, auto success save, little xp :P.
In any case, I will try the script, thank you for it. Will let you know how it went when I do.

#5
kevL

kevL
  • Members
  • 4 070 messages
yeh i guess i'm in scripting mode...

You raise an issue there as soon as I read "Perhaps PC has found an immune to charm cloak, or anything like that." Because the above script might not handle that correctly.

Here's the lowdown:

the *Save() functions you see there return
0 = failed save
1 = rolled save
2 = immune.


1 & 2 let an NPC-node fire, 0 shuffles the dialog to an NPC fallthrough. (where the Charm would happen)

But on a PC-node you'd want a ga_* script... and the Dryad would cast the Charm right then. So the dialog should use MySavingThrow() instead of the *Save() functions. Because then 2=immune would return 0=fail (don't ask) Lol


It depends on how you really want it set up.

Modifié par kevL, 01 décembre 2013 - 09:53 .


#6
kevL

kevL
  • Members
  • 4 070 messages
it should work as long as your dialog has something like

PC-"I'm gonna burn yer trees"
  +NPC-"Gah, my charm doesn't work!!!" (saved or immune)
    ++PC-"haha"
  +NPC-"No you don't!" (fallthrough: ApplyEffect(charmed) manually, not via spell)
    ++PC-"duh."

#7
andysks

andysks
  • Members
  • 1 652 messages
Alright. I did the tests, and it seems to work, but with a small glitch at first sight. Here is how the dialogue looks at the moment.

Image IPB

In game, it seems like he rolls two times. I just run the module from the toolset, so it gave me Aduin Harbor. Don't know if he has some property for double roll. One time he succeeded.

Image IPB

The other yes, and not. So it gave both options... which it shouldn't.

Image IPB

#8
kevL

kevL
  • Members
  • 4 070 messages
ok, looks like you have some confusion going on there


PC - Well, too bad. ...

make two red NPC nodes off of that one.


NPC - You suddenly feel your mind invaded...
NPC - ... but resist the force.


Only the first makes the gc_rollsave_kl check. (as NOT, like you have there) Ie. show the first NPC node if the save fails (the second will be ignored). Otherwise, if the save succeeds, only the second node will show.

Add PC dialog lines for each, tho. Carry each possible branch of the conversation through, ofc.



Now here's what my script doesn't do: add the Charm or implement any effects at all. This could be done with a ga_* Action script on the same node as the gc_ script, although sometimes it works best to shuffle it down to a subsequent line.

It seems to me a Charm might be pretty lame. depends what you want. Time for the Dryad to escape? A Fade out and the PC awakes in another zone ?? etc.

#9
andysks

andysks
  • Members
  • 1 652 messages
I see now. I thought I only have to make an NPC attempt, and the gc_ scripts goes to the PC node.
As for the effect, it doesn't matter a lot. If it fails, I won't apply charm, but impply it, by jumping the PC to another area, which will be impossible to leave if you don't complete the tasks. Or something like that... I am not certain yet. It's tough to charm-dominate the PC, since at best he will just stay there still.

For the carrying out every branch, yes. This was just a preliminary version of this dialogue, which I left as it is just to try the script. Thanks a lot.

#10
kevL

kevL
  • Members
  • 4 070 messages
sounds good. Let us know ....

kinda OT: through scripting it's possible to take control of the PC and make him walk off or whatever, but if you got something that satisfies that's just as well

#11
andysks

andysks
  • Members
  • 1 652 messages
I know, but the area of the quest is quite far away and I am sure the walk will break, if it happens in a cutscene. Also, it would be a boring cutscene to walk all the way there :D.
To my knowledge there is no way to take control out of a cutscene... but even if... the boring part :).

#12
andysks

andysks
  • Members
  • 1 652 messages
KevL, one more of your scripts works flawlessly. He rolls, he succeeds or not. I then gave him a ring with immunity to mind affecting spells, and even if there is no spell cast, the scripts realizes that a will save=mind affecting, so it's an automatic success. (He doesn't even roll), which is good. Awesome. I can do crazy things with this script. Thanks so much.

In two occasions, this one and the transfer items script, you said they are untested and unsure regarding stability, but it seems your scripts never fail :D.

#13
kevL

kevL
  • Members
  • 4 070 messages
thanks/ you're welcome


tallyho! an' all that