ajom
Well-known member
I am trying to create a "player lines.cs" without SAMPFUNCS, it simply draw a line from your actor towards all other actors. I have read two threads that posted a snippet to be an alternative from opcode 0B68, this and this. But those two snippets seems to be inaccurate when trying to draw a point-to-point line:
That demo was part of "player lines.cs", can anybody help me fix the snippet right away? im having a hard time troubleshooting this drawline snippet.
Code:
// 2@ = any actor nearby
0889: store_actor 2@ center_of_body_position_to 3@ 4@ 5@
0AB1: @WorldXYZtoGameScreenXY 3 _from3Dcoord_XYZ 3@ 4@ 5@ _toscreencoord_XY 3@ 4@
0889: store_actor $PLAYER_ACTOR center_of_body_position_to 5@ 6@ 7@
0AB1: @WorldXYZtoGameScreenXY 3 _from3Dcoord_XYZ 5@ 6@ 7@ _toscreencoord_XY 5@ 6@
0AB1: @drawLine 9 _x1y1 5@ 6@ _x2y2 3@ 4@ _thickness 1.0 _Red 0 _Green 255 _Blue 0 _Alpha 255
:drawLine
//0AB1: call_scm_func drawLine 9 x1y1 0@ 1@ x2y2 2@ 3@ thickness 1.0 R 255 G 255 B 255 A 255
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 666 position 0@ 1@ scale 9@ 4@ angle 10@ color_RGBA 5@ 6@ 7@ 8@
0AB2: ret 0
:WorldXYZtoGameScreenXY
0AA5: call 0x70CE30 num_params 6 pop 6 bFarClip 0 bNearClip 0 pMultY 6@v pMultX 5@v pScreen 3@v pCoords 0@v // Convert WorldXYZ To WindowScreenXY
0A8D: 11@ = read_memory 0xC17044 size 4 virtual_protect 0 // full screen X
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859520 size 4 virtual_protect 0 // screen X scale
006B: 11@ *= 12@
0073: 3@ /= 11@
0A8D: 11@ = read_memory 0xC17048 size 4 virtual_protect 0 // full screen Y
0093: 11@ = integer 11@ to_float
0A8D: 12@ = read_memory 0x859524 size 4 virtual_protect 0 // screen Y scale
006B: 11@ *= 12@
0073: 4@ /= 11@
0AB2: ret 2 3@ 4@
That demo was part of "player lines.cs", can anybody help me fix the snippet right away? im having a hard time troubleshooting this drawline snippet.