Bugfix, tactict iso movment

Hello, it’s kron job with pyrial tactics. I am working on the movment, but it is troubling me some. it works great at first, but then… epp, it breaks down. moves to the wrong block, and if you play around enuf then link and b.mage will just keep swapping positions X(

[color=#22229c]http://stevenstark.com/flash/pyrial_tactics.html[/color]

the functions to do with movment:


_root.select_square = function(target){
	//reset all highlights
	for(x=0;x<_root.map.my_texture.length;x++){
		for(y=0;y<_root.map.my_texture[x].length;y++){
			_root.map["box"+x+"x"+y].top.square.gotoAndStop(1);
			delete _root.map["sprite"+x+"x"+y].onPress;
			delete _root.map["sprite"+x+"x"+y].onRelease;
			delete _root.map["sprite"+x+"x"+y].onRollOver;
			delete _root.map["sprite"+x+"x"+y].onRollOut;
			delete _root.map["box"+x+"x"+y].onPress;
			delete _root.map["box"+x+"x"+y].onRelease;
			delete _root.map["box"+x+"x"+y].onRollOver;
			delete _root.map["box"+x+"x"+y].onRollOut;
		};
	};
	temp_1 = target.split("box");
	temp_2 = temp_1[1].split("x");
	new_a = temp_2[0];
	new_b = temp_2[1];
	temp_1 = _root.targetSprite.split("sprite");
	temp_2 = temp_1[1].split("x");
	old_a = temp_2[0];
	old_b = temp_2[1];
	delete temp_1;
	delete temp_2;
	var temp = [_root.map["sprite"+old_a+"x"+old_b]];
	_root.map["sprite"+new_a+"x"+new_b].swapDepths(temp);
	delete temp;
	_root.map.my_sprite[new_a][new_b] = _root.map["sprite"+old_a+"x"+old_b].character.id_num;
	_root.map.my_sprite[old_a][old_b] = 0;
	var t_x1 = _root.map["sprite"+new_a+"x"+new_b]._x;
	var t_y1 = _root.map["sprite"+new_a+"x"+new_b]._y;
	var t_x2 = _root.map["sprite"+old_a+"x"+old_b]._x;
	var t_y2 = _root.map["sprite"+old_a+"x"+old_b]._y;
	_root.map["sprite"+new_a+"x"+new_b]._x = t_x2;
	_root.map["sprite"+new_a+"x"+new_b]._y = t_y2;
	_root.map["sprite"+old_a+"x"+old_b]._x = t_x1;
	_root.map["sprite"+old_a+"x"+old_b]._y = t_y1;
	delete t_x1;
	delete t_y1;
	delete t_x2;
	delete t_y2;
	var t_name1 = ["sprite"+old_a+"x"+old_b];
	var t_name2 = ["sprite"+new_a+"x"+new_b];
	_root.map["sprite"+new_a+"x"+new_b]._name = t_name1;
	_root.map["sprite"+old_a+"x"+old_b]._name = t_name2;
	delete t_name1;
	delete t_name2;
	_root.mouse_status = "MOVED";
	_root.engine.gotoAndPlay(2);
}
 
 
 
 
_root.map_radius = function(){
	temp_1 = _root.targetSprite.split("sprite");
	temp_2 = temp_1[1].split("x");
	temp_a = temp_2[0];
	temp_b = temp_2[1];
	delete temp_1;
	delete temp_2;
	//reset all highlights
	if(_root.map["sprite"+temp_a+"x"+temp_b].character.side == "ally"){
		for(x=0;x<_root.map.my_texture.length;x++){
			for(y=0;y<_root.map.my_texture[x].length;y++){
				_root.map["box"+x+"x"+y].top.square.gotoAndStop(1);
				if((_root.map["sprite"+x+"x"+y]._name) !== ("sprite"+temp_a+"x"+temp_b)){
					delete _root.map["sprite"+x+"x"+y].onPress;
					delete _root.map["sprite"+x+"x"+y].onRelease;
					delete _root.map["sprite"+x+"x"+y].onRollOver;
					delete _root.map["sprite"+x+"x"+y].onRollOut;
					delete _root.map["box"+x+"x"+y].onPress;
					delete _root.map["box"+x+"x"+y].onRelease;
					delete _root.map["box"+x+"x"+y].onRollOver;
					delete _root.map["box"+x+"x"+y].onRollOut;
				}; 
			};
		};
		temp=0;
		if(_root.radius_type == "move"){
			_root.mouse_status = "MOVE TO?";
			radius = _root.map["sprite"+temp_a+"x"+temp_b].character.move_radius;


			for(x=0;x<RADIUS;X++){< p> 				if(_root.map.my_sprite[temp_a][(temp_b*1)+x] == "0"){
					_root.map["box"+temp_a+"x"+((temp_b*1)+x)].top.square.gotoAndStop(2);
					_root.map["box"+temp_a+"x"+((temp_b*1)+x)].top.square.onPress = function(){
						_root.select_square(this._parent._parent._name);
					}
				};
				if(_root.map.my_sprite[(temp_a*1)+x][temp_b]=="0"){
					_root.map["box"+((temp_a*1)+x)+"x"+[temp_b]].top.square.gotoAndStop(2);
					_root.map["box"+((temp_a*1)+x)+"x"+[temp_b]].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
				};
				if(_root.map.my_sprite[temp_a][(temp_b*1)-x]=="0"){
					_root.map["box"+[temp_a]+"x"+((temp_b*1)-x)].top.square.gotoAndStop(2);
					_root.map["box"+[temp_a]+"x"+((temp_b*1)-x)].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
				};
				if(_root.map.my_sprite[(temp_a*1)-x][temp_b]=="0"){
					_root.map["box"+((temp_a*1)-x)+"x"+temp_b].top.square.gotoAndStop(2);
					_root.map["box"+((temp_a*1)-x)+"x"+temp_b].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
				};


				for(y=0;y<TEMP;Y++){< p>  
					if(_root.map.my_sprite[(temp_a*1)+y][(temp_b*1)+y]=="0"){
						_root.map["box"+((temp_a*1)+y)+"x"+((temp_b*1)+y)].top.square.gotoAndStop(2);
						_root.map["box"+((temp_a*1)+y)+"x"+((temp_b*1)+y)].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
					};
					if(_root.map.my_sprite[(temp_a*1)+y][(temp_b*1)-y]=="0"){
						_root.map["box"+((temp_a*1)+y)+"x"+((temp_b*1)-y)].top.square.gotoAndStop(2);
						_root.map["box"+((temp_a*1)+y)+"x"+((temp_b*1)-y)].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
					};
					if(_root.map.my_sprite[(temp_a*1)-y][(temp_b*1)+y]=="0"){
						_root.map["box"+((temp_a*1)-y)+"x"+((temp_b*1)-y)].top.square.gotoAndStop(2);
						_root.map["box"+((temp_a*1)-y)+"x"+((temp_b*1)-y)].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
					};
					if(_root.map.my_sprite[(temp_a*1)-y][(temp_b*1)-y]=="0"){
						_root.map[((temp_a*1)-y)+"x"+((temp_b*1)-y)].top.square.gotoAndStop(2);
						_root.map[((temp_a*1)-y)+"x"+((temp_b*1)-y)].top.square.onPress = function(){_root.select_square(this._parent._parent._name);}
					};
				};
				if(temp<_root.map["sprite"+temp_a+"x"+temp_b].character.move_radius){
					temp++;
				} else {
					temp--;
				};
			};
			//change the sprite's function, then reset it to normal after
			_root.map["sprite"+temp_a+"x"+temp_b].onPress = function(){
				//reset all highlights
				for(x=0;x<_root.map.my_texture.length;x++){
					for(y=0;y<_root.map.my_texture[x].length;y++){
						_root.map["box"+x+"x"+y].top.square.gotoAndStop(1);
						delete _root.map["sprite"+x+"x"+y].onPress;
						delete _root.map["sprite"+x+"x"+y].onRelease;
						delete _root.map["sprite"+x+"x"+y].onRollOver;
						delete _root.map["sprite"+x+"x"+y].onRollOut;
						delete _root.map["box"+x+"x"+y].onPress;
						delete _root.map["box"+x+"x"+y].onRelease;
						delete _root.map["box"+x+"x"+y].onRollOver;
						delete _root.map["box"+x+"x"+y].onRollOut;
					};
				};
				_root.mouse_status = "CANCELLED";
				_root.engine.gotoAndPlay(2);
			}
			_root.map["sprite"+temp_a+"x"+temp_b].onRollOver = function(){
				_root.mouse_status = "CANCEL";
			};
			_root.map["sprite"+temp_a+"x"+temp_b].onRollOut = function(){
				_root.mouse_status = "MOVE TO?";
			};
		} else if (_root.radius_type == "attack"){
			trace(_root.map["sprite"+temp_a+"x"+temp_b].character.attack_radius);
		} else if (_root.radius_type == "magic"){
			trace(_root.map["sprite"+temp_a+"x"+temp_b].character.magic_radius);
		} else if (_root.radius_type == "item"){
			trace(_root.map["sprite"+temp_a+"x"+temp_b].character.item_radius);
		};
	};	
}

can someone please shed some light on this problem? It’s been bugging me all fricken week, I just can’t find the solution. if you need, I will zip up the project.

-steven<!-- / message --><!-- sig -->

WOAH… I dont understand that type of programming…

peace

…erm, i can’t actually do anything with the game. screen moves around, zoom’s in and out but no actual player movement. any clues?

Same here. The sprites just run in place.

sorry, I should have explained. … click on either link or b.mage, and you will get an area box to walk (warp) to.

also, what about my code don’t you understand… sems basic enuf to me, but that’s 'cause it’s mine. There are still things I have to learn, maybe you could point them out?

ok yea, I just went to test it and you have to refresh once after the blocks slooowly load in… they’ll load in fast and everything will work the 2nd time. it’s strange, I kno, something to do with loading the XML. oh, and btw> I have my_texture, my_function, my_sprite, my_height all defined as a 2D array, pulled from XML, and are the information about the map.

not doing anything sorry… no matter how many times i refresh it :snooze: