Nano-Mob Hunter GO! WIP commit 2: electric bugaloo

This commit is contained in:
FalseIncarnate
2016-09-05 01:19:07 -04:00
parent 78d311d20a
commit 42b6c73efa
8 changed files with 142 additions and 38 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ var/global/obj/machinery/mob_hunt_server/mob_hunt_server = null
/obj/machinery/mob_hunt_server/proc/register_spawn(datum/mob_hunt/mob_info)
if(!mob_info)
return 0
var/obj/effect/nanomob/new_mob = new /obj/effect/nanomob(locate(mob_info.x_coord, mob_info.y_coord, STATION_LEVEL), mob_info)
var/obj/effect/nanomob/new_mob = new /obj/effect/nanomob(get_turf(src), mob_info)
normal_spawns += new_mob
return 1
+16 -1
View File
@@ -12,6 +12,7 @@
var/list/clients_encountered = list() //tracks who has already interacted with us, so they can't attempt a second capture
/obj/effect/nanomob/New(loc, datum/mob_hunt/new_info)
..()
if(!new_info)
qdel(src)
return
@@ -21,6 +22,9 @@
icon_state = mob_info.icon_state_shiny
else
icon_state = mob_info.icon_state_normal
var/turf/target_turf = locate(mob_info.x_coord, mob_info.y_coord, STATION_LEVEL)
forceMove(target_turf)
to_chat(world, "[name] located at ([x],[y],[z])")
if(!mob_info.is_trap)
addtimer(src, "despawn", mob_info.lifetime)
@@ -43,6 +47,10 @@
return
var/datum/data/pda/app/mob_hunter_game/client = P.current_app
if(!client.connected) //must be connected to attempt captures
for(var/mob/O in hearers(4, P.loc))
O.show_message("[bicon(P)] No server connection. Capture aborted.")
return
if(mob_info.is_trap) //traps work even if you ran into them before
if(istype(P.loc, /mob/living/carbon))
@@ -84,4 +92,11 @@
mob_hunt_server.check_stability()
else
mob_hunt_server.normal_spawns -= src
qdel(src)
qdel(src)
/obj/effect/nanomob/proc/reveal()
if(invisibility == 101)
invisibility = 0
spawn(30)
if(src)
invisibility = 101
+1 -1
View File
@@ -16,10 +16,10 @@
if(mob_data.is_shiny)
name = "Holographic [mob_data.mob_name] Nano-Mob Hunter Card"
desc = "WOW! A holographic trading card containing a level [mob_data.level] [mob_data.mob_name]!"
icon_state = "trade_card_holo"
else
name = "[mob_data.mob_name] Nano-Mob Hunter Card"
desc = "A trading card containing a level [mob_data.level] [mob_data.mob_name]!"
icon_state = "trade_card_holo"
//Booster Pack Cards (random mob data)
/obj/item/weapon/nanomob_card/booster
+32 -11
View File
@@ -57,7 +57,7 @@
health[2] = base_health + (level * health_multiplier)
if(prob(1) && prob(1))
is_shiny = 1
if(no_register)
if(no_register) //for booster pack cards
return
if(mob_hunt_server)
if(set_trap)
@@ -67,6 +67,8 @@
mob_hunt_server.register_trap(src)
else if(select_spawn())
mob_hunt_server.register_spawn(src)
else //if we aren't a trap and can't spawn, delete the datum to avoid buildups
qdel(src)
else
qdel(src)
@@ -82,31 +84,37 @@
log_admin("No possible areas to spawn [type] found. Possible code/mapping error?")
return 0
var/list/possible_turfs = list()
var/turf/T
while(possible_areas.len)
//randomly select an area from our possible_areas list to try spawning in, then remove it from possible_areas so it won't get picked over and over forever.
var/spawn_area = pick(possible_areas)
possible_areas -= spawn_area
var/area/spawn_area = locate(pick_n_take(possible_areas))
if(!spawn_area)
break
//clear and generate a fresh list of turfs in the selected area, weighted based on white/black lists
possible_turfs.Cut()
for(var/turf/T in spawn_area)
for(var/turf/PT in spawn_area)
var/value = 1
if(is_type_in_list(T, turf_whitelist)) //if whitelisted, we have a significant bonus to our weight
if(is_type_in_list(PT, turf_whitelist)) //if whitelisted, we have a significant bonus to our weight
value += 2
if(is_type_in_list(T, turf_blacklist)) //blacklisting only removes 1 value (weight), so whitelisted subtypes are still more likely than normal turfs
if(is_type_in_list(PT, turf_blacklist)) //blacklisting only removes 1 value (weight), so whitelisted subtypes are still more likely than normal turfs
value -= 1 //but non-whitelisted turfs will be disqualified
if(!value)
continue
possible_turfs[T] = value
possible_turfs[PT] = value
if(!possible_turfs.len) //If we don't have any possible turfs, this attempt was a failure. Try again.
continue
//if we got this far, we're spawning on this attempt, hooray!
var/turf/T = pickweight(possible_turfs)
T = pickweight(possible_turfs)
x_coord = T.x
y_coord = T.y
break
if(T)
to_chat(world, "DEBUGGING: [type] spawning at ([x_coord], [y_coord])")
return 1
else
//if we get to this, we failed every attempt to find a suitable turf for EVERY area in our list of possible areas. DAMN.
log_admin("No acceptable turfs to spawn [type] on could be located. Possible code/mapping error, or someone replaced/destroyed all the acceptable turf types?")
return 0
log_admin("No acceptable turfs to spawn [type] on could be located. Possible code/mapping error, or someone replaced/destroyed all the acceptable turf types?")
return 0
/datum/mob_hunt/proc/calc_dam_multiplier(datum/mob_type/attack_type)
if(!primary_type)
@@ -169,6 +177,19 @@
health[2] = base_health + (level * health_multiplier)
message += "[nickname ? nickname : mob_name] has reached level [level]!"
/datum/mob_hunt/proc/get_type1()
if(!primary_type)
return "Typeless"
else
return initial(primary_type.name)
/datum/mob_hunt/proc/get_type2()
if(!secondary_type)
return null
else
return initial(secondary_type.name)
/datum/mob_hunt/nemabug
mob_name = "Nemabug"
run_chance = 50
+3
View File
@@ -427,6 +427,9 @@ var/global/list/obj/item/device/pda/PDAs = list()
user.drop_item()
C.forceMove(src)
to_chat(user, "<span class='notice'>You slide \the [C] into \the [src].</span>")
else if(istype(C, /obj/item/weapon/nanomob_card))
if(cartridge && istype(cartridge, /obj/item/weapon/cartridge/mob_hunt_game))
cartridge.attackby(C, user, params)
/obj/item/device/pda/attack(mob/living/C as mob, mob/living/user as mob)
if(istype(C, /mob/living/carbon) && scanmode)
+1 -1
View File
@@ -320,7 +320,7 @@
programs = list(
new/datum/data/pda/app/mob_hunter_game)
/obj/item/weapon/cartridge/mob_hunt_game/attackby(obj/item/O, mob/user)
/obj/item/weapon/cartridge/mob_hunt_game/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/weapon/nanomob_card))
var/obj/item/weapon/nanomob_card/card = O
var/datum/data/pda/app/mob_hunter_game/my_game = programs[1]
+35 -18
View File
@@ -13,6 +13,7 @@
var/list/my_collection = list()
var/current_index = 0
var/connected = 0
/datum/data/pda/app/mob_hunter_game/start()
..()
@@ -23,30 +24,41 @@
processing_objects.Remove(pda)
/datum/data/pda/app/mob_hunter_game/proc/scan_nearby()
if(!mob_hunt_server)
if(!mob_hunt_server || !connected)
return
for(var/turf/T in range(3, get_turf(pda)))
for(var/obj/O in T.contents)
if(!istype(O, /obj/effect/nanomob))
continue
var/obj/effect/nanomob/N = O
//reveal the mob
N.reveal()
/datum/data/pda/app/mob_hunter_game/proc/connect()
if(!mob_hunt_server || !mob_hunt_server.server_status)
/datum/data/pda/app/mob_hunter_game/proc/reconnect()
if(!mob_hunt_server || !mob_hunt_server.server_status || connected)
//show a message about the server being unavailable (because it doesn't exist / didn't get set to the global var / is offline)
return 0
mob_hunt_server.connected_clients += src
connected = 1
if(pda)
for(var/mob/O in hearers(2, pda.loc))
O.show_message("[bicon(pda)] Connection established. Capture all of the mobs, [pda.owner ? pda.owner : "hunter"]!")
return 1
/datum/data/pda/app/mob_hunter_game/proc/disconnect(reason_message = null)
/datum/data/pda/app/mob_hunter_game/proc/disconnect(reason = null)
if(!mob_hunt_server || !connected)
return
mob_hunt_server.connected_clients -= src
//show a disconnect message if we were disconnected involuntarily (message argument provided)
connected = 0
//show a disconnect message if we were disconnected involuntarily (reason argument provided)
if(pda && reason)
for(var/mob/O in hearers(2, pda.loc))
O.show_message("[bicon(pda)] Disconnected from server. Reason: [reason].")
/datum/data/pda/app/mob_hunter_game/program_process()
if(!mob_hunt_server)
return null
for(var/obj/effect/nanomob/N in range(3, pda.loc))
//TO-DO: show the mob (ideally only to the holder of the PDA, but we'll settle for the t-ray magic of showing everyone for right now)
if(N.invisibility == 101)
N.invisibility = 0
spawn(30)
if(N)
N.invisibility = 101
if(!mob_hunt_server || !connected)
return
scan_nearby()
/datum/data/pda/app/mob_hunter_game/proc/register_capture(datum/mob_hunt/captured)
if(!captured)
@@ -55,6 +67,11 @@
return 1
/datum/data/pda/app/mob_hunter_game/update_ui(mob/user as mob, list/data)
if(!mob_hunt_server || !(src in mob_hunt_server.connected_clients))
data["connected"] = 0
else
data["connected"] = 1
data["not_collection"] = 0
if(!my_collection.len)
data["no_collecton"] = 1
return
@@ -70,8 +87,8 @@
"nickname" = mob_info.nickname,
"real_name" = mob_info.mob_name,
"level" = mob_info.level,
"type1" = mob_info.primary_type,
"type2" = mob_info.secondary_type,
"type1" = mob_info.get_type1(),
"type2" = mob_info.get_type2(),
"sprite" = "[mob_info.icon_state_normal].png"
)
if(mob_info.is_shiny)
@@ -124,8 +141,8 @@
current_index--
if(current_index < 1)
current_index = my_collection.len
if("Connect")
connect()
if("Reconnect")
reconnect()
if("Disconnect")
disconnect()
if("Transfer")
+53 -5
View File
@@ -1,9 +1,36 @@
{{if data.no_collection}}
<div class="item">
<div class="itemLabel">My Collection:</div>
<div class="item">
<div class="itemLabel">
<table>
<tr>
<td>
Connection Status:
</td>
{{if data.connected}}
<td>
<span class="good">Connected</span>
</td>
<td>
{{:helper.link('Disconnect', 'sign-out', {'choice': 'Disconnect'})}}
</td>
{{else}}
<td>
<span class="bad">No Connection</span>
</td>
<td>
{{:helper.link('Connect', 'sign-in', {'choice': 'Reconnect'})}}
</td>
{{/if}}
</tr>
</table>
</div>
<div class="item">
<span class="average">Your collection is empty! Go capture some Nano-Mobs!</span>
</div>
<hr>
<div class="itemLabel">My Collection:</div>
{{if data.no_collection}}
<div class="statusDisplayRecords">
<div class="item">
<span class="average">Your collection is empty! Go capture some Nano-Mobs!</span>
</div>
</div>
{{else}}
<div class="statusDisplayRecords">
@@ -32,4 +59,25 @@
</div>
</div>
</div>
<div class="item">
<table>
<tr>
<td>
{{:helper.link('Previous Mob', 'arrow-left', {'choice': 'Prev'})}}
</td>
<td>
{{:helper.link('Transfer Mob', 'exchange', {'choice': 'Transfer'})}}
</td>
<td>
{{:helper.link('Rename Mob', 'pencil', {'choice': 'Rename'})}}
</td>
<td>
{{:helper.link('Release Mob', 'tree', {'choice': 'Release'})}}
</td>
<td>
{{:helper.link('Next Mob', 'arrow-right', {'choice': 'Next'})}}
</td>
</tr>
</table>
</div>
{{/if}}