Jump to content

usefulBleach Release 1


EnigmaGrey

Recommended Posts

https://www.dropbox.com/s/0961pa6lv0rv8lm/usefulBleach.zip

No longer just a quaint method of thirst reduction, harness the buautifying pwoer of bleach to cleanse those stubborn blood stains from walls.

Version 1 cares about your pathetic inventory and it's contents. It rejects your attempts to wash anything and everything, other than which can be washed by bleach. From removing troublesom stains on walls to floors, bleach enables all.

If it doesn't come out in one go, try two, three, four, or even five times! Get that spot out.

Spoiler

 

https://www.dropbox.com/s/0961pa6lv0rv8lm/usefulBleach.zip

No longer just a quaint method of thirst reduction, harness the beautifying power of bleach to clean those stubborn blood stains (and far too much more)  from walls.


Version 0 doesn't care about your pathetic inventory, nor it's contents. It will let you wash anything, and everything, even those which won't appear washed (floor tiles, zombie corpses, yourself), but it will remove blood from walls -- and even remove accent pieces, such as trim overlapping brick.

Though this includes an additional Java function in IsoGridSquare (UnDoBloodSplat), it appears to be unnecessary. Everything it does should be doable in the Lua side . . . eventually.

Source code included.



Note, this is not compatible with save files (it will not work on loaded blood spatter nor blood overlays). Do not use this with The Censor mod. Be sure to use only in a well-ventilated area.
Link to comment
Share on other sites

Lua-only code to replace Java modifications:

local function washSquare ( _worldObjects )    print "let's do it"    local squareClicked = nil    local squareObjects = nil        for i,v in ipairs( _worldObjects ) do        print "get that square"                squareClicked = v:getSquare()            squareClicked:DirtySlice()            print "get those objects"                squareObjects = squareClicked:getObjects()            for j = 0, squareClicked:getObjects():size()-1 do        local isoObject = squareObjects:get(j)                print "iterate through objects"                if (isoObject:getSprite() )  then            print "check sprite"                        for k,l in ipairs (validSplat) do                print "check if valid splat"                                if squareClicked:getCell():getSpriteManager() then                    print "full of sprite"                end                                                --isoSprite = isoObject:getSprite( squareClicked:getCell():getSpriteManager(), validSplat[k])                                isoSprite = isoObject:getSprite()                                local isoSpriteName = isoObject:getSprite():getName()                                if isoSpriteName:contains(validSplat[k]) then                    print "contains k "                end                            if (not isoSprite) then                                    print "abandon on null sprite"                                        return                end                                isoSpriteInstance = isoSprite:newInstance()                                if isoSpriteInstance then                    print "very valid sprite"                                        if isoObject:getAttachedAnimSprite() then                                        print "remove attached anim sprite"                                            --isoObject:getAttachedAnimSprite():remove(isoSpriteInstance)                                                isoObject:getAttachedAnimSprite():clear()                    end                                        --if isoObject:getAttachedAnimSpriteActual() then                    --    isoObject:getAttachedAnimSpirteActual():remove(isoSpriteInstance)                    --end                end            end        end    end    endend

But, there's a catch: See isoObject:getAttachedAnimSprite():clear()? That's the only way to both remove the blood spatter and not have it just "pop up" on the tile. The commented code just below it, isoObject:getAttachedAnimSpirteActual():remove(isoSpriteInstance), simply doesn't work fully.

Now why is that?. . .
Link to comment
Share on other sites

for a = 0, isoObject:getAttachedAnimSprite():size()-1 do                          print (isoObject:getAttachedAnimSprite():get(a):getClass())  print (isoObject:getAttachedAnimSprite():get(a):getID())  print "but"  print (isoSpriteInstance:getID())end

Judging by the results of this, IsoSprite's ID never matches up with IsoSpriteInstance's ID.

Link to comment
Share on other sites

local function washSquare ( _worldObjects )        local squareClicked = nil        local squareObjects = nil               for i,v in ipairs( _worldObjects ) do                squareClicked = v:getSquare()        end               squareClicked:DirtySlice()               squareObjects = squareClicked:getObjects()                    for i = 0, squareClicked:getObjects():size()-1 do                local isoObject = squareObjects:get(i)                                                              if (isoObject:getSprite() )  then                                               isoSprite = isoObject:getSprite()                                                               local isoSpriteName = isoObject:getSprite():getName()                                                               isoSpriteInstance = isoSprite:newInstance()                                                               if isoSpriteInstance then                                                                               if isoObject:getAttachedAnimSprite() then                                                                                       for j = 0, isoObject:getAttachedAnimSprite():size()-1 do                                                                                                       for k,l in ipairs (validSplat) do                                                                isoSpriteInstance_a = isoObject:getAttachedAnimSprite():get(j)                                                                isoSpriteInstance_a = isoObject:getCell():getSpriteManager():getSprite(validSplat[l]):newInstance()                                                                                                                               if isoSpriteInstance_a and isoSpriteInstance_b then                                                                        if (isoSpriteInstance_a:getID() == isoSpriteInstance_b:getID()) then                                                                                print "match"                                                                        end                                                                end                                                        end                                        end                                                                   end                        end                end        endend

Far as I managed to come today -- which is to say it's gotten no where. Without access to the tables within IsoSpriteManager, reconciling what sprites are which by ID alone probably isn't possible. I'll just have to leave it at isoObject:getAttachedAnimSprite:clear() until a work around is either figured out or the Java is modified.

Link to comment
Share on other sites

So, here's the "solution:'

Added a function to IsoGridSquare

public void UndoSplat(){    this.DirtySlice();      for(int i = 0; i < this.getObjects().size(); ++i)      {         IsoObject obj = (IsoObject)this.getObjects().get(i);            for (int j = 0; j < this.bloodSplats.size(); ++ j )            {                if ( this.bloodSplats.get(j) != null ) {                    if (obj.AttachedAnimSprite != null ) {                    if (obj.AttachedAnimSprite.contains(bloodSplats.get(j)))                    {                        obj.AttachedAnimSprite.remove(bloodSplats.get(j));                    }                    }                }            }        }       }

That uses this handy new array

private ArrayList bloodSplats = new ArrayList();

That's populated by

            IsoSpriteInstance spr = new IsoSpriteInstance(spr1);            if(obj.AttachedAnimSprite == null) {               obj.AttachedAnimSprite = new ArrayList(4);               obj.AttachedAnimSpriteActual = new ArrayList(4);            }                        this.bloodSplats.add(spr); // registry for bloodsplat objects                        obj.AttachedAnimSpriteActual.add(spr1);            obj.AttachedAnimSprite.add(spr);

in IsoGridSquare's DoSplat()

Then it can be used from Lua like so:

local function UndoSplat(_worldObjects)    for i,v in ipairs( _worldObjects ) do        squareClicked = v:getSquare()    end        for k,l in ipairs (validSplat) do        squareClicked:UndoSplat(l)    endend
Link to comment
Share on other sites

https://www.dropbox.com/s/0961pa6lv0rv8lm/usefulBleach.zip

New version is up -- requires you to have bleach in your inventory. Because I didn't think to write a check function to see if blood is on a tile, for now this will have to do. Bleach is, at the moment, an inexhaustible item.

This version works only on floor tiles for the sake of testing.

Will need to

-Add a delta value to bleach (or whatever it's called) and,

-Add a function that detects whether a tile is bloody or not.

-Make bleach dilutable by a watersource within the inventory (new recipe -- "cleaning solution?")

-Make compatible with The Censor mod

Link to comment
Share on other sites

The floor code for IsoChunk is much easier (err, hopefully):

    public ArrayList getFloorBloodSplats() {            return FloorBloodSplats;        }   public void removeBloodSplat(int removeCount)  {      if ( (FloorBloodSplats.size() > removeCount) )   {       for (int i = 0; i <= removeCount; ++i)       {            this.FloorBloodSplats.remove(i);       }   } else if ( FloorBloodSplats.size() < removeCount )   {        this.FloorBloodSplats.clear();   }    }
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Not sure if this is considered necromancy...


 
Just wondering, you are 'technically' (pun lol) staff of TIS, and this is an addition that is probably planned anyway by the devs, so have you asked them if they will look into incorporating this into the base game?
 
Nice code btw.

Link to comment
Share on other sites

Not sure if this is considered necromancy...

 

Just wondering, you are 'technically' (pun lol) staff of TIS, and this is an addition that is probably planned anyway by the devs, so have you asked them if they will look into incorporating this into the base game?

 

Nice code btw.

Every day. Every hour. Every min- *disappears* (clyde)

Link to comment
Share on other sites

  • 3 weeks later...
An incredibly useful mod! Thank you very much for this! 

 

Some questions about the mod: 

 

Works with build 27? If that's right, I'm going to use it immediately on my server!

 

For the mod to work properly, you have to install everything that is included in the compressed file? There are two folders, one is for the installation directory of the game, and the other for Zomboid folder in the Users folder. Both are necessary?

 

Thank you very much for this mod, and by the Fire Extinguisher mod!

Link to comment
Share on other sites

Both are necessary; the mod makes some modifications to the game's Java code, while doing the actual work in Lua.

I don't plan to update this until build 28 is out, however, partially because It's also possible that it'll be added to the game in the  near future. Let me know if there's any errors, though.

Link to comment
Share on other sites

Well, I have bad news. With this mod, I can create the world, but just when I see my character for first time, the game closes. A shame, I would like to clean my house of blood. 

 

I'll wait until the updated version for the new build. Thank you very much for everything!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...