About implementing an algorithm

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
Greetings, I am new here so my apologies if I posted this in the wrong section..

I am currently studying this algorithm which is A* pathfinding algorithm..

My question if I am going to apply this in rpgmaker.. where should I start?

Here is a good simulator of A* algorithm(what I am trying to implement is the one with bi-directional)

http://qiao.github.io/PathFinding.js/visual/

Thanks in Advance!
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
Hello there! 

There are lots of ways, but for example: You could write the algorithm in a module and then include the module in Game_CharacterBase, or just write the methods that you need in that class. Once the algorithm has found the path and you have all the nodes with its parents, you'll have to "reconstruct the path" by getting the direction of each node, first relatively to the character you want to move and then to the node where the character has moved, so you can create a MoveRoute (see help file).

That is pretty much where you should start, if you have some concise questions, let me know.

Cheers.
 

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
Hello there! 

There are lots of ways, but for example: You could write the algorithm in a module and then include the module in Game_CharacterBase, or just write the methods that you need in that class. Once the algorithm has found the path and you have all the nodes with its parents, you'll have to "reconstruct the path" by getting the direction of each node, first relatively to the character you want to move and then to the node where the character has moved, so you can create a MoveRoute (see help file).

That is pretty much where you should start, if you have some concise questions, let me know.

Cheers.
I see tnx :o btw another question sir.. is there a way to make the actor(our main character) automatically move to an enemy? or an npc move to another npc?
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
Game_Character has this built in method:

#-------------------------------------------------------------------------- # * Move Toward Character #-------------------------------------------------------------------------- def move_toward_character(character) sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx.abs > sy.abs move_straight(sx > 0 ? 4 : 6) move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0 elsif sy != 0 move_straight(sy > 0 ? 8 : 2) move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0 end endBut as you can see, it literally "moves it toward" the target, no pathfinding is performed. Once you have implemented your pathfinding, you will be able to move characters to any node on the map, and consequently to any character on the map (if you use the x & y of said character as the target node).
 

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
Game_Character has this built in method:

#-------------------------------------------------------------------------- # * Move Toward Character #-------------------------------------------------------------------------- def move_toward_character(character) sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx.abs > sy.abs move_straight(sx > 0 ? 4 : 6) move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0 elsif sy != 0 move_straight(sy > 0 ? 8 : 2) move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0 end endBut as you can see, it literally "moves it toward" the target, no pathfinding is performed. Once you have implemented your pathfinding, you will be able to move characters to any node on the map, and consequently to any character on the map (if you use the x & y of said character as the target node).
tnx for that.. atm I tried put a follower. My problem is that, it can follow me north,east and west.. but if I go south it blocks my way D:
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
You mean en event follower? Because default followers from Ace got the "through" variable set to true and thus they don't block your way. If it is an event, make it "through" by checking that option in the event's Option section.
 

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
You mean en event follower? Because default followers from Ace got the "through" variable set to true and thus they don't block your way. If it is an event, make it "through" by checking that option in the event's Option section.
ohh I see.. it worked.. but I think now I want them to follow my back.. guess I little more research

also is it possible to do this

1. Walk to a certain location

2. A random npc will approach another npc

3. A battle window will commence.

Thank you.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
yes, via events that is possible... you'd probably use a touch triggered event to do that...
 

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
I tried this

1. Approach npcA (with player touch) so that he will go to a certain location

2. NpcA(with the exact location of the another npc) doesn't move at all.

Also I did put a battle processing event on npcB.

NpcB also have event trigger.

where did I do wrong?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You will only use 1 event to control those two "NPC"...


You will probably use the first touch event to do it


[Event]


Set move route of NPC 1 (do not wait)


Set move route of NPC 2 (wait)


Battle Processing
 
Last edited by a moderator:

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
You will only use 1 event to control those two "NPC"...

You will probably use the first touch event to do it

[Event]

Set move route of NPC 1 (do not wait)

Set move route of NPC 2 (wait)

Battle Processing
cool it worked!

btw I just noticed that in this script.. I should use game_player if I want the enemies or npc go to me...

or put the coordinates manually for the npc to meet..

my question.. if I want it to be npc to npc I should add some code to the script?

(I am referring to pathfinding A* by jet)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
well, I never used that script... but whenever you wanna address an event script-wise it would be


$game_map.events[id]


where ID is the ID of the event
 

CodeEmpress

Villager
Member
Joined
Feb 3, 2014
Messages
21
Reaction score
0
First Language
English
Primarily Uses
well, I never used that script... but whenever you wanna address an event script-wise it would be

$game_map.events[id]

where ID is the ID of the event
ohhh gonna try that OO.. tnx alot

edit:

tnx for the help Shana I fixed it :D
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top