Skip to content

Town Crier script?

Hey,

I'm trying to set up a town crier NPC for a PW that will transmit a PC's last talk line as a shout or something similar — so players can send accouncements, calls to gather up for a small fee without having access to shouts themselves.

How would I go about that? I wasn't able to find anything that will work for this on the LS script generator and would really appreciate some help if anyone knows what I mean.

Comments

  • ProlericProleric Member Posts: 1,316
    https://neverwintervault.org/project/nwn1/prefab/creature/killer-town-crier-axe
    https://neverwintervault.org/project/nwn1/prefab/creature/simple-town-crier

    These scripts will likely need tweaking to your exact requirements, so you'll probably need to learn some scripting, but they might be a starting point.
  • ForSeriousForSerious Member Posts: 466
    If those don't do it for you, let me know. I would love to script it.
  • DembelDembel Member Posts: 8
    Proleric wrote: »
    https://neverwintervault.org/project/nwn1/prefab/creature/killer-town-crier-axe
    https://neverwintervault.org/project/nwn1/prefab/creature/simple-town-crier

    These scripts will likely need tweaking to your exact requirements, so you'll probably need to learn some scripting, but they might be a starting point.

    I'm actually using one of these for something else, but what I meant is a little different — I'd more or less like a way for players to be able to pay an NPC to send a shout or a shout-esque message so people can look for groups and spread news around without everyone having access to shout at all times. Sorry, maybe the title was a bit misleading.

    ForSerious wrote: »
    If those don't do it for you, let me know. I would love to script it.


    I would be absolutely delighted if you could help me out. =)
  • ForSeriousForSerious Member Posts: 466
    edited April 2022
    Alrighty!
    Setup the Crier conversation how you want it.
    For the pay to spread the word conversation bit. In the Text appears when slot put:
    int StartingConditional()
    {
        // Pull the gold amount from the conversation
        int iAmount = StringToInt(GetScriptParam("num"));
        if(GetGold(GetPCSpeaker()) >= iAmount)
        {
            return TRUE;
        }
        return FALSE;
    }
    
    In the variables section under the script name, enter num on the left (name) and the gold amount they need to pay on the right (value). Be sure and click on the boxes multiple times. They're wishy-washy and don't always save what you enter if you don't.
    (Doing it this way, the same script can be used any time you want to enable a conversation option based on how much gold the player has.)

    In the Actions taken slot put:
    void main()
    {
        object oPC = GetPCSpeaker();
        // Flag the PC for chat listening.
        SetLocalInt(oPC, "makecry", TRUE);
        // Get the gold cost from the conversation.
        int iAmount = StringToInt(GetScriptParam("num"));
        // Spend the gold.
        AssignCommand(oPC, TakeGoldFromCreature(iAmount, oPC, TRUE));
    }
    
    Enter the same num and gold amount in the variables section.
    Be sure to let the player know that they need to use the whisper chat. You can change this, but it makes the most sense to me.

    Lastly, in the module events, OnPlayerChat slot add:
    void main()
    {
        object oPC = GetPCChatSpeaker();
        int iVol = GetPCChatVolume();
        if(iVol == TALKVOLUME_WHISPER)
        {
            // The text the player just typed into the whisper channel.
            string sMessage = GetPCChatMessage();
            // This must match the local int set in the actions taken script.
            string sCry = "makecry";
            // Ignore all chat messages that are not flagged to be listened to.
            if(GetLocalInt(oPC, sCry))
            {
                object oPlayer = GetFirstPC();
                while(GetIsObjectValid(oPlayer))
                {
                    if(oPlayer != oPC)
                    {
                        FloatingTextStringOnCreature(sMessage, oPlayer, FALSE);
                    }
                    oPlayer = GetNextPC();
                }
                SetLocalInt(oPC, sCry, FALSE);
                return;
            }
        }
    }
    
    I did this the the floating text way because that's how I had already done similar things. It can, however, be changed to find the crier NPC and make them shout the message. I think NPCs are still allowed to shout when players are not. I seem to remember a dragon that would roar when disturbed on a server that had the shout disabled.
  • DembelDembel Member Posts: 8
    ForSerious wrote: »
    Alrighty!
    Setup the Crier conversation how you want it.
    For the pay to spread the word conversation bit. In the Text appears when slot put:
    int StartingConditional()
    {
        // Pull the gold amount from the conversation
        int iAmount = StringToInt(GetScriptParam("num"));
        if(GetGold(GetPCSpeaker()) >= iAmount)
        {
            return TRUE;
        }
        return FALSE;
    }
    
    In the variables section under the script name, enter num on the left (name) and the gold amount they need to pay on the right (value). Be sure and click on the boxes multiple times. They're wishy-washy and don't always save what you enter if you don't.
    (Doing it this way, the same script can be used any time you want to enable a conversation option based on how much gold the player has.)

    In the Actions taken slot put:
    void main()
    {
        object oPC = GetPCSpeaker();
        // Flag the PC for chat listening.
        SetLocalInt(oPC, "makecry", TRUE);
        // Get the gold cost from the conversation.
        int iAmount = StringToInt(GetScriptParam("num"));
        // Spend the gold.
        AssignCommand(oPC, TakeGoldFromCreature(iAmount, oPC, TRUE));
    }
    
    Enter the same num and gold amount in the variables section.
    Be sure to let the player know that they need to use the whisper chat. You can change this, but it makes the most sense to me.

    Lastly, in the module events, OnPlayerChat slot add:
    void main()
    {
        object oPC = GetPCChatSpeaker();
        int iVol = GetPCChatVolume();
        if(iVol == TALKVOLUME_WHISPER)
        {
            // The text the player just typed into the whisper channel.
            string sMessage = GetPCChatMessage();
            // This must match the local int set in the actions taken script.
            string sCry = "makecry";
            // Ignore all chat messages that are not flagged to be listened to.
            if(GetLocalInt(oPC, sCry))
            {
                object oPlayer = GetFirstPC();
                while(GetIsObjectValid(oPlayer))
                {
                    if(oPlayer != oPC)
                    {
                        FloatingTextStringOnCreature(sMessage, oPlayer, FALSE);
                    }
                    oPlayer = GetNextPC();
                }
                SetLocalInt(oPC, sCry, FALSE);
                return;
            }
        }
    }
    
    I did this the the floating text way because that's how I had already done similar things. It can, however, be changed to find the crier NPC and make them shout the message. I think NPCs are still allowed to shout when players are not. I seem to remember a dragon that would roar when disturbed on a server that had the shout disabled.

    Thanks a bunch, I really appreciate it. I'll give this a try when I have some time to play around on the toolset.
  • MelkiorMelkior Member Posts: 204
    I'd probably backstop the above by using an object ID on the NPC, pointing to each PC who is allowed to send a message (each one who has paid) and I'd remove that player's object ID and send the message only when that PC whispered their message. That would prevent other players from griefing by hijacking the shout.
  • ForSeriousForSerious Member Posts: 466
    How about this line of code already in there?
    if(GetLocalInt(oPC, sCry))
    
    This should cover that situation.
    I'm always up for some live testing though.
  • MelkiorMelkior Member Posts: 204
    ForSerious wrote: »
    How about this line of code already in there?
    if(GetLocalInt(oPC, sCry))
    
    This should cover that situation.
    I'm always up for some live testing though.

    That looks like it would work. I was offering an alternative method and I hadn't looked too closely at the original script. My bad.
Sign In or Register to comment.