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

EnZf OK and partially documented #988

Merged
merged 85 commits into from
Nov 6, 2021
Merged

Conversation

EllipticEllipsis
Copy link
Contributor

It took 8 months, but it's OK and PR'd. Thanks to @petrie911 for encouraging me to do it in the first place and matching those awful platform functions that we all hate, @AngheloAlf for getting me started with some ideas about the struct variables, and @Dragorn421 for getting me to read EnWf carefully, which helped a lot with this thing.

I got a lot farther with documenting than I was expecting, but a few of the actions remain a bit elusive, and I'm a bit stuck on names for other things, both functions and struct variables. Didn't put much effort into naming all the temps since I assume we're going to try and make the fighter actors consistent anyway. I started the ball rolling on that by attempting to unify all the weird curframe things that play sound, although I didn't try to name those consistently yet either.

I'll probably carry on doing some documentation, particularly the textures in the object, but thought it was worth PRing now to get some more eyes on it.

What a mess of an actor. I've never seen setup functions that sometimes set a different function instead 1UL.

@EllipticEllipsis
Copy link
Contributor Author

Oh, almost forgot:
image
Yuck!

Copy link
Collaborator

@Dragorn421 Dragorn421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job

(nice EnWf copypaste (or the other way around, or whatever enemy) by the dev)

src/overlays/actors/ovl_En_GeldB/z_en_geldb.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
Comment on lines 1855 to 1861
EnZf_SetupHopAndTaunt(this);
return;
}
EnZf_SetupApproachPlayer(this, globalCtx);
return;
}
if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EnZf_SetupHopAndTaunt(this);
return;
}
EnZf_SetupApproachPlayer(this, globalCtx);
return;
}
if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) {
EnZf_SetupHopAndTaunt(this);
} else {
EnZf_SetupApproachPlayer(this, globalCtx);
}
} else if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) {

fits better the whole function not using early returns otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer early return after running the setup funcs: it makes it clear that there is no more execution happening in this function, which is rather less obvious with the elses IMO.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that, but the pattern should be consistent at least in a single function, in this function most setup calls aren't followed with a return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'll have another look. IIRC a lot of these early returns are needed because the audio bit at the bottom is separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does match. I'll do that until Fig tells me to put it back 1UL.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, i was looking at the wrong thing. line numbers changed lol

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted my previous post, it makes sense to me here

src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@Roman971 Roman971 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this. Just a few things

src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) {
if (this->actor.colChkInfo.health == 0) {
EnZf_SetupDie(this);
} else if ((this->actor.params != ENZF_TYPE_DINOLFOS) || !EnZf_ChooseAction(globalCtx, this)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a few functions like this one could be improved with some early returns, but that comes down to personal preference I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through again, I wonder if a lot of the if (!EnZf_DodgeRanged(...))s should actually be if (EnZf_DodgeRanged(...)) { return; }? It would certainly improve the indentation, and it happens in a lot of these actionFuncs

Copy link
Collaborator

@fig02 fig02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job, and sorry for a late review. all style and doc nitpicks, code looks good

src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
Comment on lines +332 to +333
if (thisx->params < ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // Not minibosses
this->homePlatform = this->curPlatform = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= ENZF_TYPE_LIZALFOS_LONE will prob make more sense in that case. comment will prob not be needed then too

Comment on lines +356 to +357

if ((this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) /* miniboss */ &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment also not needed here imo, i think the context is clear enough from the conditional

src/overlays/actors/ovl_En_Zf/z_en_zf.c Show resolved Hide resolved
Comment on lines +527 to +528

if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last ill comment on it, but in general i think the range checks on params dont need extra explaining cause they put the params in a pretty intuitive order.
Can leave them for now and we'll iron out how exactly we do this kind of documentation later. but just putting my thoughts out now

Comment on lines +1277 to +1278
if ((globalCtx->state.frames & 0x5F) == 0) {
Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dec

Comment on lines +1445 to +1446

if ((globalCtx->gameplayFrames & 0x5F) == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last one ill point out, can check if there are anymore with a ctrl f

src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.h Outdated Show resolved Hide resolved
@EllipticEllipsis
Copy link
Contributor Author

I did an experiment with a few things we could do to Zf in terms of the type and whether or not to use returns: https://github.com/EllipticEllipsis/oot/blob/438cb9ab64466ed1a885b89625bb9d7b36d10b0b/src/overlays/actors/ovl_En_Zf/z_en_zf.c Be interested to know what people think (diff with what's currently here is https://github.com/EllipticEllipsis/oot/compare/Zf...EllipticEllipsis:Zf_experiment?expand=1, but rather difficult to read) (made a new branch to avoid messing up this one).

<Limb Name="gZfDinolfosTailBaseLimb" LimbType="Standard" Offset="0x64EC"/>
<Limb Name="gZfDinolfosScabbardRootRootLimb" LimbType="Standard" Offset="0x64F8"/>
<Limb Name="gZfDinolfosScabbardRootLimb" LimbType="Standard" Offset="0x6504"/>
<Limb Name="gZfDinolfosScabbardLimb" LimbType="Standard" Offset="0x6510"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For player we use "sheath", idk if we would want consistency for this detail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have thought scabbard would be a better name for both anyway: it's more precise.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id say sheath is way more common colloquially, even if its slightly less accurate its something more people would recognize imo

@@ -1,89 +1,91 @@
<Root>
<File Name="object_zf" Segment="6">
<Texture Name="object_zf_TLUT_000000" OutName="tlut_00000000" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gZfDinolfosTLUT" OutName="zf_dinolfos_tlut" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Texture Name="gZfDinolfosTLUT" OutName="zf_dinolfos_tlut" Format="rgba16" Width="16" Height="16" Offset="0x0"/>
<Texture Name="gZfDinolfosTLUT" OutName="dinolfos_tlut" Format="rgba16" Width="16" Height="16" Offset="0x0"/>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we prefixed everything in the object with an object-unique prefix. That's certainly what I did for objects in the past.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm I took a closer look in the repo and it's really inconsistent if outnames have the object-specific prefix

IMO it's not needed since the textures are already in a folder named after the object

<Texture Name="object_zf_Tex_000200" OutName="tex_00000200" Format="ci8" Width="8" Height="8" Offset="0x200"/>
<Texture Name="object_zf_Tex_000240" OutName="tex_00000240" Format="ci8" Width="16" Height="16" Offset="0x240"/>
<Texture Name="object_zf_Tex_000340" OutName="tex_00000340" Format="rgba16" Width="8" Height="8" Offset="0x340"/>
<Texture Name="gZfDinolfosSpineTex" OutName="zf_dinolfos_spine" Format="rgba16" Width="8" Height="8" Offset="0x340"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Texture Name="gZfDinolfosSpineTex" OutName="zf_dinolfos_spine" Format="rgba16" Width="8" Height="8" Offset="0x340"/>
<Texture Name="gZfDinolfosSpineTex" OutName="dinolfos_spine" Format="rgba16" Width="8" Height="8" Offset="0x340"/>

<Animation Name="object_zf_Anim_009530" Offset="0x9530"/>
<Animation Name="object_zf_Anim_00A3D4" Offset="0xA3D4"/>
<Animation Name="object_zf_Anim_00B10C" Offset="0xB10C"/>
<Texture Name="gZfDinolfosNormalEyeTex" OutName="zf_dinolfos_normal_eye" Format="rgba16" Width="16" Height="16" Offset="0x700"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Texture Name="gZfDinolfosNormalEyeTex" OutName="zf_dinolfos_normal_eye" Format="rgba16" Width="16" Height="16" Offset="0x700"/>
<Texture Name="gZfDinolfosNormalEyeTex" OutName="dinolfos_normal_eye" Format="rgba16" Width="16" Height="16" Offset="0x700"/>

src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
src/overlays/actors/ovl_En_Zf/z_en_zf.c Outdated Show resolved Hide resolved
} else if (this->unk_3F0 != 0) {
this->unk_3F0--;
} else {
if (Actor_IsFacingPlayer(&this->actor, 30 * 0x10000 / 360)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Actor_IsFacingPlayer(&this->actor, 30 * 0x10000 / 360)) {
if (Actor_IsFacingPlayer(&this->actor, DEGF_TO_BINANG(30))) {

apparently I already suggested this, you said it wouldn't work but apparently it does (builds OK)
(use 30.0f if you want)

also in one other spot

Comment on lines +2142 to +2148
static Vec3f footOffset = { 300.0f, 0.0f, 0.0f };
static Vec3f D_80B4A2A4 = { 300.0f, -1700.0f, 0.0f }; // Sword tip?
static Vec3f D_80B4A2B0 = { -600.0f, 300.0f, 0.0f }; // Sword hilt?
static Vec3f swordQuadOffset1 = { 0.0f, 1500.0f, 0.0f };
static Vec3f swordQuadOffset0 = { -600.0f, -3000.0f, 1000.0f };
static Vec3f swordQuadOffset3 = { -600.0f, -3000.0f, -1000.0f };
static Vec3f swordQuadOffset2 = { 1500.0f, -3000.0f, 0.0f };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer ModelPos instead of Offset since they are positions in, well, model space

the discussion on this didn't take off
https://discord.com/channels/688807550715560050/838852326231769089/881526848209707008

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I named these following GeldB/Test, iirc, so they should be renamed as well depending on what we do here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my understanding is that its an offset from the position that it already has, not an absolute position in model space. is that not correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

youll see plenty of things use 0,0,0 for this, and its not putting it at 0 in model space, but where the limb already is

if ((this->actor.bgCheckFlags & 3) && (this->hopAnimIndex != 0)) {
Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ONGND);
Animation_Change(&this->skelAnime, &gZfLandingAnim, 1.0f, 0.0f, 17.0f, ANIMMODE_ONCE, 0.0f);
this->hopAnimIndex = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since hopAnimIndex is not just used for the hop action maybe it would be better named a more generic animState ?

I'm not too convinced, I can't tell if its usage is all anim-related even. for example I don't see what its use in EnZf_SetupDamaged achieves (probably nothing afaict)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point here is that the main use for this array is the hopping: it's the thing that uses all the indices. It so happens that for some reason they ended up using it for other things.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of the 45 uses of hopAnimIndex, only 18, maybe 20, seem relevant to hopping, so I'm not sure we can really brush off those other uses

Copy link
Collaborator

@fig02 fig02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like lots of the open ended conversations here are things we will figure out as we standardize actor documentation in general. so its fine on my end

@fig02
Copy link
Collaborator

fig02 commented Nov 6, 2021

Some conflicts to fix but after that it's good to merge

@ethteck ethteck merged commit 823a3c0 into zeldaret:master Nov 6, 2021
louist103 pushed a commit to louist103/oot that referenced this pull request Jan 3, 2023
* Match Destroy

* Matched Init

* 3 more matched

* 15 functions matched, data imported

* 16 matched

* 17 matched

* 18 matched

* formatting

* 19 matched

* Fix unk_404

* Draw matched, 20 in total

* 21 matched

* 22 matched

* 23 matched

* 24 matched

* 25 matched

* 26 matched

* 27 matched

* 28 matched

* 29 matched

* 30 matched

* 31 matched

* 33 matched

* 34 matched

* 35 matched

* 36 matched

* 17 left

* 16 left

* 15 left

* 14 left

* 13 left

* 12 left

* 11 left

* 10 left

* spec

* bss

* 9 left

* 8 left

* 7 left

* 6 left

* 5 left

* 4 left

* 1 up to regalloc, 3 left

* 2 left (+ 1 regalloc)

* More naming

* 1 + regalloc left

* Some naming

* matches but for 2 words of stack in func_80B45748

* Delete some padding in header

* Merge remote-tracking branch 'upstream/master' into Zf

* func_8003426C rename

* more failed matching attempts

* Update to new function names

* OK at last

* Actually OK this time, removed pragmas, spec

* Begin documentation

* Few more names

* Some more naming, added description to z_en_geldb.c

* Confirm platform categories

* (Badly) named floor check functions

* Make fighter actors playSpeed animation frame checks consistent (up to names)

* Action enum, lot of work on the skeleton stuff in the object

* Lot of function and animation naming

* More naming, last of the hardcoded symbols

* Some name cleanup

* Remove asm

* Format

* Bit more cleanup

* Dragorn review I

* undefined syms

* Correct limb names

* Non-control flow review suggestions

* Easy review stuff

* Some more review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants