Add state Knockout to certain party member if stands on trap

● ARCHIVED · READ-ONLY
Started by Landazar 12 posts View original ↗
  1. Recently I made a map full of traps in Indiana Jones style (spikes, trenches, flames etc) and they mechanics so far works only for a leader of party, wich I make it like that
    Code:
    for (var i = 0; i <= 2; i+=1){
    var mapID = 40; //Map ID
    var eSwitch = "A"; //Event switch
    var p=[mapID,i,eSwitch];
        if($gameSelfSwitches.value(p)){
            if (($gameMap.event(i).x === $gameVariables.value(54)) && ($gameMap.event(i).y === $gameVariables.value(55)))
            //Variables IDs 54 and 55 stores current X and Y of player
            {
                //Make game over - spikes pierced a leader... Add knockout to leader
                $gameActors.actor(1).addState(1);
            }
        }
    }
    Spoiler
    party.jpg
    The trap in spoiler mechanics is that you press certain button, certain spikes will hide allowing player (team) to pass through, but after given time spikes will popup, piercing leader and making game over if leader stands on them. What I want achieve is that if
    some of party member will be left behind (standing on popup spikes) that party member will be killed. My question is how to do that with most efficient way since script event is limited to 12 lines?

    (example. Party members 1 - 4 will make to pass through spikes, but all other had no luck and they were hit by spikes, causing them death)

    edit:
    Spoiler
    ddd.jpg
    In this case Pixie should die, leaving rest unharm.
  2. Not sure if it's the most efficient method, but does this work for you?
    Code:
    var mapId = 40; var eSwitch = 'A';
    for (var i = 1; i <= 3; i++) {
      if ($gameSelfSwitches.value([mapId, i, eSwitch])) {
        if ($gameMap.event(i).pos($gamePlayer.x, $gamePlayer.y)) $gameActors.actor(1).addState(1);
        for (var n = $gamePlayer.followers()._data.length; n > 0; n--) {
          var foll = $gamePlayer.followers().follower(n - 1);
          if ($gameMap.event(i).pos(foll.x, foll.y)) foll.actor().addState(1);
        }
      }
    }
    As you can see, I've made a few changes:
    • Changed the event ID range from 0~2 -> 1~3, since event #0 does not exist.
    • Replaced the variables for player/follower coordinates with direct script references.
    • Used the function pos(x, y), which is short for "is this character at (x, y)?".
    • Merged some lines together to help keep the line count down.
    This script call in English:
    Code:
    We'll use map ID 40 and self-switch A;
    For events #1~3...
      If this event's self-switch is on...
        Add state #1 to the leader if they're standing on this event;
        For each follower...
          Store the follower in a variable named foll (this is just to make the code easier to read);
          Add state #1 to this follower if they're standing on this event.
  3. console throws an error addState() is undefined
    ddddd.jpg
  4. It works for me...oh, you must be using a plugin that increases the maximum number of followers? Try replacing the last line (before all the } brackets) with this:
    Code:
    if ($gameMap.event(i).pos(foll.x, foll.y)) $gameParty.allMembers()[n].addState(1);

    Also (don't know whether this will affect anything): you have an n in the brackets on that line but foll.actor() takes no arguments. :kaoswt:
  5. Yes. I use plugin that changes max followers. I check it when storm is over. Right now i have a really beautiful show on sky. And with that n thing, i like to check how code will work since i have rmmv for 6months
  6. I am terribly sorry for violating board rule about bumping threads, but @caethyril - still no luck. I have two other options in my sleves.
    First. I'll event as much as rmmv allows it or simply hide followers on map init.
  7. @Landazar sorry, not sure why it doesn't work for you. =(

    I guess it's a plugin; maybe post a list/screenshot(s) of the plugins you're using to see if someone can spot the problem?
  8. I check it once more without plugin, but this is a big list of used plugins. (Most of them are Yanfly's and SRDude)

    Here is my current plugin list
    Spoiler
    rrr.png

    Plugins wight LJP_ prefix are mine
  9. Ah, incorrect plugin load order can break things. I'd suggest putting your Yanfly plugins in the recommended order, listed here: http://yanfly.moe/yep/ =)
  10. I took me while to change order - plugin, by plugin but it's done... And There are two things.
    #1 I use image from 1st post
    Spoiler
    party.jpg
    when heroes 7 - 3 are on traps - code works fine.
    #2 When hero number #2 enters trap console shows error just once "undefined is not a function" and then there are no errors, but
    knockout is not affecting at all, but leader is affected. I record a video to show it.

    Edit 1: I Found!! Hero #2 has a ring protecting from knockout! So now it's ok, I'll do more test runs.

    Edit 2: After running without ring, there are no errors and code runs smoothly.
    @caethyril - Thank you for your help.

    However this time I will speak to moderators.
    Please kindly do not close this topic for more (about for 5 - 6 hours). I'm pretty sure I will find something else bothering me with this and there is no point opening new topic similar to this one.

    Thank you in advance.
  11. Landazar said:
    ...there are no errors and code runs smoothly.
    Good to hear! ^_^
  12. Now I can 100% confirm - nothing wrong happens in game, so my problem is solved.
    Thank you @caethyril