OSP Kit QoL [WB] Minesweeper

Users who are viewing this thread

Ikaguia

Grandmaster Knight
WBWF&SNW
Ok guys, it took me quite some time to get this ready, and I think it's nice, so, I decided to make it Open Source.
There is one major problem: the buttons don't stay clicked.
mb6ja.jpg

This kit needs some textures and a .BRF file, you can make your own or use this.
You need the module system to use this.
Here is the code:
Code:
########ika_minesweepwer
  ("minesweeper_0",			0, "minesweeper_0",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_1",			0, "minesweeper_1",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_2",			0, "minesweeper_2",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_3",			0, "minesweeper_3",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_4",			0, "minesweeper_4",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_5",			0, "minesweeper_5",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_6",			0, "minesweeper_6",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_7",			0, "minesweeper_7",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_8",			0, "minesweeper_8",			0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_square",	0, "minesweeper_square",	0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_mine_wrong",0, "minesweeper_mine_wrong",0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_flag",		0, "minesweeper_flag",		0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_mine_red",	0, "minesweeper_mine_red",	0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("minesweeper_mine",		0, "minesweeper_mine",		0, 0, 0, 0, 0, 0, 1, 1, 1),
########ika_minesweepwer
Code:
########ika_minesweepwer
    ("setup_minesweeper",0,mesh_load_window,[
      (ti_on_presentation_load,
       [(set_fixed_point_multiplier, 1000),
		(assign, "$g_presentation_obj_sliders_1_val", 10),
		(assign, "$g_presentation_obj_sliders_2_val", 10),
		(assign, "$g_presentation_obj_sliders_3_val", 10),
		(assign, reg1, "$g_presentation_obj_sliders_1_val"),
		(assign, reg2, "$g_presentation_obj_sliders_2_val"),
		(assign, reg3, "$g_presentation_obj_sliders_3_val"),
		(position_set_x, pos1, 600),
		(str_store_string, s1, "@How many colunms? {reg1}"),
		(create_text_overlay, "$g_presentation_credits_obj_1", s1, tf_center_justify),
		(position_set_y, pos1, 250),
		(overlay_set_position, "$g_presentation_credits_obj_1", pos1),
		(overlay_set_text, "$g_presentation_credits_obj_1", s1),
		(str_store_string, s1, "@How many rows? {reg2}"),
		(create_text_overlay, "$g_presentation_credits_obj_2", s1, tf_center_justify),
		(position_set_y, pos1, 350),
		(overlay_set_position, "$g_presentation_credits_obj_2", pos1),
		(overlay_set_text, "$g_presentation_credits_obj_2", s1),
		(str_store_string, s1, "@How many bombs? {reg3}"),
		(create_text_overlay, "$g_presentation_credits_obj_3", s1, tf_center_justify),
		(position_set_y, pos1, 450),
		(overlay_set_position, "$g_presentation_credits_obj_3", pos1),
		(overlay_set_text, "$g_presentation_credits_obj_3", s1),
		(create_slider_overlay, "$g_presentation_obj_sliders_1", 0, 30),#colunms
		(create_slider_overlay, "$g_presentation_obj_sliders_2", 0, 30),#rows
		(create_slider_overlay, "$g_presentation_obj_sliders_3", 0, 90),#bombs
		(overlay_set_val, "$g_presentation_obj_sliders_1", 10),
		(overlay_set_val, "$g_presentation_obj_sliders_2", 10),
		(overlay_set_val, "$g_presentation_obj_sliders_3", 10),
		(position_set_y, pos1, 200),
		(overlay_set_position, "$g_presentation_obj_sliders_1", pos1),
		(position_set_y, pos1, 300),
		(overlay_set_position, "$g_presentation_obj_sliders_2", pos1),
		(position_set_y, pos1, 400),
		(overlay_set_position, "$g_presentation_obj_sliders_3", pos1),
		(create_button_overlay, "$g_presentation_obj_profile_banner_selection_1", "@Start Game", tf_center_justify),
		(position_set_y, pos1, 500),
		(overlay_set_position, "$g_presentation_obj_profile_banner_selection_1", pos1),
		(create_button_overlay, "$g_presentation_obj_profile_banner_selection_2", "@Go back", tf_center_justify),
		(position_set_y, pos1, 600),
		(overlay_set_position, "$g_presentation_obj_profile_banner_selection_2", pos1),
        (presentation_set_duration, 1000000),
			]),
	  (ti_on_presentation_run,
	   [(assign, reg1, "$g_presentation_obj_sliders_1_val"),
		(assign, reg2, "$g_presentation_obj_sliders_2_val"),
		(assign, reg3, "$g_presentation_obj_sliders_3_val"),
		(str_store_string, s1, "@How many colunms? {reg1}"),
		(overlay_set_text, "$g_presentation_credits_obj_1", s1),
		(str_store_string, s1, "@How many rows? {reg2}"),
		(overlay_set_text, "$g_presentation_credits_obj_2", s1),
		(str_store_string, s1, "@How many bombs? {reg3}"),
		(overlay_set_text, "$g_presentation_credits_obj_3", s1),
		]),
      (ti_on_presentation_event_state_change,
       [(store_trigger_param_1, ":object"),
        (store_trigger_param_2, ":value"),
        (try_begin),
          (eq, ":object", "$g_presentation_obj_sliders_1"),
          (assign, "$g_presentation_obj_sliders_1_val", ":value"),
          (overlay_set_val, "$g_presentation_obj_sliders_1", "$g_presentation_obj_sliders_1_val"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_sliders_2"),
          (assign, "$g_presentation_obj_sliders_2_val", ":value"),
          (overlay_set_val, "$g_presentation_obj_sliders_2", "$g_presentation_obj_sliders_2_val"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_sliders_3"),
          (assign, "$g_presentation_obj_sliders_3_val", ":value"),
          (overlay_set_val, "$g_presentation_obj_sliders_3", "$g_presentation_obj_sliders_3_val"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_profile_banner_selection_1"),
          (start_presentation, "prsnt_play_minesweeper"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_profile_banner_selection_2"),
          (presentation_set_duration, 0),
        (try_end),
        ]),
      ]),
    ("play_minesweeper",0,mesh_load_window,[
      (ti_on_presentation_load,
       [(set_fixed_point_multiplier, 1000),
	    (call_script, "script_setup_minesweeper", reg1, reg2, reg3),
        (presentation_set_duration, 1000000),
        ]),
      (ti_on_presentation_run,
       [(store_trigger_param_1, ":time"),
	    (troop_set_slot, "trp_minesweeper", slot_game_time, ":time"),
	    (store_mul, ":num_squares", reg1, reg2),
		(try_for_range, ":square", 0, ":num_squares"),
			(troop_slot_ge, "trp_minesweeper", ":square", minesweeper_bomb + 1),
			(overlay_set_val, ":square", 1),
		(try_end),
        ]),
      (ti_on_presentation_event_state_change,
       [(store_trigger_param_1, ":object"),
        (try_begin),
          (eq, ":object", "$g_presentation_obj_profile_banner_selection_1"),
          (start_presentation, "prsnt_play_minesweeper"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_profile_banner_selection_2"),
          (presentation_set_duration, 0),
        (else_try),
		  (call_script, "script_click_minesweeper", ":object"),
        (try_end),
        ]),
      ]),
########ika_minesweepwer
Code:
########ika_minesweepwer
# script_setup_minesweeper
  ("setup_minesweeper",
   [(store_script_param, ":num_col", 1),#horizontal
	(store_script_param, ":num_row", 2),#vertical
	(store_script_param, ":num_bomb", 3),
	(store_mul, ":num_squares", ":num_col", ":num_row"),
	(store_div, ":x_size", 450, ":num_row"),
	(store_div, ":y_size", 450, ":num_col"),
	(assign, ":x_pos", 150),
	(assign, ":y_pos", 600),
	(try_for_range, ":square", 0, ":num_squares"),#clean slots
		(troop_set_slot, "trp_minesweeper", ":square", 0),
	(try_end),
	(troop_set_slot, "trp_minesweeper", slot_game_time, 0),
	(troop_set_slot, "trp_minesweeper", slot_game_clicks, 0),
	(troop_set_slot, "trp_minesweeper", slot_game_ended, 0),
	(try_for_range, ":unused", 0, ":num_bomb"),#add bombs
		(store_random_in_range, ":square", 0, ":num_squares"),
		(troop_slot_eq, "trp_minesweeper", ":square", 0),
		(troop_set_slot, "trp_minesweeper", ":square", minesweeper_bomb),
	(else_try),
		(val_add, ":num_bomb", 1),#if already used, try another one
	(try_end),
	(try_for_range, ":square", 0, ":num_squares"),#set others
		(troop_slot_eq, "trp_minesweeper", ":square", 0),
		(store_add, ":1", ":square", ":num_row"),
		(store_add, ":2", ":1", 1),
		(store_add, ":3", ":1", -1),
		(store_sub, ":4", ":square", ":num_row"),
		(store_add, ":5", ":4", 1),
		(store_add, ":6", ":4", -1),
		(store_add, ":7", ":square", 1),
		(store_add, ":8", ":square", -1),
		(assign, ":num_bombs", 0),
		(try_for_range, ":bomb", 0, ":num_squares"),#count bombs
			(troop_slot_eq, "trp_minesweeper", ":bomb", minesweeper_bomb),
			(this_or_next|eq, ":bomb", ":1"),
			(this_or_next|eq, ":bomb", ":2"),
			(this_or_next|eq, ":bomb", ":3"),
			(this_or_next|eq, ":bomb", ":4"),
			(this_or_next|eq, ":bomb", ":5"),
			(this_or_next|eq, ":bomb", ":6"),
			(this_or_next|eq, ":bomb", ":7"),
			(eq, ":bomb", ":8"),
			(val_add, ":num_bombs", 1),
		(try_end),
		(troop_set_slot, "trp_minesweeper", ":square", ":num_bombs"),
		(store_add, ":mesh_clicked", minesweeper_meshes_begin, ":num_bombs"),
		(val_clamp, ":mesh_clicked", minesweeper_meshes_begin, minesweeper_meshes_end),
		(eq, 1, 0),
	(else_try),
		(troop_slot_eq, "trp_minesweeper", ":square", minesweeper_bomb),
		(assign, ":mesh_clicked", minesweeper_meshes_end),
		(eq, 1, 0),
	(else_try),
		(create_image_button_overlay, reg0, "mesh_minesweeper_square", ":mesh_clicked"),
        (position_set_x, pos1, ":x_pos"),
        (position_set_y, pos1, ":y_pos"),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, ":x_size"),
        (position_set_y, pos1, ":y_size"),
        (overlay_set_size, reg0, pos1),
        (val_add, ":x_pos", ":x_size"),
        (ge, ":x_pos", 600),
        (assign, ":x_pos", 150),
        (val_sub, ":y_pos", ":y_size"),
	(try_end),
	#create the x/y at the right side of the screen
	(assign, ":y_pos", 550),
	(try_for_range, ":mesh", minesweeper_meshes_begin, minesweeper_meshes_end),
		(neg|is_between, ":mesh", "mesh_minesweeper_square", "mesh_minesweeper_mine_red"),
		(try_begin),
			(eq, ":mesh", "mesh_minesweeper_mine_red"),
			(assign, ":mesh", "mesh_minesweeper_mine"),
		(try_end),
		(create_mesh_overlay, reg0, ":mesh"),
		(position_set_x, pos1, 650),
        (position_set_y, pos1, ":y_pos"),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, ":x_size"),
        (position_set_y, pos1, ":y_size"),
        (overlay_set_size, reg0, pos1),
		#text
		(store_add, ":x_pos", ":x_size", 675),
		(position_set_x, pos1, ":x_pos"),
		(assign, reg20, 0),
		(assign, reg21, 0),
		(store_sub, ":cur_slot", ":mesh", minesweeper_meshes_begin),
		(store_add, ":cur_slot2", ":cur_slot", 100),
		(try_for_range, ":square", 0, ":num_squares"),
			(troop_slot_eq, "trp_minesweeper", ":square", ":cur_slot"),
			(val_add, reg21, 1),
		(else_try),
			(troop_slot_eq, "trp_minesweeper", ":square", ":cur_slot2"),
			(val_add, reg21, 1),
			(val_add, reg20, 1),
		(try_end),
		(str_store_string, s1, "@{reg20}/{reg21}"),
		(create_text_overlay, reg0, s1, tf_center_justify),
		(position_set_y, pos1, ":y_pos"),
		(overlay_set_position, reg0, pos1),
		(overlay_set_text, reg0, s1),
        (val_sub, ":y_pos", ":y_size"),
	(try_end),
	(position_set_x, pos1, 700),
	(create_button_overlay, "$g_presentation_obj_profile_banner_selection_1", "@Restart Game", tf_center_justify),
	(position_set_y, pos1, 650),
	(overlay_set_position, "$g_presentation_obj_profile_banner_selection_1", pos1),
	(create_button_overlay, "$g_presentation_obj_profile_banner_selection_2", "@Go back", tf_center_justify),
	(position_set_y, pos1, 600),
	(overlay_set_position, "$g_presentation_obj_profile_banner_selection_2", pos1),
   ]),
# script_click_minesweeper
  ("click_minesweeper",
   [(store_script_param, ":clicked_square", 1),
	(store_mul, ":num_squares", reg1, reg2),
	(troop_get_slot, ":clicks", "trp_minesweeper", slot_game_clicks),
	(val_add, ":clicks", 1),
	(troop_set_slot, "trp_minesweeper", slot_game_clicks, ":clicks"),
	(assign, ":num_col", reg1),#horizontal
	(assign, ":num_row", reg2),#vertical
	(store_div, ":x_size", 450, ":num_row"),
	(store_div, ":y_size", 450, ":num_col"),
	(try_begin),#don't allow to continue playing after it end
		(troop_slot_eq, "trp_minesweeper", slot_game_ended, 1),
		(display_message, "@You need to restart the game, it has already ended."),
	(else_try),
		(troop_get_slot, ":click", "trp_minesweeper", ":clicked_square"),
		(val_add, ":click", 100),
		(troop_set_slot, "trp_minesweeper", ":clicked_square", ":click"),
		(val_add, ":click", -100),
		(eq, ":click", minesweeper_bomb),#if it is a bomb
		(overlay_set_display, ":clicked_square", 0),#don't show
		(overlay_get_position, pos1, ":clicked_square"),
		(create_mesh_overlay, reg0, "mesh_minesweeper_mine_red"),
		(overlay_set_position, reg0, pos1),
		(position_set_x, pos1, ":x_size"),
		(position_set_y, pos1, ":y_size"),
		(overlay_set_size, reg0, pos1),
		(troop_set_slot, "trp_minesweeper", slot_game_ended, 1),
		(try_for_range, ":bomb", 0,  ":num_squares"),#show bombs
			(troop_slot_eq, "trp_minesweeper", ":bomb", minesweeper_bomb),
			(overlay_set_val, ":bomb", 1),
			(troop_get_slot, ":click", "trp_minesweeper", ":bomb"),
			(val_add, ":click", 100),
			(troop_set_slot, "trp_minesweeper", ":bomb", ":click"),
		(try_end),
		(display_message, "@You lost."),
	(else_try),
		(overlay_set_val, ":clicked_square", 1),#if not a not bomb
		(eq, ":click", 0),#if it has no bombs near
		(store_add, ":1", ":clicked_square", ":num_row"),
		(store_add, ":2", ":1", 1),
		(store_add, ":3", ":1", -1),
		(store_sub, ":4", ":clicked_square", ":num_row"),
		(store_add, ":5", ":4", 1),
		(store_add, ":6", ":4", -1),
		(store_add, ":7", ":clicked_square", 1),
		(store_add, ":8", ":clicked_square", -1),
		(try_for_range, ":square", 0,  ":num_squares"),#show others
			(this_or_next|eq, ":square", ":1"),
			(this_or_next|eq, ":square", ":2"),
			(this_or_next|eq, ":square", ":3"),
			(this_or_next|eq, ":square", ":4"),
			(this_or_next|eq, ":square", ":5"),
			(this_or_next|eq, ":square", ":6"),
			(this_or_next|eq, ":square", ":7"),
			(eq, ":square", ":8"),
			(call_script, "script_click_minesweeper", ":square"),
		(try_end),
	(try_end),
	(try_for_range, ":square", 0,  ":num_squares"),#count number of not clicked not bombs
		(neg|troop_slot_ge, "trp_minesweeper", ":square", minesweeper_bomb),
		(val_add, reg21, 1),
	(try_end),
	(try_begin),#win the game
		(le, reg21, 0),
		(troop_get_slot, reg22, "trp_minesweeper", slot_game_clicks),
		(troop_get_slot, reg23, "trp_minesweeper", slot_game_time),
		(display_message, "@Congratulations, you won the game in {reg22} seconds clicking {reg22} times!"),
		(troop_set_slot, "trp_minesweeper", slot_game_ended, 1),
	(try_end),
   ]),
########ika_minesweepwer
Code:
########ika_minesweepwer
  ["minesweeper","Minesweeper Dummy Troop","Minesweeper Dummy Troop",tf_hero, 0, reserved,  fac_commoners,[],str_3|agi_3|int_3|cha_3|level(1),wp(1),0,man_face_young_1,man_face_older_2],
########ika_minesweepwer
Code:
#ika_minesweeper constants
minesweeper_meshes_begin				= "mesh_minesweeper_0"
minesweeper_meshes_end					= "mesh_minesweeper_mine"
minesweeper_bomb						= 13
slot_game_time							= 1003##used only for "trp_minesweeper"
slot_game_clicks						= 1004##used only for "trp_minesweeper"
slot_game_ended							= 1005##used only for "trp_minesweeper"

Credits:
Windows, for Creating the game
Rubik, for the idea of getting Minesweeper into Mount&Blade
Taleworlds, for making Mount&Blade
 

Somebody

Code Pope
Baron
WBWF&S
reg1*reg2 doesn't do what you want to do - use store_mul with a local variable as the destination.
 

Revan Shan

Grandmaster Knight
What I've been waiting for is for somebody to create a chess minigame, but I fear that might be too complex.
 

Mad Vader

Duhpressed
Duke
M&BWB
Minesweeper was already made by rubik:

54726830201003161629402137202935179_000_640.jpg


I hope for your sake you can explain the similarities (including the identical 3 sliders in your code), because stealing code and representing it as your own is not a good idea.

(The image is taken from rubik's post here:
http://forums.taleworlds.com/index.php/topic,8652.msg2523358.html#msg252335:cool:
 

Revan Shan

Grandmaster Knight
Lumos said:
Not really. Designing the AI will be the complex part. :smile:

Well, that's exactly why I was saying it would be difficult. With all those movements and intelligent the PC oponent has.
 

Ikaguia

Grandmaster Knight
WBWF&SNW
well, the sliders are identical because they are from WB xD

I just adapted the custom battle code for the sliders, wich is native.
 

Ikaguia

Grandmaster Knight
WBWF&SNW
and the cross was actually just there to help me finding the right positions, that is the only Rubik's code.

and also, how can I steal his code if he is not sharing it?
the last version of his mod doesn't have the module system files and the one which had is not avaiable for download.
 

rubik

Squire
Ikaguia said:
and the cross was actually just there to help me finding the right positions, that is the only Rubik's code.

and also, how can I steal his code if he is not sharing it?
the last version of his mod doesn't have the module system files and the one which had is not avaiable for download.

What is this?
Ikaguia said:
Hey, do you still have the code for minesweeper you made?

54726830201003161629402137202935179_000_640.jpg


If you have, could you share it with me?
 

xenoargh

Grandmaster Knight
<grabs popcorn>

Y'know, if I wasn't about to leave on vacation, I'd sit back and enjoy the drama that's obviously about to unfold, since the minute I saw this, I was like, "that's Rubik's code"  :mrgreen:
 

Duh

Duke
M&BWB
Rubik only showed a message that asks for the code. Nothing that indicates that he shared it with Ikaguia.

This minewsweeper is obviously based upon rubiks screens, but im not convinced that he stole the code.
 
Duh said:
This minewsweeper is obviously based upon rubiks screens, but im not convinced that he stole the code.
Nobody is throwing accusations yet, eh? We (and rubik most of all) are waiting for what Ikaguia has to say on the matter.
The guy has made 8 posts since rubik posted a message, last one minutes ago. Answer here is kinda necessary.

And rubik does have a lot of credibility on this forum, you know.
 

MadocComadrin

Water-Borne Annelid
Count
M&BWBWF&S
That may be, but he wasn't the one that posted the first accusation. Frankly, we could all be persecuting Rubik here for using MS IP.  :wink:
 

Ikaguia

Grandmaster Knight
WBWF&SNW
as duh said, I made it based on his SS, but I didn't got his code or stealed or copiied it by any means...
If I had, why would there be errors in mine that errors in mine that doesnt seem to bee in his?


and he didn't gave me the code when I asked, that's why I made mine


and you can even ask caba'drin or taragoth if I wasn't asking them questions to help me get this thing working properly...
wait a minute and I'll post here the screens of me trying to get it working, just going to get the links at my imageshack account...

edit: here they are:









edit: if you people really want, I can remove this from here.
 

rubik

Squire
Ikaguia said:
as duh said, I made it based on his SS, but I didn't got his code or stealed or copiied it by any means...
If I had, why would there be errors in mine that errors in mine that doesnt seem to bee in his?


and he didn't gave me the code when I asked, that's why I made mine


and you can even ask caba'drin or taragoth if I wasn't asking them questions to help me get this thing working properly...
wait a minute and I'll post here the screens of me trying to get it working, just going to get the links at my imageshack account...


edit: if you people really want, I can remove this from here.

I'm sorry for failing to send an e-mail which including the code i want to give to you because of the e-mail system error. Please recheck your e-mail box.
 

Ikaguia

Grandmaster Knight
WBWF&SNW
ok, now I got it.

do you mind if I check what have your code to improve mine? I got some errors here...
 

Mad Vader

Duhpressed
Duke
M&BWB
rubik said:
Ikaguia said:
as duh said, I made it based on his SS, but I didn't got his code or stealed or copiied it by any means...
If I had, why would there be errors in mine that errors in mine that doesnt seem to bee in his?


and he didn't gave me the code when I asked, that's why I made mine


and you can even ask caba'drin or taragoth if I wasn't asking them questions to help me get this thing working properly...
wait a minute and I'll post here the screens of me trying to get it working, just going to get the links at my imageshack account...


edit: if you people really want, I can remove this from here.

I'm sorry for failing to send an e-mail which including the code i want to give to you because of the e-mail system error. Please recheck your e-mail box.

Wtf? After all this you are sending him the code?
I don't understand. The guy didn't mention you once and made a broken copy of something you created. (With alleged unauthorized use of resource files created by you.)
An intel. rights-aware person would have asked him to lock the thread and post an apology immediately. Or be banned for plagiarism (yes, it's that serious and it had happened before).

This kind of behavior should be sanctioned because it demotivates people to contribute open source packs. If any lazy person can steal and post as his own, the valuable contributors would go away. They are NOT huge multinationals, they are people who donate their free time and expertise to the community.
 
Top Bottom