Exact variable value for event

Discussion in 'RPG Maker MV' started by XGuarden, Feb 4, 2017.

  1. XGuarden

    XGuarden Veteran Veteran

    Messages:
    419
    Likes Received:
    12
    First Language:
    French
    I want to put new page on some event that react if variable have exactly some value.
    For unknow reason rpg maker for = or greater and it's really enoying.

    I explain my situation.
    MY game got arround 1000 hero playable.
    And over 100 class.
    if I want the event to start a specific page only if a specific player was the main player on the team or based on the class of the main player, i cannot do it. Basicly my first work arround idea was to hav a switch for all player of the game....
    But if I can check specific variable that will be easy to only use of variable for check witch on is the main.


    Basicly, any way to change the default behavior of rpg maker for make variabl not look = or greater but just egal(for whole game) and to change the player option from "on the team" to "main character".

    Thanks, that will be a great help.
     
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    You are asking for a script/plugin if you want to change the way the game behaves. You should post in the Plugin Request forum.

    Is this talking about the conditions on an event page, or when you use Conditional Branch? I'll assume you're talking about the conditions listed above the event image, and are happy with the Conditional Branch logic just as it is.

    Code:
    Game_Event.prototype.meetsConditions = function(page) {
        var c = page.conditions;
        if (c.switch1Valid) {
            if (!$gameSwitches.value(c.switch1Id)) {
                return false;
            }
        }
        if (c.switch2Valid) {
            if (!$gameSwitches.value(c.switch2Id)) {
                return false;
            }
        }
        if (c.variableValid) {
            if ($gameVariables.value(c.variableId) !== c.variableValue) {
                return false;
            }
        }
        if (c.selfSwitchValid) {
            var key = [this._mapId, this._eventId, c.selfSwitchCh];
            if ($gameSelfSwitches.value(key) !== true) {
                return false;
            }
        }
        if (c.itemValid) {
            var item = $dataItems[c.itemId];
            if (!$gameParty.hasItem(item)) {
                return false;
            }
        }
        if (c.actorValid) {
            var actor = $gameActors.actor(c.actorId);
            if ($gameParty.leader() !== actor) {
                return false;
            }
        }
        return true;
    };
    

    Of course, this will not change the editor, as it is not possible to modify the editor with plugins. This will only change the way the game looks at event pages to see which one should be active. Using this plugin (which you should save under any name with a .js extension into your plugins folder, then add to the plugin manager), when you use a variable in the event page conditions, it will return true only if the variable exactly matches, and when you choose an actor, it will return true only if that actor is the leader.
     
    #2
    XGuarden likes this.
  3. jezebelthenun

    jezebelthenun Veteran Veteran

    Messages:
    99
    Likes Received:
    113
    Location:
    San Diego
    First Language:
    English
    Primarily Uses:
    RMMV
    As far as checking the exact value of the variable, can't you just do it with a script call that checks the variable against a specific value, then flips a switch to start the event if it's equal?

    I know it's convoluted, but it seems like it should work.

    But I'm probably the last person who should give advice about scripts. Sorry.
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    It's not about starting the event - it's about checking which page should be active.
     
    #4
    XGuarden likes this.
  5. Linard

    Linard Veteran Veteran

    Messages:
    202
    Likes Received:
    17
    First Language:
    Filipino
    Primarily Uses:
    RMMV
    #5
    XGuarden likes this.
  6. jezebelthenun

    jezebelthenun Veteran Veteran

    Messages:
    99
    Likes Received:
    113
    Location:
    San Diego
    First Language:
    English
    Primarily Uses:
    RMMV
    @Shaz Even still, couldn't you just do the same thing to change a page?

    I'm absolutely not trying to be a jerk, and I'm sorry if I seem like one. I'm genuinely wondering. Couldn't you put in a script call conditional branch that checks the variable against the specific number, then have it flip a switch, which is the condition for a certain page? Is that essentially what the code you posted does?
     
    #6
  7. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    You would have to do that as a parallel process event - maybe a single one that does all the checks for all the pages for all the events on the current map. It would be long and would take a while to run, and then you're using up lots of switches in the process - one for each page of each event where you want to base the condition on a variable or a party member. You COULD do that, but you'd be doing lots of script calls behind the scenes (for the interpreter to do the conditional branch and then pull data from all the places you might want it to look). It's easier to just change the logic that specifies what page to run right in the script, and would not affect performance. The only issue is that it makes ALL pages of ALL events behave this way - there's no "I want it to do that for some of the events only and the others will do the normal processing", so you'd only use the plugin I provided if you definitely wanted to do it to ALL events.
     
    #7
    XGuarden likes this.
  8. jezebelthenun

    jezebelthenun Veteran Veteran

    Messages:
    99
    Likes Received:
    113
    Location:
    San Diego
    First Language:
    English
    Primarily Uses:
    RMMV
    I see, that makes sense. Thanks a lot for explaining. I guess it could really bog things down to do it my way for, like, 2000 pages or whatever.
     
    #8
  9. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    It shows you're thinking ;) I generally prefer to do things via event command rather than script, but for something like that that'll be used by a lot of events, I don't mind using scripts.
     
    #9
  10. XGuarden

    XGuarden Veteran Veteran

    Messages:
    419
    Likes Received:
    12
    First Language:
    French
    Thanks to all for your answer. Shaz your code was really great.
    But on another hand Lianard, the link you give me: http://himeworks.com/2015/10/custom-page-conditions-mv/
    is really great too... in fact it's event solve my problem with event page only if specific weapon was equiped. Thanks.

    You are really so nice with me =:0)
     
    #10
  11. XGuarden

    XGuarden Veteran Veteran

    Messages:
    419
    Likes Received:
    12
    First Language:
    French
    A little question. I looked the pluggon of Linear, but can we check if a character was the actual leader in conditional brench?
    I curently try to use conditional brench with script condition using Shaz code.

    I put: $gameParty.leader() === $gameActors.actor(3);
    3 was the number coresponding to the actor id in the list.

    Ultimatly, I want to only check if the current leader have a specific ability...
     
    #11
  12. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The line of code you put should work. Did it? Did it give you an error?

    You can also use Control Variables to get the id of the person at position 1 (use Game Data > Party > Member #1) and then put that in a conditional branch to see if the variable is equal to 3. It's just one more way to do it - two event commands, but no script calls required.
     
    #12
  13. XGuarden

    XGuarden Veteran Veteran

    Messages:
    419
    Likes Received:
    12
    First Language:
    French
    That did't make any error but that also do nothing like if that alway returning false.
    I used the formation to reorganise party for put character 3 in first position. Mayb I need to put 0003 instead of 3...

    Anyway after analyzed a lot of my code I realise that is a lot better for me to check if the leader have a specific ability.
    Any idea how? Better to start a new tread of keep that on this one?


    EDIT: I found this:
    $gameActors.actor($gameVariables.value(5)).isLearnedSkill(8)
    I think I get closer...
    SOmething like: $gameActors.actor($gameParty.leader()).isLearnedSkill(1);
    But as skill change often(add, remove) I can't put fixed number there...
    Except if I put all skill on all caracter and desactivate them...
    IM not even sure of the syntax lol

    EDIT2:
    Just for hero verification part(not skill one), I found that if I put 3 in varaible 300 then
    I can use $gameParty.leader() === $gameActors.actor($gameVariables.value(300));
    But $gameParty.leader() === $gameActors.actor(3);
    seem to create an unbelivable behavior. It's didt work as long as I did't talk back to the npc that added player un the team... Anyway I did't need this method but im curious in case in need this one later.
     
    Last edited: Feb 4, 2017
    #13
  14. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    $gameActors.actor() expects a number to be passed. $gameParty.leader() is an actor object, not a number, so you cannot do $gameActors.actor($gameParty.leader()).

    If you put 3 in variable 300, $gameActors.actor($gameVariables.value(300)) will give you exactly the same as if you had put $gameActors.actor(3). If the original command wasn't working, I suspect you may have mistyped it or something. We'd need to see a screenshot.

    What does learning skills have to do with anything? I thought you wanted to see if actor 3 was the leader? The easiest way, as I said, is to use Control Variables to put party member 1's id into a variable, and then use a conditional branch to see if that variable is equal to 3.

    However, what exactly is it that you're trying to accomplish? Your request was to change how page conditions are evaluated, and I provided something that would work. Linard also gave you something that would work. That has nothing at all to do with conditional branches or what you're talking about now. Seems like you're asking for something completely different now, which should go in a different thread, along with an explanation of what you're trying to achieve.
     
    #14
  15. XGuarden

    XGuarden Veteran Veteran

    Messages:
    419
    Likes Received:
    12
    First Language:
    French
    It's not what happen curently... And im 100% sur do no have done any mistake about it. It's can be reproduc with a blank projet. I can post one in a zip file for you see by yourself if you want. If I put directly that value 3, the condition will not be evaluated by the pluggin as long as I didt affect a variable(any). If I use variable, then it's immedatly tak effect.

    It's because since I post the tread I realize that what I really want is to check if leader member hav a specific skill.

    My fist idea is to check if a player that have a specific skill was in the party, but it's by far better to just directly check if the current party leader have the skill.

    Your right, my first question was about conditional for tab and the pluggin do the job and your script too.
    So I asked for a specific situation, maybe I need to post a new tread for that.
     
    #15
  16. Shaz

    Shaz Veteran Veteran

    Messages:
    37,927
    Likes Received:
    11,591
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I'd rather see a screenshot of your event where you've used it. But yeah, what you're asking about now is not the same as what you opened the thread for, so I'd post a new thread and get this one closed.

    You still didn't really explain what you want. Checking if the leader is a certain actor and checking if a certain actor has a certain skill are very different things. You can do all of that with event commands. It almost sounds like you're wanting to make page conditions mimic anything you can do in a conditional branch (including some Control Variables functionality). I think there's a point where you just need to do things the way they were designed to be done.
     
    #16

Share This Page