Skip to content

Commit

Permalink
fixes summoning xp exploit, fixes incorrect xp gains
Browse files Browse the repository at this point in the history
  • Loading branch information
BurgerLUA committed Mar 26, 2024
1 parent 39e7786 commit 65f20be
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 28 deletions.
65 changes: 38 additions & 27 deletions code/_core/datum/damagetype/_damagetype.dm
Original file line number Diff line number Diff line change
Expand Up @@ -731,37 +731,48 @@
A.add_skill_xp(SKILL_SURVIVAL,xp_to_give)
experience_gained[SKILL_SURVIVAL] += xp_to_give

var/total_skill_damage_amount = 0
for(var/skill in skill_stats)
//var/experience/skill/E = SSexperience.all_skills[skill]
var/xp_to_give = CEILING(skill_stats[skill] * 0.01 * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_skill_xp(skill,xp_to_give)
experience_gained[skill] += xp_to_give

total_skill_damage_amount += skill_stats[skill]
for(var/attribute in attribute_stats)
var/experience/attribute/E = SSexperience.all_attributes[attribute]
if(!(E.flags & ATTRIBUTE_DAMAGE))
continue
var/xp_to_give = CEILING(attribute_stats[attribute] * 0.01 * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_attribute_xp(attribute,xp_to_give)
experience_gained[attribute] += xp_to_give

total_skill_damage_amount += attribute_stats[attribute]
for(var/skill in bonus_experience_skill)
//var/experience/skill/E = SSexperience.all_skills[skill]
var/xp_to_give = CEILING(bonus_experience_skill[skill] * 0.01 * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_skill_xp(skill,xp_to_give)
experience_gained[skill] += xp_to_give

total_skill_damage_amount += bonus_experience_skill[skill]
for(var/attribute in bonus_experience_attribute)
var/experience/attribute/E = SSexperience.all_attributes[attribute]
if(!(E.flags & ATTRIBUTE_DAMAGE))
continue
var/xp_to_give = CEILING(bonus_experience_attribute[attribute] * 0.01 * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_attribute_xp(attribute,xp_to_give)
experience_gained[attribute] += xp_to_give
total_skill_damage_amount += bonus_experience_attribute[attribute]

if(total_skill_damage_amount > 0)
for(var/skill in skill_stats)
//var/experience/skill/E = SSexperience.all_skills[skill]
var/xp_to_give = CEILING( (skill_stats[skill]/total_skill_damage_amount) * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_skill_xp(skill,xp_to_give)
experience_gained[skill] += xp_to_give

for(var/attribute in attribute_stats)
var/experience/attribute/E = SSexperience.all_attributes[attribute]
if(!(E.flags & ATTRIBUTE_DAMAGE))
continue
var/xp_to_give = CEILING( (attribute_stats[attribute]/total_skill_damage_amount) * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_attribute_xp(attribute,xp_to_give)
experience_gained[attribute] += xp_to_give

for(var/skill in bonus_experience_skill)
//var/experience/skill/E = SSexperience.all_skills[skill]
var/xp_to_give = CEILING( (bonus_experience_skill[skill]/total_skill_damage_amount) * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_skill_xp(skill,xp_to_give)
experience_gained[skill] += xp_to_give

for(var/attribute in bonus_experience_attribute)
var/experience/attribute/E = SSexperience.all_attributes[attribute]
if(!(E.flags & ATTRIBUTE_DAMAGE))
continue
var/xp_to_give = CEILING( (bonus_experience_attribute[attribute]/total_skill_damage_amount) * real_damage_dealt * experience_multiplier, 1)
if(xp_to_give > 0)
A.add_attribute_xp(attribute,xp_to_give)
experience_gained[attribute] += xp_to_give

if(length(experience_gained))
var/list/final_experience = list()
Expand Down
2 changes: 2 additions & 0 deletions code/_core/datum/damagetype/ranged/_ranged.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

alert_on_impact = ALERT_LEVEL_CAUTION

experience_mod = 0.5

/damagetype/ranged/get_block_power_penetration(var/atom/attacker,var/atom/victim,var/atom/weapon,var/atom/hit_object)
return 0.5

Expand Down
7 changes: 6 additions & 1 deletion code/_core/obj/item/soulgems/_soulgem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
rarity = RARITY_COMMON

var/mob/living/stored_soul_path
var/soul_gives_xp = TRUE

/obj/item/soulgem/save_item_data(var/mob/living/advanced/player/P,var/save_inventory = TRUE,var/died=FALSE,var/loadout=FALSE)
RUN_PARENT_SAFE
SAVEVAR("total_charge")
SAVEVAR("soul_gives_xp")
SAVEPATH("stored_soul_path")

/obj/item/soulgem/load_item_data_pre(var/mob/living/advanced/player/P,var/list/object_data,var/loadout=FALSE)
RUN_PARENT_SAFE
LOADVAR("total_charge")
LOADVAR("soul_gives_xp")
LOADPATH("stored_soul_path")

/obj/item/soulgem/Finalize()
Expand Down Expand Up @@ -154,6 +157,7 @@
return TRUE
total_charge = min(L.soul_size,total_capacity)
stored_soul_path = L.type
soul_gives_xp = FALSE
qdel(L)
update_sprite()
return TRUE
Expand Down Expand Up @@ -182,6 +186,7 @@
var/mob/living/L = caller
L.add_skill_xp(SKILL_SUMMONING,CEILING(S.soul_size*0.01,1))
stored_soul_path = S.soul_path
soul_gives_xp = TRUE
qdel(S)
update_sprite()

Expand All @@ -198,7 +203,7 @@
caller.visible_message(span("notice","\The [caller.name] recharges \the [S.name] with \the [src.name]."),span("notice","You charge \the [S] with \the [src]."))
S.total_charge += total_charge
total_charge -= total_charge
if(is_living(caller))
if(soul_gives_xp && is_living(caller))
var/mob/living/L = caller
L.add_skill_xp(SKILL_SUMMONING,CEILING(total_charge*0.0025,1))
if(!do_not_consume && total_charge <= 0)
Expand Down

0 comments on commit 65f20be

Please sign in to comment.