Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-05-01 10:48:46 +02:00
9 changed files with 143 additions and 11 deletions
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import lombok.extern.slf4j.Slf4j;
import net.runelite.cache.definitions.SpotAnimDefinition;
import net.runelite.cache.definitions.loaders.SpotAnimLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@Slf4j
public class SpotanimDumperTest
{
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
@Rule
public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test
public void test() throws IOException
{
File dumpDir = folder.newFolder("spotanims");
int count = 0;
try (Store store = new Store(StoreLocation.LOCATION))
{
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.SPOTANIM.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
SpotAnimLoader loader = new SpotAnimLoader();
for (FSFile file : files.getFiles())
{
byte[] b = file.getContents();
SpotAnimDefinition def = loader.load(file.getFileId(), b);
if (def != null)
{
Files.asCharSink(new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(def));
++count;
}
}
}
log.info("Dumped {} spotanims to {}", count, dumpDir);
}
}
@@ -71,21 +71,22 @@ public interface Actor extends Entity, Locatable
int getRSInteracting();
/**
* Gets the health ratio of the actor.
* <p>
* The ratio is the number of green bars in the overhead
* HP display.
* Gets the health of the actor in {@link #getHealthScale()} units.
*
* @return the health ratio
* The server does not transmit actors' real health, only this value
* between zero and {@link #getHealthScale()}. Some actors may be
* missing this info, in which case -1 is returned.
*/
int getHealthRatio();
/**
* Gets the health of the actor.
* Gets the maximum value {@link #getHealthRatio()} can return
*
* @return the health
* For actors with the default size health bar this is 30, but
* for bosses with a larger health bar this can be a larger number.
* Some actors may be missing this info, in which case -1 is returned.
*/
int getHealth();
int getHealthScale();
/**
* Gets the server-side location of the actor.
@@ -11453,12 +11453,21 @@ public final class ItemID
public static final int BLIGHTED_SUPER_RESTORE3 = 24601;
public static final int BLIGHTED_SUPER_RESTORE2 = 24603;
public static final int BLIGHTED_SUPER_RESTORE1 = 24605;
public static final int BLIGHTED_ICE_BARRAGE_SACK = 24607;
public static final int BLIGHTED_ANCIENT_ICE_SACK = 24607;
public static final int BLIGHTED_BIND_SACK = 24609;
public static final int BLIGHTED_SNARE_SACK = 24611;
public static final int BLIGHTED_ENTANGLE_SACK = 24613;
public static final int BLIGHTED_TELEBLOCK_SACK = 24615;
public static final int VESTAS_BLIGHTED_LONGSWORD = 24617;
public static final int VESTAS_LONGSWORD_INACTIVE = 24619;
public static final int BLIGHTED_VENGEANCE_SACK = 24621;
public static final int DIVINE_BATTLEMAGE_POTION4 = 24623;
public static final int DIVINE_BATTLEMAGE_POTION3 = 24626;
public static final int DIVINE_BATTLEMAGE_POTION2 = 24629;
public static final int DIVINE_BATTLEMAGE_POTION1 = 24632;
public static final int DIVINE_BASTION_POTION4 = 24635;
public static final int DIVINE_BASTION_POTION3 = 24638;
public static final int DIVINE_BASTION_POTION2 = 24641;
public static final int DIVINE_BASTION_POTION1 = 24644;
/* This file is automatically generated. Do not edit. */
}
@@ -12952,5 +12952,22 @@ public final class NullItemID
public static final int NULL_24616 = 24616;
public static final int NULL_24618 = 24618;
public static final int NULL_24620 = 24620;
public static final int NULL_24622 = 24622;
public static final int NULL_24624 = 24624;
public static final int NULL_24625 = 24625;
public static final int NULL_24627 = 24627;
public static final int NULL_24628 = 24628;
public static final int NULL_24630 = 24630;
public static final int NULL_24631 = 24631;
public static final int NULL_24633 = 24633;
public static final int NULL_24634 = 24634;
public static final int NULL_24636 = 24636;
public static final int NULL_24637 = 24637;
public static final int NULL_24639 = 24639;
public static final int NULL_24640 = 24640;
public static final int NULL_24642 = 24642;
public static final int NULL_24643 = 24643;
public static final int NULL_24645 = 24645;
public static final int NULL_24646 = 24646;
/* This file is automatically generated. Do not edit. */
}
@@ -13896,6 +13896,7 @@ public final class NullObjectID
public static final int NULL_29704 = 29704;
public static final int NULL_29709 = 29709;
public static final int NULL_29710 = 29710;
public static final int NULL_29712 = 29712;
public static final int NULL_29713 = 29713;
public static final int NULL_29714 = 29714;
public static final int NULL_29715 = 29715;
@@ -14123,6 +14124,7 @@ public final class NullObjectID
public static final int NULL_30144 = 30144;
public static final int NULL_30156 = 30156;
public static final int NULL_30159 = 30159;
public static final int NULL_30161 = 30161;
public static final int NULL_30171 = 30171;
public static final int NULL_30181 = 30181;
public static final int NULL_30182 = 30182;
@@ -15803,6 +15803,7 @@ public final class ObjectID
public static final int POOL_OF_NIGHTMARES = 29706;
public static final int POOL_OF_NIGHTMARES_29707 = 29707;
public static final int SCOREBOARD_29708 = 29708;
public static final int HAMMER_29711 = 29711;
public static final int NOTICEBOARD_29718 = 29718;
public static final int BALLISTA_29719 = 29719;
public static final int STAIRCASE_29720 = 29720;
@@ -16023,6 +16024,7 @@ public final class ObjectID
public static final int PAINTING_30155 = 30155;
public static final int FURNACE_30157 = 30157;
public static final int FURNACE_30158 = 30158;
public static final int RETURN_ORB = 30160;
public static final int CRACK_30169 = 30169;
public static final int ROOT_30170 = 30170;
public static final int PORTAL_30172 = 30172;
@@ -315,6 +315,6 @@ public final class ScriptID
/**
* Called to update the PVP widget (wilderness level/protection)
*/
@ScriptArguments(integer = 3)
@ScriptArguments(integer = 1)
public static final int PVP_WIDGET_BUILDER = 388;
}
@@ -9749,5 +9749,17 @@
24601,
24603,
24605
],
"divine battlemage potion": [
24623,
24626,
24629,
24632
],
"divine bastion potion": [
24635,
24638,
24641,
24644
]
}
@@ -114,7 +114,7 @@ public abstract class RSActorMixin implements RSActor
@Inject
@Override
public int getHealth()
public int getHealthScale()
{
RSIterableNodeDeque healthBars = getHealthBars();
if (healthBars != null)