Modding - Deleting Artifact from Anomaly

Arszi
Scavenger
Posts: 16
Joined: 04 Jan 2018, 06:45

Modding - Deleting Artifact from Anomaly

Postby Arszi » 07 Feb 2018, 17:26

I would like to delete an artifact from an anomaly.
I found this callback function:

Code: Select all

function anomaly_zone_binder:on_artefact_take(obj)
   local id
   if(type(obj.id)=="number") then
      id = obj.id
   else
      id = obj:id()
   end

    parent_zones_by_artefact_id[id] = nil
   artefact_ways_by_id[id] = nil
   artefact_points_by_id[id] = nil
   self.artefact_ways_by_id[id] = nil
   self.artefact_points_by_id[id] = nil
   self.spawned_count = self.spawned_count - 1
   if (self.spawned_count < 0) then
      self.spawned_count = 0
   end
end


My question is:

I won't pick up the artifact, it should be removed from the game for good. Will running the code above with the current artifact object do the trick, or should I call

Code: Select all

safe_release_manager.release(obj)
too, to avoid potential memory leaks?

luppolo
Scavenger
Posts: 35
Joined: 04 Nov 2016, 21:58

Re: Modding - Deleting Artifact from Anomaly

Postby luppolo » 08 Feb 2018, 06:13

just remove the artifacts from the anomaly config files without messing with the code

User avatar
Balathruin
Trespasser
Posts: 54
Joined: 18 May 2017, 13:36

Re: Modding - Deleting Artifact from Anomaly

Postby Balathruin » 08 Feb 2018, 06:28

luppolo wrote:just remove the artifacts from the anomaly config files without messing with the code

I don't think you understand what he wants.

luppolo
Scavenger
Posts: 35
Joined: 04 Nov 2016, 21:58

Re: Modding - Deleting Artifact from Anomaly

Postby luppolo » 08 Feb 2018, 06:41

Balathruin wrote:
luppolo wrote:just remove the artifacts from the anomaly config files without messing with the code

I don't think you understand what he wants.

if the artifact doesnt spawn to begin with then nobody (player or npc) can pick it up

Arszi
Scavenger
Posts: 16
Joined: 04 Jan 2018, 06:45

Re: Modding - Deleting Artifact from Anomaly

Postby Arszi » 08 Feb 2018, 07:32

I am working on a mod, which spawns artefacts by dynamic percentage in anomalies (For example, anomalies in Cordon will have 10% chance to spawn artefacts during blowout), then at the next blowout, it will remove/delete every artefacts from the anomalies, and spawnsnew ones with a certain percentage randomly.
I just used the "pick up" code, to reset the anomalies.

My original question was, that resetting an anomaly like this is enough, or I should release the artefacts? I want them to cease to exists, a safe way, which won't cause any long term issues with saved games, etc.

luppolo
Scavenger
Posts: 35
Joined: 04 Nov 2016, 21:58

Re: Modding - Deleting Artifact from Anomaly

Postby luppolo » 08 Feb 2018, 13:58

i think that when an artifact is spawned in an anomaly it exists as regular item, it's just a guess since when i load a game i often see the log message saying af_whatever is spawned, if that's true then just iterating all objects and calling

Code: Select all

alife():release(obj,true)

before an emission should do, of course you'll need to do some finer checks to not delete also all artifacts in stashes, on npc etc

Arszi
Scavenger
Posts: 16
Joined: 04 Jan 2018, 06:45

Re: Modding - Deleting Artifact from Anomaly

Postby Arszi » 08 Feb 2018, 20:13

Thank you,

Code: Select all

alife():release(obj,true)
does the trick.
I store the artefact id-s in a dictionary, and get the object back by alife():object(id) to release. This way I can not do any harm to artefacts in NPC inventory, stash, etc.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest

cron