From c3ec34399a6132279a6b3dc5322d9b0069b79bf1 Mon Sep 17 00:00:00 2001 From: Kyep Date: Thu, 28 Jul 2016 02:53:57 -0700 Subject: [PATCH] Initial Checkin --- SQL/paradise_schema.sql | 1 + code/controllers/configuration.dm | 9 + code/game/gamemodes/gameticker.dm | 1 + code/game/jobs/job/engineering.dm | 9 +- code/game/jobs/job/job.dm | 3 + code/game/jobs/job/medical.dm | 2 + code/game/jobs/job/science.dm | 6 + code/game/jobs/job/security.dm | 8 + code/game/jobs/job/silicon.dm | 6 +- code/game/jobs/job/supervisor.dm | 4 + code/game/jobs/job_controller.dm | 3 + code/game/jobs/job_exp.dm | 154 ++++++++++++++++++ code/modules/client/preference/preferences.dm | 4 + .../client/preference/preferences_mysql.dm | 5 +- code/modules/mob/new_player/new_player.dm | 1 + config/example/config.txt | 4 + paradise.dme | 1 + 17 files changed, 216 insertions(+), 5 deletions(-) create mode 100644 code/game/jobs/job_exp.dm diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index dd54aea2e92..9278be59503 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -250,6 +250,7 @@ CREATE TABLE `player` ( `nanoui_fancy` smallint(4) DEFAULT '1', `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL, + `exp` mediumtext DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 5cedd40abfc..f8f5a68866b 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -127,6 +127,9 @@ var/use_age_restriction_for_jobs = 0 //Do jobs use account age restrictions? --requires database var/use_age_restriction_for_antags = 0 //Do antags use account age restrictions? --requires database + var/use_exp_tracking = 1 + var/use_exp_restrictions = 0 + var/simultaneous_pm_warning_timeout = 100 var/assistant_maint = 0 //Do assistants get maint access? @@ -239,6 +242,12 @@ if("use_age_restriction_for_antags") config.use_age_restriction_for_antags = 1 + if("use_exp_tracking") + config.use_exp_tracking = 1 + + if("use_exp_restrictions") + config.use_exp_restrictions = 1 + if("jobs_have_minimal_access") config.jobs_have_minimal_access = 1 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 7d6ea9b4e7d..aef3f54af66 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -470,6 +470,7 @@ var/round_start_time = 0 if(findtext("[handler]","auto_declare_completion_")) call(mode, handler)() + update_exp(round(ROUND_TIME / 60)) scoreboard() karmareminder() diff --git a/code/game/jobs/job/engineering.dm b/code/game/jobs/job/engineering.dm index 73e3e5717d3..c13ccc93e85 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -17,7 +17,8 @@ access_heads, access_construction, access_sec_doors, access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom) minimal_player_age = 21 - + exp_requirements = 240 + exp_type = "eng" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -54,7 +55,8 @@ minimal_access = list(access_eva, access_engine, access_engine_equip, access_tech_storage, access_maint_tunnels, access_external_airlocks, access_construction) alt_titles = list("Maintenance Technician","Engine Technician","Electrician") minimal_player_age = 7 - + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) @@ -89,7 +91,8 @@ minimal_access = list(access_eva, access_atmospherics, access_maint_tunnels, access_external_airlocks, access_emergency_storage, access_construction) alt_titles = list("Atmospheric Technician") minimal_player_age = 7 - + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index b8e7f44ecb4..209127d9abe 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -41,6 +41,9 @@ //If you have use_age_restriction_for_jobs config option enabled and the database set up, this option will add a requirement for players to be at least minimal_player_age days old. (meaning they first signed in at least that many days before.) var/minimal_player_age = 0 + var/exp_requirements = 0 + var/exp_type = "" + var/admin_only = 0 var/spawn_ert = 0 diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index a064f0247f5..4c0d54e07d6 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -15,6 +15,8 @@ access_chemistry, access_virology, access_cmo, access_surgery, access_RC_announce, access_keycard_auth, access_sec_doors, access_psychiatrist, access_maint_tunnels, access_paramedic, access_mineral_storeroom) minimal_player_age = 21 + exp_requirements = 240 + exp_type = "med" equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/science.dm b/code/game/jobs/job/science.dm index eb23d9a2427..46c99f48d5e 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -17,6 +17,8 @@ access_research, access_robotics, access_xenobiology, access_ai_upload, access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_maint_tunnels, access_mineral_storeroom) minimal_player_age = 21 + exp_requirements = 240 + exp_type = "sci" // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -55,6 +57,8 @@ minimal_access = list(access_tox, access_tox_storage, access_research, access_xenobiology, access_xenoarch, access_maint_tunnels, access_mineral_storeroom) alt_titles = list("Xenoarcheologist", "Anomalist", "Plasma Researcher", "Xenobiologist", "Chemical Researcher") minimal_player_age = 3 + exp_requirements = 240 + exp_type = "all" // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -91,6 +95,8 @@ minimal_access = list(access_robotics, access_tech_storage, access_morgue, access_research, access_maint_tunnels, access_mineral_storeroom) //As a job that handles so many corpses, it makes sense for them to have morgue access. alt_titles = list("Biomechanical Engineer","Mechatronic Engineer") minimal_player_age = 3 + exp_requirements = 120 + exp_type = "all" required_objectives=list( /datum/job_objective/make_cyborg, diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index fdf754df57f..e1b889ed75a 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -17,6 +17,8 @@ access_research, access_engine, access_mining, access_medical, access_construction, access_mailsorting, access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_pilot, access_weapons) minimal_player_age = 21 + exp_requirements = 240 + exp_type = "sec" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -60,6 +62,8 @@ access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_morgue, access_weapons) minimal_access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 21 + exp_requirements = 120 + exp_type = "sec" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -106,6 +110,8 @@ minimal_access = list(access_sec_doors, access_forensics_lockers, access_morgue, access_maint_tunnels, access_court, access_weapons) alt_titles = list("Forensic Technician") minimal_player_age = 14 + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) @@ -162,6 +168,8 @@ access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_morgue, access_weapons) minimal_access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 14 + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index 7bb2b006f87..a44040b5703 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -8,6 +8,8 @@ supervisors = "your laws" req_admin_notify = 1 minimal_player_age = 30 + exp_requirements = 240 + exp_type = "sil" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -15,7 +17,7 @@ /datum/job/ai/is_position_available() return (empty_playable_ai_cores.len != 0) - + /datum/job/cyborg title = "Cyborg" @@ -26,6 +28,8 @@ supervisors = "your laws and the AI" //Nodrak selection_color = "#ddffdd" minimal_player_age = 21 + exp_requirements = 120 + exp_type = "all" alt_titles = list("Android", "Robot") equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job/supervisor.dm b/code/game/jobs/job/supervisor.dm index 7768cf11870..980846edc53 100644 --- a/code/game/jobs/job/supervisor.dm +++ b/code/game/jobs/job/supervisor.dm @@ -12,6 +12,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) access = list() //See get_access() minimal_access = list() //See get_access() minimal_player_age = 30 + exp_requirements = 240 + exp_type = "com" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/heads/captain/alt(H), slot_l_ear) @@ -59,6 +61,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) idtype = /obj/item/weapon/card/id/silver req_admin_notify = 1 minimal_player_age = 21 + exp_requirements = 240 + exp_type = "sup" access = list(access_security, access_sec_doors, access_brig, access_court, access_forensics_lockers, access_medical, access_engine, access_change_ids, access_ai_upload, access_eva, access_heads, access_all_personal_lockers, access_maint_tunnels, access_bar, access_janitor, access_construction, access_morgue, diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 2409bda62ba..3a556f6d2e5 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -123,6 +123,9 @@ var/global/datum/controller/occupations/job_master if(job.admin_only) // No admin positions either. continue + if(!has_exp_for_job(player, job.title)) + continue + if(jobban_isbanned(player, job.title)) Debug("GRJ isbanned failed, Player: [player], Job: [job.title]") continue diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm new file mode 100644 index 00000000000..66685c85d3f --- /dev/null +++ b/code/game/jobs/job_exp.dm @@ -0,0 +1,154 @@ + +/proc/has_exp_for_job(mob/M, rank) + var/datum/job/job = job_master.GetJob(rank) + if(!job) + return 1 + if(!job.exp_requirements || !job.exp_type) + return 1 + if(!config.use_exp_restrictions) + return 1 + if(!M.client) + return 0 + //if(check_rights(R_ADMIN, 0, M)) + // return 1 + var/list/play_records = params2list(M.client.prefs.exp) + var/my_exp = text2num(play_records[job.exp_type]) + if(my_exp >= text2num(job.exp_requirements)) + //return_text += "
[C.mob] has [my_exp] of the [job.exp_requirements] [job.exp_type] EXP required for [job.title]." + return 1 + else + return 0 + +/client/verb/check_exp() + set name = "EXP Check" + set desc = "Shows your EXP status" + set category = "EXP" + if(!establish_db_connection()) + return 0 + var/exp_text = get_exp_text(src) + to_chat(src,exp_text) + +/client/proc/get_exp_text(var/client/C) + var/return_text = "" + var/list/play_records = params2list(C.prefs.exp) + var/exp_all = text2num(play_records["all"]) + var/exp_com = play_records["com"] + var/exp_sec = play_records["sec"] + var/exp_sci = play_records["sci"] + var/exp_eng = play_records["eng"] + var/exp_med = play_records["med"] + var/exp_sup = play_records["sup"] + var/exp_sil = play_records["sil"] + var/exp_ant = play_records["ant"] + var/exp_gho = play_records["gho"] + if(play_records.len) + return_text += "General EXP: [exp_all]" + if(exp_com > 0) + return_text += "
Command EXP: [exp_com]" + if(exp_sec > 0) + return_text += "
Security EXP: [exp_sec]" + if(exp_sci > 0) + return_text += "
Science EXP: [exp_sci]" + if(exp_eng > 0) + return_text += "
Engineering EXP: [exp_eng]" + if(exp_med > 0) + return_text += "
Medical EXP: [exp_med]" + if(exp_sup > 0) + return_text += "
Support EXP: [exp_sup]" + if(exp_sil > 0) + return_text += "
Silicon EXP: [exp_sil]" + if(exp_ant > 0) + return_text += "
Antag EXP: [exp_ant]" + if(exp_gho > 0) + return_text += "
Ghost EXP: [exp_gho]" + return_text += "
Jobs" + for(var/datum/job/job in job_master.occupations) + if(job.exp_requirements && job.exp_type) + if(has_exp_for_job(C.mob, job.title)) + return_text += " | [job.title] " + else + return_text += " | [job.title] " + return(return_text) + else + return("[C.mob] has no EXP records.") + +/client/verb/add_exp() + set name = "EXP ADD" + set desc = "DEBUG" + set category = "EXP" + update_exp(25) + +/client/proc/cmd_show_exp_panel(var/mob/living/M in mob_list) + set category = "EXP" + set name = "Show EXP Panel" + set desc="" + if(!check_rights(R_ADMIN)) + return + if(M.client) + var/body = "EXP for [M.key]" + body += M.client.get_exp_text(M.client) + body += "" + usr << browse(body, "window=adminplayerexp;size=550x615") + else + to_chat(usr,"Mob [M] has no client.") + +/proc/update_exp(var/minutes) + if(!establish_db_connection()) + return -1 + + for(var/client/C in clients) + if(C.inactivity < (10 * 10 * 60)) + //var/list/play_records = params2list(C.prefs.exp) + + var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") + exp_read.Execute() + var/list/play_records = list() + while(exp_read.NextRow()) + play_records = params2list(exp_read.item[1]) + // ------------- + + for(var/rtype in list("all","com","sec","sci","eng","med","sup","sil","ant", "gho")) + if(!text2num(play_records[rtype])) + play_records[rtype] = 0 + else + play_records[rtype] = text2num(play_records[rtype]) + + if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) + play_records["all"] += minutes + to_chat(C.mob,"You got: [minutes] EXP!") + if(C.mob.mind.assigned_role in command_positions) + play_records["com"] += minutes + to_chat(C.mob,"You got: [minutes] Command EXP!") + if(C.mob.mind.assigned_role in security_positions) + play_records["sec"] += minutes + to_chat(C.mob,"You got: [minutes] Security EXP!") + if(C.mob.mind.assigned_role in science_positions) + play_records["sci"] += minutes + to_chat(C.mob,"You got: [minutes] Science EXP!") + if(C.mob.mind.assigned_role in engineering_positions) + play_records["eng"] += minutes + to_chat(C.mob,"You got: [minutes] Engineering EXP!") + if(C.mob.mind.assigned_role in medical_positions) + play_records["med"] += minutes + to_chat(C.mob,"You got: [minutes] Medical EXP!") + if(C.mob.mind.assigned_role in support_positions) + play_records["sup"] += minutes + to_chat(C.mob,"You got: [minutes] Support EXP!") + if(C.mob.mind.assigned_role in nonhuman_positions) + play_records["sil"] += minutes + to_chat(C.mob,"You got: [minutes] Silicon EXP!") + if(C.mob.mind.special_role) + play_records["ant"] += minutes + to_chat(C.mob,"You got: [minutes] Special EXP!") + else if(isobserver(C.mob)) + play_records["gho"] += minutes + to_chat(C.mob,"You got: [minutes] Ghost EXP!") + else + return + var/new_exp = list2params(play_records) + C.prefs.exp = new_exp + new_exp = sanitizeSQL(new_exp) + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") + update_query.Execute() + + diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index c28f472020d..50fd26b929c 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -84,6 +84,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts //game-preferences var/lastchangelog = "" //Saved changlog filesize to detect if there was a change + var/exp var/ooccolor = "#b82e00" var/be_special = list() //Special role selection var/UI_style = "Midnight" @@ -551,6 +552,9 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(jobban_isbanned(user, rank)) HTML += "[rank] \[BANNED]" continue + if(!has_exp_for_job(user, job.title)) + HTML += "[rank] \[TIME]" + continue if(!job.player_old_enough(user.client)) var/available_in_days = job.available_in_days(user.client) HTML += "[rank] \[IN [(available_in_days)] DAYS]" diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index f72ac076dff..6bc3722c9b7 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -13,7 +13,8 @@ volume, nanoui_fancy, show_ghostitem_attack, - lastchangelog + lastchangelog, + exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'"} ) @@ -40,6 +41,7 @@ nanoui_fancy = text2num(query.item[11]) show_ghostitem_attack = text2num(query.item[12]) lastchangelog = query.item[13] + exp = query.item[14] //Sanitize ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) @@ -54,6 +56,7 @@ nanoui_fancy = sanitize_integer(nanoui_fancy, 0, 1, initial(nanoui_fancy)) show_ghostitem_attack = sanitize_integer(show_ghostitem_attack, 0, 1, initial(show_ghostitem_attack)) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) + exp = sanitize_text(exp, initial(exp)) return 1 /datum/preferences/proc/save_preferences(client/C) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 383f75b757f..bc166cfe893 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -246,6 +246,7 @@ if(!is_job_whitelisted(src, rank)) return 0 if(!job.player_old_enough(src.client)) return 0 if(job.admin_only && !(check_rights(R_EVENT, 0))) return 0 + if(!has_exp_for_job(src, rank)) return 0 if(config.assistantlimit) if(job.title == "Civilian") diff --git a/config/example/config.txt b/config/example/config.txt index 2f723c704f4..be79211b249 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -17,6 +17,10 @@ JOBS_HAVE_MINIMAL_ACCESS ## you have noone older than 0 days, since noone has been logged yet. Only turn this on once you have had the database up for 30 days. #USE_AGE_RESTRICTION_FOR_JOBS +## Unhash the first to track playtime in database. Unhash the second to restrict job access based on playtime. Note: playtime is not account age, it is actual playtime on the server. Some jobs (e.g: head jobs) require playtime in their department to unlock. +#USE_EXP_TRACKING +#USE_EXP_RESTRICTIONS + ## Unhash this entry to have certain antagonist roles require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different antag roles by editing special_role_times in /code/modules/client/preferences.dm. ## See USE_AGE_RESTRICTION_FOR_JOBS for more information #USE_AGE_RESTRICTION_FOR_ANTAGS diff --git a/paradise.dme b/paradise.dme index d79069d135d..249a386ea08 100644 --- a/paradise.dme +++ b/paradise.dme @@ -477,6 +477,7 @@ #include "code\game\gamemodes\xenos\xenos.dm" #include "code\game\jobs\access.dm" #include "code\game\jobs\job_controller.dm" +#include "code\game\jobs\job_exp.dm" #include "code\game\jobs\job_objective.dm" #include "code\game\jobs\jobs.dm" #include "code\game\jobs\whitelist.dm"