Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Format_C Pathfinding [Reupload] #412819
12/03/12 18:07
12/03/12 18:07
Joined: May 2009
Posts: 5,367
Caucasus
3run Online OP
Senior Expert
3run  Online OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
As I've seen some of the guys asking for this lately, I've decided to reupload it! I've got C-Script version from the Russian Community, where one of the members, searched and finally found it on his old HDD archive. Then I've converted it into LITE-C myself! I couldn't find an old thread (was too lazy probably), so I've made new one, and I've uploaded both "C-Script" and "Lite-C" version of my WEBSITE (yeah, good old "badcom (dot) at (dot) ua")!!
Here are the link:
Astar Pathfinding (Lite-C)
Astar Pathfinding (C-Script)
As all comments were in Russian, I've decided to translate them:
Quote:
MAIN.C
Code:
#include <acknex.h>
#include <default.c>

#include "astar.c" // here we have pathfinding functions

#define PRAGMA_PLUGIN "plugin\\format_c.dll";

STRING* level_str = "sample.WMB";
STRING* cbabe_mdl = "cbabe.mdl";

var map1; // the map of obstacles

function main(){
	// we create the map of obstacles
	create_grid_params(0, 0); // coordinates of the lower left corner of the map (x,y)
	map1 = create_grid(15, 12, 64, 64); // we create map 15x12 cells, 64,64 - width, height 1 cell
	level_load(level_str);
}

action my_target() // objects which we'll follow
{
	while(1){
		if (key_cur){ my.x += 20 * time_step; }
		if (key_cul){ my.x -= 20 * time_step; }
		if (key_cuu){ my.y += 20 * time_step; }
		if (key_cud){ my.y -= 20 * time_step; }
		wait(1);
	}
}

action finder() // object which will find path
{
	var temp;
	var dots_to_goal = 0; // ammount of cells which we'll need to go throw in order to get to the target cell
	my.skill1 = add_path(); // let's create a path and store it in skill1
	you = ent_create(cbabe_mdl, my.x, my_target); // object which we'll follow
	while(1){
		if(key_space){ 
			// if we've pressed space key, then we need to compute path to the target
			calc_path_params(my.x, my.y, you.x, you.y); //my.x,my.y - start positions, you.x,you.y - end positions
			dots_to_goal = calc_path(map1, my.skill1, 1); //computing the path
			//map1-the map of obstacles,skill1-path,1-"allow diagonal movement"
			temp = 0;
		}
		if(temp < dots_to_goal){ // we move throw path till we get to the target 
			my.x += (path_point_x(my.skill1, temp) - my.x) * time_step;
			my.y += (path_point_y(my.skill1, temp) - my.y) * time_step;
			if (vec_dist(vector(my.x, my.y, my.z), vector(path_point_x(my.skill1, temp), path_point_y(my.skill1, temp), my.z)) <= 10){
				temp += 1;
			}
		}
		wait(1);
	}
}

action obstacle()
{
	add_cell(map1, my.x, my.y, -333);
}


ASTAR.C
Code:
// defines coordinates of the lower left corner of the grid (if we look from the top view)
function create_grid_params(corner_x,corner_y);
// creates a grid, defines ammount of cells horizontally, vertically, width, height of the cell
function create_grid(grid_w,grid_h,cell_w,cell_h);
// deletes the map of obstacles
function map_destroy(map_id);
// deletes all obstacle maps
function map_destroy_all();

// adds rate of the cell in the map of obstacles(-333 - "required cell")
function add_cell(map_id,x,y,price);
// gets the rate of the cell from the obstacles map (for debugging)
function get_cell(map_id,x,y);

// adds path (just a simple massive, where we store coordinates of each node, which leads to the target)
function add_path(); // adds path
function del_path(path_id); // delets path
function path_destroy_all(); // delets all paths
function path_length(path_id); // returns the length of the path (if path was computed)

//defines parameters for pathfinding (start position, end position)
function calc_path_params(start_x,start_y,goal_x,goal_y);
//computes path. map_id,path_id - IDs of the map and path, allowdiag-admission "of walking diagonally"
//returns ammount of nodes (if path was computed) and -1 (if path wasn't computed)
function calc_path(map_id,path_id,allowdiag);
// returns coordinates of each node of the path, if it was computed. point_num - number of node (starting node - 0)
function path_point_x(path_id,point_num);
function path_point_y(path_id,point_num);

// returns number of node in the map of obstacles (for debugging)
// for example, we can check, was node included in the actual path
// if it wasn't we get -1
function point_encode(map_id,x,y);



Sorry for my English guys grin If you can't understand anything, just ask me.

Edit: I would be really grateful if someone could fix links in the Wiki, cause I've tried to login with my forum nick and password, that didn't work.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Format_C Pathfinding [Reupload] [Re: 3run] #412822
12/03/12 18:20
12/03/12 18:20
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Nice! Thanks! laugh


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Format_C Pathfinding [Reupload] [Re: alibaba] #412824
12/03/12 19:45
12/03/12 19:45
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hey 3run, thanks! laugh Where can I find the russian community site?

Re: Format_C Pathfinding [Reupload] [Re: PadMalcom] #412825
12/03/12 20:26
12/03/12 20:26
Joined: May 2009
Posts: 5,367
Caucasus
3run Online OP
Senior Expert
3run  Online OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
You are welcome guys! laugh
PadMalcom@ here you go:
3D Game Studio Academy


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Format_C Pathfinding [Reupload] [Re: 3run] #412846
12/04/12 07:24
12/04/12 07:24
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
Norton found something malicious on that site, supposed to be a web attack.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Format_C Pathfinding [Reupload] [Re: sivan] #412848
12/04/12 07:49
12/04/12 07:49
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Nice thanks laugh For all those who want to read it in english:

http://translate.google.de/translate?hl=en&sl=auto&tl=en&u=http%3A%2F%2Fwww.3dgs.ru%2F

Re: Format_C Pathfinding [Reupload] [Re: PadMalcom] #412849
12/04/12 08:14
12/04/12 08:14
Joined: May 2009
Posts: 5,367
Caucasus
3run Online OP
Senior Expert
3run  Online OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
sivan@ there is nothing wrong with my website, as you see people are downloading stuff from it without any problems laugh Your Norton may find some ads, which are visible for non-registered visitors, but I have no problems with my KIS 2011. Plus I could advice you to use AdBlock for your browser.

PadMalcom@ you are welcome, and thank you for the useful link laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Format_C Pathfinding [Reupload] [Re: 3run] #412851
12/04/12 08:21
12/04/12 08:21
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I mean the russian site, not yours!
yes, probably an advertisment contains something suspicious...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Format_C Pathfinding [Reupload] [Re: sivan] #412852
12/04/12 08:32
12/04/12 08:32
Joined: May 2009
Posts: 5,367
Caucasus
3run Online OP
Senior Expert
3run  Online OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
sivan@ there are no ads in that Russian website!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Format_C Pathfinding [Reupload] [Re: 3run] #413041
12/06/12 20:24
12/06/12 20:24
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
thanks 3run this is also handy


Compulsive compiler
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1