MV script call for movement route based on actor state?

Discussion in 'Learning Javascript' started by xoferew, Aug 3, 2019.

  1. xoferew

    xoferew Veteran Veteran

    Messages:
    104
    Likes Received:
    132
    First Language:
    English
    Hi, I'd appreciate any advice. I thought I could use a script call to make events (roaming enemies) move toward the player unless a certain actor had a certain state, in which case the event would move away from the player. When I look at the script call list I see moveType = 0 for fixed, 1 for random, and 2 for approach, with no option for move away even though there is a movement command "Move away from Player." Could 3 possibly be move away?

    A separate issue is I am quite ignorant about script calls so my sad attempt at putting this as the custom movement route failed:
    if $gameActors.actor(1).isStateAffected(50) {$gameMap.event(8)._moveType = 0} else {$gameMap.event(8)._moveType = 2}

    This gives "Unexpected Identifier."

    Thanks to anyone who can point me in the right direction!
     
    #1
  2. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,854
    Likes Received:
    9,633
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    = is "is". "is equal to" is ==
    Edit: Sorry, I'm still sleeping. You're missing brackets surrounding your if condition.
     
    #2
    xoferew likes this.
  3. xoferew

    xoferew Veteran Veteran

    Messages:
    104
    Likes Received:
    132
    First Language:
    English
    Thanks so much, Poryg! No more error messages! So if I set moveType to 0 (fixed) if state is ON and 2 (approach) if state is OFF then my enemy (as intended) either stands still or moves towards the player. But when I change the state it's not noticing the change and reevaluating the conditions until I transition off map and back on. If that is what it is, fine.

    However, when I experimentally put moveType to 3 if state is ON and 2 if OFF, then something different happens. The event stands still when the state is ON, the same as moveType 0. But as soon as I flip a switch to turn OFF the state, the enemy begins moving towards me, as if it is now a parallel process? But turning it ON has no effect until I leave the map and come back.

    Looks like this:
    if ($gameActors.actor(1).isStateAffected(50)) {$gameMap.event(8)._moveType = 3} else {$gameMap.event(8)._moveType = 2}


    Thanks for any further insight or information!
     
    #3
  4. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,556
    Likes Received:
    977
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    I think we can fix this part. Try putting this line after the state is changed:
    Code:
    $gameMap.requestRefresh()
     
    #4
  5. xoferew

    xoferew Veteran Veteran

    Messages:
    104
    Likes Received:
    132
    First Language:
    English
    Thank you, but I must be doing something wrong as it's not having an effect. :( Is this what you meant?
    [​IMG]
    (Sorry, please bear with me as I attempt to figure out how to include images properly...)
     

    Attached Files:

    #5
  6. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,209
    Likes Received:
    3,539
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA

    I've moved this thread to Learning JavaScript. Please be sure to post your threads in the correct forum next time. Thank you.


    Perhaps you can find the help you need with that last part here.
     
    #6
  7. xoferew

    xoferew Veteran Veteran

    Messages:
    104
    Likes Received:
    132
    First Language:
    English
    Hope it's okay to bump this.

    I'm still not having success. :( I have three questions/issues. 1. $gameMap.refresh() doesn't have an effect, the event still approaches until I leave the map and return, whereupon the event stands still . 2. To copy this formula for each event do I need the event's ID or can I use "this" -- if so, I haven't been successful figuring out the syntax. 3. I see in the script call list there is "Game_Character.ROUTE_MOVE_AWAY = 11;" Would that be useful and if so, how to implement? Sorry for my cluelessness. ^_^;
     
    #7

Share This Page