Fix random seed and difficulty

pull/28/head
milesthenerd 5 years ago
parent 3ad2d94a31
commit d106eb6a15

@ -1754,27 +1754,27 @@ if(instance_exists(self)){
switch(syncedDifficulty){
case 0:
//Easy
global.difficulty = syncedDifficulty;
oControl.mod_fusion = 0;
oControl.mod_diffmult = 1;
if(global.difficulty != syncedDifficulty) global.difficulty = syncedDifficulty;
if(oControl.mod_fusion != 0) oControl.mod_fusion = 0;
if(oControl.mod_diffmult != 1) oControl.mod_diffmult = 1;
break;
case 1:
//Normal
global.difficulty = syncedDifficulty;
oControl.mod_fusion = 0;
oControl.mod_diffmult = 1;
if(global.difficulty != syncedDifficulty) global.difficulty = syncedDifficulty;
if(oControl.mod_fusion != 0) oControl.mod_fusion = 0;
if(oControl.mod_diffmult != 1) oControl.mod_diffmult = 1;
break;
case 2:
//Hard
global.difficulty = syncedDifficulty;
oControl.mod_fusion = 0;
oControl.mod_diffmult = 2;
if(global.difficulty != syncedDifficulty) global.difficulty = syncedDifficulty;
if(oControl.mod_fusion != 0) oControl.mod_fusion = 0;
if(oControl.mod_diffmult != 2) oControl.mod_diffmult = 2;
break;
case 3:
//Fusion
global.difficulty = 2;
oControl.mod_fusion = 1;
oControl.mod_diffmult = 4;
if(global.difficulty != 2) global.difficulty = 2;
if(oControl.mod_fusion != 1) oControl.mod_fusion = 1;
if(oControl.mod_diffmult != 4) oControl.mod_diffmult = 4;
break;
}
</string>
@ -2796,6 +2796,29 @@ switch(type_event){
}
pbombsTimer = 1;
break;
case 29:
var syncDiff = buffer_read(_buffer, buffer_u8);
if(syncDiff != syncedDifficulty){
syncedDifficulty = syncDiff;
var str;
switch(syncedDifficulty){
case 0:
str = "Easy";
break;
case 1:
str = "Normal";
break;
case 2:
str = "Hard";
break;
case 3:
str = "Fusion";
break;
}
popup_text(str);
}
if(instance_exists(oOptionsMod) &amp;&amp; oOptionsMod.menuDifficulty != syncedDifficulty) oOptionsMod.menuDifficulty = syncedDifficulty;
break;
case 50:
var resend = false;
for(var i=0; i&lt;array_length_1d(global.item); i++){
@ -3349,6 +3372,43 @@ switch(type_event){
break;
}
}
</string>
</argument>
</arguments>
</action>
</event>
<event eventtype="7" enumb="10">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>buffer_delete(buffer);
var size, type, alignment;
size = 1024;
type = buffer_grow;
alignment = 1;
buffer = buffer_create(size, type, alignment);
buffer_seek(buffer, buffer_seek_start, 0);
buffer_write(buffer, buffer_u8, 29);
buffer_write(buffer, buffer_u8, syncedDifficulty);
var bufferSize = buffer_tell(buffer);
buffer_seek(buffer, buffer_seek_start, 0);
buffer_write(buffer, buffer_s32, bufferSize);
buffer_write(buffer, buffer_u8, 29);
buffer_write(buffer, buffer_u8, syncedDifficulty);
var result = network_send_packet(socket, buffer, buffer_tell(buffer));
</string>
</argument>
</arguments>

@ -25,7 +25,8 @@
<arguments>
<argument>
<kind>1</kind>
<string>global.curropt = 0;
<string>done = false;
global.curropt = 0;
var tempnumcounter = 0;
/*
This list dictates the order of selection in the Extras Menu.
@ -253,6 +254,7 @@ if (active) {
oClient.syncedDifficulty = 3;
menuDifficulty = 3;
}
with(oClient) event_user(0);
sfx_play(sndMenuMove);
event_user(2);
}
@ -281,6 +283,7 @@ if (active) {
oClient.syncedDifficulty = 0;
menuDifficulty = 0;
}
with(oClient) event_user(0);
sfx_play(sndMenuMove);
event_user(2);
}
@ -372,6 +375,15 @@ if (active) {
sfx_play(sndMenuSel);
event_user(2);
}
if (global.curropt == num_seedgen) {
if(instance_exists(oClient)){
randomize();
oClient.seed = random_get_seed();
random_set_seed(oClient.seed);
send_seed();
}
sfx_play(sndMenuSel);
}
if (global.curropt == lastitem) {
save_gameoptions();
view_object[0] = noone;
@ -423,6 +435,49 @@ if(instance_exists(oClient) &amp;&amp; instance_exists(self) &amp;&amp; instance
connectiontxt = "Connect";
op[num_connection].label = connectiontxt;
}
if(!done){
if(!instance_exists(oClient)){
op[num_difficulty].enabled = 0;
canedit[num_difficulty] = 0;
} else {
if(!instance_exists(oSS_Control)){
op[num_difficulty].enabled = 1;
canedit[num_difficulty] = 1;
} else {
op[num_difficulty].enabled = 0;
canedit[num_difficulty] = 0;
}
}
if(!instance_exists(oClient)){
op[num_seedgen].enabled = 0;
canedit[num_seedgen] = 0;
} else {
if(!instance_exists(oSS_Control)){
op[num_seedgen].enabled = 1;
canedit[num_seedgen] = 1;
} else {
op[num_seedgen].enabled = 0;
canedit[num_seedgen] = 0;
}
}
switch(menuDifficulty){
case 0:
op[num_difficulty].optext = "Easy";
break;
case 1:
op[num_difficulty].optext = "Normal";
break;
case 2:
op[num_difficulty].optext = "Hard";
break;
case 3:
op[num_difficulty].optext = "Fusion";
break;
}
}
</string>
</argument>
</arguments>
@ -578,21 +633,6 @@ switch(showname){
break;
}
switch(menuDifficulty){
case 0:
op[num_difficulty].optext = "Easy";
break;
case 1:
op[num_difficulty].optext = "Normal";
break;
case 2:
op[num_difficulty].optext = "Hard";
break;
case 3:
op[num_difficulty].optext = "Fusion";
break;
}
//if (oControl.mod_earlybaby == 1) {
// op[num_baby].optext = get_text("GlobalOptions", "Enabled");
//} else op[num_baby].optext = get_text("GlobalOptions", "Disabled");
@ -670,14 +710,6 @@ switch(showname){
break;
}
if(!instance_exists(oClient)){
op[num_difficulty].enabled = 0;
canedit[num_difficulty] = 0;
} else {
op[num_difficulty].enabled = 1;
canedit[num_difficulty] = 1;
}
ini_open(working_directory + "\mod_settings.ini");
ini_write_string("ModSettings", "ipaddress", ip);
ini_write_real("ModSettings", "port", real(port));
@ -712,7 +744,8 @@ oControl.port = real(port);
<arguments>
<argument>
<kind>1</kind>
<string>for (var i = 0; i &lt;= lastitem; i++)
<string>done = true;
for (var i = 0; i &lt;= lastitem; i++)
{
with (op[i]) instance_destroy();
}

@ -2,14 +2,12 @@ var temp_seed = random_get_seed();
randomize();
if(instance_exists(oClient)){
if(!is_undefined(oClient.seed)){
if(oControl.seed != oClient.seed){
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
}
} else {
oControl.seed = random_get_seed();
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
send_seed();
} else {
//oControl.seed = random_get_seed();
//random_set_seed(oControl.seed);
//send_seed();
}
} else {
oControl.seed = random_get_seed();

@ -2,14 +2,12 @@ var temp_seed = random_get_seed();
randomize();
if(instance_exists(oClient)){
if(!is_undefined(oClient.seed)){
if(oControl.seed != oClient.seed){
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
}
} else {
oControl.seed = random_get_seed();
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
send_seed();
} else {
//oControl.seed = random_get_seed();
//random_set_seed(oControl.seed);
//send_seed();
}
} else {
oControl.seed = random_get_seed();

@ -2,14 +2,12 @@ var temp_seed = random_get_seed();
randomize();
if(instance_exists(oClient)){
if(!is_undefined(oClient.seed)){
if(oControl.seed != oClient.seed){
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
}
} else {
oControl.seed = random_get_seed();
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
send_seed();
} else {
//oControl.seed = random_get_seed();
//random_set_seed(oControl.seed);
//send_seed();
}
} else {
oControl.seed = random_get_seed();

@ -2,14 +2,12 @@ var temp_seed = random_get_seed();
randomize();
if(instance_exists(oClient)){
if(!is_undefined(oClient.seed)){
if(oControl.seed != oClient.seed){
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
}
} else {
oControl.seed = random_get_seed();
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
send_seed();
} else {
//oControl.seed = random_get_seed();
//random_set_seed(oControl.seed);
//send_seed();
}
} else {
oControl.seed = random_get_seed();

@ -4,14 +4,12 @@ randomize();
if(instance_exists(oClient)){
if(!is_undefined(oClient.seed)){
if(oControl.seed != oClient.seed){
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
}
} else {
oControl.seed = random_get_seed();
oControl.seed = oClient.seed;
random_set_seed(oControl.seed);
send_seed();
} else {
//oControl.seed = random_get_seed();
//random_set_seed(oControl.seed);
//send_seed();
}
} else {
oControl.seed = random_get_seed();

@ -6,13 +6,13 @@ alignment = 1;
seedBuffer = buffer_create(size, type, alignment);
buffer_seek(seedBuffer, buffer_seek_start, 0);
buffer_write(seedBuffer, buffer_u8, 3);
buffer_write(seedBuffer, buffer_f64, oControl.seed);
buffer_write(seedBuffer, buffer_f64, oClient.seed);
buffer_write(seedBuffer, buffer_u8, global.clientID);
var bufferSize = buffer_tell(seedBuffer);
buffer_seek(seedBuffer, buffer_seek_start, 0);
buffer_write(seedBuffer, buffer_s32, bufferSize);
buffer_write(seedBuffer, buffer_u8, 3);
buffer_write(seedBuffer, buffer_f64, oControl.seed);
buffer_write(seedBuffer, buffer_f64, oClient.seed);
buffer_write(seedBuffer, buffer_u8, global.clientID);
var result = network_send_packet(oClient.socket, seedBuffer, buffer_tell(seedBuffer));
popup_text("Seed sent");

Loading…
Cancel
Save