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

Go to the source code of this file.

Functions

s32 has_enchanted_part (Actor *actor)
 
void dispatch_event_general (Actor *actor, s32 event)
 
void play_hit_sound (Actor *actor, f32 x, f32 y, f32 z, u32 hitSound)
 
void dispatch_event_actor (Actor *actor, s32 event)
 
HitResult calc_enemy_test_target (Actor *actor)
 
HitResult calc_enemy_damage_target (Actor *attacker)
 
s32 dispatch_damage_event_actor (Actor *actor, s32 damageAmount, s32 originalEvent, s32 stopMotion)
 
s32 dispatch_damage_event_actor_0 (Actor *actor, s32 damageAmount, s32 event)
 
s32 dispatch_damage_event_actor_1 (Actor *actor, s32 damageAmount, s32 event)
 
f32 update_lerp_battle (s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
 

Variables

s32 StarPointMultiplier []
 Star Point multiplier, indexed by actor count.
 

Function Documentation

◆ has_enchanted_part()

s32 has_enchanted_part ( Actor * actor)

Definition at line 8 of file 1A5830.c.

8 {
9 ActorPart* partIt = actor->partsTable;
10 s32 ret = FALSE;
11
12 while (partIt != NULL) {
14 ret = TRUE;
15 break;
16 } else {
17 partIt = partIt->nextPart;
18 }
19 }
20
21 return ret;
22}
struct ActorPart * partsTable
struct ActorPart * nextPart
@ ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
Actor glows and listens for Star Beam and Peach Beam events.
Definition enums.h:3386
@ ACTOR_EVENT_FLAG_ENCHANTED
Actor glows and listens for the Star Beam event.
Definition enums.h:3385

Referenced by calc_enemy_damage_target().

◆ dispatch_event_general()

void dispatch_event_general ( Actor * actor,
s32 event )

Definition at line 24 of file 1A5830.c.

24 {
25 switch (actor->actorID & ACTOR_CLASS_MASK) {
28 break;
31 break;
33 dispatch_event_actor(actor, event);
34 break;
35 }
36}
void dispatch_event_actor(Actor *actor, s32 event)
Definition 1A5830.c:103
@ ACTOR_CLASS_ENEMY
Definition enums.h:2079
@ ACTOR_CLASS_PLAYER
Definition enums.h:2077
@ ACTOR_CLASS_PARTNER
Definition enums.h:2078
@ ACTOR_CLASS_MASK
Definition enums.h:2080
void dispatch_event_player(s32)
Definition dmg_player.c:131
void dispatch_event_partner(s32)
Definition dmg_partner.c:7

Referenced by calc_enemy_damage_target(), and calc_enemy_test_target().

◆ play_hit_sound()

void play_hit_sound ( Actor * actor,
f32 x,
f32 y,
f32 z,
u32 hitSound )

Definition at line 38 of file 1A5830.c.

38 {
39 s32 actorClass = actor->actorID & ACTOR_CLASS_MASK;
40
41 switch (hitSound) {
42 case HIT_SOUND_MISS:
44 break;
45 case HIT_SOUND_BONES:
47 break;
49 switch (actorClass) {
52 break;
55 break;
58 break;
59 }
60 break;
61 case HIT_SOUND_FIRE:
62 switch (actorClass) {
65 break;
68 break;
71 break;
72 }
73 break;
74 case HIT_SOUND_ICE:
75 switch (actorClass) {
78 break;
81 break;
84 break;
85 }
86 break;
87 case HIT_SOUND_SHOCK:
88 switch (actorClass) {
91 break;
94 break;
97 break;
98 }
99 break;
100 }
101}
#define sfx_play_sound_at_position
@ HIT_SOUND_NORMAL
Definition enums.h:2187
@ HIT_SOUND_FIRE
Definition enums.h:2188
@ HIT_SOUND_SHOCK
Definition enums.h:2190
@ HIT_SOUND_BONES
Definition enums.h:2186
@ HIT_SOUND_ICE
Definition enums.h:2189
@ HIT_SOUND_MISS
Definition enums.h:2185
@ SOUND_IMMUNE
Definition enums.h:745
@ SOUND_HIT_PLAYER_ICE
Definition enums.h:721
@ SOUND_HIT_PLAYER_SHOCK
Definition enums.h:1194
@ SOUND_HIT_PLAYER_FIRE
Definition enums.h:720
@ SOUND_HIT_NORMAL
Definition enums.h:724
@ SOUND_HIT_SHOCK
Definition enums.h:1195
@ SOUND_HIT_ICE
Definition enums.h:726
@ SOUND_HIT_FIRE
Definition enums.h:725
@ SOUND_HIT_BONES
Definition enums.h:746
@ SOUND_HIT_PLAYER_NORMAL
Definition enums.h:719
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737

Referenced by calc_enemy_damage_target().

◆ dispatch_event_actor()

void dispatch_event_actor ( Actor * actor,
s32 event )

Definition at line 103 of file 1A5830.c.

103 {
104 Evt* handleEventScript = actor->handleEventScript;
105 s32 onHitID = actor->handleEventScriptID;
106
107 if (actor->handleEventSource != NULL) {
108 Evt* newScript;
109
110 actor->lastEventType = event;
112 actor->handleEventScript = newScript;
113 actor->handleEventScriptID = newScript->id;
114 newScript->owner1.actorID = actor->actorID;
115 }
116
117 if (actor->takeTurnScript != NULL) {
120 actor->takeTurnScript = NULL;
121 }
122
123 if (handleEventScript != NULL) {
124 kill_script_by_ID(onHitID);
125 }
126}
struct Evt * takeTurnScript
EvtScript * handleEventSource
struct Evt * handleEventScript
s32 takeTurnScriptID
s32 handleEventScriptID
union Evt::@8 owner1
Initially -1.
@ EVT_PRIORITY_A
Definition evt.h:153
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:161
Evt * get_script_by_index(s32 index)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void kill_script_by_ID(s32 id)

Referenced by btl_state_update_9(), calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_partner_test_enemy(), calc_player_damage_enemy(), calc_player_test_enemy(), dispatch_damage_event_actor(), and dispatch_event_general().

◆ calc_enemy_test_target()

HitResult calc_enemy_test_target ( Actor * actor)

Definition at line 128 of file 1A5830.c.

128 {
129 PlayerData* playerData = &gPlayerData;
130 BattleStatus* battleStatus = &gBattleStatus;
131 s32 targetID = battleStatus->curTargetID;
132 s32 targetPartIdx = battleStatus->curTargetPart;
133 Actor* target;
134 Actor* target2;
135 ActorPart* targetPart;
136 s32 actorClass;
137 s32 hitResult;
138
139 battleStatus->curTargetID2 = battleStatus->curTargetID;
140 battleStatus->curTargetPart2 = battleStatus->curTargetPart;
141
142 target = get_actor(targetID);
143 if (target == NULL) {
144 return HIT_RESULT_HIT;
145 }
146
147 targetPart = get_actor_part(target, targetPartIdx);
148 ASSERT(targetPart != NULL);
149
150 actorClass = targetID & ACTOR_CLASS_MASK;
151 switch (actorClass) {
153 target->curHP = playerData->curHP;
154 break;
156 target->curHP = 127;
157 break;
159 break;
160 }
161
162 if (battleStatus->curAttackElement & DAMAGE_TYPE_TRIGGER_LUCKY) {
164 return HIT_RESULT_HIT;
165 }
166
167 hitResult = HIT_RESULT_HIT;
168 target2 = target;
169 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY || battleStatus->outtaSightActive || target2->transparentStatus == STATUS_KEY_TRANSPARENT) {
170 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_MAGIC)) {
171 hitResult = HIT_RESULT_MISS;
172 }
173 }
174
175 if (hitResult == HIT_RESULT_MISS) {
176 return HIT_RESULT_MISS;
177 }
178 hitResult = HIT_RESULT_HIT;
179 switch (actorClass) {
181 if (battleStatus->cloudNineTurnsLeft) {
182 if (rand_int(100) < battleStatus->cloudNineDodgeChance) {
183 hitResult = HIT_RESULT_MISS;
184 break;
185 }
186 } else {
188 if (rand_int(100) < 10) {
189 hitResult = HIT_RESULT_LUCKY;
190 break;
191 }
192 }
193 if (player_team_is_ability_active(target2, ABILITY_CLOSE_CALL) && (target2->curHP < 6)) {
194 if (rand_int(100) < 30) {
195 hitResult = HIT_RESULT_LUCKY;
196 break;
197 }
198 }
200 if (rand_int(100) < 20) {
201 hitResult = HIT_RESULT_LUCKY;
202 break;
203 }
204 }
205 }
206 break;
208 break;
210 break;
211 }
212
213 if (hitResult == HIT_RESULT_MISS) {
214 return HIT_RESULT_MISS;
215 }
216
217 if (hitResult == HIT_RESULT_LUCKY) {
218 return HIT_RESULT_LUCKY;
219 }
220
221 if (target2->stoneStatus == STATUS_KEY_STONE) {
222 return HIT_RESULT_IMMUNE;
223 }
224
225 if (target2->staticStatus == STATUS_KEY_STATIC) {
227 }
228
229 return HIT_RESULT_HIT;
230}
void dispatch_event_general(Actor *actor, s32 event)
Definition 1A5830.c:24
s8 transparentStatus
#define rand_int
#define ASSERT(condition)
@ ACTOR_EVENT_FLAG_ILLUSORY
Player attacks pass through and miss.
Definition enums.h:3374
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2210
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_KEY_STONE
Definition enums.h:2208
@ HIT_RESULT_HIT_STATIC
Definition enums.h:1957
@ HIT_RESULT_HIT
Definition enums.h:1950
@ HIT_RESULT_LUCKY
Definition enums.h:1955
@ HIT_RESULT_IMMUNE
Definition enums.h:1958
@ HIT_RESULT_MISS
Definition enums.h:1956
@ ABILITY_CLOSE_CALL
Definition enums.h:469
@ ABILITY_LUCKY_DAY
Definition enums.h:471
@ ABILITY_PRETTY_LUCKY
Definition enums.h:444
@ EVENT_LUCKY
Definition enums.h:2172
@ DAMAGE_TYPE_MAGIC
Definition enums.h:2855
@ DAMAGE_TYPE_TRIGGER_LUCKY
Definition enums.h:2881
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11

◆ calc_enemy_damage_target()

HitResult calc_enemy_damage_target ( Actor * attacker)
Bug
? repeated paralyze and dizzy infliction

Definition at line 232 of file 1A5830.c.

232 {
233 BattleStatus* battleStatus = &gBattleStatus;
234 ActorState* state = &attacker->state;
235 s32 targetID = battleStatus->curTargetID;
236 s32 targetPartIdx = battleStatus->curTargetPart;
237 s32 actorClass;
238 Actor* target;
239 ActorPart* targetPart;
240 s32 hitResult;
241 s32 one = TRUE;
242 s32 statusInflicted = FALSE;
243 s32 statusInflicted2 = FALSE;
244 s32 isFire = FALSE;
245 s32 isWater = FALSE;
246 s32 isIce = FALSE;
247 s32 isElectric = FALSE;
248 s32 madeElectricContact = FALSE;
249 s32 isPlayer;
250 s32 defense;
251 s32 event;
252 s32 damage;
253 Evt* script;
254
255 battleStatus->wasStatusInflicted = FALSE;
256 battleStatus->lastAttackDamage = 0;
257
258 battleStatus->attackerActorID = attacker->actorID;
259 battleStatus->curTargetID2 = targetID;
260 battleStatus->curTargetPart2 = targetPartIdx;
261
262 target = get_actor(targetID);
263 if (target == NULL) {
264 return HIT_RESULT_HIT;
265 }
266
267 targetPart = get_actor_part(target, targetPartIdx);
268 ASSERT(targetPart != NULL);
269
270 actorClass = targetID & ACTOR_CLASS_MASK;
271 target->lastDamageTaken = 0;
272
273 switch (actorClass) {
275 target->curHP = gPlayerData.curHP;
276 break;
278 target->curHP = 127;
279 break;
281 break;
282 }
283
284 // handle defender status
285
286 if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY) {
287 return HIT_RESULT_MISS;
288 }
289
291 || (targetPart->eventFlags & ACTOR_EVENT_FLAG_BURIED && !(battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE))
292 ) {
293 return HIT_RESULT_MISS;
294 }
295
296 if (target->stoneStatus == STATUS_KEY_STONE) {
297 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, -1);
298 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 0);
299 play_hit_sound(attacker, state->goalPos.x, state->goalPos.y, state->goalPos.z, 0);
301 return HIT_RESULT_HIT;
302 }
303
304 // handle attack element
305
306 if (battleStatus->curAttackElement & DAMAGE_TYPE_BLAST) {
307 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
309 ) {
310 play_hit_sound(attacker, state->goalPos.x, state->goalPos.y, state->goalPos.z, 3);
312 return HIT_RESULT_BACKFIRE;
313 }
314 }
315 if ((battleStatus->curAttackElement & DAMAGE_TYPE_QUAKE) && (target->flags & ACTOR_FLAG_FLYING)) {
316 play_hit_sound(attacker, state->goalPos.x, state->goalPos.y, state->goalPos.z, 1);
318 }
319 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
320 fx_ring_blast(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
321 isFire = TRUE;
322 }
323 if (battleStatus->curAttackElement & DAMAGE_TYPE_SHOCK) {
324 apply_shock_effect(target);
325 isElectric = TRUE;
326 }
327 if (battleStatus->curAttackElement & DAMAGE_TYPE_WATER) {
328 fx_water_splash(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f, 1.0f, 24);
329 isWater = TRUE;
330 }
331 if (battleStatus->curAttackElement & DAMAGE_TYPE_ICE) {
332 fx_big_snowflakes(0, state->goalPos.x, state->goalPos.y, state->goalPos.z + 5.0f);
333 isIce = TRUE;
334 }
335
336 if (!(attacker->staticStatus == STATUS_KEY_STATIC)
337 && ((target->staticStatus == STATUS_KEY_STATIC) || (targetPart->eventFlags & ACTOR_EVENT_FLAG_ELECTRIFIED))
340 && !has_enchanted_part(attacker)) // enchanted attacks ignore electrified defenders
341 {
342 madeElectricContact = TRUE;
344 }
345
346 // ------------------------------------------------------------------------
347 // damage calculation
348
349 gBattleStatus.flags1 &= ~BS_FLAGS1_ATK_BLOCKED;
350
351 // determine target defense
352
353 defense = get_defense(target, targetPart->defenseTable, battleStatus->curAttackElement);
354
355 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_IGNORE_DEFENSE)) {
356 defense += target->defenseBoost;
357
358 if (actorClass == ACTOR_CLASS_PLAYER) {
359 if (battleStatus->waterBlockTurnsLeft > 0) {
360 if ((battleStatus->curAttackElement & (DAMAGE_TYPE_BLAST | DAMAGE_TYPE_FIRE))) {
361 defense += 2;
362 } else {
363 defense += 1;
364 }
365 }
366
368 defense += 1;
369 }
370 }
371 }
372
373 // apply attacker damage modifiers
374
375 damage = battleStatus->curAttackDamage;
376
377 switch (actorClass) {
379 damage -= battleStatus->merleeDefenseBoost;
380 break;
383 break;
384 }
385
386 damage += attacker->attackBoost;
387
388 if (attacker->chillOutTurns != 0) {
389 damage -= attacker->chillOutAmount;
390 }
391
392 if (attacker->debuff == STATUS_KEY_SHRINK) {
393 if (damage > 0) {
394 damage /= 2;
395 }
396 }
397
398 if (damage > 99) {
399 damage = 99;
400 }
401 if (damage < 1) {
402 defense = 0;
403 }
404
405 target->hpChangeCounter = 0;
406 damage -= defense;
407
408 // apply damage mitigation from defensive badges
409
410 isPlayer = actorClass == ACTOR_CLASS_PLAYER;
411 if (isPlayer) {
413 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
414 damage--;
415 }
416 }
417
421
422 if (target->curHP <= 5) {
424 damage /= 2;
425 }
426 }
427 }
428
429 // apply damage mitigation from blocking
430
431 switch (actorClass) {
433 // TODO figure out how to better write target->debuff >= STATUS_KEY_POISON
434 if ((target->debuff == 0 || target->debuff >= STATUS_KEY_POISON)
435 && (target->stoneStatus == 0)
436 && !(battleStatus->curAttackElement & DAMAGE_TYPE_UNBLOCKABLE)
437 ) {
438 s32 blocked;
439
441 blocked = rand_int(1);
442 } else {
443 blocked = check_block_input(BUTTON_A);
444 }
445
446 if (blocked) {
447 damage--;
450 show_action_rating(ACTION_RATING_NICE, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
452 break;
453 }
454 func_80266970(target);
455 }
456 break;
458 if (target->stoneStatus == 0) {
459 if (target->koStatus == 0 && !(battleStatus->curAttackElement & DAMAGE_TYPE_UNBLOCKABLE)) {
461 damage = 0;
463 show_action_rating(ACTION_RATING_NICE, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
465 break;
466 }
467 func_80266970(target);
468 }
469 }
470 break;
471 }
472
474 func_80266970(target);
475 }
476
477 // deal damage and determine resulting battle event
478
479 event = EVENT_HIT_COMBO;
480 if (damage < 1) {
481 target->hpChangeCounter = 0;
482 if (!(battleStatus->curAttackElement & DAMAGE_TYPE_STATUS_ALWAYS_HITS)) {
483 hitResult = HIT_RESULT_NO_DAMAGE;
484 event = EVENT_ZERO_DAMAGE;
485 } else {
486 hitResult = HIT_RESULT_NO_DAMAGE;
487 event = EVENT_ZERO_DAMAGE;
488 if (target->curHP < 1) {
489 event = EVENT_DEATH;
490 }
491 }
492 battleStatus->lastAttackDamage = 0;
493 } else {
494 target->damageCounter += damage;
495 target->hpChangeCounter -= damage;
496 battleStatus->lastAttackDamage = 0;
497 hitResult = HIT_RESULT_HIT;
498 if (!(targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE)
500 ) {
501 if (!(target->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
502 target->curHP -= damage;
503 }
504
505 if (target->curHP < 1) {
506 target->curHP = 0;
507 event = EVENT_DEATH;
508 }
509 }
510 battleStatus->lastAttackDamage += damage;
511 target->lastDamageTaken = battleStatus->lastAttackDamage;
512 target->hpChangeCounter = 0;
513
514 if (actorClass == ACTOR_CLASS_PLAYER) {
515 battleStatus->damageTaken += damage;
516 gPlayerData.curHP = target->curHP;
517 }
518 }
519
521 if (event == EVENT_HIT_COMBO) {
522 event = EVENT_HIT;
523 }
524 if (event == EVENT_ZERO_DAMAGE) {
525 event = EVENT_IMMUNE;
526 }
527 if (target->curHP < 1 && event == EVENT_IMMUNE) {
528 event = EVENT_DEATH;
529 }
530 } else if (event == EVENT_DEATH) {
531 event = EVENT_HIT_COMBO;
532 }
533
535 clear_part_pal_adjustment(targetPart);
536 }
537
540 && (targetPart->eventFlags & ACTOR_EVENT_FLAG_FLIPABLE)
541 ) {
542 if (event == EVENT_HIT) {
543 event = EVENT_FLIP_TRIGGER;
544 }
545 if (event == EVENT_IMMUNE) {
546 event = EVENT_FLIP_TRIGGER;
547 }
548 }
549
552 && (targetPart->eventFlags & ACTOR_EVENT_FLAG_FLIPABLE)
553 ) {
554 if (event == EVENT_HIT_COMBO) {
555 event = EVENT_FLIP_TRIGGER;
556 }
557 if (event == EVENT_ZERO_DAMAGE) {
558 event = EVENT_FLIP_TRIGGER;
559 }
560 }
561
564 ) {
565 if (event == EVENT_HIT) {
566 event = EVENT_BURN_HIT;
567 }
568 if (event == EVENT_DEATH) {
569 event = EVENT_FIRE_DEATH;
570 }
571 isFire = TRUE;
572 }
573
575 if (event == EVENT_HIT_COMBO) {
576 event = EVENT_18;
577 }
578 if (event == EVENT_HIT) {
579 event = EVENT_BLOCK;
580 }
581 if (event == EVENT_ZERO_DAMAGE) {
582 event = EVENT_18;
583 }
584 if (event == EVENT_IMMUNE) {
585 event = EVENT_BLOCK;
586 }
587 if (event == EVENT_BURN_HIT) {
588 event = EVENT_BLOCK;
589 }
590 }
591
592 // try inflicting status effect
593
595 && battleStatus->lastAttackDamage >= 0
596 && event != EVENT_DEATH
597 && event != EVENT_SPIN_SMASH_DEATH
598 && event != EVENT_EXPLODE_TRIGGER
601 && !(actorClass == ACTOR_PLAYER && is_ability_active(ABILITY_HEALTHY_HEALTHY) && (rand_int(100) < 50)))
602 {
604 statusInflicted = one;
605 statusInflicted2 = one;
606 }
608 statusInflicted = one;
609 statusInflicted2 = one;
610 }
612 statusInflicted = one;
613 statusInflicted2 = one;
614 }
616 statusInflicted = one;
617 statusInflicted2 = one;
618 }
620 statusInflicted = one;
621 statusInflicted2 = one;
622 }
624 statusInflicted = one;
625 statusInflicted2 = one;
626 }
628 statusInflicted = one;
629 statusInflicted2 = one;
630 }
632 statusInflicted = one;
633 statusInflicted2 = one;
634 }
636 statusInflicted = one;
637 statusInflicted2 = one;
638 }
639
642 statusInflicted = one;
643 statusInflicted2 = one;
644 }
646 statusInflicted = one;
647 statusInflicted2 = one;
648 }
649
651 statusInflicted = one;
652 statusInflicted2 = one;
653 }
654
655 if (statusInflicted) {
656 if (event == EVENT_ZERO_DAMAGE) {
657 event = EVENT_HIT_COMBO;
658 }
659 if (event == EVENT_IMMUNE) {
660 event = EVENT_HIT;
661 }
662 }
663 }
664
665 // dispatch events and play damage effects
666
667 battleStatus->wasStatusInflicted = statusInflicted;
668
669 switch (actorClass) {
672 break;
675 break;
677 dispatch_event_actor(target, event);
678 break;
679 }
680
681 if (actorClass == ACTOR_CLASS_PARTNER
682 && battleStatus->lastAttackDamage > 0
684 && !(target->flags & ACTOR_FLAG_NO_DMG_APPLY))
685 {
687 }
688
689 if (!(target->flags & ACTOR_FLAG_NO_DMG_POPUP)) {
690 switch (actorClass) {
693 if (battleStatus->lastAttackDamage == 0) {
694 if (!statusInflicted2 && !statusInflicted) {
695 // immune star fx?
696 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, -3);
697 }
698 } else if (battleStatus->curAttackElement & (DAMAGE_TYPE_MULTIPLE_POPUPS | DAMAGE_TYPE_SMASH)) {
699 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 1);
700 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
701 } else {
702 show_primary_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 1);
703 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
704 break;
705 }
706 break;
708 if (battleStatus->lastAttackDamage == 0) {
709 if (!statusInflicted2 && !statusInflicted) {
710 show_immune_bonk(state->goalPos.x, state->goalPos.y, state->goalPos.z, 0, 1, 3);
711 }
712 } else if (battleStatus->curAttackElement & (DAMAGE_TYPE_MULTIPLE_POPUPS | DAMAGE_TYPE_SMASH)) {
713 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
714 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
715 } else {
716 show_primary_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
717 show_damage_fx(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
718 }
719 break;
720 }
721 }
722
723 if (battleStatus->lastAttackDamage > 0) {
724 u32 hitSound;
725
726 set_actor_flash_mode(target, 1);
727
728 if (attacker->actorTypeData1[5] != SOUND_NONE) {
730 }
731
732 if (isFire) {
733 hitSound = HIT_SOUND_FIRE;
734 } else if (!isElectric) {
735 hitSound = HIT_SOUND_NORMAL;
736 } else {
737 hitSound = HIT_SOUND_SHOCK;
738 }
739
740 play_hit_sound(target, state->goalPos.x, state->goalPos.y, state->goalPos.z, hitSound);
741 }
742
743 if ((battleStatus->lastAttackDamage < 1 && !statusInflicted2 && !madeElectricContact) || targetPart->flags & ACTOR_PART_FLAG_DAMAGE_IMMUNE) {
745 }
746
747 if ((battleStatus->curAttackStatus & STATUS_FLAG_SLEEP) && statusInflicted) {
749 script->varTable[0] = state->goalPos.x;
750 script->varTable[1] = state->goalPos.y;
751 script->varTable[2] = state->goalPos.z;
753 }
754 if ((battleStatus->curAttackStatus & STATUS_FLAG_DIZZY) && statusInflicted) {
756 script->varTable[0] = state->goalPos.x;
757 script->varTable[1] = state->goalPos.y;
758 script->varTable[2] = state->goalPos.z;
760 }
761 if ((battleStatus->curAttackStatus & STATUS_FLAG_PARALYZE) && statusInflicted) {
763 script->varTable[0] = state->goalPos.x;
764 script->varTable[1] = state->goalPos.y;
765 script->varTable[2] = state->goalPos.z;
767 }
768 if ((battleStatus->curAttackStatus & STATUS_FLAG_POISON) && statusInflicted) {
770 script->varTable[0] = state->goalPos.x;
771 script->varTable[1] = state->goalPos.y;
772 script->varTable[2] = state->goalPos.z;
774 }
775 if ((battleStatus->curAttackStatus & STATUS_FLAG_STOP) && statusInflicted) {
777 script->varTable[0] = state->goalPos.x;
778 script->varTable[1] = state->goalPos.y;
779 script->varTable[2] = state->goalPos.z;
781 }
782 if ((battleStatus->curAttackStatus & STATUS_FLAG_FROZEN) && statusInflicted) {
784 script->varTable[0] = state->goalPos.x;
785 script->varTable[1] = state->goalPos.y;
786 script->varTable[2] = state->goalPos.z;
787 script->varTablePtr[3] = target;
789 }
790 if ((battleStatus->curAttackStatus & STATUS_FLAG_SHRINK) && statusInflicted) {
792 script->varTable[0] = state->goalPos.x;
793 script->varTable[1] = state->goalPos.y;
794 script->varTable[2] = state->goalPos.z;
795 script->varTablePtr[3] = target;
797 }
798
799 if ((battleStatus->curAttackElement & DAMAGE_TYPE_SMASH) && target->actorType == ACTOR_TYPE_GOOMNUT_TREE) {
801 }
802
803 show_actor_health_bar(target);
804
805 if (attacker->staticStatus != STATUS_KEY_STATIC
807 && !(battleStatus->curAttackElement & DAMAGE_TYPE_NO_CONTACT)
810 && !has_enchanted_part(attacker))
811 {
813 apply_shock_effect(attacker);
815 return HIT_RESULT_BACKFIRE;
816 }
817
818 return hitResult;
819}
s32 dispatch_damage_event_actor_1(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:893
void play_hit_sound(Actor *actor, f32 x, f32 y, f32 z, u32 hitSound)
Definition 1A5830.c:38
s32 has_enchanted_part(Actor *actor)
Definition 1A5830.c:8
s32 check_block_input(s32 buttonMask)
Definition action_cmd.c:537
s16 lastDamageTaken
s32 actorTypeData1[6]
ActorState state
s16 damageCounter
s8 chillOutAmount
s16 hpChangeCounter
@ ACTION_RATING_NICE
sets nice hits = 1
Definition enums.h:1979
@ BUTTON_A
Definition enums.h:2790
@ BS_FLAGS1_TUTORIAL_BATTLE
Definition enums.h:3594
@ BS_FLAGS1_PLAYER_DEFENDING
Definition enums.h:3591
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_ATK_BLOCKED
Definition enums.h:3600
@ ACTOR_EVENT_FLAG_ELECTRIFIED
Player takes shock damage upon contact.
Definition enums.h:3375
@ 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
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3618
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_TURN_MOD_PARALYZE
Definition enums.h:2234
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_TURN_MOD_SLEEP
Definition enums.h:2228
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2232
@ STATUS_TURN_MOD_POISON
Definition enums.h:2233
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_TURN_MOD_STOP
Definition enums.h:2237
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_TURN_MOD_STONE
Definition enums.h:2236
@ STATUS_TURN_MOD_FROZEN
Definition enums.h:2230
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_TURN_MOD_STATIC
Definition enums.h:2229
@ STATUS_TURN_MOD_FEAR
Definition enums.h:2231
@ STATUS_TURN_MOD_SHRINK
Definition enums.h:2235
@ STATUS_KEY_DAZE
Definition enums.h:2209
@ HIT_RESULT_BACKFIRE
Definition enums.h:1949
@ HIT_RESULT_NO_DAMAGE
Definition enums.h:1952
@ SUPPRESS_EVENT_SHOCK_CONTACT
Definition enums.h:2903
@ STATUS_FLAG_FEAR
Definition enums.h:2815
@ STATUS_FLAG_STOP
Definition enums.h:2821
@ STATUS_FLAG_FROZEN
Definition enums.h:2814
@ STATUS_FLAG_STATIC
Definition enums.h:2813
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ STATUS_FLAG_PARALYZE
Definition enums.h:2816
@ STATUS_FLAG_STONE
Definition enums.h:2820
@ STATUS_FLAG_DIZZY
Definition enums.h:2818
@ STATUS_FLAG_SLEEP
Definition enums.h:2812
@ STATUS_FLAG_POISON
Definition enums.h:2817
@ ABILITY_BERSERKER
Definition enums.h:457
@ ABILITY_P_DOWN_D_UP
Definition enums.h:473
@ ABILITY_HEALTHY_HEALTHY
Definition enums.h:491
@ ABILITY_DEFEND_PLUS
Definition enums.h:463
@ ABILITY_DAMAGE_DODGE
Definition enums.h:487
@ ABILITY_LAST_STAND
Definition enums.h:468
@ ABILITY_P_UP_D_DOWN
Definition enums.h:470
@ ABILITY_FIRE_SHIELD
Definition enums.h:443
@ SOUND_DAMAGE_STARS
Definition enums.h:950
@ SOUND_INFLICT_STATUS
Definition enums.h:1355
@ SOUND_NONE
Definition enums.h:547
@ SOUND_SMACK_TREE
Definition enums.h:787
@ SOUND_INFLICT_SLEEP
Definition enums.h:1354
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_FLAG_FLYING
Quake Hammer can't hit.
Definition enums.h:3329
@ ACTOR_FLAG_NO_DMG_POPUP
Hide damage popup.
Definition enums.h:3341
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_BURN_HIT
Definition enums.h:2136
@ EVENT_FIRE_DEATH
Definition enums.h:2162
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_EXPLODE_TRIGGER
Definition enums.h:2155
@ EVENT_BLOCK
Definition enums.h:2147
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2154
@ EVENT_18
Definition enums.h:2145
@ EVENT_HIT_COMBO
Definition enums.h:2131
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_FLIP_TRIGGER
Definition enums.h:2135
@ EVENT_SHOCK_HIT
Definition enums.h:2165
@ ACTOR_PART_FLAG_DAMAGE_IMMUNE
electrified Plays extra hurt SFX?
Definition enums.h:3358
@ DAMAGE_TYPE_POW
Definition enums.h:2861
@ DAMAGE_TYPE_4000
Definition enums.h:2865
@ DAMAGE_TYPE_ICE
Definition enums.h:2854
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
Definition enums.h:2880
@ DAMAGE_TYPE_SMASH
Definition enums.h:2857
@ DAMAGE_TYPE_UNBLOCKABLE
Definition enums.h:2875
@ 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_JUMP
Definition enums.h:2858
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
@ 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
s32 is_ability_active(s32 arg0)
Definition inventory.c:1725
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 apply_shock_effect(Actor *)
void show_action_rating(s32, Actor *, f32, f32, f32)
Definition 190B20.c:2360
s32 try_inflict_status(Actor *, s32, s32)
Definition 190B20.c:2532
s32 inflict_partner_ko(Actor *target, s32 statusTypeKey, s32 duration)
Definition 190B20.c:2203
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
s32 curAttackEventSuppression

◆ dispatch_damage_event_actor()

s32 dispatch_damage_event_actor ( Actor * actor,
s32 damageAmount,
s32 originalEvent,
s32 stopMotion )

Definition at line 821 of file 1A5830.c.

821 {
822 BattleStatus* battleStatus = &gBattleStatus;
823 ActorState* state = &actor->state;
824 s32 dispatchEvent = originalEvent;
825 s32 currentAttackDamage;
826 s32 hpChangeCounter;
827 s32 hpChange;
828 s32 flagCheck;
829 s32 new_var;
830
831 battleStatus->curAttackDamage = damageAmount;
832 hpChange = (s16) damageAmount;
833 actor->hpChangeCounter += hpChange;
834 new_var = actor->hpChangeCounter;
835 hpChange = new_var;
836 actor->damageCounter += hpChange;
837 actor->hpChangeCounter -= hpChange;
838 battleStatus->lastAttackDamage = 0;
839 actor->curHP -= hpChange;
840
841 if (actor->curHP <= 0) {
842 dispatchEvent = EVENT_DEATH;
843 battleStatus->lastAttackDamage += actor->curHP;
844 actor->curHP = 0;
845 }
846
847 battleStatus->lastAttackDamage += hpChange;
848 actor->lastDamageTaken = battleStatus->lastAttackDamage;
849 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
850 if (battleStatus->flags1 & BS_FLAGS1_TRIGGER_EVENTS) {
851 if (dispatchEvent == EVENT_HIT_COMBO) {
852 dispatchEvent = EVENT_HIT;
853 }
854 if (dispatchEvent == EVENT_ZERO_DAMAGE) {
855 dispatchEvent = EVENT_IMMUNE;
856 }
857 }
858 if (dispatchEvent == EVENT_DEATH) {
859 if (originalEvent == EVENT_SPIN_SMASH_LAUNCH_HIT) {
860 dispatchEvent = EVENT_SPIN_SMASH_LAUNCH_DEATH;
861 }
862 if (originalEvent == EVENT_SHOCK_HIT) {
863 dispatchEvent = EVENT_SHOCK_DEATH;
864 }
865 }
866
867 if (!stopMotion) {
868 s32 savedTargetActorID = actor->targetActorID;
869
870 if (func_80263230(actor, actor) != 0) {
871 show_next_damage_popup(actor->targetData[0].truePos.x, actor->targetData[0].truePos.y, actor->targetData[0].truePos.z, battleStatus->lastAttackDamage, 0);
872 show_damage_fx(actor, actor->targetData[0].truePos.x, actor->targetData[0].truePos.y, actor->targetData[0].truePos.z, battleStatus->lastAttackDamage);
873 }
874 actor->targetActorID = savedTargetActorID;
875
876 } else {
877 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage, 0);
878 show_damage_fx(actor, state->goalPos.x, state->goalPos.y, state->goalPos.z, battleStatus->lastAttackDamage);
879 }
880
881 if (battleStatus->lastAttackDamage > 0) {
882 set_actor_flash_mode(actor, 1);
883 }
885 dispatch_event_actor(actor, dispatchEvent);
886 return 0;
887}
struct SelectableTarget targetData[24]
s16 targetActorID
@ DMG_SRC_DEFAULT
Definition enums.h:1988
@ ACTOR_FLAG_HEALTH_BAR_HIDDEN
Definition enums.h:3338
@ EVENT_SPIN_SMASH_LAUNCH_HIT
Definition enums.h:2138
@ EVENT_SHOCK_DEATH
Definition enums.h:2159
@ EVENT_SPIN_SMASH_LAUNCH_DEATH
Definition enums.h:2158
s32 func_80263230(Actor *, Actor *)
Definition 190B20.c:558

Referenced by dispatch_damage_event_actor_0(), and dispatch_damage_event_actor_1().

◆ dispatch_damage_event_actor_0()

s32 dispatch_damage_event_actor_0 ( Actor * actor,
s32 damageAmount,
s32 event )

Definition at line 889 of file 1A5830.c.

889 {
890 return dispatch_damage_event_actor(actor, damageAmount, event, FALSE);
891}
s32 dispatch_damage_event_actor(Actor *actor, s32 damageAmount, s32 originalEvent, s32 stopMotion)
Definition 1A5830.c:821

Referenced by btl_state_update_9().

◆ dispatch_damage_event_actor_1()

s32 dispatch_damage_event_actor_1 ( Actor * actor,
s32 damageAmount,
s32 event )

Definition at line 893 of file 1A5830.c.

893 {
894 return dispatch_damage_event_actor(actor, damageAmount, event, TRUE);
895}

Referenced by calc_enemy_damage_target().

◆ update_lerp_battle()

f32 update_lerp_battle ( s32 easing,
f32 start,
f32 end,
s32 elapsed,
s32 duration )

Definition at line 2093 of file 1A5830.c.

2093 {
2094 s32 timeLeft;
2095 f32 absMag;
2096 f64 start1;
2097 f64 start2;
2098 f32 len1;
2099 f32 len2;
2100 f32 len3;
2101 f32 len4;
2102 f64 len5;
2103 f32 len6;
2104 f64 len7;
2105
2106 switch (easing) {
2107 case EASING_LINEAR:
2108 return start + (end - start) * elapsed / duration;
2110 return start + SQ(elapsed) * (end - start) / SQ(duration);
2111 case EASING_CUBIC_IN:
2112 return start + CUBE(elapsed) * (end - start) / CUBE(duration);
2113 case EASING_QUARTIC_IN:
2114 return start + QUART(elapsed) * (end - start) / QUART(duration);
2116 len1 = end - start;
2117 return end - (len1 * cos_rad(((f32)elapsed / duration) * PI_D * 4.0) * (duration - elapsed) *
2118 (duration - elapsed)) / SQ((f32)duration);
2120 len2 = end - start;
2121 return end - (len2 * cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 15.0) * (duration - elapsed) *
2122 (duration - elapsed)) / SQ((f32)duration);
2124 timeLeft = duration - elapsed;
2125 return start + (end - start) - ((SQ(timeLeft) * (end - start))) / SQ(duration);
2126 case EASING_CUBIC_OUT:
2127 len3 = end - start;
2128 timeLeft = duration - elapsed;
2129 return start + len3 - ((CUBE(timeLeft) * len3)) / CUBE(duration);
2130 case EASING_QUARTIC_OUT:
2131 len4 = end - start;
2132 timeLeft = duration - elapsed;
2133 return start + len4 - ((QUART(timeLeft) * len4)) / QUART(duration);
2134 case EASING_COS_BOUNCE:
2135 absMag = cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 40.0) * (duration - elapsed) *
2136 (duration - elapsed) / SQ((f32)duration);
2137 if (absMag < 0.0f) {
2138 absMag = -absMag;
2139 }
2140 return end - (end - start) * absMag;
2141 case EASING_COS_IN_OUT:
2142 len5 = end - start;
2143 start1 = start;
2144 return start1 + (len5 * (1.0 - cos_rad(((f32)elapsed * PI_D) / (f32)duration)) / 2);
2145 case EASING_SIN_OUT:
2146 len6 = end - start;
2147 return start + (len6 * sin_rad((((f32) elapsed) * (PI_D / 2)) / ((f32) duration)));
2148 case EASING_COS_IN:
2149 len7 = end - start;
2150 start2 = start;
2151 return start2 + (len7 * (1.0 - cos_rad(((f32)elapsed * (PI_D / 2)) / (f32)duration)));
2152 }
2153
2154 return 0.0f;
2155}
@ EASING_SIN_OUT
Definition enums.h:521
@ EASING_COS_IN
Definition enums.h:522
@ EASING_CUBIC_IN
Definition enums.h:512
@ EASING_CUBIC_OUT
Definition enums.h:515
@ EASING_QUARTIC_IN
Definition enums.h:513
@ EASING_COS_BOUNCE
Definition enums.h:519
@ EASING_COS_SLOW_OVERSHOOT
Definition enums.h:517
@ EASING_QUADRATIC_IN
Definition enums.h:511
@ EASING_COS_IN_OUT
Definition enums.h:520
@ EASING_QUARTIC_OUT
Definition enums.h:516
@ EASING_QUADRATIC_OUT
Definition enums.h:514
@ EASING_LINEAR
Definition enums.h:510
@ EASING_COS_FAST_OVERSHOOT
Definition enums.h:518
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 sin_rad(f32 x)
Definition 43F0.c:713
#define PI_D
Definition macros.h:127
#define QUART(x)
Definition macros.h:168
#define CUBE(x)
Definition macros.h:167
#define SQ(x)
Definition macros.h:166

Variable Documentation

◆ StarPointMultiplier

s32 StarPointMultiplier[]
Initial value:
= {
100, 100, 100,
110,
130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
}

Star Point multiplier, indexed by actor count.

+10% multiplier for three actors +30% multiplier for four or more actors

Definition at line 2704 of file 1A5830.c.

2704 {
2705 100, 100, 100,
2706 110,
2707 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
2708};