MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / thunderIdleCB

Function thunderIdleCB

src/SB/Game/zNPCTypeTiki.cpp:1514–1560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1512}
1513
1514static S32 thunderIdleCB(xGoal* rawgoal, void*, en_trantype* trantype, F32 dt, void*)
1515{
1516 zNPCTiki* tiki = (zNPCTiki*)rawgoal->GetOwner();
1517 zNPCGoalTikiIdle* goal = (zNPCGoalTikiIdle*)rawgoal;
1518 S32 nextgoal = 0;
1519 F32 factor;
1520
1521 tiki->t1 = -(0.75f * dt - tiki->t1);
1522 if (tiki->t1 < 0.0f)
1523 {
1524 tiki->t1 += 1.0f;
1525 }
1526
1527 factor = tiki->t1;
1528 factor = (factor * factor + 1.0f) - factor;
1529 tiki->model->RedMultiplier = factor;
1530 tiki->model->BlueMultiplier = factor;
1531 tiki->model->GreenMultiplier = factor;
1532
1533 goal->tmr_wait -= dt;
1534 if (goal->tmr_wait < 0.0f)
1535 {
1536 xVec3 vec;
1537 xVec3Sub(&vec, (xVec3*)&tiki->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->pos);
1538
1539 F32 dist2 = xVec3Length2(&vec);
1540
1541 // 457.0f / 500 = 0.914f, but missing the float precision error
1542 F32 max_dist = globals.player.ent.bound.box.box.upper.x + 0.91400003f;
1543
1544 if (dist2 < max_dist * max_dist)
1545 {
1546 if (globals.player.SlideTrackSliding & 1)
1547 {
1548 tiki->Damage(DMGTYP_SIDE, 0, 0);
1549 }
1550 else
1551 {
1552 tiki->t1 = 0.0f;
1553 nextgoal = NPC_GOAL_TIKICOUNT;
1554 *trantype = GOAL_TRAN_SET;
1555 }
1556 }
1557 }
1558
1559 return nextgoal;
1560}
1561
1562// WIP
1563static S32 thunderCountCB(xGoal* rawgoal, void*, en_trantype* trantype, F32 dt, void*)

Callers

nothing calls this directly

Calls 4

xVec3SubFunction · 0.85
xVec3Length2Function · 0.85
GetOwnerMethod · 0.80
DamageMethod · 0.45

Tested by

no test coverage detected