This thread was made to be tutorial/manual for eMafia Role Creation.
The main concept around eMafia is to allow the players to choose how they want to play their game. And what is the biggest influence on a Mafia game? The roles of course! The roles define almost everything from the Setup, the player reaction, ability to do things, and the mystery. It's what makes or break a game setup.
Making your own role is more of an advanced step and may be more suited for players wanting to setup FM like games.
If your looking for a simple renaming of a role to suit a match's theme, at some later release Apo plans to have the ability to without creating a whole new role.
A Role consists of these items:
Name
Affiliation (Town,Mafia,Neutral,ect)
Category (CORE,INVESTIGATIVE,EVIL,ect) up to two
Team options: (If being on Team is enabled)
Team name Defaults to Affiliation name
Teammates visible On/Off (Think of Cult,Mason,Mafia/ Town is indeed a team, you just don't know who is who)
Share Night chat On/off (Simplifies creating chat channels without the need of scripts)
Share Win On/Off, All members of the team win as long as the team wins
Action Category:name of category to go into (Heal,Roleblock,Kill,Invest, ect)
Number of Day Targets: 0-2
Number of Night Targets: 0-2
Who you may target during Day:
Who you may target during Night:
Options currently include:
Everyone
Everyone except self
Only self
*Everyone except team
*All of team
*All of team except self
Event Scripts(all optional):Each role performs the script based time of day
onStartup - Just before game starts, allows exec to choose a random player, sets number of shots for vig, ect(only runs once)
onDayStart - Just before the Day discussion starts, player deaths happen just before this event
onDayTargetChoice - When a target is clicked during the day(if the role has the option to)
onDayEnd - Just before the day is over and after a lynch
onNightStart - Just before night starts
onNightTargetChoice - When a target is clicked during the night(if the role has the option to)
onNightEnd - Just before night ends. Most night actions such as attacking,blocking,healing,ect happen at this moment
onVisit - When the player is visited ( .visit() ) ,the visited player runs script.. includes player object 'visitor'
onAttacked - When the player is attacked ( .attack(int,String,String) ) ,the attacked player runs script.. includes player object 'visitor'
onDeath - When the player is killed
*onLynch - When the player is lynched
Victory Condition Script(optional):
Game Endable Script(optional):
When 'Team Share Win' is enabled, Victory Condition and Game Endable become the script for the entire Team, 'self' scriptObject is no longer usable and is instead replaced with 'team' due to the fact you are controlling a group rather than an individual.
---------------------------------------------------
Now just to give you a quick example of a common default role, Whee:
Name: Doctor
Affiliation: TOWN
Category: CORE PROTECTIVE
Action Category: Heal
onTeam: ON
Team Name: (blank)
Teammates visible OFF
Share Night chat OFF
Share Win ON
Number of Day Targets: 1
Number of Night Targets: 0
Who you may target during Day: Everyone except self
(During the example of these scripts the object references 'match', 'self', and sometimes 'team' are already provided)
onNightTargetChoice:
var target = self.getTarget1();
if(target != null){
self.text("You will heal "+target.getName()+" tonight.");
}
else{
self.text("You will not heal anyone tonight.");
}
onNightEnd:
if(self.isAlive()){
if(!self.hasFlag("ROLEBLOCKED")){
var target = self.getTarget1();
if(target != null){
self.visit(target);
target.setHp(target.getHp() + 1);
target.addFlag("healInform");
target.getFlag("healInform").setScriptPost("onAtta cked","
var doc = match.getPlayer("+self.getPlayerNum()+");
if(doc != null){
doc.text(\"Your target looks to have been attacked! Atleast you arrived to perform surgery.\");
self.text(\"Luckly, someone came to your rescue and performed surgery!\");
}
");
target.getFlag("healInform").setScriptPre("onDaySt art","
self.removeFlag(\"healInform\");
");
}
}
}
Victory Conditon: (Team Shared)
if(!match.isAffAlive("MAFIA")){
if(!match.isCatAlive("EVIL")){
team.setVictory(true);
}
}
Game Endable: (Team Shared) (this could have been combined in Victory Condition)
if(team.getVictory()){
team.setMayGameEnd(true);
}
-----------------------------------------------------------------
To some this may look complex, to others maybe not.
In english, this is what is happening:
During night, when the player selects a target(or selects it again to cancel),
-display "You will heal (name here) tonight." to the user.
After night ends, the game processes all night actions, the Heal actionCategory is next:
If the doctor is not roleblocked or dead
The player first visits the target.
-Increase the target's health by 1
-Creates a flag labeled 'healInform' (all this is going to do is inform the player and text about the healing if there is an attacker.
-Adds a script to run on the target in the event that the target is attacked containing:
-Tell my player "Your target looks to have been attacked! Atleast you arrived to perform surgery."
-Tell my target "Luckly, someone came to your rescue and performed surgery!" (They were most likly informed they were attacked first)
-Remove the flag at Day Start
-----------------------------------------------------------------------------
Mafiaso script example:
onNightTargetChoice:
var target = self.getTarget1();
if(target != null){
if(self.getVarInt("lastTarget") != 0){
team.pollVoteRemove("killTarget",self.getVarInt("l astTarget"));
}
team.pollVoteAdd("killTarget",target.getPlayerNum( ));
self.setVarInt("lastTarget",target.getPlayerNum()) ;
team.text(self.getName()+" suggests to kill "+target.getName()+" tonight.");
}
else{
if(self.getVarInt("lastTarget") != 0){
team.pollVoteRemove("killTarget",self.getVarInt("l astTarget"));
}
team.text(self.getName()+" withdraws their suggestion to kill anyone tonight.");
}
Godfather script example:
onStartup:
team.setScript("onNightEnd","
var killer;
var numMafiaioso = team.numRoleAlive(4);
var mafiaosos = new Array();
var loop = 0;
for(var player : team.getAliveTeammates()){
if(player.getRoleId() == 4){//mafiaso
player.clearTargets();
mafiaosos[loop] = player;
loop++;
}
if(player.getRoleId() == 7){//godfather
player.clearTargets();
killer = player;
}
}
var targetNum = team.getVarInt(\"GFKillTarget\");
if(targetNum == 0){//group vote(gf didnt decide)
targetNum = team.pollHighestVote(\"killTarget\");
}
if(targetNum > 0){
if(numMafiaioso >= 0){//if there are mafiaso
//random mafiaoso will kill
killer = match.randomPlayer(mafiaosos);
}
//else godfather will kill
if(killer != null){
team.text(killer.getName()+" has been sent to kill "+match.getPlayer(targetNum).getName()"+".");
killer.setTarget1(targetNum);
killer.addFlag("killTarget");
killer.getFlag("killTarget").setScriptPost(\"onNig htEnd\",\"
if(self.isAlive()){
if(!self.hasFlag(\\\"ROLEBLOCKED\\\")){
var target = self.getTarget1();
if(target != null){
self.visit(target);
self.attack(target,\\\"Shot\\\", \\\"shot between the eyes\\\");
}
}
}
\");
}
}
team.pollClear();
team.setVarInt(\"GFKillTarget\",0)
");
The main purpose of this thread is to explain how to make your own script and list of all the current commands.