Problem with finding distances -solved- now problem with random

Users who are viewing this thread

Status
Not open for further replies.

MartinF

Squire
I'm working on a code for patrols.

Basically right now I'm making a script that chooses a random patrol location within a certain radius of the home base. So checking for faction, etc. Everything works fine.

Except.. when using ((store_distance_to_party_from_party, ":distance", ":temp_object", ":cur_home_base"), it always returns a 0

Now I know the store distance thing works, because I use it to keep my patrols from wandering too far away from the base, for assigning them certain targets within a radius of the base, etc.

For some reason though, when both parties are a town, village or castle, it doesn't seem to want to work.

The piece of the script that checks it is this (variables are defined earlier):

Code:
(try_for_range, ":temp_object", centers_begin, centers_end),
				(neq, ":temp_object", ":cur_object"),
				(store_distance_to_party_from_party, ":distance", ":temp_object", ":cur_home_base"),
				(lt, ":distance", 30),
				(store_faction_of_party, ":temp_faction", ":temp_object"),
				(eq, ":temp_faction", ":cur_faction"), #only patrol own faction locations
				(val_add, ":num_objects", 1),
			(try_end),

I've tried echoing all the different variables and the base number is set correctly. So I get 'target 178 found, base is 52, distance is 0' when I print it all out.

Any thoughts? Maybe different ways of doing this?

I tried using the (party_get_position) for both parties and then using (get_distance_between_positions,) but that command seems to be meant for scenes (header_operations says it returns in cm) and doesn't give the expected result either, it also comes back with 0

[edit] there are scripts in the game that do use the get_distance_between_positions for the world map. However I still can't get it to work in mine.. whatever I do the distance comes back as 0

[edit2] ok now I'm really confused.. I tried running a simple trigger:

(1, [(store_distance_to_party_from_party, ":distance", "p_town_1", "p_town_6"),
(assign, reg18, ":distance"),
(display_message, "@distance from town 1 to town 6 is {reg18}"),
]),

and that comes back with 116

What am I missing here? I've got two party id's, which should be the same as using "p_town_1"...
 
ok..  :oops: :oops: :oops: :oops: :oops: :oops: :oops:

You're all going to laugh at me but I was echoing to wrong reg nr.. so it kept returning 0  :oops:

I must've checked the whole script five times, commented stuff out, tried again and again, but no go. Jesus.. haha. Well at least it's working now and I only wasted 3 hours  :roll:


It's all better now.. locking the thread so you can't mock me  :grin:
 
Status
Not open for further replies.
Back
Top Bottom