Post by Kamuna on Feb 9, 2014 7:25:53 GMT
Tutorial: Creating Normal Mode and Dependencies: Plain Text Version: dl.dropboxusercontent.com/u/176781620/IntermediateGuideToMysteryScript.txt
So you've finished making a Basic mode, and are ready to tackle on the next challenge? Good! So let's get to it!
Step 1: Setup
If you already read the previous tutorial, you already know the deal with setup. But, I'm here to pamper you, so I will briefly run over it with you.
We have to create one to three files, only with the script file's name being the same as the mode's name with a .ms extension at the end. Let's say you want to name your mode "Replica" mode. You'll have to create or get one to three files, the last two optional: Replica.ms (The script); Replica.ogg or similar supported types (The music); Replica.dmi (The picture, must be 512x512 pixels to fit). Inside the dmi file, there must be a icon state named Replica as well.
Step 2: Scripting the main file
The main file is the script file that will be run, Replica.ms in this case. Let's get started on it!
This mode will be a replica of Normal Mode, and so, we want the Normal mode roles. What this will be is actually four modes in one, one with just the killer, one with the killer and the suspect, one with the killer and the accomplice, and one with all three of them in play. So, we'll start with this:
setkiller("Killer");
setcustomrole1("Accomplice",0,2);
setcustomrole2("Suspect",1,2);
All this does is set the names of the roles inside Set Custom Roles. Remember to always end your lines with a semicolon, it lets the compiler know you're done with that line. You also may notice that both suspect and accomplice have extra arguments. The first extra argument sets a variable named “multi” which means it doesn't care if someone already has a role, it will set it to anybody. The second argument sets a variable named “forcerole” which will force a role to be on no matter what. 0 sets it to be off no matter what, 1 sets it to be on no matter what, and 2 lets the game decide whether or not it should be on based on the number of players. Be careful with this one! If there's not enough players to go around, the game will go into an infinite loop, which is very bad!
Time to set up the mode! Should go a little something like this:
setcustommode("Replica",1,"http://misuteriihigh.boards.net/thread/77/creating-normal-mode-dependencies-intermediate","Replica.ogg","Replica.dmi",file2text("ReplicaStart.ms"),file2text("ReplicaEnd.ms"),1);
This gives us a mode that is named Replica, requires one player, has the guide at misuteriihigh.boards.net/thread/77/creating-normal-mode-dependencies-intermediate, has a music file named Replica.ogg, has a picture named Replica.dmi, has the game start code refer to a dependency named ReplicaStart.ms, has the game end code refer to a dependency named ReplicaEnd.ms, and has one role by default.
Now, we're gonna decide whether or not we want the suspect and/or accomplice. To do this (NOTE - As of a previous update, you now must spawn this code in order to get your picture/music to show):
gameinprogress = gameinprogress();
checkmode = checkmode();
while(!gameinprogress && checkmode == "Replica")
{
gameinprogress = gameinprogress();
checkmode = checkmode();
numofplayers = numofplayers();
setcustomrole2("Suspect",1,0);
setcustomrole1("Accomplice",0,0);
if(numofplayers > 2 && numofplayers < 10 && prob(25) || numofplayers >= 10 && numofplayers < 13 && prob(75) || numofplayers >= 13 && prob(90))
{
setcustomrole1("Accomplice",0,1);
}
if(numofplayers >= 2 && prob(50))
{
setcustomrole2("Suspect",1,1);
}
wait(tick_lag());
}
What this code does? It checks if the game is NOT in progress, and if the current mode is Replica mode. (We set those as variables as functions cannot be compared in Mystery Script) Then, every frame (because of the wait(tick_lag()), which is important, else you'll have an infinite loop, which is, as I've said before, VERY BAD.), it resets the custom roles, then sets them based on the conditions set. Those conditions are self-explanatory, prob is true at probability of argument 1 percent, numofplayers is the number of players in the signup list. Now we're all done with that, onto the dependencies!
Step 3: Scripting the dependencies
Dependencies are files that are required in order for the main file to properly function. We'll start on the start game function, ReplicaStart.ms. Open up this file in a plain text editor, or create it if you haven't already. We start with the warning:
wprint("<big><font color=red><b>Warning:</b></font> Dead body located on the premises. Simple program analysis highly suggest either murder or assisted suicide; saving video feed from just before the event. Facility has been locked down until This System's authorities can be reached.</big>");
wprint just prints a message to the world. So far, so good. What's next? Ah right:
showkiller("You are the killer!");
printto(killer,"<b><i>You are the killer!</i></b>");
printto(killer,"<i>For whatever reason, you've killed one of the teachers. You left her body in the courtyard and made a mad dash to wash the evidence away. However, you've been caught out by the school security system and now you're trapped with a whole bunch of other students. If you don't do something, they're bound to discover that you're the killer and then who knows what'll happen? Your only choice is to wipe them all out and remove all the evidence.</i>");
We're setting the killer's role in the statpanel (showkiller), and telling them who they are in by printing two messages to them.
Now, let's check if we have an accomplice, and do the same to them, all the while letting the killer know that they have an accomplice.
if(customrole1)
{
showcustomrole1("You are the accomplice!");
x = strcat("<i>",get_alias(customrole1));
printto(killer,strcat(x," also had a hand in the murder. It's best the two of you get together to plot your next move."));
printto(customrole1,"<b><i>You are the accomplice!</i></b>");
a = strcat("Together with ",get_alias(killer));
printto(customrole1,strcat(a,", you killed one of the teachers, leaving her body in the courtyard. However, you've been caught out by the school security system and now you're trapped with a whole bunch of other students. If you don't do something, they're bound to discover that you're the killer and then who knows what'll happen? Your only choice is to wipe them all out and remove all the evidence."));
printto(customrole1,"<i>For whatever reason, you've killed one of the teachers. You left her body in the courtyard and made a mad dash to wash the evidence away. However, you've been caught out by the school security system and now you're trapped with a whole bunch of other students. If you don't do something, they're bound to discover that you're the killer and then who knows what'll happen? Your only choice is to wipe them all out and remove all the evidence.</i>");
}
What is this? A new function? If you've seen C++, this one might seem familiar to you. What this function does (strcat) is add onto your string (text) that you put as the first argument, and combines it with the second.
Now, we want to check if we have a suspect, no? Let's do that! And everything else with the suspect too!
gameinprogress = gameinprogress();
while(gameinprogress && customrole2)
{
gameinprogress = gameinprogress();
time = checktime();
if(customrole2)
{
if(time == "7PM")
{
y = strcat("<big><font color=red><b>Warning:</b></font>A suspect has been identified; Suspect is believed to have ",get_haircolor(customrole2));
wprint(strcat(y," colored hair.</big>"));
playsound(world,"alarm.wav");
break;
}
}
wait(tick_lag());
}
This bit of code waits until we get to 7PM, sounds an alarm and prints the suspect if there is one, then breaks out of the loop.
All done! Onto the end game code! Open up or create ReplicaEnd.ms and let's hop to it!
Here we are, the last part of the scripting. All we do is create a bunch a strings, put them together, and tell who is who, as well as some additional info.
a = strcat("The killer was ",get_realname(killer));
b = strcat(" / ",get_alias(killer));
c = strcat(", played by ",get_key(killer));
d = strcat(a,b);
e = strcat(d,c);
wprint(e);
wait(3);
if(customrole1)
{
k = strcat("The accomplice was ",get_realname(customrole1));
l = strcat(" / ",get_alias(customrole1));
m = strcat(", played by ",get_key(customrole1));
n = strcat(k,l);
o = strcat(n,m);
wprint(o);
wait(3);
}
if(customrole2)
{
f = strcat("The suspect was ",get_realname(customrole2));
g = strcat(" / ",get_alias(customrole2));
h = strcat(", played by ",get_key(customrole2));
i = strcat(f,g);
j = strcat(i,h);
wprint(j);
wait(3);
}
numdead = length(GetDead());
numalive = length(GetAlive());
if(numdead > 0)
{
if(numalive < 1)
{
wprint("Everyone died, including the killer!");
}
if(numalive == 1)
{
if(!findinlist(killer,GetAlive()))
{
wprint("Some people lived and some people died. The killer among them");
}
else
{
wprint("Everyone died but the killer. The killer wins!");
}
}
if(numalive > 1)
{
if(!findinlist(killer,GetAlive()))
{
wprint("Some people lived and some people died. The killer among them");
}
else
{
wprint("Some people lived and some people died. The killer, however, survived.");
}
}
}
else
{
wprint("It seems that nobody died. The killer loses.");
}
Nothing much new here. The ! operator just checks if the statement directly following it is false. GetDead may not include everyone, so we use the opposite of GetAlive to achieve the effect that we want. The length function gets the length of the list GetAlive and GetDead, which are pretty self-explanatory. Which means... We can finally upload our shiny new custom mode!
Step 4: Uploading
Ah, now the hard part is out of the way. Now... as a host or minihost, you want to upload your dependencies first, as the main script will need these in play. So go ahead and go to your host/minihost/admin tab, and click on Upload Custom Mode Dependency and select your ReplicaStart.ms. Do this again for the other file, ReplicaEnd.ms, as well as your alarmsound.wav. Now go ahead and upload your main script with music and picture as you did before (if you followed the previous tutorial). Now you can test your beautiful new mode! It's a masterpiece! Congratulations! You've reached the end of this rather lengthy tutorial. You may be able to call yourself a true Mystery Scripter now!