Shoukang

Veteran
Veteran
Joined
Jan 28, 2021
Messages
64
Reaction score
77
First Language
Chinese
Primarily Uses
RMMV
Hello

Sorry for delayed reply.
I don't have the time I used to have when I created the script but I have updated my script to do a null check
I also added srpgThroughTag compatability

Pathfinding works by creating a map (as an assocative array) which lists each tile as either passable or not.
A tile is flagged as impassable if its defined in the editor or an event is on it (with object tag / active unit)
The new fix adds a check to change a tile to be impassable only if terrainTag == 0 or if terrainTag of tile is greater the srpgThroughTag
Thanks! I tried your code and it works well! I just find one minor issue.
On line 625, you inserted the null check, I think you should also add
else {
targettable = false;}
for the null check. Or the empty actor event will still be recognized as targettable.
Recently, I also find another issue. When the map's height is longer than its width, and you have your actors at the bottom of the map, the enemies won't reach there.
I think it's because of the code around line 147.
if (location.distanceFromLeft < 0 || location.distanceFromLeft >= gridSize || location.distanceFromTop < 0 || location.distanceFromTop >= gridSize) { // location is not on the grid--return false return 'Invalid';
The gridsize equals the grid.length, which is the width of the map. so if the height exceeds the width it will become invalid. I tried to define a new variable which equals the map's height but somehow it failed......
Another suggestion (which might be greedy) is to consider the terrain cost in your plugin. Currently, if the AI is around tiles with terrain cost above 1, they will not move. The terrain cost system will affect the flying units so I'm not using it now... but it can be a future improvement.
 

boomy

Veteran
Veteran
Joined
Jan 6, 2013
Messages
177
Reaction score
149
First Language
English
Primarily Uses
RMMV
Thanks! I tried your code and it works well! I just find one minor issue.
On line 625, you inserted the null check, I think you should also add
else {
targettable = false;}
for the null check. Or the empty actor event will still be recognized as targettable.
Recently, I also find another issue. When the map's height is longer than its width, and you have your actors at the bottom of the map, the enemies won't reach there.
I think it's because of the code around line 147.
if (location.distanceFromLeft < 0 || location.distanceFromLeft >= gridSize || location.distanceFromTop < 0 || location.distanceFromTop >= gridSize) { // location is not on the grid--return false return 'Invalid';
The gridsize equals the grid.length, which is the width of the map. so if the height exceeds the width it will become invalid. I tried to define a new variable which equals the map's height but somehow it failed......
Another suggestion (which might be greedy) is to consider the terrain cost in your plugin. Currently, if the AI is around tiles with terrain cost above 1, they will not move. The terrain cost system will affect the flying units so I'm not using it now... but it can be a future improvement.
After trouble shooting for about 5 hours I fixed the bug where if the map height is greater than its width, units would stop moving at coordinate y = map.height.

I don't know how I fixed it but I did change the conditional from gridSize to $gameMap.width() and $gameMap.height(). I also realised i was referencing variables (mixing x and y values) incorrectly which seems to actually fix the problem


I've pushed the new update to my github

I'll consider adding support to terrain support (and if so, zone of control)
Which terrain control plugin are you using? The srpg_TerrainControl.js one or RangeControl.js?

EDIT:

I've added compatability with RangeControl.js and its implementation of terrain movement restriction. It's a hack compatability job but it allows units to traverse through tiles with movement cost of more than 1 (which the original script assume all tiles would be)

The flow for movement selection (at least with nearest/furthest target) is as follows:
1. Go through all events on the map and pick all valid targets
2. Find the shortest route to all valid targets ignoring movement cost
3. Find the location that is closest to the best target
4. Work out a set of movement sequences to get to the best square and ensure its reachable
5. Set the location via aiPos and let SRPG_AIcontrol.js do the rest (match the location with the unit's move table (which is affected by terrain movement cost) and if valid move unit to location)

The issue was SRPG_AIControl creates moveTables (an associative array that contains how 'far' a map tile is from the unit based on unit's srpgMove and terrain passability/ZoC) which is slightly different to how SRPG_Pathfinding.js creates its own 'moveTable' (I called it grid) - my implementation ignores terrain passability

I fixed this issue by making routes that go through 'terrain-restricting-tiles' result in a valid destination as what is defined in the unit's moveTable range.

The issues are as follows:

1. I only changed the PathToCoordinate function that just spits out a bunch of directions to the target destination but not the PathTo function that actually calculates the best path to take. This means units will always take the shortest route, even if it means they travel through really slowly along tiles that restrict movement.

1615991252517.png


2. Zone of Control is not implemented and any unit blocked by zone of control will not move as they will have a 'best location' set outside its moveTable. Probably less of an issue because if a unit is within a ZoC it's probably not going to use a predictive formula to find the best path to the target as the target is within range (may be an issue for AI that ignore targetting when valid targets are within movement range).
 
Last edited:

strbxl

Villager
Member
Joined
Aug 14, 2016
Messages
13
Reaction score
1
First Language
French
Primarily Uses
N/A
Hello everybody, i have some issues trying to make traps and spiked floors in SRPG Engine. Maybe someone here can help me ?!

First:
I want to make a spiked floor that activates or deactivates every turn. If you step on it while its activated you get floor damage, if you step on it while deactivated, you don't get floor damage.

I made an event with <damageFloor> event note and two pages, i made the first page empty with no sprite and the second page has the spiked floor sprite and is only active when the trap switch is on.

However when my units step on the deactivated trap, it still deals them the damage.

Then:
All my traps only deal damage when the unit finishes their turn on the trap event, i would like it if they got floor damage just by passing through the trap, how is that possible ?


Thanks in advance !

PS: I own all the YEP plugins and i would buy more plugins if it could solve my problems.
 

Shoukang

Veteran
Veteran
Joined
Jan 28, 2021
Messages
64
Reaction score
77
First Language
Chinese
Primarily Uses
RMMV
After trouble shooting for about 5 hours I fixed the bug where if the map height is greater than its width, units would stop moving at coordinate y = map.height.

I don't know how I fixed it but I did change the conditional from gridSize to $gameMap.width() and $gameMap.height(). I also realised i was referencing variables (mixing x and y values) incorrectly which seems to actually fix the problem


I've pushed the new update to my github

I'll consider adding support to terrain support (and if so, zone of control)
Which terrain control plugin are you using? The srpg_TerrainControl.js one or RangeControl.js?

EDIT:

I've added compatability with RangeControl.js and its implementation of terrain movement restriction. It's a hack compatability job but it allows units to traverse through tiles with movement cost of more than 1 (which the original script assume all tiles would be)

The flow for movement selection (at least with nearest/furthest target) is as follows:
1. Go through all events on the map and pick all valid targets
2. Find the shortest route to all valid targets ignoring movement cost
3. Find the location that is closest to the best target
4. Work out a set of movement sequences to get to the best square and ensure its reachable
5. Set the location via aiPos and let SRPG_AIcontrol.js do the rest (match the location with the unit's move table (which is affected by terrain movement cost) and if valid move unit to location)

The issue was SRPG_AIControl creates moveTables (an associative array that contains how 'far' a map tile is from the unit based on unit's srpgMove and terrain passability/ZoC) which is slightly different to how SRPG_Pathfinding.js creates its own 'moveTable' (I called it grid) - my implementation ignores terrain passability

I fixed this issue by making routes that go through 'terrain-restricting-tiles' result in a valid destination as what is defined in the unit's moveTable range.

The issues are as follows:

1. I only changed the PathToCoordinate function that just spits out a bunch of directions to the target destination but not the PathTo function that actually calculates the best path to take. This means units will always take the shortest route, even if it means they travel through really slowly along tiles that restrict movement.

View attachment 183220


2. Zone of Control is not implemented and any unit blocked by zone of control will not move as they will have a 'best location' set outside its moveTable. Probably less of an issue because if a unit is within a ZoC it's probably not going to use a predictive formula to find the best path to the target as the target is within range (may be an issue for AI that ignore targetting when valid targets are within movement range).
Thanks for your work! I'm using the RangeControl.js plugin for terrain cost.
 

posfan12

Veteran
Veteran
Joined
Jun 4, 2014
Messages
74
Reaction score
7
First Language
English
Primarily Uses
RMMV
Can I use the same map for exploration and combat or do I need to create separate maps?
 

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
863
Reaction score
467
First Language
German
Primarily Uses
RMMV
Hello everybody, i have some issues trying to make traps and spiked floors in SRPG Engine. Maybe someone here can help me ?!

First:
I want to make a spiked floor that activates or deactivates every turn. If you step on it while its activated you get floor damage, if you step on it while deactivated, you don't get floor damage.

I made an event with <damageFloor> event note and two pages, i made the first page empty with no sprite and the second page has the spiked floor sprite and is only active when the trap switch is on.

However when my units step on the deactivated trap, it still deals them the damage.

Then:
All my traps only deal damage when the unit finishes their turn on the trap event, i would like it if they got floor damage just by passing through the trap, how is that possible ?


Thanks in advance !

PS: I own all the YEP plugins and i would buy more plugins if it could solve my problems.
about "first":
as far i know, the eventnote <damageFloor> makes an event "a floordmg event"
(its not the img that makes it an dmgFloor)
-> so it doesnt matter how much eventpages u use..
=> if you want to deactivate the dmg floor, you would have to change the eventnote via script and perhaps even need to initizialise the event again..
OR
replace the event with another event which has the same eventIMG but not that eventnote "<damageFloor>"
(this second solution is probably easier because it could be done with eventing.. for example with placeholder events or eventspawner plugin to spawn and unspawn the event..)
edit
i probably could add a switch as restriction to activate/deactivate all dmg floors , by editing the plugin itself, but thats future musik till i get to rework some plugins..
(currently i have still 5 units to rework from the 40 chars/units which i wanted to finish before i start focus on JS again for more infos read this here->#1,456 & here#1,459)


about "then":
I guess that could be made without any plugin usage just by using the event itself and its xy position..
-so that every "active unit" that moves on that position will get some hp loss
-> therefor you would need some custom script insert in the event page and a "frame wait" to make sure that happen only 1 time.. perhaps even add a switch to avoid infinite hp loss incase the unit stays on that position..
=> so this needs a "if condition" about the dmgfloor_event position and the position of the "active event"..
and if these positions are the same, activate the script that does hp loss on the "active unit"
edit
you could probably also use the event trigger "touch event", to do hp loss on the "active Unit".. thats probably the better solution .. instead of using the xy position


about "PS":
to do that you need to get a bit into scripting , buying plugins wont help because the srpg plugins are free anyway..

(i allready explained a few times in this thread how "$gameSystem.EventToUnit(eventID)[1]" works and how to use "hp gain" ect -> here#1,482 for example)

-------
-------
@posfan12
Can I use the same map for exploration and combat or do I need to create separate maps?
probably yes, if you make sure that all unit events that are used will only be activated if the battlemap(srpgBattle) is ON..
also you have to make sure that the "gamer" cant move the "gameplayer" over any "battlemap making events" this would do unwanted conflicts..
 
Last edited:

posfan12

Veteran
Veteran
Joined
Jun 4, 2014
Messages
74
Reaction score
7
First Language
English
Primarily Uses
RMMV
I am new to MV. I am copying stuff from the demo into my game. I am trying to start combat and move to another map but I get an error.


Clipboard-3.png

How do I debug the error? There are no descriptive remarks. Which is the first and last of the chain? Top or bottom? How do I tie what's in the log to what's in the game editor? Should I upload my work? Thanks.
 
Last edited:

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
863
Reaction score
467
First Language
German
Primarily Uses
RMMV
I am new to MV. I am copying stuff from the demo into my game. I am trying to start combat and move to another map but I get an error.


View attachment 183358

How do I debug the error? There are no descriptive remarks. Which is the first and last of the chain? Top or bottom? How do I tie what's in the log to what's in the game editor? Should I upload my work? Thanks.
this isnt enough information to tell you anything,you can hit f8 for more infos..
(there is no info about your plugin manager for example)
But i would advice you to use ryans demo as base..
 
Last edited:

Shoukang

Veteran
Veteran
Joined
Jan 28, 2021
Messages
64
Reaction score
77
First Language
Chinese
Primarily Uses
RMMV
I was testing skills and noticed some weird behavior regarding counterattacks and the AreaAttack plugin. Looks like a bug.

My actor has an attack with a range of 2 and area range of 1. From where he's standing, he can hit all three enemies with it at once by targetting the one in the middle. These enemies all have a counterattack range of 1. Because of how area attacks work, the player selects a target for the attack and then "confirms" the decision by selecting one of the enemies within area range.

If I confirm the attack by selecting the enemy on the left, all three of them are able to counterattack. If I confirm the attack by selecting either of the other two enemies, none of them are able to counterattack. I would think that the left enemy would be the only one to counterattack regardless of how I confirm the skill.
Hi Jonruy,
This is also what I want to optimize, after checking the codes in the SRPE_AOE.js, I find the solution.
1616471850944.png
On line 671(maybe shift a few lines, but absolutely below this line: $gameTemp.setTargetEvent(nextaction.event);
add the code I wrote:
$gameTemp.setSrpgDistance($gameSystem.unitDistance($gameTemp.activeEvent(), nextaction.event));
This should refresh the distance between the next target and the user.
If you want to use the area attack plugin you can do something similar, I guess add this code below line 232:
$gameTemp.setSrpgDistance($gameSystem.unitDistance($gameTemp.activeEvent(), nextaction[3]);

@Doktor_Q Maybe you can update this in the SRPE_AOE plugin (if my modification is desirable).
 
Last edited:

Shoukang

Veteran
Veteran
Joined
Jan 28, 2021
Messages
64
Reaction score
77
First Language
Chinese
Primarily Uses
RMMV
A minor error I discovered: when using <srpgUncounterable> on an enemy who would normally be able to counter attack, the pop up that shows the damage they would be able to do still appears, despite the fact that they aren't able to counter attack.

Also, <srpgUncounterable> does not appear in the tag list of the core, despite being added in.
Hi,
To check uncounterable you can add this code in the srpg core plugin. Check my screenshot to see where to add it.
if (this._actionArray[1].currentAction().item().meta.srpgUncounterable) { action = null; }
1616512668301.png

I also did another optimization in the core. The selector can't move when you open the enemy status window. If the enemy has a large attack range, it will be hard to see the entire attack range. so I enabled it as the screenshot shows.
1616513292492.png

In the range control, the movetable is weird as I mentioned before#1,418. As long as the unit has remaining move point, it can step on the next tile, no matter how high that tile cost is. At least this is not how fire emblem does this...... So I add this condition check to fix it.
@boomy , if you are optimizing the pathfinding plugin please consider this.
1616514802213.png
 
Last edited:

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
863
Reaction score
467
First Language
German
Primarily Uses
RMMV

@Shoukang

- thanks for your effords in working on JS stuff for srpg
(even i i didnt had the time to look into it yet^^)
---------


@ ALL

I am happy to anounce that i finished the 39 Free chars for 4 Directional weapon usage in the rpg maker and made for SRPG!
(used for mapbattle)

( next thing will be to get into JS again in order to first make some edits for map battle usage, to make sure that the active unit sprite is allways displayed above the target unit sprite .. after that ill rework some of my selfmade srpg_plugins)

these chars can be found here:
 
Last edited:

Jonruy

Villager
Member
Joined
Sep 16, 2013
Messages
19
Reaction score
0
First Language
English
Primarily Uses
Hi Jonruy,
This is also what I want to optimize, after checking the codes in the SRPE_AOE.js, I find the solution.
View attachment 183662
On line 671(maybe shift a few lines, but absolutely below this line: $gameTemp.setTargetEvent(nextaction.event);
add the code I wrote:
$gameTemp.setSrpgDistance($gameSystem.unitDistance($gameTemp.activeEvent(), nextaction.event));
This should refresh the distance between the next target and the user.
If you want to use the area attack plugin you can do something similar, I guess add this code below line 232:
$gameTemp.setSrpgDistance($gameSystem.unitDistance($gameTemp.activeEvent(), nextaction[3]);

@Doktor_Q Maybe you can update this in the SRPE_AOE plugin (if my modification is desirable).
Good find! I may have to work AoE back into my game again with this.

My next task is building a mechanic where certain skills have an optimal range, and using a skill outside that range has an accuracy penalty. I think I can do this with just Yanfly's HitAccuracy plugin. For testing purposes, I have this code in the "User Magical Hit" parameter:

if ($gameSystem.unitDistance($gameTemp.activeEvent(), $gameTemp.targetEvent()) == 2) { 1; } else { 0; }

This doesn't appear to do anything, though. I might be referencing the wrong variables, or maybe just referencing them improperly. Thoughts, anyone?
 

Shoukang

Veteran
Veteran
Joined
Jan 28, 2021
Messages
64
Reaction score
77
First Language
Chinese
Primarily Uses
RMMV
Good find! I may have to work AoE back into my game again with this.

My next task is building a mechanic where certain skills have an optimal range, and using a skill outside that range has an accuracy penalty. I think I can do this with just Yanfly's HitAccuracy plugin. For testing purposes, I have this code in the "User Magical Hit" parameter:

if ($gameSystem.unitDistance($gameTemp.activeEvent(), $gameTemp.targetEvent()) == 2) { 1; } else { 0; }

This doesn't appear to do anything, though. I might be referencing the wrong variables, or maybe just referencing them improperly. Thoughts, anyone?
I think you should write return 1; and return 0; instead of 1 and 0.
If you don't have the word return, your method will return nothing.
Also, you can always use console.log(......); to see what you get, it's very powerful when you debug.
For example, console.log($gameSystem.unitDistance($gameTemp.activeEvent(), $gameTemp.targetEvent())); will show you the distance in console.
console.log($gameTemp.activeEvent()); will show you the activeEvent.
Put the console.log(...) code before your code incase your code report error and the console.log(...)didn't process......

Press F8 in game to check the console.
 
Last edited:

posfan12

Veteran
Veteran
Joined
Jun 4, 2014
Messages
74
Reaction score
7
First Language
English
Primarily Uses
RMMV
Where would the best place be to add the TDDP_BindPicturesToMap.js script to the plugins list? Thanks.

Also, every few seconds I get a Loading Error where the game tries to load a PNG with a thirteen digit file name. Any idea what that's about?
 
Last edited:

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
863
Reaction score
467
First Language
German
Primarily Uses
RMMV
Where would the best place be to add the TDDP_BindPicturesToMap.js script to the plugins list? Thanks.

Also, every few seconds I get a Loading Error where the game tries to load a PNG with a thirteen digit file name. Any idea what that's about?
i didnt used that plugin, you gotta try it out .. i would try it out at the end of the srpg plugins , and before all SRPG plugins.. and look what works better

sry no idea (perhaps just make sure that pngs have shorter names)
 
Last edited:

posfan12

Veteran
Veteran
Joined
Jun 4, 2014
Messages
74
Reaction score
7
First Language
English
Primarily Uses
RMMV
It's a random name I think. I noticed the name changes each time I load the game.

[ed]

It may be because I changed tilesets without repainting the map and the new tileset only has Page C. (I use parallax so tilesets are mostly useless to me except as temporary markers.)

[ed]

Whatever the problem was it seems to be fixed now.
 
Last edited:

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
863
Reaction score
467
First Language
German
Primarily Uses
RMMV
It's a random name I think. I noticed the name changes each time I load the game.
i am not sure if i understand correctly..
a png is an IMG or not?
and all IMGs in your project are named and implemented to the project by yourself..
so how can their name be random?

(has this something to do with a plugin that changes the names or anything??)
 

posfan12

Veteran
Veteran
Joined
Jun 4, 2014
Messages
74
Reaction score
7
First Language
English
Primarily Uses
RMMV
In the past I was using Yanfly Core Engine to change the screen width and height. Is there a simpler alternative or should I just stick with Yanfly?

[ed]

Never mind. There already are options within the SRPG demo for this.
 
Last edited:

posfan12

Veteran
Veteran
Joined
Jun 4, 2014
Messages
74
Reaction score
7
First Language
English
Primarily Uses
RMMV
i am not sure if i understand correctly..
a png is an IMG or not?
and all IMGs in your project are named and implemented to the project by yourself..
so how can their name be random?

(has this something to do with a plugin that changes the names or anything??)
The error message was asking for a PNG image with a seemingly random 13 digit name. The exact numbers in the name changed every time I restarted the game. See:

Clipboard-4.png

Anyway, I think I fixed the problem as I described in my earlier post. The error message has gone away.
 

Latest Threads

Latest Profile Posts

Bengawan Solo with fantasy style arrangement. :D
So I just got my computer back (Was posting stuff on my phone) But now my dang monitor's broken! I'll need to get a new one, which means... JOBS! Yaaay... When I get a new monitor, I'll post picture of one of my RPGMMV projects.
Wish me luck... :kaodes:
Had to clean up disk space because Windows Updates was having my primaries' disk space for breakfast, lunch and dinner. I guess the clean up thingy doesn't work or something because there were 15gigs of old update files in it.
Monday morning, and the sudden message: Hey, can you set up a full second lesson about pixel art till tomorrow?

Forum statistics

Threads
115,890
Messages
1,093,756
Members
151,138
Latest member
SouthernGamer
Top