Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
dmg_partner.c File Reference

Go to the source code of this file.

Macros

#define INFLICT_STATUS(STATUS_TYPE)
 

Functions

s32 dispatch_damage_event_partner_1 (s32, s32)
 
void dispatch_event_partner (s32 lastEventType)
 
void dispatch_event_partner_continue_turn (s8 lastEventType)
 
HitResult calc_partner_test_enemy (void)
 
HitResult calc_partner_damage_enemy (void)
 
s32 dispatch_damage_event_partner (s32 damageAmount, s32 event, s32 stopMotion)
 
s32 dispatch_damage_event_partner_0 (s32 damageAmount, s32 event, s32 stopMotion)
 

Macro Definition Documentation

◆ INFLICT_STATUS

#define INFLICT_STATUS ( STATUS_TYPE)
Value:
if ((battleStatus->curAttackStatus & STATUS_FLAG_##STATUS_TYPE) && \
try_inflict_status(target, STATUS_KEY_##STATUS_TYPE, STATUS_TURN_MOD_##STATUS_TYPE)) { \
wasSpecialHit = TRUE; \
wasStatusInflicted = TRUE; \
} \
s32 try_inflict_status(Actor *, s32, s32)
Definition 190B20.c:2532

Function Documentation

◆ dispatch_damage_event_partner_1()

s32 dispatch_damage_event_partner_1 ( s32 damageAmount,
s32 event )

Definition at line 976 of file dmg_partner.c.

976 {
977 return dispatch_damage_event_partner(damageAmount, event, TRUE);
978}
s32 dispatch_damage_event_partner(s32 damageAmount, s32 event, s32 stopMotion)

Referenced by calc_partner_damage_enemy(), and calc_partner_test_enemy().

◆ dispatch_event_partner()

void dispatch_event_partner ( s32 lastEventType)

Definition at line 7 of file dmg_partner.c.

7 {
8 BattleStatus* battleStatus = &gBattleStatus;
9 Actor* partnerActor = battleStatus->partnerActor;
10 Evt* handleEventScript = partnerActor->handleEventScript;
11 s32 onHitID = partnerActor->handleEventScriptID;
12 Evt* script;
13
14 partnerActor->lastEventType = lastEventType;
16 partnerActor->handleEventScript = script;
17 partnerActor->handleEventScriptID = script->id;
18 script->owner1.actorID = ACTOR_PARTNER;
19
20 if (partnerActor->takeTurnScript != NULL) {
22 partnerActor->takeTurnScript = NULL;
23 }
24
25 if (handleEventScript != NULL) {
26 kill_script_by_ID(onHitID);
27 }
28}
struct Evt * takeTurnScript
EvtScript * handleEventSource
struct Evt * handleEventScript
s32 takeTurnScriptID
s32 handleEventScriptID
union Evt::@8 owner1
Initially -1.
@ ACTOR_PARTNER
Definition enums.h:2086
@ EVT_PRIORITY_A
Definition evt.h:153
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:161
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void kill_script_by_ID(s32 id)
struct Actor * partnerActor
BattleStatus gBattleStatus
Definition battle.c:11

Referenced by btl_state_update_begin_partner_turn(), btl_state_update_end_training_battle(), btl_state_update_victory(), calc_enemy_damage_target(), dispatch_damage_event_partner(), and dispatch_event_general().

◆ dispatch_event_partner_continue_turn()

void dispatch_event_partner_continue_turn ( s8 lastEventType)

Definition at line 30 of file dmg_partner.c.

30 {
31 BattleStatus* battleStatus = &gBattleStatus;
32 Actor* partnerActor = battleStatus->partnerActor;
33 Evt* handleEventScript = partnerActor->handleEventScript;
34 s32 onHitID = partnerActor->handleEventScriptID;
35 Evt* script;
36
37 partnerActor->lastEventType = lastEventType;
39 partnerActor->handleEventScript = script;
40 partnerActor->handleEventScriptID = script->id;
41 script->owner1.actorID = ACTOR_PARTNER;
42
43 if (handleEventScript != NULL) {
44 kill_script_by_ID(onHitID);
45 }
46}

◆ calc_partner_test_enemy()

HitResult calc_partner_test_enemy ( void )

Definition at line 48 of file dmg_partner.c.

48 {
49 BattleStatus* battleStatus = &gBattleStatus;
50 Actor* partner = battleStatus->partnerActor;
51 s32 currentTargetID = battleStatus->curTargetID;
52 s32 currentTargetPart = battleStatus->curTargetPart;
53 Actor* target;
54 ActorState* state;
55 ActorPart* part;
56
57 battleStatus->curTargetID2 = battleStatus->curTargetID;
58 battleStatus->curTargetPart2 = battleStatus->curTargetPart;
59 target = get_actor(currentTargetID);
60 state = &partner->state;
61
62 if (target == NULL) {
63 return HIT_RESULT_HIT;
64 }
65
66 part = get_actor_part(target, currentTargetPart);
67 ASSERT(part != NULL);
68
69 if (target->stoneStatus == STATUS_KEY_STONE) {
70 return HIT_RESULT_IMMUNE;
71 }
72
74 return HIT_RESULT_MISS;
75 }
76
77 // check partner jumping on top-spiky enemy (cannot be suppressed)
78 if ((battleStatus->curAttackElement & DAMAGE_TYPE_JUMP)
80 && !(target->flags2 & ACTOR_FLAG_UPSIDE_DOWN)
81 ) {
84 }
85
86 // check partner contacting front-spiky enemy
91 ) {
96 }
97
98 // check partner contacting fiery enemy
102 ) {
106 return HIT_RESULT_BACKFIRE;
107 }
108
109 // special handling for air lift
110 if (battleStatus->curAttackElement & DAMAGE_TYPE_AIR_LIFT) {
111 // check partner airlifting top-spiky enemy
112 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)) {
114 && !(target->flags & ACTOR_FLAG_UPSIDE_DOWN)
116 ) {
120 return HIT_RESULT_BACKFIRE;
121 }
122
123 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
125 && !(target->flags & ACTOR_FLAG_UPSIDE_DOWN)
127 ) {
131 return HIT_RESULT_BACKFIRE;
132 }
133 }
134
135 // check partner airlifting electrified enemy
136 if (partner->staticStatus != STATUS_KEY_STATIC
138 && !(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
140 {
142 apply_shock_effect(partner);
144 return HIT_RESULT_BACKFIRE;
145 }
146
147 // check partner airlifting fiery enemy
151 {
155 return HIT_RESULT_BACKFIRE;
156 }
158 }
159 return HIT_RESULT_HIT;
160}
s8 transparentStatus
ActorState state
s32 dispatch_damage_event_partner_1(s32, s32)
#define sfx_play_sound_at_position
#define ASSERT(condition)
@ ACTOR_EVENT_FLAG_ELECTRIFIED
Player takes shock damage upon contact.
Definition enums.h:3375
@ ACTOR_EVENT_FLAG_SPIKY_FRONT
Player takes spike damage from hammer attacks.
Definition enums.h:3384
@ ACTOR_EVENT_FLAG_FIREY
Player takes burn damage upon contact.
Definition enums.h:3371
@ ACTOR_EVENT_FLAG_ALT_SPIKY
Additional spiky quality associated with Pokeys and Spinies.
Definition enums.h:3388
@ ACTOR_EVENT_FLAG_ILLUSORY
Player attacks pass through and miss.
Definition enums.h:3374
@ ACTOR_EVENT_FLAG_SPIKY_TOP
Player takes spike damage from jump attacks.
Definition enums.h:3373
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2210
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_KEY_STONE
Definition enums.h:2208
@ HIT_RESULT_LANDED_ON_SPIKE
Definition enums.h:1954
@ HIT_RESULT_BACKFIRE
Definition enums.h:1949
@ HIT_RESULT_HIT
Definition enums.h:1950
@ HIT_RESULT_IMMUNE
Definition enums.h:1958
@ HIT_RESULT_MISS
Definition enums.h:1956
@ SUPPRESS_EVENT_SPIKY_TOP
Definition enums.h:2900
@ SUPPRESS_EVENT_ALT_SPIKY
Definition enums.h:2905
@ SUPPRESS_EVENT_SHOCK_CONTACT
Definition enums.h:2903
@ SUPPRESS_EVENT_SPIKY_FRONT
Definition enums.h:2902
@ SUPPRESS_EVENT_BURN_CONTACT
Definition enums.h:2904
@ ABILITY_SPIKE_SHIELD
Definition enums.h:438
@ SOUND_HIT_SPIKE
Definition enums.h:743
@ SOUND_HIT_SHOCK
Definition enums.h:1195
@ SOUND_HIT_FIRE
Definition enums.h:725
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
Definition enums.h:3331
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ EVENT_SPIKE_CONTACT
Definition enums.h:2163
@ EVENT_SPIKE_TAUNT
Definition enums.h:2148
@ EVENT_BEGIN_AIR_LIFT
Definition enums.h:2175
@ EVENT_SHOCK_HIT
Definition enums.h:2165
@ EVENT_BURN_CONTACT
Definition enums.h:2164
@ EVENT_BURN_TAUNT
Definition enums.h:2149
@ DAMAGE_TYPE_SMASH
Definition enums.h:2857
@ DAMAGE_TYPE_AIR_LIFT
Definition enums.h:2866
@ DAMAGE_TYPE_JUMP
Definition enums.h:2858
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:103
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void apply_shock_effect(Actor *)
s32 curAttackEventSuppression

◆ calc_partner_damage_enemy()

HitResult calc_partner_damage_enemy ( void )

Definition at line 162 of file dmg_partner.c.

162 {
163 BattleStatus* battleStatus = &gBattleStatus;
164 Actor* partner = battleStatus->partnerActor;
165 s32 currentTargetID = battleStatus->curTargetID;
166 s32 currentTargetPartID = battleStatus->curTargetPart;
167 s32 hitResult = HIT_RESULT_HIT;
168 s32 partImmuneToElement = FALSE;
169 s32 isFireDamage = FALSE;
170 s32 isWaterDamage = FALSE;
171 s32 isShockDamage = FALSE;
172 s32 isIceDamage = FALSE;
173 s32 wasSpecialHit = FALSE;
174 s32 wasStatusInflicted = FALSE;
175 Actor* target;
176 ActorPart* targetPart;
177 ActorState* state;
178 Evt* evt;
179 s32 statusChanceOrDefense;
180 s32 damageDealt;
181 s32 dispatchEvent;
182
183 battleStatus->wasStatusInflicted = FALSE;
184 battleStatus->lastAttackDamage = 0;
185 battleStatus->attackerActorID = partner->actorID;
186 battleStatus->curTargetID2 = battleStatus->curTargetID;
187 battleStatus->curTargetPart2 = battleStatus->curTargetPart;
188 target = get_actor(currentTargetID);
189 state = &partner->state;
190
191 if (target == NULL) {
192 return HIT_RESULT_HIT;
193 }
194
195 targetPart = get_actor_part(target, currentTargetPartID);
196
197 ASSERT(targetPart != NULL);
198
199 target->lastDamageTaken = 0;
200
202 hitResult = HIT_RESULT_NO_DAMAGE;
203 dispatchEvent = EVENT_ZERO_DAMAGE;
205 } else {
206 if ((targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY)
208 || (targetPart->eventFlags & ACTOR_EVENT_FLAG_BURIED && !(battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE))
209 ) {
210 return HIT_RESULT_MISS;
211 }
212
213 if (target->stoneStatus == STATUS_KEY_STONE) {
215 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 1);
216 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 0);
217
219 return HIT_RESULT_NICE;
220 } else {
221 return HIT_RESULT_HIT;
222 }
223 }
224
225 if (targetPart->elementalImmunities & battleStatus->curAttackElement) {
226 partImmuneToElement = TRUE;
227 }
228
229 // check jumping on spiky enemy
230 if (battleStatus->curAttackElement & DAMAGE_TYPE_JUMP
232 ) {
236 return HIT_RESULT_BACKFIRE;
237 }
238
239 // check explode on contact
240 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
242 ) {
244
248 return HIT_RESULT_BACKFIRE;
249 }
250
252
254 return HIT_RESULT_NICE;
255 } else {
256 return HIT_RESULT_HIT;
257 }
258 }
259
260 // check touching fiery enemy
262 && targetPart->eventFlags & ACTOR_EVENT_FLAG_FIREY
264 ) {
268 return HIT_RESULT_BACKFIRE;
269 }
270
271 // check touching spiky-front enemy
275 ) {
279 return HIT_RESULT_BACKFIRE;
280 }
281
282 // check explode on ignition
284 && battleStatus->curAttackElement & DAMAGE_TYPE_FIRE
286 ) {
289
291 return HIT_RESULT_NICE;
292 } else {
293 return HIT_RESULT_HIT;
294 }
295 }
296
297 // unknown alternate spiky #1
298 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
300 && !(target->flags & ACTOR_FLAG_UPSIDE_DOWN)
302 ) {
306 return HIT_RESULT_BACKFIRE;
307 }
308
309 // unknown alternate spiky top
310 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
312 && !(target->flags & ACTOR_FLAG_UPSIDE_DOWN)
314 ) {
318 return HIT_RESULT_BACKFIRE;
319 }
320
321 // check explode on ignition (duplicate of previous check)
323 && battleStatus->curAttackElement & DAMAGE_TYPE_FIRE
325 ) {
328
330 return HIT_RESULT_NICE;
331 } else {
332 return HIT_RESULT_HIT;
333 }
334 }
335
336 // check shock contact for airlift
337 if (battleStatus->curAttackElement & DAMAGE_TYPE_AIR_LIFT) {
338 if (partner->staticStatus != STATUS_KEY_STATIC
340 && !(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
342 ) {
344 apply_shock_effect(partner);
346 return HIT_RESULT_BACKFIRE;
347 } else {
348 return HIT_RESULT_HIT;
349 }
350 }
351
352 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
353 fx_ring_blast(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
354 isFireDamage = TRUE;
355 }
356
357 if (battleStatus->curAttackElement & DAMAGE_TYPE_SHOCK) {
358 apply_shock_effect(target);
359 isShockDamage = TRUE;
360 }
361
362 if (battleStatus->curAttackElement & DAMAGE_TYPE_WATER) {
363 fx_water_splash(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
364 isWaterDamage = TRUE;
365 }
366
367 if (battleStatus->curAttackElement & DAMAGE_TYPE_ICE) {
368 fx_big_snowflakes(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f);
369 isIceDamage = TRUE;
370 }
371
372 if (partner->staticStatus != STATUS_KEY_STATIC
376 ) {
378 }
379
381 battleStatus->curAttackElement &= ~DAMAGE_TYPE_IGNORE_DEFENSE;
382 }
383
384 statusChanceOrDefense = get_defense(target, targetPart->defenseTable, battleStatus->curAttackElement);
385
386 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_IGNORE_DEFENSE)) {
387 statusChanceOrDefense += target->defenseBoost;
388 }
389
390 damageDealt = battleStatus->curAttackDamage + partner->attackBoost;
391
393 if (battleStatus->curAttackElement & DAMAGE_TYPE_BLAST
395 ) {
396 statusChanceOrDefense = 0;
397 damageDealt = target->curHP;
398 }
399 }
400
402 statusChanceOrDefense = 0;
403 damageDealt = 0;
404 }
405
406 if (partner->debuff == STATUS_KEY_SHRINK) {
407 if (damageDealt != 0) {
408 damageDealt /= 2;
409
410 if (damageDealt == 0) {
411 damageDealt = 1;
412 }
413 }
414 }
415
416 if (damageDealt > 99) {
417 damageDealt = 99;
418 }
419
420 if (damageDealt < 0) {
421 statusChanceOrDefense = 0;
422 }
423
424 damageDealt -= statusChanceOrDefense;
425 target->hpChangeCounter = 0;
426
427 if (damageDealt < 0) {
428 damageDealt = 0;
429 }
430
431 if (battleStatus->curAttackElement & DAMAGE_TYPE_POWER_BOUNCE && damageDealt > 0) {
432 damageDealt += battleStatus->powerBounceCounter;
433
434 if (damageDealt < 1) {
435 damageDealt = 1;
436 }
437 }
438
439 battleStatus->lastAttackDamage = 0;
440
441 if (damageDealt < 1) {
442 target->hpChangeCounter = 0;
443
444 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_STATUS_ALWAYS_HITS)) {
445 hitResult = HIT_RESULT_NO_DAMAGE;
446 dispatchEvent = EVENT_ZERO_DAMAGE;
448 } else {
449 hitResult = HIT_RESULT_NO_DAMAGE;
450 if (target->curHP < 1) {
451 dispatchEvent = EVENT_DEATH;
452 } else {
453 dispatchEvent = EVENT_ZERO_DAMAGE;
454 }
455 }
456
457 battleStatus->lastAttackDamage = 0;
458 } else {
459 target->damageCounter += damageDealt;
460 target->hpChangeCounter -= damageDealt;
461 battleStatus->lastAttackDamage = 0;
462 dispatchEvent = EVENT_HIT_COMBO;
463 hitResult = HIT_RESULT_HIT;
464
465 if (!(targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE)
467 && !partImmuneToElement
468 && !(targetPart->targetFlags & ACTOR_PART_TARGET_NO_DAMAGE)
469 ) {
470 target->curHP -= damageDealt;
471
472 if (target->curHP < 1) {
473 target->curHP = 0;
474 dispatchEvent = EVENT_DEATH;
475 }
476 }
477
478 battleStatus->lastAttackDamage += damageDealt;
479 target->lastDamageTaken = battleStatus->lastAttackDamage;
480 target->hpChangeCounter = 0;
481 }
482
483 if (targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE) {
484 if (partner->staticStatus == STATUS_KEY_STATIC
488 ) {
491 dispatch_event_actor(target, dispatchEvent);
492 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 3);
494 return HIT_RESULT_NICE;
495 } else {
496 return HIT_RESULT_HIT;
497 }
498 }
499
501 apply_shock_effect(partner);
503 return HIT_RESULT_BACKFIRE;
504 }
505 }
506
508 if (dispatchEvent == EVENT_HIT_COMBO) {
509 dispatchEvent = EVENT_HIT;
510 }
511
512 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
513 dispatchEvent = EVENT_IMMUNE;
514 }
515
516 if (target->curHP < 1) {
517 if (dispatchEvent == EVENT_IMMUNE) {
518 dispatchEvent = EVENT_DEATH;
519 }
520 }
521 } else if (dispatchEvent == EVENT_DEATH) {
522 dispatchEvent = EVENT_HIT_COMBO;
523 }
524
526 clear_part_pal_adjustment(targetPart);
527 }
528
530 if (battleStatus->curAttackElement & DAMAGE_TYPE_SPIN_SMASH) {
531 if (dispatchEvent == EVENT_HIT) {
532 dispatchEvent = EVENT_SPIN_SMASH_HIT;
533 }
534
535 if (dispatchEvent == EVENT_DEATH) {
536 dispatchEvent = EVENT_SPIN_SMASH_DEATH;
537 }
538
539 wasSpecialHit = TRUE;
540 }
541
544 if (dispatchEvent == EVENT_HIT_COMBO) {
545 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
546 }
547
548 if (dispatchEvent == EVENT_HIT) {
549 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
550 }
551
552 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
553 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
554 }
555
556 if (dispatchEvent == EVENT_IMMUNE) {
557 dispatchEvent = EVENT_POWER_BOUNCE_HIT;
558 }
559
560 if (dispatchEvent == EVENT_DEATH) {
561 dispatchEvent = EVENT_POWER_BOUNCE_DEATH;
562 }
563 }
564
566 if (battleStatus->curAttackElement & DAMAGE_TYPE_JUMP && targetPart->eventFlags & ACTOR_EVENT_FLAG_GROUNDABLE) {
567 if (dispatchEvent == EVENT_HIT) {
568 dispatchEvent = EVENT_FALL_TRIGGER;
569 }
570
571 if (dispatchEvent == EVENT_IMMUNE) {
572 dispatchEvent = EVENT_FALL_TRIGGER;
573 }
574
575 wasSpecialHit = TRUE;
576 }
577
579 if (battleStatus->curAttackElement & DAMAGE_TYPE_JUMP && targetPart->eventFlags & ACTOR_EVENT_FLAG_FLIPABLE) {
580 if (dispatchEvent == EVENT_HIT) {
581 dispatchEvent = EVENT_FLIP_TRIGGER;
582 }
583
584 if (dispatchEvent == EVENT_IMMUNE) {
585 dispatchEvent = EVENT_FLIP_TRIGGER;
586 }
587
588 if (!(target->flags & ACTOR_FLAG_FLIPPED)) {
589 wasSpecialHit = TRUE;
590 }
591 }
592 }
593 }
594 }
595 }
596
598 && battleStatus->curAttackElement & DAMAGE_TYPE_JUMP
600 ) {
601 if (dispatchEvent == EVENT_HIT_COMBO) {
602 dispatchEvent = EVENT_FLIP_TRIGGER;
603 }
604
605 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
606 dispatchEvent = EVENT_FLIP_TRIGGER;
607 }
608
609 if (!(target->flags & ACTOR_FLAG_FLIPPED)) {
610 wasSpecialHit = TRUE;
611 }
612 }
613
615 && battleStatus->curAttackElement & DAMAGE_TYPE_BLAST
617 ) {
618 if (dispatchEvent == EVENT_DEATH) {
619 dispatchEvent = EVENT_EXPLODE_TRIGGER;
620 }
621
622 if (dispatchEvent == EVENT_IMMUNE) {
623 dispatchEvent = EVENT_EXPLODE_TRIGGER;
624 }
625
626 if (dispatchEvent == EVENT_HIT) {
627 dispatchEvent = EVENT_EXPLODE_TRIGGER;
628 }
629
630 wasSpecialHit = TRUE;
631 isFireDamage = TRUE;
632 }
633
635 if (battleStatus->curAttackElement & (DAMAGE_TYPE_BLAST | DAMAGE_TYPE_FIRE)) {
636 if (dispatchEvent == EVENT_HIT) {
637 dispatchEvent = EVENT_BURN_HIT;
638 }
639
640 if (dispatchEvent == EVENT_DEATH) {
641 dispatchEvent = EVENT_BURN_DEATH;
642 }
643
644 isFireDamage = TRUE;
645 }
646
648 && battleStatus->lastAttackDamage >= 0
649 && dispatchEvent != EVENT_DEATH
650 && dispatchEvent != EVENT_SPIN_SMASH_DEATH
651 && dispatchEvent != EVENT_EXPLODE_TRIGGER
652 && !(targetPart->targetFlags & ACTOR_PART_TARGET_NO_DAMAGE)
653 ) {
654 #define INFLICT_STATUS(STATUS_TYPE) \
655 if ((battleStatus->curAttackStatus & STATUS_FLAG_##STATUS_TYPE) && \
656 try_inflict_status(target, STATUS_KEY_##STATUS_TYPE, STATUS_TURN_MOD_##STATUS_TYPE)) { \
657 wasSpecialHit = TRUE; \
658 wasStatusInflicted = TRUE; \
659 } \
660
661 INFLICT_STATUS(SHRINK);
662 INFLICT_STATUS(POISON);
663 INFLICT_STATUS(STONE);
664 INFLICT_STATUS(SLEEP);
665 INFLICT_STATUS(STOP);
666 INFLICT_STATUS(STATIC);
667 INFLICT_STATUS(FEAR);
668 INFLICT_STATUS(PARALYZE);
669 INFLICT_STATUS(DIZZY);
670
671 #undef INFLICT_STATUS
672
673 statusChanceOrDefense = target->actorBlueprint->spookChance;
674
675 if (statusChanceOrDefense > 0) {
676 statusChanceOrDefense = 100;
677 }
678
679 statusChanceOrDefense = (battleStatus->statusChance * statusChanceOrDefense) / 100;
680
681 if (battleStatus->curAttackStatus & STATUS_FLAG_400000) {
682 if (rand_int(99) < statusChanceOrDefense) {
683 if (!(target->debuff == STATUS_KEY_FEAR
684 || target->debuff == STATUS_KEY_DIZZY
685 || target->debuff == STATUS_KEY_PARALYZE
686 || target->debuff == STATUS_KEY_SLEEP
687 || target->debuff == STATUS_KEY_FROZEN
688 || target->debuff == STATUS_KEY_STOP)
689 && !(target->flags & ACTOR_FLAG_FLIPPED)
690 ) {
691 dispatchEvent = EVENT_SCARE_AWAY;
692 wasStatusInflicted = TRUE;
693 hitResult = HIT_RESULT_HIT;
694 wasSpecialHit = TRUE;
701 } else {
702 dispatchEvent = EVENT_IMMUNE;
703 hitResult = HIT_RESULT_NO_DAMAGE;
704 }
705 } else {
706 dispatchEvent = EVENT_IMMUNE;
707 hitResult = HIT_RESULT_NO_DAMAGE;
708 }
709 }
710
711 if (wasStatusInflicted) {
712 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
713 dispatchEvent = EVENT_HIT_COMBO;
714 }
715
716 if (dispatchEvent == EVENT_IMMUNE) {
717 dispatchEvent = EVENT_HIT;
718 }
719 }
720 }
721 }
722
723 statusChanceOrDefense = target->actorBlueprint->spookChance;
724 statusChanceOrDefense = (battleStatus->statusChance * statusChanceOrDefense) / 100;
725
727 if (battleStatus->curAttackElement & DAMAGE_TYPE_FEAR) {
728 if (rand_int(99) < statusChanceOrDefense) {
729 if (!(target->debuff == STATUS_KEY_FEAR ||
730 target->debuff == STATUS_KEY_DIZZY ||
731 target->debuff == STATUS_KEY_PARALYZE ||
732 target->debuff == STATUS_KEY_SLEEP ||
733 target->debuff == STATUS_KEY_FROZEN ||
734 target->debuff == STATUS_KEY_STOP) && !(target->flags & ACTOR_FLAG_FLIPPED)) {
735 dispatchEvent = EVENT_SCARE_AWAY;
736 wasStatusInflicted = TRUE;
737 hitResult = HIT_RESULT_HIT;
738 wasSpecialHit = TRUE;
745 } else {
746 dispatchEvent = EVENT_IMMUNE;
747 hitResult = HIT_RESULT_NO_DAMAGE;
748 }
749 } else {
750 dispatchEvent = EVENT_IMMUNE;
751 hitResult = HIT_RESULT_NO_DAMAGE;
752 }
753 }
754 }
755
756 battleStatus->wasStatusInflicted = wasStatusInflicted;
757 dispatch_event_actor(target, dispatchEvent);
758
759 if (!(target->flags & ACTOR_FLAG_NO_DMG_POPUP)) {
760 if (battleStatus->lastAttackDamage == 0) {
761 if (!wasSpecialHit && !wasStatusInflicted) {
762 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 3);
763 }
764 } else if (!partImmuneToElement) {
766 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
767 } else {
768 show_primary_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
769 }
770
771 if (!(targetPart->targetFlags & ACTOR_PART_TARGET_NO_DAMAGE)) {
772 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
773 }
774 }
775 }
776
779 ) {
780 if (battleStatus->lastAttackDamage > 0) {
782 }
783
784 if (battleStatus->lastAttackDamage > 0 || (battleStatus->curAttackElement & DAMAGE_TYPE_STATUS_ALWAYS_HITS && wasSpecialHit)) {
786 show_action_rating(ACTION_RATING_NICE, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
787 } else {
788 show_action_rating(ACTION_RATING_SUPER, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
789 }
790 }
791 }
792
794 func_80266970(target);
795 }
796
797 if (battleStatus->lastAttackDamage > 0) {
798 if (partImmuneToElement == 0) {
799 if (partner->actorTypeData1[5] != 0) {
801 }
802
803 set_actor_flash_mode(target, 1);
804
805 if (isFireDamage) {
807 } else if (isShockDamage) {
809 } else if (isIceDamage) {
811 } else {
813 }
814 }
815 }
816
817 if (battleStatus->lastAttackDamage < 1
818 && !(wasSpecialHit || wasStatusInflicted)
819 || targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE
820 ) {
822 }
823
824 if (battleStatus->curAttackStatus & STATUS_FLAG_SLEEP && wasStatusInflicted) {
826 evt->varTable[0] = state->goalPos.x;
827 evt->varTable[1] = state->goalPos.y;
828 evt->varTable[2] = state->goalPos.z;
830 }
831
832 if (battleStatus->curAttackStatus & STATUS_FLAG_DIZZY && wasStatusInflicted) {
834 evt->varTable[0] = state->goalPos.x;
835 evt->varTable[1] = state->goalPos.y;
836 evt->varTable[2] = state->goalPos.z;
838 }
839
840 if (battleStatus->curAttackStatus & STATUS_FLAG_PARALYZE && wasStatusInflicted) {
842 evt->varTable[0] = state->goalPos.x;
843 evt->varTable[1] = state->goalPos.y;
844 evt->varTable[2] = state->goalPos.z;
846 }
847
848 if (battleStatus->curAttackStatus & STATUS_FLAG_POISON && wasStatusInflicted) {
850 evt->varTable[0] = state->goalPos.x;
851 evt->varTable[1] = state->goalPos.y;
852 evt->varTable[2] = state->goalPos.z;
854 }
855
856 if (battleStatus->curAttackStatus & STATUS_FLAG_STOP && wasStatusInflicted) {
858 evt->varTable[0] = state->goalPos.x;
859 evt->varTable[1] = state->goalPos.y;
860 evt->varTable[2] = state->goalPos.z;
862 }
863
864 if (battleStatus->curAttackStatus & STATUS_FLAG_FROZEN && wasStatusInflicted) {
866 evt->varTable[0] = state->goalPos.x;
867 evt->varTable[1] = state->goalPos.y;
868 evt->varTable[2] = state->goalPos.z;
869 evt->varTablePtr[3] = target;
871 }
872
873 if (battleStatus->curAttackStatus & STATUS_FLAG_SHRINK && wasStatusInflicted) {
875 evt->varTable[0] = state->goalPos.x;
876 evt->varTable[1] = state->goalPos.y;
877 evt->varTable[2] = state->goalPos.z;
878 evt->varTablePtr[3] = target;
880 }
881
882 if (battleStatus->curAttackElement & DAMAGE_TYPE_SMASH && target->actorType == ACTOR_TYPE_GOOMNUT_TREE) {
884 }
885
886 show_actor_health_bar(target);
887
889 if (hitResult == HIT_RESULT_HIT) {
890 hitResult = HIT_RESULT_NICE;
891 }
892 if (hitResult == HIT_RESULT_NO_DAMAGE) {
893 hitResult = HIT_RESULT_NICE_NO_DAMAGE;
894 }
895 }
896
897 if (partner->staticStatus != STATUS_KEY_STATIC && (target->staticStatus == STATUS_KEY_STATIC ||
901 apply_shock_effect(partner);
903 return HIT_RESULT_BACKFIRE;
904 }
905
906 return hitResult;
907}
s16 lastDamageTaken
struct ActorBlueprint * actorBlueprint
s32 elementalImmunities
s32 actorTypeData1[6]
s16 damageCounter
s16 hpChangeCounter
Bytecode EvtScript[]
#define INFLICT_STATUS(STATUS_TYPE)
#define rand_int
@ ACTION_RATING_SUPER
sets nice hits = 2
Definition enums.h:1982
@ ACTION_RATING_NICE
sets nice hits = 1
Definition enums.h:1979
@ BS_FLAGS1_TUTORIAL_BATTLE
Definition enums.h:3594
@ BS_FLAGS1_NO_RATING
Definition enums.h:3577
@ BS_FLAGS1_FORCE_IMMUNE_HIT
Definition enums.h:3580
@ BS_FLAGS1_SUPER_HIT
Definition enums.h:3579
@ BS_FLAGS1_NICE_HIT
Definition enums.h:3576
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3568
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3571
@ BS_FLAGS1_ACTORS_VISIBLE
Definition enums.h:3565
@ ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
Actor glows and listens for Star Beam and Peach Beam events.
Definition enums.h:3386
@ ACTOR_EVENT_FLAG_GROUNDABLE
Actor can be knocked down from flight; triggered by jump attacks.
Definition enums.h:3382
@ ACTOR_EVENT_FLAG_FIRE_EXPLODE
Fire attacks trigger an explosion, used only by bullet/bombshell bills.
Definition enums.h:3378
@ ACTOR_EVENT_FLAG_POWER_BOUNCE
Actor listens for Power Bounce events.
Definition enums.h:3387
@ ACTOR_EVENT_FLAG_EXPLODE_ON_CONTACT
Attacks that contact will trigger an explosion.
Definition enums.h:3383
@ ACTOR_EVENT_FLAG_BURIED
Actor can only by hit by quake-element attacks.
Definition enums.h:3379
@ ACTOR_EVENT_FLAG_FLIPABLE
Actor can be flipped; triggered by jump and quake attacks.
Definition enums.h:3380
@ ACTOR_EVENT_FLAG_EXPLODE_ON_IGNITION
Blast and fire attacks trigger an explosion.
Definition enums.h:3377
@ ACTOR_EVENT_FLAG_ENCHANTED
Actor glows and listens for the Star Beam event.
Definition enums.h:3385
@ ACTOR_PART_TARGET_NO_DAMAGE
Definition enums.h:1877
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ HIT_RESULT_NO_DAMAGE
Definition enums.h:1952
@ HIT_RESULT_NICE_NO_DAMAGE
Definition enums.h:1953
@ HIT_RESULT_NICE
Definition enums.h:1951
@ SUPPRESS_EVENT_EXPLODE_CONTACT
Definition enums.h:2901
@ STATUS_FLAG_STOP
Definition enums.h:2821
@ STATUS_FLAG_FROZEN
Definition enums.h:2814
@ STATUS_FLAG_400000
Definition enums.h:2822
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ STATUS_FLAG_PARALYZE
Definition enums.h:2816
@ STATUS_FLAG_DIZZY
Definition enums.h:2818
@ STATUS_FLAG_SLEEP
Definition enums.h:2812
@ STATUS_FLAG_POISON
Definition enums.h:2817
@ SOUND_IMMUNE
Definition enums.h:745
@ SOUND_DAMAGE_STARS
Definition enums.h:950
@ SOUND_INFLICT_STATUS
Definition enums.h:1355
@ SOUND_HIT_NORMAL
Definition enums.h:724
@ SOUND_SMACK_TREE
Definition enums.h:787
@ SOUND_HIT_ICE
Definition enums.h:726
@ SOUND_INFLICT_SLEEP
Definition enums.h:1354
@ ACTOR_FLAG_NO_DMG_POPUP
Hide damage popup.
Definition enums.h:3341
@ ACTOR_FLAG_FLIPPED
Actor has been flipped over.
Definition enums.h:3330
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_SCARE_AWAY
Definition enums.h:2174
@ EVENT_BURN_HIT
Definition enums.h:2136
@ EVENT_POWER_BOUNCE_DEATH
Definition enums.h:2161
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_FALL_TRIGGER
Definition enums.h:2134
@ EVENT_BURN_DEATH
Definition enums.h:2157
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_SPIN_SMASH_HIT
Definition enums.h:2133
@ EVENT_EXPLODE_TRIGGER
Definition enums.h:2155
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2154
@ EVENT_HIT_COMBO
Definition enums.h:2131
@ EVENT_POWER_BOUNCE_HIT
Definition enums.h:2142
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_FLIP_TRIGGER
Definition enums.h:2135
@ ACTOR_PART_FLAG_DAMAGE_IMMUNE
electrified Plays extra hurt SFX?
Definition enums.h:3358
@ DAMAGE_TYPE_SPIN_SMASH
Definition enums.h:2876
@ DAMAGE_TYPE_ICE
Definition enums.h:2854
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
Definition enums.h:2880
@ DAMAGE_TYPE_POWER_BOUNCE
Definition enums.h:2870
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_SHOCK
Definition enums.h:2856
@ DAMAGE_TYPE_BLAST
Definition enums.h:2860
@ DAMAGE_TYPE_FIRE
Definition enums.h:2852
@ DAMAGE_TYPE_QUAKE
Definition enums.h:2862
@ DAMAGE_TYPE_FEAR
Definition enums.h:2863
@ DAMAGE_TYPE_MULTIPLE_POPUPS
Definition enums.h:2879
@ DAMAGE_TYPE_WATER
Definition enums.h:2853
void show_primary_damage_popup(f32 x, f32 y, f32 z, s32 attack, s32 a)
Definition 190B20.c:2269
void show_immune_bonk(f32 x, f32 y, f32 z, s32, s32, s32)
void show_actor_health_bar(Actor *)
Definition 190B20.c:2505
void clear_part_pal_adjustment(ActorPart *)
Definition 190B20.c:2618
void set_actor_flash_mode(Actor *actor, s32 arg1)
Definition 190B20.c:2696
void show_damage_fx(Actor *actor, f32 x, f32 y, f32 z, s32 damage)
Definition 190B20.c:2334
s32 get_defense(Actor *actor, s32 *defenseTable, s32 elementFlags)
Definition 190B20.c:2219
void func_80266970(Actor *)
Definition 190B20.c:2439
void show_next_damage_popup(f32 x, f32 y, f32 z, s32 damageAmount, s32)
Definition 190B20.c:2295
void show_action_rating(s32, Actor *, f32, f32, f32)
Definition 190B20.c:2360
EvtScript EVS_PlayStopHitFX
Definition dmg_player.c:109
EvtScript EVS_PlayFreezeHitFX
Definition dmg_player.c:115
EvtScript EVS_PlayShrinkHitFX
Definition dmg_player.c:125
EvtScript EVS_PlayParalyzeHitFX
Definition dmg_player.c:97
EvtScript EVS_PlayPoisonHitFX
Definition dmg_player.c:103
EvtScript EVS_PlaySleepHitFX
Definition dmg_player.c:85
EvtScript EVS_PlayDizzyHitFX
Definition dmg_player.c:91

◆ dispatch_damage_event_partner()

s32 dispatch_damage_event_partner ( s32 damageAmount,
s32 event,
s32 stopMotion )

Definition at line 909 of file dmg_partner.c.

909 {
910 BattleStatus* battleStatus = &gBattleStatus;
911 Actor* partner = battleStatus->partnerActor;
912 ActorState* state = &partner->state;
913 s32 hpChange;
914 s32 flagCheck;
915
916 battleStatus->curAttackDamage = damageAmount;
917
918 hpChange = (s16)damageAmount;
919 partner->hpChangeCounter += hpChange;
920
921 hpChange = partner->hpChangeCounter;
922 partner->curHP = 127;
923 partner->damageCounter += hpChange;
924 partner->hpChangeCounter -= hpChange;
925 battleStatus->lastAttackDamage = 0;
926 partner->curHP -= hpChange;
927
928 if (partner->curHP <= 0) {
929 event = EVENT_DEATH;
930 battleStatus->lastAttackDamage += partner->curHP;
931 partner->curHP = 0;
932 }
933
934 battleStatus->lastAttackDamage += hpChange;
935 partner->lastDamageTaken = battleStatus->lastAttackDamage;
936 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
938 if (event == EVENT_HIT_COMBO) {
939 event = EVENT_HIT;
940 }
941 if (event == EVENT_ZERO_DAMAGE) {
942 event = EVENT_IMMUNE;
943 }
944 }
945
946 if (battleStatus->lastAttackDamage > 0) {
948
949 inflict_status(partner, STATUS_KEY_DAZE, battleStatus->lastAttackDamage);
950 }
951
952 if (!stopMotion) {
954 }
955
956 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z,
957 battleStatus->lastAttackDamage, 1);
958 show_damage_fx(partner, state->goalPos.x, state->goalPos.y, state->goalPos.z,
959 battleStatus->lastAttackDamage);
960
961 if (battleStatus->lastAttackDamage > 0) {
962 set_actor_flash_mode(partner, 1);
963 }
964
966
969 return flagCheck;
970}
void dispatch_event_partner(s32 lastEventType)
Definition dmg_partner.c:7
@ STATUS_KEY_DAZE
Definition enums.h:2209
@ DMG_SRC_DEFAULT
Definition enums.h:1988
@ ACTOR_FLAG_HEALTH_BAR_HIDDEN
Definition enums.h:3338
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:2084
void set_goal_pos_to_part(ActorState *state, s32 actorID, s32 partID)
Definition actor_api.c:44

Referenced by dispatch_damage_event_partner_0(), and dispatch_damage_event_partner_1().

◆ dispatch_damage_event_partner_0()

s32 dispatch_damage_event_partner_0 ( s32 damageAmount,
s32 event,
s32 stopMotion )

Definition at line 972 of file dmg_partner.c.

972 {
973 return dispatch_damage_event_partner(damageAmount, event, FALSE);
974}