Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, AndrewAMD), 1,278 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Tactical RPG Grid Calculation #354942
01/23/11 14:48
01/23/11 14:48
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Hey guys

I wonder if someone of you knows the game "Disgaea" or "Final Fantasy Tactics".
I thought about the system that is behind all this and how to code it actually. The theory behind the system is quite simple but the implementation of that system is quite difficult.



this is a map with a grid of 10 x 10 nodes, the green node is my current position, the orange nodes are the move area in which the
player is able to do his turn. I wanted to calculate the move area
related to the Move value each character has. (in this case its 3)



related to the players position i want to calculate this. (as shown in the picture above)
I just tried to calculate every node in the array and set them to 0 which are higher than the move value of the player. the values in the
table above are actually the amount of steps the player would use to reach this node

does anyone have a solution for solving the calculation? I'm getting crazy trying it.

Thanks for replies in advance~
Roxas

Last edited by Roxas; 01/23/11 14:50.
Re: Tactical RPG Grid Calculation [Re: Roxas] #354952
01/23/11 15:45
01/23/11 15:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
for(i = 0; i < x_size; i++) {
for(j = 0; j < y_size; j++) {
x_diff = player_node%x_size;
y_diff = integer(player_node/y_size);

grid_value[i*x_size+j] = x_diff+y_diff;
if(grid_value[i*x_size+j] > player_range) { grid_value[i*x_size+j] = 0; }

}
}

Should work.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tactical RPG Grid Calculation [Re: Superku] #354957
01/23/11 16:37
01/23/11 16:37
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Alright, so it took me a bit to make this, but I had fun for an hour or so tongue
I made an array code (which also properly wraps around the edges!) that calculates the movement cost in a given diameter.

use the mouse position to pick a tile, and use the scrollwheel to increase/decrease the tile movement diameter.

have fun!

Code:
#include <acknex.h>
#include <default.c>

#define GRID_size 10
#define GRID_cellsize 32

var GridMoveSquares = 3; // stores size of movement diameter
var GridArray[GRID_size][GRID_size]; // stores size of grid

// visual debug representation variables
var current_row = 3;
var current_col = 1;

// function that resets every GRID value
function resetGrid() {
	var X_index = 0;
	var Y_index = 0;
	
	for(X_index=0; X_index<GRID_size; X_index++) {
		for(Y_index=0; Y_index<GRID_size; Y_index++) {
			GridArray[X_index][Y_index] = 0;
		}
	}
}

// function that visually represents the GRID data
function drawGridData() {
	var column_index = 0;
	var row_index = 0;
	
	for(column_index=0; column_index<GRID_size; column_index++) {
		for(row_index=0; row_index<GRID_size; row_index++) {
			if(GridArray[column_index][row_index] == 0) {
				draw_text(str_for_num(NULL, GridArray[column_index][row_index]), GRID_cellsize*column_index, GRID_cellsize*row_index, vector(255,255,255));
			} else {
				draw_text(str_for_num(NULL, GridArray[column_index][row_index]), GRID_cellsize*column_index, GRID_cellsize*row_index, vector(0,0,255));
			}
		}
	}
}

// actually calculate the cells that can be moved on
function setMoveGrid(var row, var col) {
	var column_index = 0;
	var row_index = 0;
	var clampedIndex;
	
	resetGrid(); // reset
	
	for(column_index=GridMoveSquares; column_index>=0; column_index--) {
		// fill right hand side of column
		clampedIndex = clamp(col+column_index, 0, GRID_size-1);
		GridArray[row][clampedIndex] = column_index;
		for(row_index=GridMoveSquares; row_index>=column_index; row_index--) {
			GridArray[clamp(row+(row_index-column_index), 0, GRID_size-1)][clampedIndex] = row_index;
			GridArray[clamp(row-(row_index-column_index), 0, GRID_size-1)][clampedIndex] = row_index;
		}
		
		// fill left hand side of column
		clampedIndex = clamp(col-column_index, 0, GRID_size-1);
		GridArray[row][clampedIndex] = column_index;
		for(row_index=GridMoveSquares; row_index>=column_index; row_index--) {
			GridArray[clamp(row+(row_index-column_index), 0, GRID_size-1)][clampedIndex] = row_index;
			GridArray[clamp(row-(row_index-column_index), 0, GRID_size-1)][clampedIndex] = row_index;
		}
	}
}

function getMouseInput() {
	current_row = clamp(integer(abs(mouse_pos.x) / GRID_cellsize), 0, GRID_size-1);
	current_col = clamp(integer(abs(mouse_pos.y) / GRID_cellsize), 0, GRID_size-1);
	GridMoveSquares += (mickey.z/120); GridMoveSquares = clamp(GridMoveSquares, 0, GRID_size);
}

function main() {
	mouse_mode = 4;
	resetGrid(); // reset GRID
	
	while(1) {
		getMouseInput();
		setMoveGrid(current_row,current_col); // calculate new GRID data
		
		drawGridData(); // debug draw grid
		wait(1);
	}
}




Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Tactical RPG Grid Calculation [Re: Helghast] #354974
01/23/11 18:14
01/23/11 18:14
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Wow thank you, you two !
I'll definitely give it a try.

Yeah the thing with the wrapping around the edges is a little tricky, I wasn't able to manage that too, I'll check out your code and play around with it to actually understand what it does

If i got further questions to this topic I'll post here
thank you again !

Roxas


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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