This Snippet Gets the Pedestrian / Car / Object / Building / Particle XYZ Offsets That is Relative to the World XYZ Coordinates.
Code:
:worldCoordsToEntityOffsets
{
By Wesser modernized by ajom
Description: Convert world coordinates to entity's relative offsets.
Passed:     0@ - entity pointer     1@ - position X     2@ - position Y     3@ - position Z
Result:     7@ - relative offset X     8@ - relative offset Y     9@ - relative offset Z
Example:   0AB1: @worldCoordsToEntityOffsets 4 _entity 0x00000000 _coords_XYZ 0.0 0.0 0.0 _storeoffsets_XYZ 1@ 2@ 3@
}
0@ += 0x14 // CEntity.m_clPlaceable.m_pclMatrix
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
0A8E: 4@ = 0@ + 0x30 // CMatrix.m_clOrigin
0AA5: call 0x40FE60 num_params 3 pop 3 pclVectorB 4@ pclVectorA 1@v pclOffset 1@v // vectorSub
0AA5: call 0x59C810 num_params 3 pop 3 pclMatrix 0@ pclAbsOffset 1@v pclRelOffset 7@v // absToRelOffset
0AB2: ret 3 offsetX 7@ offsetY 8@ offsetZ 9@


Code:
066A: 137@ = attach_particle "PETROLCAN" to_actor 71@ with_offset 0.0 0.116 0.048 rotation 95@ 96@ 97@ type 1
0669: 55@ = attach_particle "EXHALE" to_actor $ACTOR_RYDER with_offset 90@ 91@ 92@ type 1
09A0: actor $PLAYER_ACTOR attach_object 26@ with_offset 0.0 0.0 0.0 on_bone 5 16 perform_animation "NULL" IFP_file "NULL" time -1
08A0: actor 0@ in_radius 100.0 near_model #NULL with_offset 0.0 0.0 0.0 end_script_named "PCUSTOM" // IF and SET
06C2: AS_actor -1 goto -1762.369 951.1278 23.7487 mode 4 turn_radius 1.0 stop_radius 1.0 actor 37@ with_offset 0.0 0.0 0.0
070A: AS_actor 358@ attach_to_object 359@ offset 0.0 0.0 0.0 on_bone 6 16 perform_animation "NULL" IFP_file "NULL" time 1
069B: attach_object 88@ to_actor 38@ with_offset 0.0 0.5 -1.0 rotation 0.0 0.0 0.0
09B8: create_blood_gush_at $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3 with_offset 207@ 208@ 209@ density 20 on_actor $ACTOR_RYDER
06A7: put_actor $PLAYER_ACTOR into_turret_on_car 386@ at_car_offset -0.2 0.5 0.0 position 1 shooting_angle 110.0 70.0 with_weapon 43
04F4: put_actor 37@ into_turret_on_object 52@ offset_from_object_origin 2.85 -0.7 5.9 orientation 0 both_side_angle_limit 360.0 lock_weapon 0
0464: put_actor 99@ into_turret_on_car 68@ at_car_offset 266@ 267@ 268@ position 0 shooting_angle_limit 0.0 with_weapon 0
067C: put_camera_on_actor $PLAYER_ACTOR offset 0.0 2.0 -2.0 rotation 0.0 0.0 0.0 tilt 0.0 switchstyle 2
067E: put_camera_on_actor 70@ offset 0.0 -5.0 4.0 target_actor 70@ tilt 0.0 switchstyle 2
067B: put_camera_on_car $1238 with_offset -1.5 1.5 1.5 point_to_actor $1237 tilt 6.0 2
04C4: store_coords_to $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3 from_actor 215@ with_offset 1.0 3.0 1.0


I used this snippets on many single player mods that I created, thus, this snippet is almost useful on any modes even at SAMP and MTA. Some Example Applications of This Snippet:
Code:
00A0: store_actor $PLAYER_ACTOR position_to 0@ 1@ 2@
0AE2: 3@ = random_vehicle_near_point 0@ 1@ 2@ in_radius 10.0 find_next 0 pass_wrecked 1
if 056E:   car 3@ defined
then
    if 0547:   actor $PLAYER_ACTOR colliding_with_car 3@
    then
        0A97: 4@ = car 3@ struct
        0AB1: @worldCoordsToEntityOffsets 4 _entity 4@ _coords_XYZ 0@ 1@ 2@ _storeoffsets_XYZ 0@ 1@ 2@
        0464: put_actor $PLAYER_ACTOR into_turret_on_car 3@ at_car_offset 0@ 1@ 2@ position 2 shooting_angle_limit 360.0 with_weapon 0
    end
end
 
Top