lil' puzzle for ya

Sami_Tervo in my project there is a little problem in combat walking system (= the range you can walk is defined by action points you have).

at first time when i programmed that, it went quite good. when player wanted to go to place B, i subtracted amount of required action points of current action points. although there was a problem. if player hits to other object or block of somekind, he stops but he "lost" some action points coz he didnt managed to travel distance he planned. and subtracting action points after he has reached the destination, offered many ways to cheat.

so i tried to program system which subtracts little bit action points in every cycle and it failed. i uploaded that to net if someone of you could take a look and tell how solve the problem.

combat walking-code is in logic.123

DOS-Version
http://koti.mbnet.fi/sterv/aqd.zip
WIN-Version
http://koti.mbnet.fi/sterv/aqw.zip

please help!
Andrew_Baker What I had in mind was more of a step-by-step AP subtraction with the keypad.

if(isset(f60)){ // If movement flag is on
get.posn(o0,v40,v41);
if ((new_ego_x>v40 ||
new_ego_x<v40 ||
new_ego_y>v41 ||
new_ego_y<v41)){
AP-=1;
}
}

Unfortunately, I have no idea if this will work or not, because I can't figure out what variable you are using for AP, and command-line input won't work.
Sami_Tervo strange..command line input should work..well ap-variable (191) and other stuff are found from logic.000 start
Andrew_Baker This is what I have so far. I'm missing something, I know, Sami. Could you please supply a defines.txt that names all the variables you're using. It would be a big help. I'm going to try something similar, but simpler in a game I plan on working on next, so I have an active interest in seeing this code worked out.

#include "defines.txt"

if(isset(f99)){ // Double click with one click-disabler
v66+=1;
if(v66==2){
reset(f99);
}
}


if(isset(f60)){ // If movement flag is on
get.posn(o0,v40,v41);
if ((new_ego_x>v40 ||
new_ego_x<v40 ||
new_ego_y>v41 ||
new_ego_y<v41)){
v191-=1;
}
}

if(mouse_y < 147) {
// Walk-AP-Cost-Show-Code
if(mouse_button == 0 && isset(f50) && isset(f41) && !isset(f60)) {
v29 -= 8;
reposition.to.v(o10,v28,v29);
distance(o0,o10,v193);
reposition.to(o10,1,1);
set.text.attribute(0,0);
display(19,37," ");
if(v191 >= v193){
set.text.attribute(15,0);
display(19,37,"%v193");
}
else{
set.text.attribute(15,0);
display(19,37,"-");
}

}
// Movement
if(mouse_button == 1 && isset(f50) && isset(f41) && !isset(f60) && !isset(f99)) {
v29 -= 8;
reposition.to.v(o10,v28,v29);
distance(o0,o10,v193);
reposition.to(o10,1,1);
set.text.attribute(0,0);
display(19,37," ");
if(v191 >= v193){
v62=v193;
set(f99);
set(f60);
v63=v28;
v64=v29;
set.text.attribute(15,0);
display(19,37,"%v193");
move.obj.v(o0, v28, v29, 2, f255);
}
else{
set.text.attribute(15,0);
display(19,37,"-");
}

}

}

return();
Sami_Tervo :P okie...i defined variables, objects and flags for logic.123...get it from :
http://koti.mbnet.fi/sterv/defines.txt