shokkueibu
Knight
I want to use the compass in the battle map.
So far I've managed to use the mesh from the one in world map and make it rotate as I do. Obviously, I want it to work like a real compass except I don't have the necessary mathematical knowledge to do so. (arctangent? )
I take it [font=Consolas,Fixedsys]overlay_set_mesh_rotation[/font] is a good start, along with [font=Consolas,Fixedsys]agent_get_look_position[/font]?
How can I make it point towards a single point?
Can I define where in the scene that point is?
Working code:
Still in [font=consolas,fixedsys]module_mission_templates.py[/font], add
[font=consolas,fixedsys]multiplayer_compass,[/font]
by the end of any gametype you wish (multiplayer_bt, multiplayer_dm, etc).
Many thanks to Caba`drin, dunde and Somebody!
EDIT: Turns out I was wrong. The angle calculations aren't really working, it was a coincidence it pointed at the right place in Ruins. Yeah I know, bad testing from my part :/
As a workaround I set North manually for each stock map, excluding Siege and random maps. If someone knows how to fix it please do say so.
So far I've managed to use the mesh from the one in world map and make it rotate as I do. Obviously, I want it to work like a real compass except I don't have the necessary mathematical knowledge to do so. (arctangent? )
I take it [font=Consolas,Fixedsys]overlay_set_mesh_rotation[/font] is a good start, along with [font=Consolas,Fixedsys]agent_get_look_position[/font]?
How can I make it point towards a single point?
Can I define where in the scene that point is?
Working code:
Code:
("multiplayer_compass", prsntf_read_only|prsntf_manual_end_only, 0, [
(ti_on_presentation_load, [
(set_fixed_point_multiplier, 1000),
(create_mesh_overlay, "$bi_compass", "mesh_compass"),
(position_set_x, pos1, 50),
(position_set_y, pos1, 550),
(overlay_set_position, "$bi_compass", pos1),
(position_set_x, pos1, 500),
(position_set_y, pos1, 500),
(overlay_set_size, "$bi_compass", pos1),
(store_current_scene, ":cur_scene"),
(try_begin),
(is_between, ":cur_scene", multiplayer_scenes_begin, multiplayer_scenes_end),
(try_begin),
(this_or_next|eq, ":cur_scene", scn_multi_scene_1), #Ruins
(eq, ":cur_scene", scn_multi_scene_14), #Battle on Ice
(assign, "$bi_compass_north", 135),
(else_try),
(eq, ":cur_scene", scn_multi_scene_2), #Village
(assign, "$bi_compass_north", 180),
(else_try),
(this_or_next|eq, ":cur_scene", scn_multi_scene_4), #Ruined Fort
(this_or_next|eq, ":cur_scene", scn_multi_scene_12), #Port Assault
(eq, ":cur_scene", scn_multi_scene_18), #Forest Hideout
(assign, "$bi_compass_north", 0),
(else_try),
(eq, ":cur_scene", scn_multi_scene_7), #Field by the River
(assign, "$bi_compass_north", 225),
(else_try),
(eq, ":cur_scene", scn_multi_scene_9), #Snowy Village
(assign, "$bi_compass_north", 45),
(else_try),
(eq, ":cur_scene", scn_multi_scene_11), #Nord Town
(assign, "$bi_compass_north", 315),
(else_try),
(eq, ":cur_scene", scn_multi_scene_17), #The Arena
(assign, "$bi_compass_north", 20), #The map isn't aligned to its borders
(try_end),
(else_try),
(entry_point_get_position, pos1, multi_initial_spawn_point_team_1),
(entry_point_get_position, pos2, multi_initial_spawn_point_team_2),
(get_angle_between_positions, "$bi_compass_north", pos2, pos1),
(try_end),
(assign, "$bi_compass_active", 1), #TODO: Let the user toggle this from
(assign, "$bi_compass_3d", 1), # a menu or with a key
(presentation_set_duration, 999999),
]),
(ti_on_presentation_run, [
(try_begin),
(eq, "$bi_compass_active", 1),
(set_fixed_point_multiplier, 1),
(init_position, pos3),
(position_rotate_z, pos3, "$bi_compass_north"),
(mission_cam_get_position, pos1),
(position_get_rotation_around_z, ":view_angle", pos1),
(init_position, pos2),
(val_mul, ":view_angle", -1), #Invert the angle
(position_rotate_z, pos2, ":view_angle"),
#Here we get the angle between the player and north
(set_fixed_point_multiplier, 1),
(get_angle_between_positions, ":angle", pos3, pos2),
(init_position, pos10),
(try_begin), #by dunde
(eq, "$bi_compass_3d", 1),
(position_get_rotation_around_x, ":pitch", pos1),
(store_sub, ":pitch", -90, ":pitch"),
(try_begin),
(gt, ":pitch", 360),
(val_mod, ":pitch", 360),
(else_try),
(lt, ":pitch", -360),
(val_abs, ":pitch"),
(val_mod, ":pitch", 360),
(val_mul, ":pitch", -1),
(try_end),
(try_begin),
(is_between, ":pitch", 180, 361),
(val_sub, ":pitch", 360),
(try_end),
(val_clamp, ":pitch", -90, 1),
(position_rotate_x, pos10, ":pitch"),
(try_end),
(position_rotate_z, pos10, ":angle"),
(overlay_set_mesh_rotation, "$bi_compass", pos10),
(else_try),
(presentation_set_duration, 0),
(try_end),
]),
]),
Code:
("compass", 0, "compass", 0, 0, 0, 0, 0, 0, 1, 1, 1),
Code:
multiplayer_compass = (
ti_battle_window_opened, 0, 0, [], [
(start_presentation, "prsnt_multiplayer_compass"),
])
Still in [font=consolas,fixedsys]module_mission_templates.py[/font], add
[font=consolas,fixedsys]multiplayer_compass,[/font]
by the end of any gametype you wish (multiplayer_bt, multiplayer_dm, etc).
Many thanks to Caba`drin, dunde and Somebody!
EDIT: Turns out I was wrong. The angle calculations aren't really working, it was a coincidence it pointed at the right place in Ruins. Yeah I know, bad testing from my part :/
As a workaround I set North manually for each stock map, excluding Siege and random maps. If someone knows how to fix it please do say so.