Skip to content

Commit 55edc7c

Browse files
authored
Merge pull request bfbbdecomp#22 from bluisblu/main
Some xtaskbox and xWad5 work
2 parents 7975bfe + 96e6115 commit 55edc7c

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

src/SB/Core/x/xEvent.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,5 +563,7 @@ void zEntEvent(xBase* from, xBase* to, U32 toEvent);
563563
void zEntEvent(xBase* from, xBase* to, U32 toEvent, const F32* toParam);
564564
void zEntEvent(xBase* from, U32 fromEvent, xBase* to, U32 toEvent, const F32* toParam,
565565
xBase* toParamWidget, S32 forceEvent);
566+
void zEntEvent(xBase* from, U32 fromEvent, xBase* to, U32 toEvent, const F32* toParam,
567+
xBase* toParamWidget, U32 unknown, S32 forceEvent);
566568

567569
#endif

src/SB/Core/x/xWad5.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,13 @@ void xCameraFXShake(F32 maxTime, F32 magnitude, F32 cycleMax, F32 rotate_magnitu
12801280
}
12811281
}
12821282

1283+
void xCameraFXShakeEnd(cameraFX* fx, F32 fadeOutTime)
1284+
{
1285+
fx->maxTime = fadeOutTime;
1286+
fx->elapsedTime = 0.0f;
1287+
fx->shake.dampenRate = (1.0f / fadeOutTime);
1288+
}
1289+
12831290
void xCameraFXZoomUpdate(cameraFX* f, F32 dt, const xMat4x3*, xMat4x3* m)
12841291
{
12851292
switch (f->zoom.mode)

src/SB/Game/zTaskBox.cpp

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern ztaskbox* shared;
1616
void ztaskbox::load(const asset_type& a)
1717
{
1818
xBaseInit((xBase*)this, &(xBaseAsset)a);
19-
this->baseType = eBaseTypeEnv;
19+
this->baseType = eBaseTypeTaskBox;
2020
// FIXME: can't force const to non-const?
2121
// this->asset = &a;
2222

@@ -177,7 +177,7 @@ void ztaskbox::complete()
177177
{
178178
this->state = STATE_INVALID;
179179
this->flag.enabled = false;
180-
zEntEvent(this, this, eEventTaskBox_OnComplete);
180+
zEntEvent(this, 0, this, eEventTaskBox_OnComplete, 0, NULL, 0, 1);
181181
this->current = (ztaskbox*)zSceneFindObject(this->asset->next_task);
182182

183183
// Bruh
@@ -211,12 +211,60 @@ bool ztaskbox::exists(state_enum stage)
211211
return state != STATE_BEGIN && xSTFindAsset(state, NULL);
212212
}
213213

214+
void ztaskbox::set_state(state_enum stage)
215+
{
216+
this->state = stage;
217+
this->current = this;
218+
219+
// todo
220+
}
221+
222+
void ztaskbox::cb_dispatch(xBase*, xBase* to, U32 event, F32*, xBase*, U32)
223+
{
224+
ztaskbox& taskbox = *(ztaskbox*)to;
225+
226+
switch (event)
227+
{
228+
case eEventReset:
229+
taskbox.reset();
230+
break;
231+
case eEventStartConversation:
232+
taskbox.start_talk(NULL);
233+
break;
234+
case eEventEndConversation:
235+
taskbox.stop_talk();
236+
break;
237+
case eEventTaskBox_Initiate:
238+
taskbox.initiate();
239+
break;
240+
case eEventTaskBox_SetSuccess:
241+
taskbox.succeed();
242+
break;
243+
case eEventTaskBox_SetFailure:
244+
taskbox.fail();
245+
break;
246+
case eEventTaskBox_OnAccept:
247+
case eEventTaskBox_OnDecline:
248+
case eEventTaskBox_OnComplete:
249+
break;
250+
}
251+
}
252+
214253
void ztaskbox::talk_callback::on_start()
215254
{
216-
this->task->on_talk_start();
255+
this->task->flag.unk_11 = 1;
256+
if (this->task->cb != nullptr)
257+
{
258+
this->task->cb->on_talk_start();
259+
}
217260
}
218261

219262
void ztaskbox::talk_callback::on_stop()
220263
{
221264
this->task->on_talk_stop(answer);
222265
}
266+
267+
void ztaskbox::talk_callback::on_answer(answer_enum answer)
268+
{
269+
this->answer = answer;
270+
}

src/SB/Game/zTaskBox.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct ztaskbox : xBase
1616
struct flagData
1717
{
1818
U8 enabled : 8;
19-
U32 dummy : 24;
19+
U8 unk_11 : 8;
20+
U16 dummy : 16;
2021
};
2122

2223
enum state_enum
@@ -33,6 +34,8 @@ struct ztaskbox : xBase
3334

3435
struct callback
3536
{
37+
virtual void on_talk_start();
38+
virtual void on_talk_stop();
3639
};
3740

3841
struct talk_callback : callback
@@ -88,6 +91,7 @@ struct ztaskbox : xBase
8891
void complete();
8992
static void init();
9093
bool exists(state_enum stage);
94+
void cb_dispatch(xBase*, xBase* to, U32 event, F32*, xBase*, U32);
9195
};
9296

9397
#endif

0 commit comments

Comments
 (0)