[XP] Causing status on attackers and defensors

Kavaline

GameDev
Member
Joined
Oct 29, 2018
Messages
9
Reaction score
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.
 

Powell

Veteran
Veteran
Joined
Mar 19, 2018
Messages
61
Reaction score
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
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
@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
 

Kavaline

GameDev
Member
Joined
Oct 29, 2018
Messages
9
Reaction score
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?
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
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.
 

Kavaline

GameDev
Member
Joined
Oct 29, 2018
Messages
9
Reaction score
0
First Language
Português
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.
Thanks for explanation, now I understand about this parameter, looks totally usefull for acessories or bonus attachments, like reforge or slots.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,882
Messages
1,017,230
Members
137,607
Latest member
Maddo
Top