Optimization (ft. common data pointers)

This commit is contained in:
kevinmonitor 2022-09-18 20:50:17 +07:00
parent b9c85d7580
commit dba085c30f
10 changed files with 21 additions and 16 deletions

Binary file not shown.

View File

@ -12,9 +12,6 @@
#include "script/KevinSystem/kevin_system/Lib_Const.dnh"
let ITEMID_PTR = LoadAreaCommonDataValuePointer("ScriptID", "ItemID", 0);
let SYSTEMID_PTR = LoadAreaCommonDataValuePointer("ScriptID", "SystemID", 0);
// Code by Kevinmonitor with some assistance.
/*
@ -839,8 +836,8 @@ task _EnemyItemDrop(
{
if (isFlying) {SetCommonData("Flying Defeated", GetCommonData("Flying Defeated", 0)+1);}
else {SetCommonData("Ground Defeated", GetCommonData("Ground Defeated", 0)+1);}
if (isFlying) {SetCommonDataPtr(FLYINGENM_PTR, GetCommonDataPtr(FLYINGENM_PTR, 0)+1);}
else {SetCommonDataPtr(GROUNDENM_PTR, GetCommonDataPtr(GROUNDENM_PTR, 0)+1);}
//_ExplosionEffect(enmX, enmY, PetalEffect);
//_ScorePopup(float enmX, float enmY, int pointNum, int pivNum);

View File

@ -22,6 +22,12 @@
// Convenience constants
let ITEMID_PTR = LoadAreaCommonDataValuePointer("ScriptID", "ItemID", 0);
let SYSTEMID_PTR = LoadAreaCommonDataValuePointer("ScriptID", "SystemID", 0);
let FLYINGENM_PTR = LoadCommonDataValuePointer("Flying Defeated", 0);
let GROUNDENM_PTR = LoadCommonDataValuePointer("Ground Defeated", 0);
const STG_WIDTH = GetStgFrameWidth();
const STG_HEIGHT = GetStgFrameHeight();

View File

@ -8,6 +8,8 @@
int rank = 1; // Increases through time
let RANK_PTR = LoadCommonDataValuePointer("Rank", 1);
let objScene = GetEnemyBossSceneObjectID();
let csd = GetCurrentScriptDirectory();
@ -603,7 +605,7 @@ task EndBonus(int ID, int IDship){
ObjEnemy_SetLife(bossObj, -1);
let timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMERF);
WriteLog(timer);
//WriteLog(timer);
// Bonus Calculations:
@ -639,8 +641,8 @@ task EndBonus(int ID, int IDship){
rankAvgFinal = rankSum/length(rankAvg);
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-180, 30, 0x397FFF, "TIME REMAINING: " ~ vtos("5.2f", timer/60));
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-140, 30, 0x00CC00, "GROUND ENEMIES DEFEATED: " ~ IntToString(GetCommonData("Ground Defeated", 0)));
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-100, 30, 0x8400CC, "FLYING ENEMIES DEFEATED: " ~ IntToString(GetCommonData("Flying Defeated", 0)));
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-140, 30, 0x00CC00, "GROUND ENEMIES DEFEATED: " ~ IntToString(GetCommonDataPtr(GROUNDENM_PTR, 0)));
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-100, 30, 0x8400CC, "FLYING ENEMIES DEFEATED: " ~ IntToString(GetCommonDataPtr(FLYINGENM_PTR, 0)));
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-60, 30, 0x3400CC, "AVERAGE RANK: " ~ vtos("5.2f", rankAvgFinal));
_CreateBonusText(STG_WIDTH/2, STG_HEIGHT/2-20, 30, 0xCC00C8, "MULTIPLIER: " ~ vtos("5.2f", GetAreaCommonData("PIV", "currentvalue", 0)/10000));
@ -648,7 +650,7 @@ task EndBonus(int ID, int IDship){
wait(120);
float multiplierBonus = timer/60 * 5 + GetCommonData("Ground Defeated", 0)/5 + GetCommonData("Flying Defeated", 0)/5 + rankAvgFinal * 5;
float multiplierBonus = timer/60 * 5 + GetCommonDataPtr(GROUNDENM_PTR, 0)/5 + GetCommonDataPtr(FLYINGENM_PTR, 0)/5 + rankAvgFinal * 5;
int scoreBonus = trunc ( (multiplierBonus * GetAreaCommonData("PIV", "currentvalue", 0)) / 10 ) * 10;

View File

@ -190,7 +190,7 @@ task _SmallFairyFallingLine(
_EnemyItemDrop(
enm, true,
5, 3,
10+(GetCommonData("Rank", 1)-1)*2, 6+(GetCommonData("Rank", 1)-1)*1,
10+(GetCommonDataPtr(RANK_PTR, 1)-1)*2, 6+(GetCommonDataPtr(RANK_PTR, 1)-1)*1,
120, smallEnemyHitbox*2
);
@ -252,7 +252,7 @@ task _SmallFairyAimedFan(
_EnemyItemDrop(
enm, true,
5, 3,
10+(GetCommonData("Rank", 1)-1)*2, 6+(GetCommonData("Rank", 1)-1)*1,
10+(GetCommonDataPtr(RANK_PTR, 1)-1)*2, 6+(GetCommonDataPtr(RANK_PTR, 1)-1)*1,
120, smallEnemyHitbox*2
);
@ -321,7 +321,7 @@ task _SmallFairyRing(
_EnemyItemDrop(
enm, true,
5, 3,
10+(GetCommonData("Rank", 1)-1)*2, 6+(GetCommonData("Rank", 1)-1)*1,
10+(GetCommonDataPtr(RANK_PTR, 1)-1)*2, 6+(GetCommonDataPtr(RANK_PTR, 1)-1)*1,
120, smallEnemyHitbox*2
);
@ -379,7 +379,7 @@ task _CreateFrog(
_EnemyItemDrop(
enm, false,
4, 8,
7+round((GetCommonData("Rank", 1)-1)*1.25), 15+(GetCommonData("Rank", 1)-1)*2,
7+round((GetCommonDataPtr(RANK_PTR, 1)-1)*1.25), 15+(GetCommonDataPtr(RANK_PTR, 1)-1)*2,
120, popcornHitbox*2
);
@ -506,7 +506,7 @@ task _CreateKingFrog(
_EnemyItemDrop(
enm, false,
8, 14,
round(15+(GetCommonData("Rank", 1)-1)*1.25), round(20+(GetCommonData("Rank", 1)-1)*2),
round(15+(GetCommonDataPtr(RANK_PTR, 1)-1)*1.25), round(20+(GetCommonDataPtr(RANK_PTR, 1)-1)*2),
180, largeEnemyHitbox*2.5
);
@ -758,7 +758,7 @@ task _CreateRybbShip(
_EnemyItemDrop(
enm, true,
6, 10,
round(9+(GetCommonData("Rank", 1)-1)*1.1), round(16+(GetCommonData("Rank", 1)-1)*1.4),
round(9+(GetCommonDataPtr(RANK_PTR, 1)-1)*1.1), round(16+(GetCommonDataPtr(RANK_PTR, 1)-1)*1.4),
180, largeEnemyHitbox*2.5
);
@ -858,7 +858,7 @@ task _LargeFairyAimedFan(
_EnemyItemDrop(
enm, true,
15, 6,
round(20+(GetCommonData("Rank", 1)-1)*2.25), round(12+(GetCommonData("Rank", 1)-1)*2),
round(20+(GetCommonDataPtr(RANK_PTR, 1)-1)*2.25), round(12+(GetCommonDataPtr(RANK_PTR, 1)-1)*2),
180, largeEnemyHitbox*2
);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.