Yes, that is the correct scripted check. Much easier than the evented one, right? 😛
Ruby/RGSSx questions that don't deserve their own thread
RGSSx Script SupportCan someone please explain to me what the functional difference is between these two script calls in simple terms?
In a Set Move route command, 'Repeat' box checked
turn_toward_character($game_map.events[29])
where 29 is the id of the event that the the NPC will turn towards
In the custom move route of the NPC (and the +2 or -2 is because that was the distance away that I wanted the player to influence the behaviour of the NPC)
self.x.between?($game_player.x - 2, $game_player.x + 2) && self.y.between?($game_player.y - 2, $game_player.y + 2) ? turn_toward_player : set_direction(2)
Is the more complicated second one needed because it is the player, rather than another event, that the NPC is turning towards? Or is it solely because of the specification of the distance away? Can the first one be used to turn towards the player?
I am about to need an event to turn towards the player, and don't know on what basis I should choose between these.
Thanks.
In a Set Move route command, 'Repeat' box checked
turn_toward_character($game_map.events[29])
where 29 is the id of the event that the the NPC will turn towards
In the custom move route of the NPC (and the +2 or -2 is because that was the distance away that I wanted the player to influence the behaviour of the NPC)
self.x.between?($game_player.x - 2, $game_player.x + 2) && self.y.between?($game_player.y - 2, $game_player.y + 2) ? turn_toward_player : set_direction(2)
Is the more complicated second one needed because it is the player, rather than another event, that the NPC is turning towards? Or is it solely because of the specification of the distance away? Can the first one be used to turn towards the player?
I am about to need an event to turn towards the player, and don't know on what basis I should choose between these.
Thanks.
Exactly that.
self.x.between?($game_player.x - 2, $game_player.x + 2) && self.y.between?($game_player.y - 2, $game_player.y + 2) ? turn_toward_player : set_direction(2)
The teal colored part is used as a fork condition (self is within a 2x2 square from the player). If it is fulfilled, the purple colored command is executed (turn towards the player), otherwise the brown one (turn down).
The condition might not work correctly for looped maps. There is a function that takes the map loop border into account, but I'm not sure what it was called. Something like self.distance_x_from($game_player.x)
Thank you.
So if I just want the NPC to turn towards the player, irrespective of distance, then I could use the first formulation, in a set move route, 'Repeat' checked, and it would just be
turn_toward_player. I wouldn't need to specify anything further. Is that correct?
EDIT That wasn't as clear as perhaps it should have been - but anyway, having checked it myself, I can't see anything wrong, as it turns when the player is still some distance away, which is what I wanted.
Once more, thanks for the clarification.
So if I just want the NPC to turn towards the player, irrespective of distance, then I could use the first formulation, in a set move route, 'Repeat' checked, and it would just be
turn_toward_player. I wouldn't need to specify anything further. Is that correct?
EDIT That wasn't as clear as perhaps it should have been - but anyway, having checked it myself, I can't see anything wrong, as it turns when the player is still some distance away, which is what I wanted.
Once more, thanks for the clarification.
Sorry about that.
Yes, turn_towards_player should be correct, even though you probably don't need a script command for that as it is already a built in move command option.
The problem is that the fork condition does not take the map wrapping into account. When the player happens to be near the left side of the map and the event stays near the right side so they seem to be close to each other, the fork condition will still calculate a huge difference in their coordinates and does not trigger.
(For example, if you have a 100x100 map, the player is located at (0, 40) and the event at (98, 40) it seems the player stands two tiles to the right of the event. The fork condition will conclude that the player stands 98 tiles to the left of the event instead.)
An alternative for the teal colored part could be for example:
distance_x_from($game_player.x).between?(-2, 2) && distance_y_from($game_player.y).between?(-2, 2)
Of course, if you don't use looping maps, that issue should not be a problem. 🙂
Yes, turn_towards_player should be correct, even though you probably don't need a script command for that as it is already a built in move command option.
The problem is that the fork condition does not take the map wrapping into account. When the player happens to be near the left side of the map and the event stays near the right side so they seem to be close to each other, the fork condition will still calculate a huge difference in their coordinates and does not trigger.
(For example, if you have a 100x100 map, the player is located at (0, 40) and the event at (98, 40) it seems the player stands two tiles to the right of the event. The fork condition will conclude that the player stands 98 tiles to the left of the event instead.)
An alternative for the teal colored part could be for example:
distance_x_from($game_player.x).between?(-2, 2) && distance_y_from($game_player.y).between?(-2, 2)
Of course, if you don't use looping maps, that issue should not be a problem. 🙂
I'm not using looping maps in this project, but I have copied that alternative into my "useful script calls for all eventualities" document.
So thank you.
So thank you.
If I wanted to change the x and y location of battle animations in scripts where and how would I do this?
Based on the information in the help the x and y is for each cell located in a frame of the animation stored in a 2 dimensional array. Meaning to do this properly I believe I am going to have to use a for loop based on the number of frames then another one for the number of cells in a frame. Is my understanding of what I need to do correct (would this be the most efficient way to do this)?
Thanks in advance.
Based on the information in the help the x and y is for each cell located in a frame of the animation stored in a 2 dimensional array. Meaning to do this properly I believe I am going to have to use a for loop based on the number of frames then another one for the number of cells in a frame. Is my understanding of what I need to do correct (would this be the most efficient way to do this)?
Thanks in advance.
Script call to end game?
The following didn't work:
The following didn't work:
Code:
SceneManager.goto(Scene_End)
Code:
SceneManager.call(Scene_End)
Do you want the game over screen or just shutdown?
SceneManager.call(Scene_Gameover) is for game over screen.
SceneManager.exit to shutdown.
SceneManager.call(Scene_Gameover) is for game over screen.
SceneManager.exit to shutdown.
Ahh thanks.
Is there any way to change an already initialized viewport's X/Y position?
I can't seem to do this...
And since I can't see the default Viewport class, I can't even make a working method for this. >.>
When I try to specify an X or Y value for a viewport, it says that those methods are not defined (x= and y=). So, I tried to define them, but nothing I do works. -.-
Anyone knows how to do this?
I can't seem to do this...
And since I can't see the default Viewport class, I can't even make a working method for this. >.>
When I try to specify an X or Y value for a viewport, it says that those methods are not defined (x= and y=). So, I tried to define them, but nothing I do works. -.-
Anyone knows how to do this?
Yes. When you initialize a viewport, you set its rect's parameters. The X and Y positions of the viewport are the X and Y positions of its rect. Simply change its rect's X and Y.
viewport.rect.x = new_xviewport.rect.y = new_yCheck the Viewport page from the help file for more information. 🙂
Lmao, I was so distracted by searching for the X and Y properties in the help files, that I didn't notice the rect property. 😀
Frustrated by it, I changed from sprite to an invisible window, so I managed to fix my issue in a different way (which actually made my job easier, because I could move it together with the other things on the same viewport effortlessly), but it is certainly good to know that it can be done!
Thanks for the info!
Frustrated by it, I changed from sprite to an invisible window, so I managed to fix my issue in a different way (which actually made my job easier, because I could move it together with the other things on the same viewport effortlessly), but it is certainly good to know that it can be done!
Thanks for the info!
hey, I don't really know where to look at... is there any way to change the animations so that they are displayed above star passability?? best would be if I can turn it on or off with a script or something or changing the value directly... ^^"
thanks in advance
thanks in advance
So like, help me out here. I use a few Japanese scripts in my project and prefer not to "translate it" to avoid breaking it. but I want to try and alias some of the modules due to some of the contents requiring translating.
For Example
For Example
You're welcome!
Hello! Try changing the z value in Sprite_Base. Search for "sprite.z".
What do you mean by "alias some of the modules"? You can't use alias with a module. What are you trying to do? You could always keep a .txt or .rb with the original code in case you want to go back to the original settings.
Basically any function that draws text in game, I want to be aliased/overwritten with a custom snippet due to any updates the main script may have. Through I think a direct overwrite might work as well.
1: Is there a script that enables multiple enemies to attack at the same time?
2: Is there a script that enables "hit" animations the moment damage is displayed?
3: Is there a script where enemies periodically make "fidget" sounds when idle?
4: And is there a script that displays multiple damage counters at once, in different locations relative to the target?
Here's a couple videos for reference:
#1-3 - 6:01 - Watch how the magical attacks are displayed when a character is hit by it, and how several creatures can attack at once during turns. Also note the sounds made by the other monsters throughout the dungeon when idle.
#4 - 2:47 - Watch how a character named Gadot deals damage during combat:
2: Is there a script that enables "hit" animations the moment damage is displayed?
3: Is there a script where enemies periodically make "fidget" sounds when idle?
4: And is there a script that displays multiple damage counters at once, in different locations relative to the target?
Here's a couple videos for reference:
#1-3 - 6:01 - Watch how the magical attacks are displayed when a character is hit by it, and how several creatures can attack at once during turns. Also note the sounds made by the other monsters throughout the dungeon when idle.
#4 - 2:47 - Watch how a character named Gadot deals damage during combat:
You're asking for a script so that deserves it's own thread... anyway, you can do all that using scripts
I wasn't sure, so posted it here just in case. I might commission a scripter at some point to make a combination of the 4 functions in a script, I am the last person in the world who should be touching Ruby.
Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/