if(src in perk_archive.contents)
var/p = ""
for(var/req in src.prerequisites)
p += "[req]"
if(req != src.prerequisites[src.prerequisites.len])
p += ", "
if(p == "") p = "None"
var/DESC = "<font color=white><small>Tier [src.tier] Perk<br>[src.description]</small>"
usr << browse("\ <body bgcolor=black><font color=white>[DESC]","window=perk_shop.perk_desc")
At this point, everything is working fine. The player then clicks the Purchase button and an alert asks if they're sure they want to purchase (insert name here). They hit purchase, and:
switch(input("Are you sure you wish to buy [usr.databaseperk.name]?","Confirmation") in list("No","Yes"))
var/PR = locate(usr.databaseperk) in usr.contents
alert(usr,"You already have that perk.")
var/reqs = check_reqs(usr.databaseperk)
if(reqs != "Pass")
else if(reqs == "Pass")
if(usr.databaseperk.RPPCost > 0 && usr.RPP >= usr.databaseperk.RPPCost)
usr.RPP -= usr.databaseperk.RPPCost
alert(usr, "You have purchased [usr.databaseperk] for [usr.databaseperk.RPPCost] RPP.")
It first checks if they already have the perk. If they don't, it proceeds to check the reqs before copying the object to them. The check_reqs proc takes the referenced object's prerequisites(stored in a list) and compares it to what the user has. It returns "Pass" if they have everything.
var/list/listed_requirements = perk.prerequisites.Copy()
for(var/obj/Perk/P in src)
if(P.name in listed_requirements)
listed_requirements -= P.name
var/text = "You don't meet the requirements for [perk] ( "
for(var/t in listed_requirements)
text += "[t])"
Assuming they both confirm their purchase and meet the requirements, it copies the object to them, excluding specific variables:
var/obj/copy_o = new O.type (usr)
copy_o.name = O.name
var/list/denyvar = list("client","key","loc","x","y","z","type")
for(var/V in O.vars)
if(V in denyvar)
copy_o.vars[V] = O.vars[V]
The problem seems to happen after saying "Yes" but before copying the object, as according to all reports I've gotten everything is normal until then - but all that happens during that time is checking if they already have that object, and checking the reqs. Neither of those two things influence their current choice(specifically, the databaseperk variable)
Often times a player will purchase a perk and be given a completely different one. I haven't personally experienced this, but the people I've spoken with who have had this happen(some of which are admins) tell me that up until they say "Yes" to purchasing, everything is correct - it tells them the name of the perk they want, etc. It's only after hitting "Yes" that it suddenly tells them they purchased something else. As an aside, while it's possible to click another object before confirming the purchase, all the reqs are checked at the time they press yes. Occasionally someone will obtain a perk they don't actually meet the reqs for, so I don't think that has anything to do with it.
I can't seem to find the cause for this. There seems to be no constant way to trigger it and I haven't been able to recreate it. Can anyone glean anything from my shop code or give any insight on why this would happen?