Get skill's target and user name?

Discussion in 'RGSSx Script Support' started by BlueMage, Jun 8, 2019.

  1. BlueMage

    BlueMage Slime Lv99 Veteran

    Messages:
    58
    Likes Received:
    41
    First Language:
    English
    Primarily Uses:
    RMVX
    Hi guys.
    What is the script snippet to get target's name & user's name,
    assume that i will run it from a Common Event which has been assigned for skillX
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    27,944
    Likes Received:
    6,307
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    doesn't exist by default.

    common evvents attached to skills are all executed at the end of the battleturn, after every skill action has its damage formula processed. And the engine only stores the last skill and skill target, it does not keep in mind which skills were used previously.

    what you need to do is store some marker with the skill effects and damage formula and then have the common event look for which actor and enemy have those markers. Something like invisible target states that do nothing or similiar.
     
    #2
    BlueMage likes this.
  3. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,145
    Likes Received:
    4,581
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Use damage formula, save it in the variable.
    Code:
    v[99] = a.name; v[100] = b.name; <ur damage formula>
    Then use those variables in the common event.
     
    #3
    BlueMage likes this.
  4. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,668
    Likes Received:
    686
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    EDITED

    you want the actors, not the item, but the actors are grabbed *from* the item, which is the object that handles the process.
    that requires a method to save those, separately, added *to* the item skill, to perform the save at process time.

    here:
    Code:
    class Scene_ItemBase < Scene_MenuBase
    attr_reader :last_target
    attr_reader :last_user
    
    alias orig_use_item use_item
    alias orig_start start
    
    def start
     orig_start
     @last_target = nil
     @last_user = nil
    end
    
    def use_item
     orig_use_item
     @last_target = item_target_actors
     @last_user = user
    end
    end
    
    (I *THINK*)

    access with last_target and last_user
    turns out that the item itself doesn't store the target, that's done by the scene handling the item, but there's item skills and item usable items, which are handled by different scenes, so I had to go to the scene immediately above.
     
    Last edited: Jun 9, 2019
    #4
    BlueMage likes this.
  5. BlueMage

    BlueMage Slime Lv99 Veteran

    Messages:
    58
    Likes Received:
    41
    First Language:
    English
    Primarily Uses:
    RMVX
    Now that's really a simple way, thank you :o

    It's great to know this too, thank you =)
     
    #5

Share This Page