[RM2K3] DYNRPG ANIMATIONINBATTLE

Posts

Pages: 1
Trying to access the members in this class results in an Access violation at 66D110A3 and offset 00000018 of type read. Am I doing something wrong here:

RPG::AnimationInBattle *currentAnim
if(currentAnim->currentAnimationId == specialAnimId)
    getSpecialAction(); //This is not the issue. I have tried omitting this.

I can't find any information on this class aside from this:
https://www.rewking.com/dynrpg/_animation_in_battle_8h_source.html
Is this the actual code? You are declaring an uninitialized pointer and accessing it...

Check the "animData" member of the Actor and Monster classes, this is where this class is used, for example:

RPG::actors[1]->animData->currentAnimationId
Wait, did I misunderstand this class? I thought it took the values of the current animation being displayed in battle? If no animation was displayed the values would be null, otherwise they would contain the values of the animation being displayed? I didn't realize the class was tied to the Actors.

If I understand correctly, then I need to do something like this to access the current animation frame being displayed?


currentFrame = (!battler->isMonster()) ? RPG::monsters[battler->id]->animData->currentAnimationFrame : RPG::actors[battler->id]->animData->currentAnimationFrame;

This seems to work, but the frames do not match the cels. Are cels displayed every other frame or something?

Edit: So it seems animations display each cel for 2 frames before drawing the next one.
Right, just a small optimization:

RPG::AnimationInBattle* animData = !battler->isMonster() ? ((RPG::Monster*) battler)->animData : ((RPG::Actor*) battler)->animData;
currentFrame = animData->currentAnimationFrame

You already have a pointer to the actor/monster, no need to fetch it again.

(But I'm wondering why animData is not in the base class, is it really at two different memory offsets of actors and monsters...? @PepsiOtaku)
I think you're missing parentheses, but even when added, that code won't compile. I get error: conversion from 'RPG::AnimationInBattle*' to non-scalar type 'RPG::AnimationInBattle' requested. This is what I ended up using in the onFrame callback:

//isMon is one of the variables in my cbs plugin that tracks active battler along with
//currentBattler which ranges from 0-7
//Hero is defined as RPG::Actor::partyMember(currentBattler)
//Monster is defined as RPG::monsters[currentBattler]
currentFrame = (isMon) ? RPG::actors[RPG::Actor::partyMember(Monster->action->targetId)->id]->animData->currentAnimationFrame : RPG::monsters[RPG::->action->targetId]->animData->currentAnimationFrame;
//Using the battler class kept giving me issues, which is why I wrote it like this.
The purpose of this code is to know when to update my own action window with the damage number.



I should have realized the AnimationInBattle class was tied to something else when there was no cast for it. Oddly the help file doesn't mention animData or even RPG::Actor in the see also links which is why I couldn't find animData cast.

As for your question for Pepsi, I think so, at least according to the implementation.
Check my code again, yes I made a mistake ^^
Pages: 1