Author Topic: Script Requests.  (Read 334 times)

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Script Requests.
« on: November 07, 2013, 12:15:03 am »


               First of all I apologize if this has already been touched on earlier. I did a search on the Vault, but couldn't find it.

Some time ago, a community member kindly shared a set of scripts for experience rewards on disabling traps and unlocking, which used the skill level on those particular actions as the base difficulty rate rewarded. If the trap had a difficulty of 20, upon disabling it, he would recieve 20 XP points for the action. I loved how simple to use, and yet rewarding the whole idea was However, as I was working on yet another module which had no experience rewards for other skill checks, it occured to me the same could be done with those skill checks happening through conversation. This is, if a character makes a succesful skill check during conversation through the use of persuasion, intimidation, apparaisal, etc, he would receive the skill rank he currently posseses as experience.

I tried doing it myself, but failed miserably, since scripting is what I do worst when it comes to NWN. Which is why I come here to humbly ask a kind soul to share such script if it can be done, or point me towards it, in case it already exists.

Finally, I have always been annoyed by the timelapse it takes a character to detect traps in the environment. No matter how high the skill rank for spot and search is, it takes  quite some time and distance for the "red overlays" to appear, alerting you to the presence of traps. I wonder if such can be fixed, so that if a character has the required skill ranks, the traps become evident automatically, without wait.

As usual, any insight you can offer is appreciated! '<img'>
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Script Requests.
« Reply #1 on: November 07, 2013, 06:40:45 am »


               The former two are doable, I don't believe the latter is (I think it's hardcoded).

For the persuade/intim/etc you'd simply add in some code adding some experience within the script that determines whether the check is successful.  Can give an example tomorrow if no one has by then.
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Script Requests.
« Reply #2 on: November 07, 2013, 07:00:44 am »


               Thank you! I am looking forward to it!
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Script Requests.
« Reply #3 on: November 09, 2013, 08:06:52 pm »


               Your Persuade check would look something like this:

// This would be used for persuasion -- adjust the DC if needed
int StartingConditional()
{
    // Variables
    object oPC = GetPCSpeaker();
    int nPersuade = GetSkillRank(SKILL_PERSUADE, oPC), nDC = 40;

    // Do the check however you want here
    if (nPersuade >= nDC)
    {
        // This gives XP equal to the persuasion skill -- might want to change it
        // if you don't want people getting 50 XP for a DC 10 persuade or something.
        // Also need to change it if you want to give XP to an entire party
        GiveXPToCreature(oPC, nPersuade);
        return 1;
    }

    return 0;
}

You'll obviously need to adjust the DC, whether you want it for a party, and whether you want people to get the DC of the Persuade or the ranks in Persuade as XP.
               
               

               
            

Legacy_Grymlorde

  • Sr. Member
  • ****
  • Posts: 362
  • Karma: +0/-0
Script Requests.
« Reply #4 on: November 09, 2013, 10:34:25 pm »


                Alternatively. . .

Since this is happening during a conversation. . .

The logic could be thus:

[PC] Persuade check DC 20

[NPC] Success! "You have persuaded me." Give PC 20 xp and Set Variable on PC so that they can't repeat this convo node.

[NPC] Failure! "Sorry, I don't agree with you." Set Variable on PC so that they can't repeat this convo node (or to increase future DCs).

The Bioware convo/script wizard is an extremely easy way to create an Action Taken script that gives an XP reward to either the PC Speaker or the entire party. The same wizard can set a local variable and check for local variables.

And if you want to be fancy, you can set a variable on the PC for a failed persuade check so that either they can't persudade the NPC on the same topic or there is a penalty for each failed persuasion. Just create a Text Appears When script that checks for the variable value (0-N) and show the appropriate convo node with the increased DC or hide the convo node altogether.

For traps, create an OnDisarm and for doors & chests create an OnUnLock script:

void main()
{
   object oSelf = OBJECT_SELF;

   // Get the creature who triggered this event.
   object oPC = GetLastOpenedBy();

   // Give 20 experience to us.
   GiveXPToCreature(oSelf, 20);
}

Name the script OnUnDC20 and create different versions by changing the XP reward and the name to reflect the different DC. The above script was created by Script Generator, not myself. It's a great tool for non-scripters like myself.

NOTE that is isn't exactly what you asked for. This assumes that XP = DC in all cases. Harder to unlock/untrap gives more expereince points but as characters increase in level the value of 20, 30, or 40 xp becomes negligible. The logic is much simpler than trying to figure out what the actual risk of failure is. The result is that a 1st level Rogue will get the same xp as a 1st level Fighter even though the Rogue has an easier time of it. I personally think that it falls in line with the fact that combat experience is paid based on how hard the creature is for anyone to kill rather than how difficult it is for that one PC.

Please feel free to ignore all of this as it is your game and not mine.
               
               

               


                     Modifié par Grymlorde, 09 novembre 2013 - 10:40 .
                     
                  


            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Script Requests.
« Reply #5 on: November 10, 2013, 02:00:37 am »


               MagicalMaster: Thanks for following up on this! Errr... No no, see, I'm afraid I wasn't clear enough on the opening post. The previously mentioned disarm trap/unlock scripts shared by a contributor were pretty much plug and play. We copied the actual script from here to a clean one in a module, and then named them and saved them, only to export them, making it so we could import them to any other module and keep its functionality. Such scripts reward experience on the exact amount of the DC for the trap or lock being affected. So, if the DC is 20, the player gets 20XP, regardless of skill or actual player level.

My request was for a script like that, only for the conversation skills like Persuasion, Intimidation, Bluffing, etc. I figured such could be done in a similar manner, but also as a plug-and-play script. I know nothing about scripting, but I imagine you can set it so the script identifies which skill is being used in the conversation, and then rewards the player based entirely on the DC check regardless of level or skill rank.

I hope I wasn't so vague this time, and I also hope such is possible... 0__0

Grymlorde: Thanks for sharing your own insights on this! And no, there will be no ignoring your comment, no, but I must say it goes well over my head. As mentioned earlier, I am not proficient on scripting, and even though I get some of the technicalities in your post, I am quite lost. If you could read the previous part of this comment, I hope the request becomes a little bit clearer. You see, this isn't meant for a party, or for different and fancy options. This is merely for personal use in single-player modules which don't have skill check rewards. The disarmtrap and unlock scripts have already been shared earlier by a community member, and can even be found by doing a quick search in the forums, I believe. The one/s I was asking for would only affect conversation-activated skill-checks. I was hoping against hope for a single script that was able to work for every skillcheck during conversation, but if it isn't possible, then a template that would work for all of them by changing merely one or two variables like the skill type.

Regardless, thanks to the both of you for helping! '^_^'
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Script Requests.
« Reply #6 on: November 10, 2013, 03:52:37 am »


               

Master Jax wrote...

My request was for a script like that, only for the conversation skills like Persuasion, Intimidation, Bluffing, etc. I figured such could be done in a similar manner, but also as a plug-and-play script. I know nothing about scripting, but I imagine you can set it so the script identifies which skill is being used in the conversation, and then rewards the player based entirely on the DC check regardless of level or skill rank.

I hope I wasn't so vague this time, and I also hope such is possible... 0__0


No, you can't.  Or rather, you sort of could, but you'd have to use ANOTHER script (multiple ones, actually) to set stuff up the action persuade/XP script.

Let me ask you this: how exactly are you handling persuade checks WITHOUT the XP part?  What are you doing for those?
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Script Requests.
« Reply #7 on: November 10, 2013, 05:02:35 am »


               Nothing much... 0__0 That's the thing. These modules I am working on are not mine, they are from many different authors, different playstyles etc, and they all share this in common: None of them reward any successful skill usage. You see, the more recent a module is, the more fancy and useful scripts it holds in it. Some reward such skill-checks, but they do so on an arbitrary manner, like rewarding a set amount of experience. I was just hoping I could use a script similar to the plug_and-play one we got for traps and unlocks, but regarding skillchecks through conversation.

As I said before, this is merely for my personal use as I go through single-player modules, which I re-furbish and add to. Of course, I brought it up here like any other requests so any community member can benefit from the resolution, like said trap/unlock script, or the glare-less light sources, or any of the others that have been successfully tackled!
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Script Requests.
« Reply #8 on: November 10, 2013, 06:20:33 am »


               As for detecting traps automatically, create an item (may I suggest the Miscellaneous Small magnifying glass?), give it the unique power property, and save this script with the item's tag as its filename. Using the item should show the player the location of any traps within the area (or a radius, configurable by you) whose DC they can meet.
               
               

               


                     Modifié par Squatting Monk, 10 novembre 2013 - 06:24 .
                     
                  


            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Script Requests.
« Reply #9 on: November 10, 2013, 06:38:04 am »


               When you unlock an object or disable a trap, it fires an event (OnUnLock and OnTrapDisarm, respectively), so we attach scripts to these events to award XP to the PC. The OnUnLock script only fires for that event, so we know what skill had to be used to open the door. The DC of the check is stored on the object (and you can modify it in the object's properties in the toolset).

In contrast, conversation skills are handled within a script, not by the engine. The script simulates a skill roll for the PC for a given skill and then returns TRUE or FALSE in order to steer the conversation to the correct node. Without examining the conversation tree and either altering existing scripts or adding your own (possibly changing the conversation tree in the process), there is no way to know what skill is being used when and what the DC is. Any changes to an existing module are going to be specific to that module, not plug-n-play.

Here's a simple example. The following is a simple script that returns TRUE if the PC succeeds on a persuade check of DC 20. It would be attached to the Text Appears When tab of a node that should only appear if the PC successfully persuaded the NPC.

int StartingConditional()
{
    object oPC   = GetPCSpeaker();
    int    nRoll = GetSkillRank(SKILL_PERSUADE, oPC) + d20();

    return nRoll >= 20;
}

Given this script, we could alter it to give us XP on a successful roll based on the DC, like so:

int StartingConditional()
{
    object oPC   = GetPCSpeaker();
    int    nRoll = GetSkillRank(SKILL_PERSUADE, oPC) + d20();

    if (nRoll >= 20)
    {
        GiveXPToCreature(oPC, 20);
        return TRUE;
    }

    return FALSE;
}

Make sense?
               
               

               


                     Modifié par Squatting Monk, 10 novembre 2013 - 06:48 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Script Requests.
« Reply #10 on: November 10, 2013, 08:35:13 am »


               You'll note that effectively all Squatting Monk and I are doing is adding in a way to make sure the PC gets XP when they succeed at a check -- so we need an IF statement which returns 1 (or TRUE) and gives the XP.  Otherwise, it returns 0 (or FALSE).

This literally means you would need to adjust every single check in a conversation that involves a skill in the entire module.  Some authors already do this but it would be a pain for you.  Honestly, you're better off using debug mode to give yourself the XP when you succeed on a check or something.  Faster and same net result.
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Script Requests.
« Reply #11 on: November 11, 2013, 06:19:30 am »


               Squatting Monk: Thanks for sharing the templates! That was a most useful explanation you did of both as well! I certainly got how to do it with your comment.

MagicalMaster: HAHAHAHAHAHA That was so honest! I just wanted to see if it could be done easily like the other plug-and-play scripts! Too bad, but still, thank you for sticking to this thread from the beginning! regardless of the outcome, I did learn a couple things! I'll experiment and tinker with the templates provided!