|
 |
|
|
|
|
|
GTA Modification Forums
nearest point
 |
|
 |
| |
2FriedEggz  |
Posted: Wednesday, Jun 13 2012, 18:20
|
Player Hater

Group: Members
Joined: Jun 13, 2012

|
| CODE | :GOSUB9 0AB4: 22@ = var 5 0AB4: 23@ = var 6 0AB4: 24@ = var 7 0AB4: 4@ = var 8 0AB4: 5@ = var 9 0AB4: 6@ = var 10 Actor.StorePos($PLAYER_ACTOR, 7@, 8@, 9@) if 80EC: not actor $PLAYER_ACTOR sphere 0 near_point 15@ 16@ radius 20.0 20.0 0AA1: return_if_false 050A: 0@ = distance_between_XYZ 4@ 5@ 6@ and_XYZ 15@ 16@ 17@ 050A: 1@ = distance_between_XYZ 4@ 5@ 6@ and_XYZ 7@ 8@ 9@ if 0025: 1@ > 0@ // point must be nearer to 4,5,6 than the player. 0AA1: return_if_false 050A: 0@ = distance_between_XYZ 7@ 8@ 9@ and_XYZ 15@ 16@ 17@ 050A: 1@ = distance_between_XYZ 7@ 8@ 9@ and_XYZ 22@ 23@ 24@ if 0025: 1@ > 0@ // player <-> best point > player <-> point 0AA1: return_if_false 0AB3: var 5 = 15@ //new best point 0AB3: var 6 = 16@ 0AB3: var 7 = 17@ return |
I use this multiple times in a row with a different input (15@, 16@, 17@) to calculate the nearest point for the player that fits all the conditions. However, it keeps outputting 0, 0, 0. Yet I made sure all variables start as 3000 to prevent this from being output. I'm quite happy to clarify anything necessary.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
2FriedEggz  |
Posted: Thursday, Jun 14 2012, 09:15
|
Player Hater

Group: Members
Joined: Jun 13, 2012

|
| QUOTE | | Do you know what are you doing ??? |
The mod is currently 30kb compiled, and this is the only part that causes issues. So I'm pretty sure I know what I'm doing; even if my methods are a bit unorthodox. | QUOTE | you can't get more nearest point than this Actor.StorePos($PLAYER_ACTOR, 7@, 8@, 9@) |
That made me laugh. | QUOTE | | pls don't show your script just tell us what you want ? |
I need this gosub to process multiple points to determine which is closest to the player. 1) It must not be too close to the player. (1st return_if_false) 2) The point chosen must be nearer to 4@, 5@, 6@ than the player. (2nd return_if_false) 3) The point must be closer than the closest point found so far. (3rd return_if_false) I've gone over this a hundred or so times, and I cannot fathom why it is outputting 0, 0, 0.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
2FriedEggz  |
|
Player Hater

Group: Members
Joined: Jun 13, 2012

|
| QUOTE | | Also, I get a feeling that if your CLEO script is 30kb, you probably need to enable "Skip scm header" in Sanny Builders options (something like that, anyway). |
Aside from cutting kb off a file, does that actually do anything beneficial? My script's 1800 lines BTW. Anyway this is a compilable script that demonstrates the problem. Can anyone help? | CODE | {$CLEO .cs}
0000:
:START0 wait 0 if Player.Defined($PLAYER_CHAR) jf @START0 select_interior 0 0860: link_actor $PLAYER_ACTOR to_interior 0 00A1: put_actor $PLAYER_ACTOR at 1178.093 -166.0749 40.58875
:START1 wait 0 if and Player.Defined($PLAYER_CHAR) 00E1: key_pressed 0 4 // Action 00E1: key_pressed 0 16 // Sprint jf @START1
22@ = 3000 // Should prevent 0, 0, 0 23@ = 3000 24@ = 3000 4@ = -98.40488 5@ = -938.9159 6@ = 20.60678 gosub @PLACE_1 gosub @POINTCHECK gosub @PLACE_2 gosub @POINTCHECK gosub @PLACE_3 gosub @POINTCHECK Jump @TELEPORT
:PLACE_1 15@ = 908.501 16@ = -175.6631 17@ = 10.80305 return
:PLACE_2 15@ = 620.4529 16@ = 308.6574 17@ = 19.87542 return
:PLACE_3 15@ = -98.40488 16@ = -938.9159 17@ = 20.60678 return
:POINTCHECK Actor.StorePos($PLAYER_ACTOR, 7@, 8@, 9@) if 80EC: not actor $PLAYER_ACTOR sphere 0 near_point 15@ 16@ radius 20.0 20.0 0AA1: return_if_false 050A: 0@ = distance_between_XYZ 4@ 5@ 6@ and_XYZ 15@ 16@ 17@ 050A: 1@ = distance_between_XYZ 4@ 5@ 6@ and_XYZ 7@ 8@ 9@ if 0025: 1@ > 0@ 0AA1: return_if_false 050A: 0@ = distance_between_XYZ 7@ 8@ 9@ and_XYZ 15@ 16@ 17@ 050A: 1@ = distance_between_XYZ 7@ 8@ 9@ and_XYZ 22@ 23@ 24@ if 0025: 1@ > 0@ 0AA1: return_if_false 0087: 22@ = 15@ 0087: 23@ = 16@ 0087: 24@ = 17@ return
:TELEPORT 00A1: put_actor $PLAYER_ACTOR at 22@ 23@ 24@ Jump @START1 |
It should teleport the player to 908.501, -175.6631, 10.80305, but it teleports him to 0, 0, 0. Does anyone know why?
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|