Skip to content

To the scripting gods: Giving your character an ability via script at the start of the game...

AkuroAkuro Member Posts: 93
Hey folks,

so I want my child of bhaal to be really that powerful as all the people say. Until now, I've always given him a permanent innate ability via 2DA-file which allows him to cast spells without the 6-seconds-delay.

Now here's the problem: If my character is a mage-thief, that 2DA-file would give that ability every other character who is also a mage-thief, and I'd like to avoid that for obvious reasons.
Editing it in via the keeper is not an option because of rp-feelings :)

So I'd like to have a script which applies, let's say, ability "SPIN0101.spl" to my main char at the start of the game. Does anybody have an idea how to write such a script? Is it difficult? I could really use some help here, since I have no clue at all when it comes to scripting :-(

Thanks in advance!
Akuro

Comments

  • MathsorcererMathsorcerer Member Posts: 3,037
    If the timing of the innate ability spin0101.spl is "instant/permanent after death (9)" then it may be done very easily. This section could be added to ar0602.bcs.

    IF
    Global("FastCaster","GLOBAL",0)
    THEN
    RESPONSE #100
    ActionOverride(Player1,ApplySpell(Myself,30101))
    SetGlobal("FastCaster","GLOBAL",1)
    END

    The game will auto-translate 30101 as spin0101, unless you want to add an entry to spell.ids but you really shouldn't need to.
  • AkuroAkuro Member Posts: 93
    Wow, thank you very much, I will test it asap! Yes, the spell would have the parameters permanent after death.
    Do you think it's possible to edit ar0602.bcs with notepad++, add those lines and save the file?
    I gotta try it out :)
  • AkuroAkuro Member Posts: 93
    Okay, I created the spell with the DLTC Editor and loaded the script with it. After pasting your lines at the end of the script, the editor translated them into the following:
    ---------
    IF
    Global("FASTCASTER","GLOBAL",0)
    THEN
    RESPONSE #100
    ActionOverride([INANIMATE.21],ApplySpell([INANIMATE.HUMANOID],30101))
    SetGlobal("FASTCASTER","GLOBAL",1)
    END
    ---------
    So far I haven't seen any difference, I'm sure I've forgotten a little detail... Hmm...
    The spell is named SPIN0101 and I tried it with the parameters target:myself and target:creature - both versions show now effect.
    I will have to check again... :)
  • MathsorcererMathsorcerer Member Posts: 3,037
    edited November 2013
    hrm...odd. I always use Near Infinity, myself, for scripting. It looks like something strange happened and the script is having troubles translating both "Player1" and "Myself". The latest version of NI is 1.35 and...hrm...I am not seeing a link for it right now. I'll find a link and put it here.

    Okay....I have the link now. Use the one that says "infinity".

    Actually...on second thought....don't use that link--it doesn't go where I thought it goes. Well, it is NearInfinity, yes, but the link I posted is more for like getting the source code. You probably don't want that.
    Post edited by Mathsorcerer on
  • AkuroAkuro Member Posts: 93
    @Mathsorcerer

    Heya, it's me again!
    Thanks for the link (or the reference to) Near Infinity - so far NI managed to compile the script without the odd "INAMINATE" component.
    Now my script ar0602.bcs has the exact lines you gave me at the end. Nevertheless nothing happens...
    Did I forget something?
    Do I have to declare the variable "Fastcaster" somewhere else? Humm....

    Akuro
  • MathsorcererMathsorcerer Member Posts: 3,037
    No, global variables don't have to be declared. Let me test it a little and I'll figure out what is going on then post the fix later.
  • WispWisp Member Posts: 1,102
    ApplySpell() casts the spell on the target creature. You want AddSpecialAbility(). You could also use opcode 171 (with, e.g., ApplySpell()). Also, you should stay out of the SP(WI|PR|IN|CL) namespaces unless you absolutely have no other choice. Most actions either have *RES versions that take arbitrary resrefs, or do so by default.

    (And yeah, DLTCEP's internal script compiler has some issues. I believe it's generally recommended that you set DLTCEP up to use WeiDU as an external compiler.)
  • AkuroAkuro Member Posts: 93
    Okay, this time I tried the suggested "ApplySpell()". I had to change the lines to the following, to be accepted by Near Infinity:
    ---
    IF
    Global("FastCaster","GLOBAL",0)
    THEN
    RESPONSE #100
    ActionOverride(Player1,AddSpecialAbility("spin0101")) // No such index
    SetGlobal("FastCaster","GLOBAL",1)
    END
    ---
    Now when I load up my game, the following occurs:
    1. The "bling"-sound (level up sound) plays once
    2. A message in the box appears "CHARNAME gained special ability:" (No name, because it isn't meant to be shown.
    3. A new, blank icon appears under the innates-tab
    4. It doesn't give me any effects, nor can I activate it

    Okay, at least this is better than nothing - we're near the end, I know it :)
    Does "ApplySpell" not work?

  • ShinShin Member Posts: 2,345
    You could just give your character a permanent improved alacrity while you're using NI...
  • AkuroAkuro Member Posts: 93
    Hmmm, I'd only do that if there's no other way, because somehow it doesn't "fit" to me... (You know - RP-reasons... *grin*)
  • ShinShin Member Posts: 2,345
    Right, fair enough. Just thought I'd point it out.
Sign In or Register to comment.