Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor change item int variable fixes #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ func int G1CP_044_BugmeatCategory() {
ITEM_KAT_NONE = G1CP_GetIntConst("ITEM_KAT_NONE", 0, ITEM_KAT_NONE);
ITEM_KAT_FOOD = G1CP_GetIntConst("ITEM_KAT_FOOD", 0, ITEM_KAT_FOOD);

// Replace any assignments to mainflag
var int itemId; itemId = G1CP_GetItemInstId("ItAt_Meatbug_01");
return (G1CP_ReplaceAssignInt(itemId, 0, "C_ITEM.mainflag", 0, ITEM_KAT_NONE, ITEM_KAT_FOOD) > 0);
return G1CP_ItemChangeIntVar("ItAt_Meatbug_01", "mainflag", ITEM_KAT_NONE, ITEM_KAT_FOOD);
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ func int G1CP_157_SpeedPotion2Value() {
return FALSE;
};

// Replace any assignments to value
var int itemId; itemId = G1CP_GetItemInstId("ItFo_Potion_Haste_02");
return (G1CP_ReplaceAssignInt(itemId, 0, "C_ITEM.value", 0, Value_Haste1, Value_Haste2) > 0);
return G1CP_ItemChangeIntVar("ItFo_Potion_Haste_02", "value", Value_Haste1, Value_Haste2);
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ func int G1CP_158_SpeedPotion3Value() {
return FALSE;
};

// Replace any assignments to value
var int itemId; itemId = G1CP_GetItemInstId("ItFo_Potion_Haste_03");
return (G1CP_ReplaceAssignInt(itemId, 0, "C_ITEM.value", 0, Value_Haste1, Value_Haste3) > 0);
return G1CP_ItemChangeIntVar("ItFo_Potion_Haste_03", "value", Value_Haste1, Value_Haste2);
};
8 changes: 8 additions & 0 deletions src/Ninja/G1CP/Content/Misc/item.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Change the value of an item's int variable. Returns true on success.
*/
func int G1CP_ItemChangeIntVar(var string name, var string prop, var int originalInt, var int correctedInt) {
var int itemId; itemId = G1CP_GetItemInstId(name);

return (G1CP_ReplaceAssignInt(itemId, 0, ConcatStrings("C_Item.", prop), 0, originalInt, correctedInt) > 0);
}
1 change: 1 addition & 0 deletions src/Ninja/G1CP/Content_G1.src
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Content\Misc\vobLight.d
Content\Misc\npc.d
Content\Misc\ou.d
Content\Misc\routine.d
Content\Misc\item.d

Content\Fixes\record.d

Expand Down