ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Sat Dec 14, 2019 10:15 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Thu Jul 13, 2017 4:33 pm 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
How do I change the faction of player undead to Allied Kingdoms without editing the rest? In the Uncloak of Inconvenience addon, it overloads the undead birther file. Amongst other things, it says this:

Code:
copy = {
      resolvers.genericlast(function(e) e.faction = "allied-kingdoms" end),
      starting_zone = "blighted-ruins",
      starting_level = 3, starting_level_force_down = true,
      starting_quest = "start-undead",
      undead = 1,
      forbid_nature = 1,
      inscription_restrictions = { ["inscriptions/runes"] = true, ["inscriptions/taints"] = true, },
      resolvers.inscription("RUNE:_SHIELDING", {cooldown=14, dur=5, power=130}),
      --resolvers.inscription("RUNE:_PHASE_DOOR", {cooldown=7, range=10, dur=5, power=15}),
      resolvers.inscription("RUNE:_HEAT_BEAM", {cooldown=18, range=8, power=40}), -- yeek and undead starts are unfun to the point of absurdity
      resolvers.inventory({id=true, transmo=false,
         {type="scroll", subtype="rune", name="phase door rune", ego_chance=-1000, ego_chance=-1000}}), -- keep this in inventory incase people actually want it, can't add it baseline because some classes start with 3 inscribed
   },


So it is overwriting everything, including the inscriptions, which mucks up Tinker starts big time.

I tried to change just the faction with a ToME:load hook as here:

Code:
class:bindHook('ToME:load', function(self, data)
   local Birther = require 'engine.Birther'
    local undeadrace = Birther:getBirthDescriptor('race', 'Undead')
   undeadrace.copy.faction = resolvers.genericlast(function(e) e.faction = "allied-kingdoms" end)
end)


However, based on what I do, it either stays as Undead faction (at least the text does), or it mucks up other parts of the game (for example, the Necromancer being neutral to the player undead).

What is the way to change this so all Maj'Eyal Undead Players always start with Allied Kingdoms faction? Do I need to superload the undead.lua birther file instead?


Top
 Profile  
 
PostPosted: Fri Jul 14, 2017 3:11 pm 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
Any ideas? I'd love to make this change, and after that edit the starting text and perhaps remove the Cloak of Deception from even appearing (or change its description) once the Maj'Eyal Undead Player has the Allied Kingdoms faction.


Top
 Profile  
 
PostPosted: Sat Jul 15, 2017 12:47 am 
Offline
Sher'Tul Godslayer

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1724
Location: A shallow water area south of Bree
[sound F/X: source diving] I think the order in which the genericlast() resolvers are resolved is undetermined, so adding your own isn't guaranteed to work. (You definitely don't want to assign the resolver to the 'faction' field, though, since the resolver function you're providing returns nil, which would clobber the faction field immediately after you set it…)

In this case, you might need to do something a bit more invasive and surgically remove the genericlast() resolver. Something like this might work:
Code:
for k, v in pairs(undeadrace.copy) do
  if type(v) == 'table' and v.__resolver == 'genericlast' then
    undeadrace.copy[k] = nil
    break
  end
  undeadrace.copy.faction = 'allied-kingdoms'
end

[That could mess up if some other addon modified the descriptor before you did and added another resolvers.genericlast(), but I assess that as unlikely.]

Steven Aus wrote:
However, based on what I do, it either stays as Undead faction (at least the text does), or it mucks up other parts of the game (for example, the Necromancer being neutral to the player undead).

Hmm, yeah, I think that's what would happen if you clobbered your faction setting as I described above, which would leave the player with no faction at all.

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Sat Jul 15, 2017 1:14 am 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
I did this:

Code:
class:bindHook('ToME:load', function(self, data)
   local Birther = require 'engine.Birther'
   local undeadrace = Birther:getBirthDescriptor('race', 'Undead')
   for k, v in pairs(undeadrace.copy) do
      if type(v) == 'table' and v.__resolver == 'genericlast' then
      undeadrace.copy[k] = nil
      break
   end
   undeadrace.copy.faction = 'allied-kingdoms'
end
end)


and the faction the undead player had was "Players", and with the Cloak equipped it had "Allied Kingdoms" faction. Is it possible to make the undead player from the Allied Kingdoms faction without having the Cloak equipped? Is this even necessary considering the "Players" faction which undead players in Maj'Eyal currently start with with the above code would be allied with the people it needs to be, and opposed to the enemies it needs to be?

Btw: what do the two "_" in "v.__resolver" do? I also tried it with less or more of those, and the player faction was Undead. Only with two "_" was there the Players faction.


Top
 Profile  
 
PostPosted: Sat Jul 15, 2017 3:39 am 
Offline
Sher'Tul Godslayer

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1724
Location: A shallow water area south of Bree
Steven Aus wrote:
and the faction the undead player had was "Players", and with the Cloak equipped it had "Allied Kingdoms" faction.

…Huh. Maybe that's why the descriptor has to try so hard to set the 'undead' faction, because something else further downstream is clobbering it with the 'players' faction. Maybe you could try overwriting the resolvers.genericlast() with your own resolvers.genericlast(), something like this:
Code:
class:bindHook('ToME:load', function(self, data)
  local Birther = require 'engine.Birther'
  local undeadrace = Birther:getBirthDescriptor('race', 'Undead')
  for k, v in pairs(undeadrace.copy) do
    if type(v) == 'table' and v.__resolver == 'genericlast' then
      undeadrace.copy[k] = resolvers.genericlast(function(e) e.faction = "allied-kingdoms" end)
      break
    end
  end
end)


Steven Aus wrote:
Btw: what do the two "_" in "v.__resolver" do?

(shrug) It doesn't "do" anything per se; that's just the name of the field you're looking for. I wrote up a quick description of how resolvers work a while back; basically, the resolvers.genericlast() function literally returns a table with a __resolver='genericlast' field, which is what Entity:resolve() looks for to do its work [and what your ToME:load hook looks for to find and remove the resolver].

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Sat Jul 15, 2017 9:58 am 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
Now called Intrinsic Deception and uploaded to te4.org:

viewtopic.php?f=50&t=48119

https://te4.org/games/addons/tome/intrinsicdeception

Apart from the overloads of quest, chat, and objects (so the Necromancer talks about the ritual effect of making you look human was what caused your free will to remain), I made the "The rotting stench of the dead" quest to update when he died, rather than when you pick up the (now non-existent) Cloak.


Top
 Profile  
 
PostPosted: Sat Jul 15, 2017 1:22 pm 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
Is it possible to edit the data\chats\shertul-fortress-butler.lua file to add a condition to an existing option, via superload or hooks, without having to overload it?


Top
 Profile  
 
PostPosted: Sun Jul 16, 2017 12:55 am 
Offline
Sher'Tul Godslayer

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1724
Location: A shallow water area south of Bree
Steven Aus wrote:
Is it possible to edit the data\chats\shertul-fortress-butler.lua file to add a condition to an existing option, via superload or hooks, without having to overload it?

Yeah, you want the Chat:load hook. My Golem Speed Lock addon modifies that chat, so you can see how it's done.

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Sun Jul 16, 2017 2:39 am 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
So I guess it's possible to add a condition to an existing option, edit an option, or delete an option entirely?


Top
 Profile  
 
PostPosted: Tue Jul 18, 2017 1:35 am 
Offline
Sher'Tul Godslayer

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1724
Location: A shallow water area south of Bree
Steven Aus wrote:
So I guess it's possible to add a condition to an existing option, edit an option, or delete an option entirely?

Oh, sure, you can make all kinds of changes. Talent Point Planner, for instance, does extensive en passant meatball surgery on several store dialogs so that it can make a note that the player knows you can buy talents or talent trees there.

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Tue Aug 08, 2017 9:43 am 
Offline
Wyrmic

Joined: Sat Dec 13, 2014 3:38 pm
Posts: 287
How do I create a talent effect? I've said that the talent is only available for those players who have the undead attribute.

This is from an edited version of Intrinsic Deception, with the new talent added (\mod\class\Player.lua):

Code:
local _M = loadPrevious()

local super_onBirth = _M.onBirth
function _M:onBirth(birther)
  if self:attr("undead")
  then   self.descriptor.fake_race = "Human"
      self.descriptor.fake_subrace = "Cornac"
      [ActorTalents.T_SHOW_TRUE_FORM] = 1,
      end
end

return _M


How do I define that talent? What type of directory (data, superload, overload, hooks) and what to put in it? I'm thinking that when Show True Form is active, damage vs. Living will be +20%, but I'm open to other suggestions.

Also, what I want to do with this is the reverse of the Cloak of Deception effect, which is:

Code:
newEffect{
   name = "CLOAK_OF_DECEPTION", image = "shockbolt/object/artifact/black_cloak.png",
   desc = "Cloak of Deception",
   long_desc = function(self, eff) return "The target is under the effect of the cloak of deception, making it look human." end,
   decrease = 0, no_remove = true,
   type = "other",
   subtype = { undead=true },
   status = "neutral",
   parameters = {},
   on_gain = function(self, err) return ("#LIGHT_BLUE#An illusion appears around #Target# making %s appear human."):format(self:him_her()), "+CLOAK OF DECEPTION" end,
   on_lose = function(self, err) return "#LIGHT_BLUE#The illusion covering #Target# disappears.", "-CLOAK OF DECEPTION" end,
   activate = function(self, eff)
      self.old_faction_cloak = self.faction
      self.faction = "allied-kingdoms"
      if self.descriptor and self.descriptor.race and self:attr("undead") then self.descriptor.fake_race = "Human" end
      if self.descriptor and self.descriptor.subrace and self:attr("undead") then self.descriptor.fake_subrace = "Cornac" end
      if self.player then engine.Map:setViewerFaction(self.faction) end
   end,
   deactivate = function(self, eff)
      self.faction = self.old_faction_cloak
      if self.descriptor and self.descriptor.race and self:attr("undead") then self.descriptor.fake_race = nil end
      if self.descriptor and self.descriptor.subrace and self:attr("undead") then self.descriptor.fake_subrace = nil end
      if self.player then engine.Map:setViewerFaction(self.faction) end
   end,
}


So I guess this can be edited to get the effect I want, but how do I define the Talent that has the effect of changing Faction to Undead, and removing the fake_race and fake_subrace?

Also, is there any way to give this to an undead player whose game has already started? Obviously if I put it where it currently is it only works with new undead characters.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group