JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 24 of 171 View original ↗
  1. HeartCase龍 said:
    I am trying add an event to the map using the 'F8' console



    var e = {"id":2,"name":"EV002","note":"","pages":[{"conditions":{"actorId":1,"actorValid":false,"itemId":1,"itemValid":false,"selfSwitchCh":"A","selfSwitchValid":false,"switch1Id":1,"switch1Valid":false,"switch2Id":1,"switch2Valid":false,"variableId":1,"variableValid":false,"variableValue":0},"directionFix":false,"image":{"tileId":0,"characterName":"Actor1","direction":2,"pattern":0,"characterIndex":0},"list":[{"code":101,"indent":0,"parameters":["Actor1",0,0,2]},{"code":401,"indent":0,"parameters":["I am the 3rd Event"]},{"code":0,"indent":0,"parameters":[]}],"moveFrequency":3,"moveRoute":{"list":[{"code":0,"parameters":[]}],"repeat":true,"skippable":false,"wait":false},"moveSpeed":3,"moveType":0,"priorityType":1,"stepAnime":true,"through":false,"trigger":0,"walkAnime":false}],"x":5,"y":5};
    var l = $dataMap.events.length;
    $dataMap.events[l] = e;
    $gameMap._events[l] = new Game_Event($gameMap._mapId, l);


    it should add an event at pos(5,5). However, the event can be triggered but the character is not shown. Could you point me out where the issue is? Thanks.

    Do a map transfer to the same map
  2. DreamX said:
    Do a map transfer to the same map

    thanks, it works.... but it refreshes the $dataMap( I use the $dataMap.events to store my events).


    I could reload the events though, but is there any more atomic way to do that?
  3. HeartCase龍 said:
    thanks, it works.... but it refreshes the $dataMap( I use the $dataMap.events to store my events).


    I could reload the events though, but is there any more atomic way to do that?

    Hmm, maybe try storing $dataMap into a variable before transferring and alias DataManager.loadMapData so that it loads from the variable if it exists instead of the file.
  4. DreamX said:
    Hmm, maybe try storing $dataMap into a variable before transferring and alias DataManager.loadMapData so that it loads from the variable if it exists instead of the file.

    Well, I track the "transfer" function to see how it solves my problem, I think "transfer map" is too big for dis task.


    and I find that the current scene( SceneManager._scene ) call the SceneManager._scene.createDisplayObjects to add the display object to the container which include sprite set which is also responsible to showing the character in the event. The problem is if I call createDisObjects, all the displayable stuff will add to the container twice. I can use remove child function to remove the content from the container first then add a new content to the container after that. and it works perfectly.



    SceneManager._scene.children = []; SceneManager._scene.createDisplayObjects();


    it has to be input at once cuz the nul set will cause the program cracked in the update loop.


    Thanks for the inspiration. Have a great day.


    note:


    more efficient way without redraw the whole map:

    Code:
    SceneManager._scene.children[0]._tilemap.addChild(new Sprite_Character($gameMap._events[l]));
  5. So I'm using YEP Row Formation, and I was wondering what would be the best way to approach using the left/right keys to shift a character's row during their turn. Basically positioning them with left and right (which currently do nothing, as I've disabled the party command window), then using up and down to select the command you want them to use. Obviously this would have to only work at the main command screen, and not in any sub-menus like a skill or item selection window, etc. I feel like there are a number of ways to approach this, but I'm not sure what the best one would be. I'd probably have to learn a bit more than what minuscule Javascript I know in order to do it, too.


    The closest thing I could find was Gilgamar's Button Cast Plugin, but it's for ATB and is for use when it is not the character's turn. So... the same thing, but in some ways kind of the opposite. Also, for non-ATB systems.


    Any suggestions?
  6. How do I call the self event in a script call?


    For example:


    $gameMap.event(id).requestBalloon(4);


    what do I put in the id space if I want it to call itself. I remember "event_id" worked in Ace, however it doesn't seem to be the same name in mv.


    Thanks for your time.
  7. Hey guys and girls,


    is there a way to force an action to miss?


    Something like this simple psoydo code: (character/action).setForceMiss(true);


    Background:


    I'd like to make a state using Yanflys BuffStateCore plugin, that makes the next hit the character recieves to miss. My idea is to make a <Custom React Effect>. In there I can get access to the enemy that hits me with a skill (user), my character, which is under the influance of the state (target) and something called a "Game_Action" (this). I don't exacty know what a Game Action is, but as far as I understood it, it is the action or attack the enemy performes. It also has a property called "isForceMiss = false" so I wonder if I can set this property to true somehow.


    Thanks in advance.
  8. Is there a way to add more escape / process codes? I was thinking of doing something like /hr[x] where x is the id of the actor. When shown in messages, it displays a certain attribute I made personally for that actor.
  9. Edit: I didn't know what I was looking for. Going to try again on my own.
  10. Hey everyone!


    I defined a bunch of functions to use in script calls, one of them is the ability to check if the party has a weapon, this is the code:


    (I removed every other command but that one, but they are all defined like this.)


    var _Game_Interpreter_Astfgl = Game_Interpreter.prototype.command355;

    Game_Interpreter.prototype.command355 = function() {
    var script = this.currentCommand().parameters[0] + '\n';
    while (this.nextEventCode() === 655) {
    this._index++;
    script += this.currentCommand().parameters[0] + '\n';
    }

    weaponC = function(id,bool) {
    var id, bool
    if (bool === undefined) {bool = false}
    return $gameParty.hasItem($dataWeapons[id], bool)
    }

    eval(script);
    return true;
    }




    So far it works perfectly, it returns true or false adequately and I can call it without any problem inside a script call event command.


    My problem is that when I use it inside a conditional branch: script, it returns an error: "weaponC is not defined".


    What makes the behaviour even more odd is that if I use a script command, any, even an empty one, just before the conditional then it works.


    So: Use it in a script event command : works all the time


    Use it in a conditional : script, returns an error


    Use it in a conditional: script after a normal script command: works.


    Any idea why?


    It's doing this for pretty much all my other commands too. An easy fix would be to always use an empty script call before my function, but if that can be avoided, all the better.


    I know I could just use the regular command but the point is to simplify the syntax...


    Thanks for the help!
  11. Hi just wanna ask if is a way to change the actor battle command to show a vertical list instead the horizontal list:


    This:


    attack guard skill item


    Instead of:


    attack


    guard


    skill


    item 
  12. Hey there. Yanfly basically send me here. xD


    So I was looking for a way to implement poison effects that deal a fixed amount of damage without killing the target afterwards. I used Quasi Params Plus, but that causes some errors with another of Yanfly's scripts I am using. So Yanfly showed me his DOT effect:


    http://yanfly.moe/2016/04/30/tips-tricks-damage-over-time-stacking-rpg-maker-mv/


    This is basically what I want, but it kills the target, which it shouldn't do. So, basically, what do I need to change so it no longer kills the target upon receiving damage?
  13. change the var damage line to read:


    var damage = Math.min(stacks * 100, target.hp - 1);


    This should result in it only doing the smaller of the two damages, the stacks of poison * 100 or the target's HP - 1. So if the poison would have done 200 damage and they only have 150 HP it should do 149.
  14. Yep, works, thanks!
  15. Real simple.  How do I check if a critical hit has occurred in the damage formula.  

    In relevance to my game, the characters can get a passive state that will make critical hits instantly kill the enemy.  If enemies are immune to instant death, it will just deal flat damage instead.  I have all of it worked out, but I don't know how to check to see if a critical hit has occurred.  any help would be appreciative.    
  16. Been awhile, trying my hand at learning again with no experience. I have a few questions (forgive most likely my ignorance):

    1. I want to create a script call in a plugin that I only have to input in to an event once, while the plugin defines multiple other script calls to be executed.

    Ex; 
    Function I want to call once - "Thief_Battle"
     In this function, starts calling outside scripts such as $gameScreen.startFadeOut(x) -> $gameSwitches.setValue(x, true/false); -> 
    $gameInterpreter.wait(frames);, etc

    After this, I want to create an event and just have it execute the overall script call (or plugin command), where the function defined by code handles the rest.

    2. How do I go about changing player input from the main actor to another event?
  17. The following forces an action in battle:


    $gameParty.members()[0].forceAction(1, 1);
    BattleManager.forceAction($gameParty.members()[0]);
    BattleManager.processForcedAction();


    But what can I call to then end the player's turn and go to the enemy's turn?


    (I have a button for Attack which on pressed forces the attack action.)
  18. lithkast said:
    Real simple.  How do I check if a critical hit has occurred in the damage formula.  

    In relevance to my game, the characters can get a passive state that will make critical hits instantly kill the enemy.  If enemies are immune to instant death, it will just deal flat damage instead.  I have all of it worked out, but I don't know how to check to see if a critical hit has occurred.  any help would be appreciative.    

    if (target.result().critical){


    [insert code]


    }
  19. Hi,


    I'm using the Yanfly's JobPoints for RPG Maker MV. 


    With "loseJp actorId jp" I can take JP away and learn for instance a skill. But how I do an if-condition with the current JP of an actor? 


    if( actorJP >= 300) { 


      loseJp 1 300;


      learn skill etc..;


    }


    the player shouldn't be able to learn a skill if he has insufficient points. 


    I know I could use Yanfly's SkillLearnSystem, but I want "visual" Skill Trees which I can not realize with that plugin.


    thx for help.
  20. I'm trying to correct a stupid problem in an action sequence, and to do it, I need to know if the target of an action is an enemy or an ally.


    Does anyone know what function to call to check this in a true/false way?


    target.isAlly() and target.isFriendly() are all I can come up with right now, and neither of them work.


    thanks in advance.