Well, I've liked very much the way that cRPG has done the quick talk and I decided to make sth like it, I even got that part of the source from the cRPG team, but I decided I was too lazy to adjust it to my liking, so I made my own system using to python to read a list of strings and options, basically like this:
so, here is the code, add this, it's a very crude code to create the presentation we need.
hope I haven't forgot anything
edit: of course, I'd forgotten module_meshes
Code:
quick_talk = [
("@menu name", key, "snd_sound", "@Message"),
# or
("@menu name", key, expandable, [
#submenu options
]),
so, here is the code, add this, it's a very crude code to create the presentation we need.
Well, you shouldn't exactly copy this, but use it as a template, since it's a copy of what is in my mod and i just made it for test as I wrote most of those strings while as spectator on a cRPG server clicking q many times .
you can add it to any file you like, I just created a file and named it as "module_quick_talk"
in the same file:
you can add it to any file you like, I just created a file and named it as "module_quick_talk"
Code:
expandable = -2
no_sound = -1
quick_talk = [
#("@menu name", key, "snd_sound", "@Message"),
# or
#("@menu name", key, expandable, [
#submenu options
#]),
#support 5 expands
("@[Q]uick", key_q, expandable,[
("@[Q]Help me", key_q, no_sound, "@Help me!"),
("@[H]ello", key_h, no_sound, "@Hello!"),
("@[I]'m sorry", key_i, no_sound, "@I'm sorry!"),
("@[W]atch your aim", key_w, no_sound, "@Watch your aim!"),
("@[T]hank you", key_t, no_sound, "@Thank you!"),
("@[S]ilence", key_s, no_sound, "@Silence!"),
("@[Y]es", key_y, no_sound, "@Yes!"),
("@[N]o", key_n, no_sound, "@No!"),
]),
("@[A]tack", key_a, expandable,[
("@[A]tack", key_a, no_sound, "@Atack!"),
("@Atack [L]eft flank", key_l, no_sound, "@Atack left flank!"),
("@Atack [R]ight flank", key_r, no_sound, "@Atack right flank!"),
("@[X]Charge", key_x, no_sound, "@Charge!"),
("@[O]pen the gate", key_o, no_sound, "@Open the gate!"),
("@Atack the [W]alls", key_w, no_sound, "@Atack the walls!"),
("@Atack their [S]iege tower", key_s, no_sound, "@Atack their siege tower!"),
("@Atack their [I]nfantry", key_i, no_sound, "@Atack their Infantry!"),
("@Atack their [A]rchers", key_a, no_sound, "@Atack their Archers!"),
("@Atack their [C]avalry", key_c, no_sound, "@Atack their Cavalry!"),
("@Atack their [F]lag", key_f, no_sound, "@Atack their flag!"),
]),
("@[D]efend", key_d, expandable,[
("@[D]efend", key_d, no_sound, "@Defend!"),
("@[C]lose the gate", key_c, no_sound, "@Close the gate!"),
("@Defend the [W]alls", key_w, no_sound, "@Defend the walls!"),
("@Defend the [L]adders", key_l, no_sound, "@Defend the ladders!"),
("@Defend the [S]iege tower", key_s, no_sound, "@Defend the siege tower!"),
("@Defend the [A]rchers", key_a, no_sound, "@Defend our archers!"),
("@Defend the [B]ase", key_b, no_sound, "@Defend our base!"),
("@Defend the [G]ate", key_g, no_sound, "@Defend the gate!"),
("@Defend the [F]lag", key_f, no_sound, "@Defend our flag!"),
]),
("@[I]ncoming", key_i, expandable,[
("@Incoming [I]nfantry", key_i, expandable,[
("@Incoming [I]nfantry", key_i, no_sound, "@Incoming Infantry!"),
("@Incoming Infantry from [B]ehind", key_b, no_sound, "@Incoming Infantry from behind!"),
("@Incoming Infantry from the [L]eft", key_l, no_sound, "@Incoming Infantry from the left!"),
("@Incoming Infantry from the [R]ight", key_r, no_sound, "@Incoming Infantry from the right!"),
]),
("@Incoming [C]avalry", key_c, expandable,[
("@Incoming [C]avalry", key_c, no_sound, "@Incoming Cavalry!"),
("@Incoming Cavalry from [B]ehind", key_b, no_sound, "@Incoming Cavalry from behind!"),
("@Incoming Cavalry from the [L]eft", key_l, no_sound, "@Incoming Cavalry from the left!"),
("@Incoming Cavalry from the [R]ight", key_r, no_sound, "@Incoming Cavalry from the right!"),
]),
("@Incoming [S]iege tower", key_s, no_sound, "@Incoming siege tower!"),
("@[A]rrows Incoming!", key_a, no_sound, "@Arrows Incoming!"),
]),
("@[S]elf", key_s, expandable,[
("@[A]tacking", key_a, expandable,[
("@I'm atacking [T]hem", key_t, no_sound, "@I'm atacking them!"),
("@I'm atacking their [I]nfantry", key_i, no_sound, "@I'm atacking their Infantry!"),
("@I'm atacking their [C]avalry", key_c, no_sound, "@I'm atacking their Cavalry!"),
("@I'm atacking their [A]rchers", key_a, no_sound, "@I'm atacking their Archers!"),
("@I'm atacking their [B]ase", key_b, no_sound, "@I'm atacking their Base!"),
("@I'm atacking their [F]lag", key_f, no_sound, "@I'm atacking their Flag!"),
("@I'm atacking their [W]alls", key_w, no_sound, "@I'm atacking their Walls!"),
("@I'm atacking their [G]ate", key_g, no_sound, "@I'm atacking their Gate!"),
("@I'm atacking their [S]iege tower", key_s, no_sound, "@I'm atacking their Siege tower!"),
]),
("@[D]efending", key_d, expandable,[
("@I'm [D]efending", key_d, no_sound, "@I'm defending!"),
("@I'm defending our [I]nfantry", key_i, no_sound, "@I'm defending our Infantry!"),
("@I'm defending our [C]avalry", key_c, no_sound, "@I'm defending our Cavalry!"),
("@I'm defending our [A]rchers", key_a, no_sound, "@I'm defending our Archers!"),
("@I'm defending our [B]ase", key_b, no_sound, "@I'm defending our Base!"),
("@I'm defending our [F]lag", key_f, no_sound, "@I'm defending our Flag!"),
("@I'm defending our [W]alls", key_w, no_sound, "@I'm defending our Walls!"),
("@I'm defending our [G]ate", key_g, no_sound, "@I'm defending our Gate!"),
("@I'm defending our [S]iege tower", key_s, no_sound, "@I'm defending our Siege tower!"),
]),
]),
("@[F]ormation", key_f, expandable,[
("@[T]ake cover", key_t, no_sound, "@Take cover!"),
("@[A]rchers", key_a, expandable,[
("@[H]old your fire", key_h, no_sound, "@Archers, Hold your fire!"),
("@Release [A]rrows", key_a, no_sound, "@Archers, Release arrows!"),
("@[F]ire at will", key_f, no_sound, "@Archers, Fire at will!"),
("@[R]etreat", key_r, no_sound, "@Archers, Retreat!"),
]),
("@[I]nfantry", key_i, expandable,[
("@[H]old your position", key_h, no_sound, "@Infantry, Hold your position!"),
("@Spread [O]ut", key_o, no_sound, "@Infantry, Spread out!"),
("@Stand [C]loser", key_c, no_sound, "@Infantry, Stand closer!"),
("@[P]ikewall", key_p, no_sound, "@Infantry, Pikewall formation!"),
("@[S]hieldwall", key_s, no_sound, "@Infantry, form a Shieldwall!"),
("@[B]ox", key_b, no_sound, "@Infantry, Box formation!"),
("@[A]dvance", key_a, no_sound, "@Infantry, Advance!"),
("@[R]etreat", key_r, no_sound, "@Infantry, Retreat!"),
("@[F]ollow me", key_f, no_sound, "@Infantry, Follow me!"),
("@[T]ake cover", key_t, no_sound, "@Infantry, Take cover!"),
("@[K]eep your formation", key_k, no_sound, "@Infantry, Keep your formation!"),
("@[X]Charge", key_x, no_sound, "@Infantry, Charge!"),
]),
("@[C]avalry", key_c, expandable,[
("@[H]old your position", key_h, no_sound, "@Cavalry, Hold your position!"),
("@Spread [O]ut", key_o, no_sound, "@Cavalry, Spread out!"),
("@Stand [C]loser", key_c, no_sound, "@Cavalry, Stand closer!"),
("@[W]edge", key_p, no_sound, "@Cavalry, Wedge formation!"),
("@[A]dvance", key_a, no_sound, "@Cavalry, Advance!"),
("@[R]etreat", key_r, no_sound, "@Cavalry, Retreat!"),
("@[F]ollow me", key_f, no_sound, "@Cavalry, Follow me!"),
("@[T]ake cover", key_t, no_sound, "@Cavalry, Take cover!"),
("@[K]eep your formation", key_k, no_sound, "@Cavalry, Keep your formation!"),
("@[X]Charge", key_x, no_sound, "@Cavalry, Charge!"),
]),
]),
]
in the same file:
Code:
def depth1(tuple,a,string,b):
block = []
for optiona in range(0,len(tuple)):
option = tuple[optiona]
if option[2] == -2:
option = option[3]
a = a - 1
if (not string is None) and ( string <> ""):
string = "%s_%s"%(string,optiona)
else:
string = "%s"%optiona
if a == 0:
if b == 1:
block += generate_state_change_trigger1(option,string)
else:
block += generate_load_trigger1(option,string)
else:
block += depth2(option,a,string,b)
return block[:]
def depth2(tuple,a,string,b):
block = []
for optiona in range(0,len(tuple)):
option = tuple[optiona]
if option[2] == -2:
option = option[3]
a = a - 1
if (not string is None) and ( string <> ""):
string = "%s_%s"%(string,optiona)
else:
string = "%s"%optiona
if a == 0:
if b == 1:
block += generate_state_change_trigger1(option,string)
else:
block += generate_load_trigger1(option,string)
else:
block += depth3(option,a,string,b)
return block[:]
def depth3(tuple,a,string,b):
block = []
for optiona in range(0,len(tuple)):
option = tuple[optiona]
if option[2] == -2:
option = option[3]
a = a - 1
if (not string is None) and ( string <> ""):
string = "%s_%s"%(string,optiona)
else:
string = "%s"%optiona
if a == 0:
if b == 1:
block += generate_state_change_trigger1(option,string)
else:
block += generate_load_trigger1(option,string)
else:
block += depth4(option,a,string,b)
return block[:]
def depth4(tuple,a,string,b):
block = []
for optiona in range(0,len(tuple)):
option = tuple[optiona]
if option[2] == -2:
option = option[3]
a = a - 1
if (not string is None) and ( string <> ""):
string = "%s_%s"%(string,optiona)
else:
string = "%s"%optiona
if a == 0:
if b == 1:
block += generate_state_change_trigger1(option,string)
else:
block += generate_load_trigger1(option,string)
else:
block += depth5(option,a,string,b)
return block[:]
def depth5(tuple,a,string,b):
block = []
for optiona in range(0,len(tuple)):
option = tuple[optiona]
if option[2] == -2:
option = option[3]
a = a - 1
if (not string is None) and ( string <> ""):
string = "%s_%s"%(string,optiona)
else:
string = "%s"%optiona
if a == 0:
if b == 1:
block += generate_state_change_trigger1(option,string)
else:
block += generate_load_trigger1(option,string)
else:
print "error: trying to get depth 6 quick chat"
return block[:]
def generate_load_trigger1(option,string):
block1 = []
block1 += [
(try_begin),
(dict_get_str,s0,"$dict","@quick_talk"),
(str_equals,s0,"@%s" % string),
]
for option2 in option:
block1 += [
(position_set_x,pos1,0),
(position_set_y,pos1,":pos_y"),
(position_set_x,pos2,700),
(position_set_y,pos2,700),
(create_mesh_overlay, reg0, "mesh_mp_ui_order_button"),
(overlay_set_position, reg0, pos1),
(overlay_set_size, reg0, pos2),
(position_set_x,pos1,2),
(position_move_y,pos1,4),
(position_set_x,pos2,975),
(position_set_y,pos2,975),
(create_text_overlay, reg1, option2[0], 0),
(overlay_set_position, reg1, pos1),
(overlay_set_size, reg1, pos2),
(val_sub,":pos_y",50),
]
block1 += [
(try_end),
]
return block1[:]
def generate_load_trigger2():
block1 = [
(set_fixed_point_multiplier,1000),
(presentation_set_duration,5*100),
(assign,":pos_y",700),
(create_text_box_overlay,"$temp","@_"),
(position_set_x,pos1,-9999),
(position_set_y,pos1,-9999),
(overlay_set_position,"$temp",pos1),
]
block1 += depth1(quick_talk,1,"",0)
block1 += depth1(quick_talk,2,"",0)
block1 += depth1(quick_talk,3,"",0)
block1 += depth1(quick_talk,4,"",0)
block1 += depth1(quick_talk,5,"",0)
return block1[:]
def generate_state_change_trigger1(option,string):
block1 = []
block1 += [
(try_begin),
(dict_get_str,s0,"$dict","@quick_talk"),
(str_equals,s0,"@%s" % string),
(try_begin),
(eq,1,0),
]
for option2a in range(0,len(option)):
option2 = option[option2a]
block1 += [
(else_try),
(key_clicked,option2[1]),
]
if option2[2] == -2:
block1 += [
(dict_set_str,"$dict","@quick_talk","@%s"%string),
(presentation_set_duration,0),
(start_presentation,"prsnt_quick_talk"),
]
else:
block1 += [
(multiplayer_send_string_to_server,multiplayer_event_server_show_quick_talk_message,option2[3]),
(neq,option2[2],-1),
(multiplayer_send_int_to_server,multiplayer_event_sound_at_player,option2[2]),
]
block1 += [
(try_end),
(try_end),
]
return block1[:]
def generate_state_change_trigger2():
block1 = []
block1 += depth1(quick_talk,1,"",1)
block1 += depth1(quick_talk,2,"",1)
block1 += depth1(quick_talk,3,"",1)
block1 += depth1(quick_talk,4,"",1)
block1 += depth1(quick_talk,5,"",1)
return block1[:]
quick_talk_prsnt = ("quick_talk",prsntf_read_only,0,[
(ti_on_presentation_load,generate_load_trigger2()),
(ti_on_presentation_event_state_change,generate_state_change_trigger2()),
])
at module_presentations, add at the top
and at the last "]"
Code:
from module_quick_talk import quick_talk_prsnt
Code:
] + quick_talk_prsnt
at module_mission_templates
Code:
quick_talk_triggers = [
(ti_after_mission_start,0,0,[(create_dict,"$dict"),(dict_set_str,"$dict","@quick_talk","@0")],[]),
(0,3,0,[(key_clicked,key_q),(start_presentation,"prsnt_quick_talk"),],[(dict_set_str,"$dict","@quick_talk","@0")]),
at module_scripts
add to script_game_receive_network_message on the server events part
and at the player events part
add to script_game_receive_network_message on the server events part
Code:
(else_try),
(eq, ":event_type", multiplayer_event_server_show_quick_talk_message),
(get_max_players,":max"),
(try_for_range,":player",0,":max"),
(player_is_active,":player"),
(multiplayer_send_string_to_player,":player",multiplayer_event_show_quick_talk_message,s0),
(try_end),
Code:
(else_try),
(eq, ":event_type", multiplayer_event_show_quick_talk_message),
(str_store_player_username,s1,":player_no"),
(display_message, "@{s1}:{s0}", 0x347235),
define
multiplayer_event_server_show_quick_talk_message
and
multiplayer_event_show_quick_talk_message
at header_common
multiplayer_event_server_show_quick_talk_message
and
multiplayer_event_show_quick_talk_message
at header_common
at module_meshes:
Code:
("mp_ui_order_button", 0, "mp_ui_order_button", 0, 0, 0, 0, 0, 0, 1, 1, 1),
hope I haven't forgot anything
edit: of course, I'd forgotten module_meshes