Skip to content
Snippets Groups Projects
Commit a6d277ae authored by DarkGod's avatar DarkGod
Browse files

can register on boot

parent 572e0d39
No related branches found
No related tags found
No related merge requests found
......@@ -747,9 +747,13 @@ function _M:instanciate(mod, name, new_game, no_reboot)
-- Load the savefile if it exists, or create a new one if not (or if requested)
local save = engine.Savefile.new(_G.game.save_name)
if save:check() and not new_game then
local delay
_G.game, delay = save:loadGame()
delay()
local g, delay = save:loadGame()
if not g then
save:delete()
else
_G.game = g
delay()
end
else
save:delete()
end
......
......@@ -91,6 +91,7 @@ function _M:uiLogin(uis)
local str = Textzone.new{auto_width=true, auto_height=true, text="#GOLD#Online Profile"}
local bt = Button.new{text="Login", width=50, fct=function() self:login() end}
local btr = Button.new{text="Register", fct=function() self:register() end}
self.c_login = Textbox.new{title="Username: ", text="", chars=16, max_len=20, fct=function(text) self:login() end}
self.c_pass = Textbox.new{title="Password: ", size_title=self.c_login.title, text="", chars=16, max_len=20, hide=true, fct=function(text) self:login() end}
......@@ -98,7 +99,8 @@ function _M:uiLogin(uis)
uis[#uis+1] = {hcenter=0, bottom=bt.h + self.c_login.h + self.c_pass.h, ui=str}
uis[#uis+1] = {left=0, bottom=bt.h + self.c_pass.h, ui=self.c_login}
uis[#uis+1] = {left=0, bottom=bt.h, ui=self.c_pass}
uis[#uis+1] = {hcenter=0, bottom=0, ui=bt}
uis[#uis+1] = {left=0, bottom=0, ui=bt}
uis[#uis+1] = {right=0, bottom=0, ui=btr}
end
function _M:uiLoginSteam(uis)
......@@ -147,6 +149,14 @@ function _M:loginSteam()
end
end
function _M:register()
local dialogdef = {}
dialogdef.fct = function(login) game:setPlayerLogin(login) end
dialogdef.name = "creation"
dialogdef.justlogin = false
game:registerDialog(require('mod.dialogs.ProfileLogin').new(dialogdef, game.profile_help_text))
end
function _M:logout()
profile:logOut()
self:on_recover_focus()
......
......@@ -1968,6 +1968,19 @@ function _M:hasAxeWeapon()
return weapon
end
--- Check if the actor has a weapon
function _M:hasWeaponType(type)
if self:attr("disarmed") then
return nil, "disarmed"
end
if not self:getInven("MAINHAND") then return end
local weapon = self:getInven("MAINHAND")[1]
if not weapon then return nil end
if type and weapon.combat.talented ~= type then return nil end
return weapon
end
--- Check if the actor has a cursed weapon
function _M:hasCursedWeapon()
if self:attr("disarmed") then
......
......@@ -227,13 +227,8 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
if dam ~= lastdam then
game:delayedLogDamage(src, target, 0, ("%s(%d to psi shield)#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", lastdam-dam), false)
end
lastdam = dam
if type ~= DamageType.PHYSICAL and target.knowTalent and target:knowTalent(target.T_STONE_FORTRESS) and target:hasEffect(target.EFF_DWARVEN_RESILIENCE) then
dam = math.max(0, dam - target:combatArmor() * (50 + target:getTalentLevel(target.T_STONE_FORTRESS) * 10) / 100)
end
if dam ~= lastdam then
game:delayedLogDamage(src, target, 0, ("%s(%d to armor)#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", lastdam-dam), false)
end
--target.T_STONE_FORTRESS could be checked/applied here (ReduceDamage function in Dwarven Fortress talent)
-- Damage Smearing
if dam > 0 and type ~= DamageType.TEMPORAL and target:hasEffect(target.EFF_DAMAGE_SMEARING) then
......@@ -309,8 +304,8 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
-- Flat damage reduction ("armour")
if dam > 0 and target.flat_damage_armor then
local dec = (target.flat_damage_armor.all or 0) + (target.flat_damage_armor[type] or 0)
if dec > 0 then game:delayedLogDamage(src, target, 0, ("%s(%d reduction)#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", dec), false) end
local dec = math.min(dam, (target.flat_damage_armor.all or 0) + (target.flat_damage_armor[type] or 0))
if dec > 0 then game:delayedLogDamage(src, target, 0, ("%s(%d resist armor)#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", dec), false) end
dam = math.max(0, dam - dec)
print("[PROJECTOR] after flat damage armor", dam)
end
......@@ -385,9 +380,9 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
if visible then -- don't log damage that the player doesn't know about
local source = src.__project_source or src
if src.turn_procs and src.turn_procs.is_crit then
game:delayedLogDamage(source, target, dam, ("#{bold}#%s%d %s#{normal}##LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", math.ceil(dam), DamageType:get(type).name), true)
game:delayedLogDamage(source, target, dam, ("#{bold}#%s%d %s#{normal}##LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", dam, DamageType:get(type).name), true)
else
game:delayedLogDamage(source, target, dam, ("%s%d %s#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", math.ceil(dam), DamageType:get(type).name), false)
game:delayedLogDamage(source, target, dam, ("%s%d %s#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", dam, DamageType:get(type).name), false)
end
end
end
......@@ -1624,7 +1619,7 @@ newDamageType{
local target = game.level.map(x, y, Map.ACTOR) -- Get the target first to make sure we heal even on kill
local realdam = DamageType:get(DamageType.BLIGHT).projector(src, x, y, DamageType.BLIGHT, dam.dam)
if target and realdam > 0 then
src:heal(realdam * dam.healfactor)
src:heal(realdam * dam.healfactor, target)
src:logCombat(target, "#Source# drains life from #Target#!")
end
return realdam
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment