Triggering something when a certain note-tagged enemy dies

● ARCHIVED · READ-ONLY
Started by Sixth 13 posts View original ↗
  1. Ahoy, experienced scripters!

    I got a little problem and it seems that I can't figure this one out on my own, so I kindly ask for a little help! *-*

    So, in short, here is what I want to do:

    I want to trigger something when a certain note-tagged enemy dies.

    Setting up the note-tags is not an issue. But most of what comes after is. >.>

    Triggering it when an enemy dies, and only when it is note-tagged with the required note-tags is just above my limited knowledge of scripting.

    The note-tags would look like this:

    <demon:12>

    <animal:8>

    And so on, so it consists from a type identifier (demon, animal, etc) and a number.

    Now, I know that I should probably split the note-tag somehow in the script, because I will need the type identifier and the number separately for triggering what I want, which is adding some kind of XP to that type, where the amount of XP would be the number in the note-tag.

    So, how could I do this? 

    Thanks for any help in advance!
  2. What do demon and animal represent? How is that used to determine whether something should be triggered when they die? What do you want to happen when they die - the EXP in the notetag is added, to whom, and in addition to the EXP already spedified for the enemy? Should it happen every time or just the first? Where is the note tag set up - you have a demon enemy with a note tag of <demon: 12>?


    Bit more information about how it all works would be helpful
  3. The actual trigger is already done. The note-tags will represent the data only. At least that is the plan.

    I am using CSCA Professions script, and trying to add XP to certain professions when the actors kill the enemies.

    The trigger piece of script looks like:

    $csca.change_profession_exp:)prof_symbol, amount)I would like to convert the note-tags to be data for that line above.

    The note-tag <:demonology:10>, for example, would add 10 XP to the demonology profession.

    So the first part from the note-tag would be the actual profession symbol used for the profession, and the number from it would be the amount of XP added to the profession.

    And this should happen every time when a note-tagged enemy is killed.

    The note-tags are in the enemy note-box.

    An example note-tag: /<demon (\d+)>/.

    This should add XP to the profession with symbol :demon.

    It might be better to get rid of the : sign in the middle, so that the note could be split like letters and numbers. Or does this even possible? I guess, it is obvious by now, but I'm not experienced with note-tags at all. 

    But I have seen something like this in a script I use, and edited to look like this:

         enemy.note =~ /<demon (\d+)>/      $csca.change_profession_exp:)demonology, amount)

     

    I have no idea how to convert the amount thou.

    So the code can even be hard-coded full with case/when or if statements, as long as it works, it is fine for me.

    Would this be possible somehow?
  4. I just quickly scanned your post as I have to get off the computer for a little while, but I think you're so close, and just a small change might get you across the line.


    try replacing amount with $1.to_i
  5. Lmao, this was much easier than I thought it would be.

    Turns out, I just kinda over-complicated it with too much thinking. >.>

    Simply doing this:

    Code:
    class Game_Enemy < Game_Battler  alias sixth_prof_die die  def die    sixth_prof_die      enemy.note =~ /<demon (\d+)>/      $csca.change_profession_exp(:demonology, ($~[1].to_i)) if $imported["CSCA-Professions"] && $~      enemy.note =~ /<animal (\d+)>/      $csca.change_profession_exp(:animalism, ($~[1].to_i)) if $imported["CSCA-Professions"] && $~  endend

     

    Made it work like a charm!

     

    I couldn't really find where to put that, I mean in which definition, but after watching the code in Yin's unfinished Bestiary for the code-off challenge, I found the place for it.

    The note-tags and their setup I got from one of Vlue's script, but went back to there only after you told me to replace the amount with $1.to_i, because I remembered that he did something very similar (if not the same, still no idea what I just did, rofl) to that.

     

    That's my scripting, copy and paste from other scripts. :D

    But day after day, I learn more, so sooner or later, I won't need to copy/paste anymore. At least I hope. >.>

     

    One last question thou...

    What is the difference between $1.to_i and $~[1].to_i?

    Is it that the first scans the whole note-tag and the second only scans the part after the first space in the note-tag? Or something else?

     

    Thank you very much for the help! 
  6. lol - that's more than I could tell you. This is the first time I've ever seen anyone do $~[1].to_i and now I have to go and look up what it means myself :D
  7. Ohh, well, the important thing is that my issue is solved. :D

    Ima mark it as solved.

    Thanks for all the help!
  8. I am a programming teacher but I barely know Ruby myself.

    Never had to teach this language yet so....

    I just scratch it a bit.

    Since Ruby has similarities though... It seems to me like

    $~[1].to_i

    takes an array value and converts it into an integer.

    These [] symbols seems to me like an array reference with pointer to the position 1

    Array named "A":

    A[0] = "5" 

    A[1] = "7"

    A[2] = "12"

    A[3] = "0"

    $~[1].to_i 

    will take the STRING 7 and make it an integer 7

    I can't be sure though, since it needs some research. 

    Since I have no time at the moment, I can not confirm if I am right or wrong.

    And this is just my instict. Just a guess.

    Now what is that ~ ???

    Maybe instead of   ~   you meant   _    ?

    CLICK ME

    Or maybe you meant just an operator that shifts a bit or something?

    CLICK ME

    Wow! Look what I found!!!

    CLICK ME!

    Gee that was a tricky question!

    Had to search a lot for it.
  9. I still don't understand it. Not sure if their explanation is correct, or complete.


    I don't think your example is right either, because you define an array A, but $~[1] makes no reference to that array.


    Maybe $~ is the name of the array ($ is simply setting the variable to be global) and $1 is a shortcut to $~[1]


    ???


    Probably more a question for the Learning Ruby forum.
  10. The first was a guess. It seems that 

    ~ [1] is something like an operator and a  reference.

    A little complicated.

    So I guess it is indeed a Ruby question. I provided some links that I found, I still have absolutely no idea if whatever they say is correct.

    I must learn Ruby ASAP I guess, or I will not be of any help here.

      :headshake:   

    Maybe it is a reference to a returned value from an object at that time.

    MAYBE the following link is half the answer (about ~)

    LINK

    I give up before this will haunt me. :p
  11. Lol, I see I made quite a headache for you guys. :D

    Even thought most of the times I had no idea what I just read, the thing with ROT13 was quite educational. 

    So that thing (ROT13) can be used in RGSS3 too? o_O

    That makes it possible to make different languages (kinda) in the game with a breeze. I think I got a new thing to meddle with. :D

    Thanks for the links!