Skip to content

Commit

Permalink
Added support for a new PPDrop field in enemy information
Browse files Browse the repository at this point in the history
  • Loading branch information
nbfields2 committed Sep 17, 2024
1 parent 3d44060 commit 7d3bfd9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
53 changes: 36 additions & 17 deletions Arrowgene.Ddon.Shared/AssetReader/EnemySpawnAssetDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ namespace Arrowgene.Ddon.Shared.AssetReader
{
public class EnemySpawnAssetDeserializer : IAssetDeserializer<EnemySpawnAsset>
{

// Consider this a macro that may be changed for balance
// reasons. Each enemy drops PP equal to its experience points
// divided by this number, unless an explicit value is
// provided (called "PPDrop") in which case that value is used
// instead.
private static uint EXP_PER_PP = 7500;

private static readonly ILogger Logger = LogProvider.Logger(typeof(EnemySpawnAssetDeserializer));

private static readonly string[] ENEMY_HEADERS = new string[]{"StageId", "LayerNo", "GroupId", "SubGroupId", "EnemyId", "NamedEnemyParamsId", "RaidBossId", "Scale", "Lv", "HmPresetNo", "StartThinkTblNo", "RepopNum", "RepopCount", "EnemyTargetTypesId", "MontageFixNo", "SetType", "InfectionType", "IsBossGauge", "IsBossBGM", "IsManualSet", "IsAreaBoss", "BloodOrbs", "HighOrbs", "Experience", "DropsTableId", "SpawnTime"};
private static readonly string[] ENEMY_HEADERS = new string[]{"StageId", "LayerNo", "GroupId", "SubGroupId", "EnemyId", "NamedEnemyParamsId", "RaidBossId", "Scale", "Lv", "HmPresetNo", "StartThinkTblNo", "RepopNum", "RepopCount", "EnemyTargetTypesId", "MontageFixNo", "SetType", "InfectionType", "IsBossGauge", "IsBossBGM", "IsManualSet", "IsAreaBoss", "BloodOrbs", "HighOrbs", "Experience", "DropsTableId", "SpawnTime", "PPDrop"};
private static readonly string[] DROPS_TABLE_HEADERS = new string[]{"ItemId", "ItemNum", "MaxItemNum", "Quality", "IsHidden", "DropChance"};

private Dictionary<uint, NamedParam> namedParams;
Expand Down Expand Up @@ -109,22 +117,33 @@ public EnemySpawnAsset ReadPath(string path)
Subgroup = subGroupId,
};

//checking if the file has spawntime, if yes we convert the time and pass it along to enemy.cs
if (enemySchemaIndexes.ContainsKey("SpawnTime"))
{
string SpawnTimeGet = row[enemySchemaIndexes["SpawnTime"]].GetString();
ConvertSpawnTimeToMilliseconds(SpawnTimeGet, out long start, out long end);
enemy.SpawnTimeStart = start;
enemy.SpawnTimeEnd = end;
}
else
{
// if no, we define it to the "allday" spawn time range and pass this along to the enemy.cs instead.
ConvertSpawnTimeToMilliseconds("00:00,23:59", out long start, out long end);
enemy.SpawnTimeStart = start;
enemy.SpawnTimeEnd = end;
}

// checking if the file has spawntime, if yes we convert the time and pass it along to enemy.cs
if(enemySchemaIndexes.ContainsKey("SpawnTime"))
{
string SpawnTimeGet = row[enemySchemaIndexes["SpawnTime"]].GetString();
ConvertSpawnTimeToMilliseconds(SpawnTimeGet, out long start, out long end);
enemy.SpawnTimeStart = start;
enemy.SpawnTimeEnd = end;
}
else
{
// if no, we define it to the "allday" spawn time range and pass this along to the enemy.cs instead.
ConvertSpawnTimeToMilliseconds("00:00,23:59", out long start, out long end);
enemy.SpawnTimeStart = start;
enemy.SpawnTimeEnd = end;
}

// check if the file has PPDrop.
if(enemySchemaIndexes.ContainsKey("PPDrop"))
{
// If yes, get it as a uint32.
enemy.PPDrop = row[enemySchemaIndexes["PPDrop"]].GetUInt32();
}
else
{
// If no, set the value to its experience / EXP_PER_PP.
enemy.PPDrop = enemy.Experience / EXP_PER_PP;
}

int dropsTableId = row[enemySchemaIndexes["DropsTableId"]].GetInt32();
if(dropsTableId >= 0)
Expand Down
4 changes: 2 additions & 2 deletions Arrowgene.Ddon.Shared/Files/Assets/EnemySpawn.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"HighOrbs",
"Experience",
"DropsTableId",
"SpawnTime"
"SpawnTime",
],
"dropsTables.items": [
"ItemId",
Expand Down Expand Up @@ -249547,4 +249547,4 @@
"00:00,23:59"
]
]
}
}
6 changes: 3 additions & 3 deletions Arrowgene.Ddon.Shared/Model/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Arrowgene.Ddon.Shared.Model
{
public class Enemy
{
private static uint EXP_PER_PP = 7500;

public Enemy()
{
NamedEnemyParams = NamedParam.DEFAULT_NAMED_PARAM;
Expand Down Expand Up @@ -41,6 +39,7 @@ public Enemy(Enemy enemy)
DropsTable = enemy.DropsTable;
NotifyStrongEnemy = enemy.NotifyStrongEnemy;
Subgroup = enemy.Subgroup;
PPDrop = enemy.PPDrop;
}

public uint Id { get; set; }
Expand Down Expand Up @@ -69,6 +68,7 @@ public Enemy(Enemy enemy)
public uint Experience { get; set; }
public DropsTable DropsTable { get; set; }
public bool NotifyStrongEnemy { get; set; }
public uint PPDrop { get; set; }
public uint UINameId { get
{
return NameMap.GetValueOrDefault(EnemyId);
Expand All @@ -83,7 +83,7 @@ public uint GetDroppedExperience()

public uint GetDroppedPlayPoints()
{
return GetDroppedExperience()/EXP_PER_PP; //TODO: Totally arbitrary. Figure out how to do this properly.
return PPDrop;
}

public CDataStageLayoutEnemyPresetEnemyInfoClient asCDataStageLayoutEnemyPresetEnemyInfoClient()
Expand Down

0 comments on commit 7d3bfd9

Please sign in to comment.