[XP] Causing status on attackers and defensors

Discussion in 'RGSSx Script Support' started by Kavaline, Oct 29, 2018.

  1. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    Hi,
    I'm new with RMXP, and want add a debuff when someone attack a target in guard stance. I know where I add the code, but can't find how inflict this status, what function I can use.
    I need put in Game_battler_3, in section "Applying Normal Attack Effects" (I made changes in script that affect the number of lines).
    I think that the solution is in something with "add_state(id)" or "states_plus(plus_state_set)", but I have no idea of how to set this on the attacker.
    And, I want give a status effect via script when someone use the guard action (in the self user), in Scene_Battle_4, new line* 221 (if I put in Game_battler_3, the status will be triggered only when I receive damage, and I want when I choose the defense command).

    Someone know help me in this 2 problems?
    Thanks so much, and sorry for the bad english, I hope that no one have difficult to understand my questions.
     
    #1
  2. Powell

    Powell Veteran Veteran

    Messages:
    59
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    N/A
    You could try having Defend Skill add a custom state that would trigger an auto-counter attack

    State adds
    Ex-Parameter CNT + 100 %
    Parameter ATK * 0 %
    State Rate example Poison 100 %
    Have the state removed automatically at the end of the round.
    upload_2018-10-29_0-57-20.png
     
    #2
  3. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    359
    Likes Received:
    84
    First Language:
    English
    @Kavaline You're on the right track. You'll want to call the "add_state" method on the attacker in the "attack_effect" method. My code below shows how to do this. (Note that you need to replace the "state_id" value with the actual state you want.)
    Code:
    class Game_Battler
    
        alias original_attack_effect attack_effect
       
        def attack_effect(attacker)
            # Run original method and store result
            result = original_attack_effect(attacker)
            # Apply state to attacker if target was guarding
            if self.guarding?
                # The ID of the state to add
                state_id = 1
                # Should the state be forcibly added?
                force = false
                # Add state to attacker
                attacker.add_state(state_id, force)
            end
        end
    end
    

    The other thing is a bit trickier. Since "guarding" doesn't call any methods in the "Game_Battler" class, we need to make changes to "Scene_Battle". The method we're looking for is "make_basic_action_result". There we can add another call to the "add_state" method, but this time on the defender. My code below shows how to do this.
    Code:
    class Scene_Battle
    
        alias original_make_basic_action_result make_basic_action_result
       
        def make_basic_action_result
            original_make_basic_action_result()
            # If guard, add guard state
            if @active_battler.current_action.basic == 1
                # The ID of the state to add
                state_id = 1
                # Should the state be forcibly added?
                force = false
                # Add state to attacker
                @active_battler.add_state(state_id, force)
            end
        end
    
    end
    
     
    #3
    Kavaline likes this.
  4. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    @Powell Thanks for the reply, but I want a different solution, via script, because I think to make some edits in the status ailments and mechanics. I will considerate this, for future or alternatives solutions :)

    @MobiusXVI Yes, the state id I will use is 17 in first case, and 18 in second case, both solutions works fine! I didn't know that "add_state(state_id, force)" could be used like a method, because of it I couldn't find the right code. This is very usefull for many futures edits, thanks so much!
    I tried learn about force status, but looks a little confuse for me. Whats this do?
     
    #4
  5. KK20

    KK20 Just some XP Scripter Veteran

    Messages:
    86
    Likes Received:
    37
    Location:
    Orange County, California
    First Language:
    English
    Primarily Uses:
    RMXP
    The 'force' parameter, at least in the default scripts, applies to armors that add states to the actor (Game_Actor#update_auto_state). The state will be permanently applied to the actor even if the state naturally wears off after a set number of turns. According to your first post, it doesn't sound like you want to use this.

    @Powell
    This is for XP, which doesn't have those features like VXA.
     
    #5
    Kavaline likes this.
  6. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    Thanks for explanation, now I understand about this parameter, looks totally usefull for acessories or bonus attachments, like reforge or slots.
     
    #6

Share This Page