Skip to content

Question regarding "Cast Spell on Condition" and Familiars

CorsymyrCorsymyr Member Posts: 146
I am trying to find a way to use the "Spell Effect: Cast Spell on Condition [232]" OPCODE with Familiars. The idea is to set "Target" to 0, and the Condition to 4 (HP<10%) and the resource to be "get into my backpack before you get squished". Obviously the piece missing is how to recall your familiar without the dialog file. I have found the IDS from the DLG file

GiveItemCreate("FAMFER",PLAYER1,0,0,0)
DestroySelf()

How would I get this to be a spell? I wrote it as a script but 232 wants it to be a spl file not a bcs. Any help would be very much appreciated!

TIA

Comments

  • WispWisp Member Posts: 1,102
    You can't do this with spell (at least not non-crappily), nor should you. What you can and want to do is assign your script to the familiar.
  • CorsymyrCorsymyr Member Posts: 146
    edited January 2013
    @wisp I can assign the "get back into my backpack before he squishes you to goo" part as a script to my familiar, but then how do I get the 232 OPCODE to call it? I am pretty new to all this and I don't see how the familiar will run the script upon dropping below 10% health.
  • lansounetlansounet Member Posts: 1,182
    edited January 2013
    Assign a script to FAMFER.CRE such as :

    IF
    HPLT(Myself,10)
    THEN
    RESPONSE #100
    GiveItemCreate("FAMFER",PLAYER1,0,0,0)
    DestroySelf()
    END

    ?

    With some WeiDU magic and variable switching (that I suck at) you could do this for all familiars in a single command.
  • CorsymyrCorsymyr Member Posts: 146
    @Iansounet Looks great. So if hitpoints are less than 10% on the target "myself" then run the rest? Thanks so much!
  • CamDawgCamDawg Member, Developer Posts: 3,438
    edited January 2013
    HPLT is actually a real HP count, so once the familiar hits 9 HP or less they'll run. HPPercentLT is the trigger you can use if you want to go by percentages.

    I can't remember if familiars heal themselves when they go to your pack--if they don't, you'll never be able to get them out again with that script. Every time they emerged they'd still be under 10 HP and go right back in. With a few more refinements:

    IF HPLT(Myself,10) ActuallyInCombat() THEN RESPONSE #100 MoveToObject(Player1) GiveItemCreate("FAMFER",PLAYER1,0,0,0) DestroySelf() END

    This adds a trigger so that the familiar only flees if combat is active and will move to Player1 before going into the pack for a little more realism.
  • CorsymyrCorsymyr Member Posts: 146
    @CamDawg I like the realism part! Very nice. Thanks for all the help. I am trying to make Familiars a little more useful.
  • CorsymyrCorsymyr Member Posts: 146
    If I added Regeneration to the Familiar, with a really slow tick, then he would be able to be recalled after his hitpoints moved above the mark. This would be nice so you cannot just recall the Familiar right away; a small penalty for letting the little guy get hurt.
  • lansounetlansounet Member Posts: 1,182
    edited January 2013
    With @Camdawg 's advice I came up with this TP2 that seems to work! (I'm so proud of myself)
    Feel free to use it to enhance all your familiars. Also open to all criticism.

    BACKUP ~familiar_script/backup~
    AUTHOR ~lansounet~

    BEGIN ~Familiar automatic move to inventory~

    ACTION_FOR_EACH familiar IN famcat famdust famfair famfer famimp fampsd famquas famrab BEGIN
    <<<<<<<< %familiar%.baf

    IF
    HPPercentLT(Myself,10)
    ActuallyInCombat()
    THEN
    RESPONSE #100
    MoveToObject(Player1)
    GiveItemCreate("%familiar%",Player1,0,0,0)
    DestroySelf()
    END
    >>>>>>>>
    COMPILE EVALUATE_BUFFER ~%familiar%.baf~
    COPY_EXISTING ~%familiar%.cre~ ~override~
    PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCIIE 0x248 ~%familiar%~
    END
    BUT_ONLY
    END


  • CorsymyrCorsymyr Member Posts: 146
    @CamDawg Strangely enough the script won't make my little rabbit run back to my pack. I tried it as each of the script option blocks in DLTCP, and no matter what he will not break combat and get back in my pack. I rechecked the Script and used NI to verify the script, and it reported no errors. Perhaps he is hard-coded to fight to the death.

    The funny thing is that the rabbit can do some serious butt kicking. I had to kill about 4 gaurds in Candlekeep before he dies.

    Here is the BAF file I compiled to BCS.

    IF
    HPLT(Myself,10)
    ActuallyInCombat()
    THEN
    RESPONSE #100
    MoveToObject(Player1)
    GiveItemCreate("FAMRAB",PLAYER1,0,0,0) //Familiar
    DestroySelf()
    END

    I then changed it to:

    IF
    HPPercentLT(Myself,90) //Went with 90 to get a one hit run back to me.
    ActuallyInCombat()
    THEN
    RESPONSE #100
    MoveToObject(Player1)
    GiveItemCreate("FAMRAB",PLAYER1,0,0,0) //Familiar
    DestroySelf()
    END

    Neither one made any difference in his actions. Weird. Perhaps I will try to create an item and equip him with it and see if that changes anything. Either way, thanks for all the information, as I am sure it will come in handy.
  • CorsymyrCorsymyr Member Posts: 146
    Thanks @Iansounet even better than I could've asked for. This takes care of all of them in one file.
  • lansounetlansounet Member Posts: 1,182
    Could be an issue with ActuallyInCombat() trigger, just tested w/o it and it works.

    As for familiar HP, I think they only recover health when you rest so they will come for the backpack as long as they're hurt (whatever the hp trigger you use) if you remove the combat trigger, which makes some sense anyway.
  • WispWisp Member Posts: 1,102
    @lansounet
    You cannot safely call inlined files "%familiar%.baf". They should have names guaranteed to be unique to your mod.
  • CorsymyrCorsymyr Member Posts: 146
    @Iansounet @CamDawg I have this now working thanks for everything.
  • lansounetlansounet Member Posts: 1,182
    @Wisp Yeh I get that for an official mod release but this was mostly to help Corsymyr.
    However I would like to know how to compile 1 -inlined or not- baf into several others with a variable that changes on every occurence, I couldn't find an easy solution so I went with what worked.
  • LugeLuge Member Posts: 90
    If ActuallyInCombat() isn't working, then heal the familiar to 11points just before it moves to the pack.

    cbission's Familiars pack gave all the familiars a hidden ring of regeneration to avoid this problem.

    L.
  • CorsymyrCorsymyr Member Posts: 146
    @Luge I just discovered "cbission's Familiars Pack, and I am getting some really good ideas from it. The "healing before moving to the backpack" is an awesome idea as well.

    Thanks!
  • LugeLuge Member Posts: 90
    @Corsymyr You're very welcome. The regeneration really makes the familiars easier to use. No one really wants to have to keep track of how many hitpoints they have all the time. The cloaks of non-detection prevents certain advanced scripts (like those from SCS) from casting detect invisibility, etc.

    L.
  • CorsymyrCorsymyr Member Posts: 146
    edited January 2013
    @Luge ... would you know how to get a "Familiar" to be able to use an Innate Ability, or to say use the Hide button, if the said "Familiar" does not have the ability by default?

    I actually figured out the Hide Button, I have to set it's class to one that uses said feature. If I set his class to Bard I would get Bard Song, I assume. Still unable to get Innate button to light up though. Perhaps I could just give him items with spell effects and go that route ... not as clean, but doable.
  • LugeLuge Member Posts: 90
    I'm not completely sure what you're asking, @Corsymyr . cbission changed all the classes of the familiars to mage-thiefs, so that they would inherit the abilities to cast and do stealthy stuff. I THINK that's what determines what buttons appear.

    If this isn't what you're asking, are you aware of the Hide() action? I don't think you need the actual button to be able to do this; you can just stick it in the script. Of course, unless the actor (the familiar) is a thief, they will have a Hide in shadow skill of zero, so it will automatically fail. So make sure you give the actor profile some skill points.

    If you're not willing to make the actor a thief class, you can create a custom innate ability (which we'll call HideCheating for this post), simply containing the action Hide(). Then you can either add the innate ability to the actor in the usual way. That seems a lot of work though, given you can just do what I explained above?

    You might find http://www.pocketplane.net/tutorials/simscript.html very useful as it has several different methods of actually using scripts and new abilities/spells you've created.

    L.

  • CorsymyrCorsymyr Member Posts: 146
    @Luge ... thanks for the link, this will be very helpful! I have the Hide Button working now.
  • LugeLuge Member Posts: 90
    Hey @Corsymyr. I saw you uploaded your mod. What did you go for in the end?

    L.
  • CorsymyrCorsymyr Member Posts: 146
    I ended up making him a Thief class, and his leveling is handled with items and a script. It seems to work pretty smooth. I initially had him as a Thief/Cleric, but he was just too powerful. I ended up giving him a heal and a charm as his innates.
Sign In or Register to comment.