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
Drake has wrong body skin color #129
Conversation
|
gothic-1-community-patch/scriptbase/_work/Data/Scripts/Content/Story/NPC/GRD_260_Drake.d Lines 20 to 28 in 56e45df
The forth argument passed to the function |
We want to change the body texture, so it's actually the second argument. |
No, the second argument is the body mesh. Gothic refers to a 3D model as mesh and a surface color/pattern/image as texture. Parameters of Mdl_SetVisualBody:
Here, Drake's body skin has a darker shade than his head does. (I will update the title and description of this issue.) changed to Provided Fixgothic-1-community-patch/scriptbase/_work/Data/Scripts/Content/Story/NPC/GRD_260_Drake.d Lines 20 to 28 in 56e45df
changed to //-------- visuals --------
// animations
Mdl_SetVisual (self,"HUMANS.MDS");
Mdl_ApplyOverlayMds (self,"Humans_Militia.mds");
// body mesh ,bdytex,skin,head mesh ,1headtex,teethtex,ruestung
Mdl_SetVisualBody (self,"hum_body_Naked0", 0, 1,"Hum_Head_Fighter",110 , 1, GRD_ARMOR_M);
B_Scale (self);
Mdl_SetModelFatness(self,0); Since the NPC appearance is not loaded from the savegame but set by the NPC's instance function, this fix does not have to be reverted. Instead, the instance function will be modified to replace the forth argument to the function call. The way I would implement it is by finding the last call to
/*
* #129 Drake has wrong body skin color
*/
func int G1CP_149_DrakeBodySkin() {
var int applied; applied = FALSE;
// Get necessary symbol indices
var int symbId; symbId = G1CP_GetNpcInstID("Grd_260_Drake");
if (symbId == -1) {
return FALSE;
};
// Find call to "Mdl_SetVisualBody"
const int bytes[2] = {zPAR_TOK_CALLEXTERNAL<<24, -1};
bytes[1] = MEM_GetFuncID(Mdl_SetVisualBody);
var int matches; matches = G1CP_FindInFunc(symbId, _@(bytes)+3, 5);
// Check for last occurrence
if (MEM_ArraySize(matches) > 0) {
var int pos; pos = MEM_ArrayLast(matches);
// Get the necessary pushed arguments
var int arg6; arg6 = MEM_ReadInt(pos-14);
var int arg4; arg4 = MEM_ReadInt(pos-24);
if (MEM_ReadByte(pos-15) == zPAR_TOK_PUSHVAR) {
arg6 = G1CP_GetIntI(arg6, 0, arg6);
};
if (MEM_ReadByte(pos-25) == zPAR_TOK_PUSHVAR) {
arg4 = G1CP_GetIntI(arg4, 0, arg4);
};
// Confirm head texture and body skin color
if (arg6 == 110) && (arg4 == 3) {
// Write the correct byte code for the forth argument
MEMINT_OverrideFunc_Ptr = pos-25;
MEMINT_OFTokPar(zPAR_TOK_PUSHINT, 1);
applied = TRUE;
};
};
// Free the array
MEM_ArrayFree(matches);
return applied;
}; As for a test, create a manual one, that teleports the player to the waypoint in front of Drake. There is example code on how to auto-trigger changing the world. See the test regarding the Free Mine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AmProsius I noted a slight improvement. Otherwise all good.
// Find call to "Mdl_SetVisualBody" | ||
const int bytes[2] = {zPAR_TOK_CALLEXTERN<<24, -1}; | ||
bytes[1] = MEM_GetFuncID(Mdl_SetVisualBody); | ||
var int matches; matches = G1CP_FindInFunc(symbId, _@(bytes)+3, 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to more recent changes we can replace these three lines by just one:
// Find call to "Mdl_SetVisualBody"
var int matches; matches = G1CP_FindCall(symbId, 0, MEM_GetFuncID(Mdl_SetVisualBody));
It may be even possible to omit the call to MEM_GetFuncID
- that should be tested.
Describe the bug
Drake's body skin color does not match his head.
Expected behavior
Drake's body skin color now matches his head.
Additional context
Instance
Grd_260_Drake
.