Skip to content

JoinParty in scripts

semiticgoddesssemiticgoddess Member Posts: 14,903
I would like to create a spell that would add the target to the player's party--basically, a spell version of CTRL-Q. The idea is to create a charm spell that would let you bring the charmed creature to any area and trade items with them. This way, you could charm a spider from the Cloakwood and use it to poison Davaeorn, or charm Koshi and steal his katana, or charm a Shadow Thief and have him use the Staff of Striking to backstab Aran Linvail. It would be open to lots of abuses (Clay Golems would be invincible in certain fights), but I could find ways to balance it out.

Problem is, I don't know how. I think the only way to bring people into the party without using CTRL-Q is to use the JoinParty command via scripting, but I know little about scripts and do not know how to implement this using a spell.

Would it be possible to create a spell that could force the target to join the party? And would it be possible to make them exit the party after a certain amount of time?

Comments

  • argent77argent77 Member Posts: 3,478
    edited April 2017
    I don't think there is an opcode that behaves like JoinParty(). You probably have to summon a helper creature to force the target into the party.

    It might also work to use opcode 82 (Set AI Script) to temporarily assign a script to the target which triggers the JoinParty() action. However, I don't know if it's possible to safely restore the original script of the creature afterwards.

    Edit: Just tested myself. Forcing a creature into the party is trivial. However, the process overrides several scripts (e.g. class script with default combat script) which probably can't be restored when the creature leaves the party again.
  • The user and all related content has been deleted.
  • argent77argent77 Member Posts: 3,478
    Yes, most likely. The same script action is also used for regular NPCs.
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    @argent77: How would I do this? I can work out the details of opcode 82 and put it in a spell somewhere, but I've never created a BCS script before.

    So it only overrides the class script and combat script? Does that mean the character just will not fight properly when it leaves the party? Or does it mean it can break quest-related scripts that could render certain quests unfinishable?
  • ArdanisArdanis Member Posts: 1,736
    JoinParty() forcibly sets all the script slots except the override. Race and generic ones are changed to NONE. So yeah, it *might* be possible to break something if you start randomly recruiting people, albeit in theory all vital information should be stored in their override slot.

    As for how to make a script, I'd suggest to take apart a couple mods, they usually ship scripts in uncompiled .baf format (which is just a renamed .txt) and have some commentary inside, which is not available with compiled .bcs form.
  • argent77argent77 Member Posts: 3,478
    Example join script:
    IF !InParty(Myself) Global("SomeGuardVariable","LOCALS",0) THEN RESPONSE #100 SetGlobal("SomeGuardVariable","LOCALS",1) JoinParty() END
    The guard variable makes sure to trigger it only once, in case you have to reject the creature because of a full party. However, you have to reset it at some point if you intend to hire the creature a second time.

    Place it into a text file with .baf extension and convert it into a BCS file in NI or with weidu (e.g. executing "weidu.exe myscript.baf" generates myscript.bcs).
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    @argent77: I've created a simple spell that can force the target into the party by overwriting its "race" script (I assumed that was the least intrusive type). I can give the ability to my Seducer kit.

    But I want to weaken some possible exploits and prevent the player from accidentally breaking a quest. The restrictions are:

    1. The target must already be charmed by the Seducer's Charm or Domination abilities.
    2. The spell cannot be cast in the middle of combat.
    3. The spell cannot affect very high-level creatures, and maybe critters with MINHP1 items. This is just to decrease the chance of the player charming plot-critical critters like Irenicus (or most Legacy of Bhaal enemies).
    4. The target goes hostile after a period of time. This is to make sure that abnormally powerful critters can't be used for the entire game. Otherwise, why charm anyone else? And why keep the Seducer in the party?.
    5. The target goes hostile and leave the party if you try to kill it. Otherwise, it's a guaranteed kill: you could just attack it and it would never fight back; party members never fight you if you try to kill them.

    I know how to handle 1-3, but 4 and 5 are a problem. I can make the character go hostile by having the thing cast a delayed spell after 24 hours (say) that changes the script again, turning them hostile and removing them from the party. But you can get around that by getting the charmed character killed, which means that that delayed spell would never get cast (delayed effects dispel on death).

    Question 1: Would it be possible to rig the JoinParty script so it would also remove the target from the party and turn them hostile after a set amount of time?

    As for 5, I guess I could use a spell to give party members on-hit effects that turn the target (and only the target) hostile and remove them from the party. But you could just dispel that effect by killing a party member, allowing them to kill the target. You could also still kill the target using summoned monsters (preventable by granting the target immunity to summoned critters), a different charmed enemy (you could charm a guard), or spell damage.

    The only other fix I can think of is to give the target a Cast Spell on Condition effect that would force them out of the party and turn them hostile if they ever got below 50% HP (justified by saying the charm can't make them suicidal). But you could still get a guaranteed kill by using stat drain or instant death effects (and granting them immunity to those things would allow them to tank vampires and such). Ideally, I'd like a cleaner solution.

    Question 2: Would it be possible to rig the JoinParty script so it would also remove the target from the party and turn them hostile when the party (but only the party) tries to kill them?

    Tagging @subtledoctor, @Grammarsalad, and @Demivrgvs.
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    Also, would it be possible to rig the target to go neutral or hostile or stay in one place after it leaves the party? Because if you just kick it out of the party normally, it will leave the area and be gone forever--another kind of guaranteed kill, but with the added problem of being even more likely to break a questline.
  • GrammarsaladGrammarsalad Member Posts: 2,582
    I think that it may be a good idea to exclude quest

    Also, would it be possible to rig the target to go neutral or hostile or stay in one place after it leaves the party? Because if you just kick it out of the party normally, it will leave the area and be gone forever--another kind of guaranteed kill, but with the added problem of being even more likely to break a questline.

    I don't know how to do this off the top of my head, but i think tweaks anthology does something to change the leave party behavior. That's the place to look for that.

    If you are going to make the creature hostile anyway, then you are going to break whatever quest that is attached to that creature anyway.

    Also, you can probably figure out how to kill the creature anyway. You can position them wherever you want and you can ensure that you hit them very hard before they have a chance to defend themselves.

    Anyway, if you are already messing with their race script, you can set conditions where they leave party.

    Looking at IESDP, this looks like a pretty standard leave party block:
    IF
        HappinessLT(Myself,-299)
      THEN
        RESPONSE #100
          ChangeAIScript("",DEFAULT)
          SetLeavePartyDialogFile()
          LeaveParty()
          EscapeArea()
      END
    You can just modify the trigger to something more suitable, and get rid of that EscapeArea() ( so probably no need look at tweaks...)
Sign In or Register to comment.