[SNIPPET] DrawLine between 2 points

Using this you can draw a line like using 0B68:
*I've made this by myself after reading Opcode's post about getting Y/Z angle.
*I've tested this and works perfect.

Call function:
Code:
0AB1: call_scm_func drawLine 9 x1y1 0@ 1@ x2y2 2@ 3@ thickness 1.0 R 255 G 255 B 255 A 255

Function:
Code:
:drawLine
//0AB1: call_scm_func drawLine 9 x1y1 0@ 1@ x2y2 2@ 3@ thickness 1.0 R 255 G 255 B 255 A 255
0390: load_txd_dictionary 'LD_DUAL'
038F: load_texture "white" as 300
0509: 9@ = distance_between_XY 0@ 1@ and_XY 2@ 3@ 
0063: 2@ -= 0@
0063: 3@ -= 1@
0604: get_Z_angle_for_point 2@ 3@ store_to 10@ 
10@ += 90.0
0017: 2@ /= 2.0
0017: 3@ /= 2.0
005B: 0@ += 2@  
005B: 1@ += 3@  
074B: draw_texture 300 position 0@ 1@ scale 9@ 4@ angle 10@ color_RGBA 5@ 6@ 7@ 8@
0391: release_textures 
0AB2: ret 0
 

PopandaulX

Active member
Joined
Jul 15, 2013
Messages
189
Reaction score
1
Re: DrawLine between 2 points

Tested both, this works better... o_O
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: DrawLine between 2 points

What are variable 5@ 6@ 7@ 8@ for ?
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
Re: DrawLine between 2 points

Grubitsh link said:
What are variable 5@ 6@ 7@ 8@ for ?

I think it's RGBA: color_RGBA 5@ 6@ 7@ 8@

RED 255 GREEN 0 BLUE 0 ALPHA 255 -> FF0000FF -> RED
 

|]_ReT1neX_[|

Active member
Joined
Jul 28, 2014
Messages
132
Reaction score
0
Re: DrawLine between 2 points

PopandauL link said:
Using this you can draw a line like using 0B68:
*I've made this by myself after reading Opcode's post about getting Y/Z angle.
*I've tested this and works perfect.

Call function:
Code:
0AB1: call_scm_func drawLine 9 x1y1 0@ 1@ x2y2 2@ 3@ thickness 1.0 R 255 G 255 B 255 A 255

Function:
Code:
:drawLine
//0AB1: call_scm_func drawLine 9 x1y1 0@ 1@ x2y2 2@ 3@ thickness 1.0 R 255 G 255 B 255 A 255
0390: load_txd_dictionary 'LD_DUAL'
038F: load_texture "white" as 300
0509: 9@ = distance_between_XY 0@ 1@ and_XY 2@ 3@ 
0063: 2@ -= 0@
0063: 3@ -= 1@
0604: get_Z_angle_for_point 2@ 3@ store_to 10@ 
10@ += 90.0
0017: 2@ /= 2.0
0017: 3@ /= 2.0
005B: 0@ += 2@  
005B: 1@ += 3@  
074B: draw_texture 300 position 0@ 1@ scale 9@ 4@ angle 10@ color_RGBA 5@ 6@ 7@ 8@
0391: release_textures 
0AB2: ret 0

It's Not Working  :surprised:

Code:
GOSUB @GET_AIMING_POS
00A0: store_actor $PLAYER_ACTOR position_to 5@ 6@ 7@

// 0@ , 1@ Aim Position, 5@, 6@ Player's Position, i've also tried setting Player's position coords in x1y1, It simply does not work  :surprised:  :hellno: 
0AB1: @drawline 9 x1y1 0@ 1@ x2y2 5@ 6@ thickness 1.0 R 255 G 0 B 0 A 255

[member=3582]PopandauL[/member]
[member=6677]TH3RM4L[/member]
[member=60]Opcode.eXe[/member]
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,493
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
Re: DrawLine between 2 points

You first need to convert your 3D position:5@ 6@ 7@
Into a 2D Screen Position like 9@ 10@

You can do it with another snippet.

Code:
//0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
:getScreenXYFrom3DCoords
0AC7: 14@ = var 0@ offset
0AC7: 15@ = var 3@ offset
0AC7: 16@ = var 6@ offset
0AC7: 17@ = var 9@ offset
0AA5: call 0x70CE30 num_params 6 pop 6 {18@ 18@} 0 0 17@ 16@ 15@ 14@
0007: 12@ = 640.0
0007: 13@ = 448.0
0A8D: 14@ = read_memory 0xC17044 size 4 virtual_protect 0
0A8D: 15@ = read_memory 0xC17048 size 4 virtual_protect 0
0093: 14@ = integer 14@ to_float
0093: 15@ = integer 15@ to_float
0073: 12@ /= 14@
0073: 13@ /= 15@
006B: 3@ *= 12@
006B: 4@ *= 13@
0AB2: ret 2 3@ 4@
 

|]_ReT1neX_[|

Active member
Joined
Jul 28, 2014
Messages
132
Reaction score
0
Re: DrawLine between 2 points

Opcode.eXe link said:
You first need to convert your 3D position:5@ 6@ 7@
Into a 2D Screen Position like 9@ 10@

You can do it with another snippet.

Code:
//0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
:getScreenXYFrom3DCoords
0AC7: 14@ = var 0@ offset
0AC7: 15@ = var 3@ offset
0AC7: 16@ = var 6@ offset
0AC7: 17@ = var 9@ offset
0AA5: call 0x70CE30 num_params 6 pop 6 {18@ 18@} 0 0 17@ 16@ 15@ 14@
0007: 12@ = 640.0
0007: 13@ = 448.0
0A8D: 14@ = read_memory 0xC17044 size 4 virtual_protect 0
0A8D: 15@ = read_memory 0xC17048 size 4 virtual_protect 0
0093: 14@ = integer 14@ to_float
0093: 15@ = integer 15@ to_float
0073: 12@ /= 14@
0073: 13@ /= 15@
006B: 3@ *= 12@
006B: 4@ *= 13@
0AB2: ret 2 3@ 4@

Thank You  :somuchwin:
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
52
Location
LongForgotten <-> 0x32789
since this creates a static line, Can I change the position of it while it is created? I mean
I am tracing a vehicle and it shows a tracer towards me, The car is moving and the line would be updating (It works with opcode but when many cars near it will just flash)
is it possible to do that in ur snippet?
and since I am currently using opcodes and it is flashing when alot of cars nearby and changing
 
Top