14 s32 availableRenderTasks;
65 itemToDrop = ITEM_NONE;
79 if (curWeight >= dropCount) {
85 if (itemToDrop != ITEM_NONE) {
90 if (spawnCounter >= 12) {
92 angle = angleMult * 8;
108 if (spawnCounter >= 12) {
110 angle = angleMult * 8;
118 itemToDrop = ITEM_NONE;
124 attempts /= 32767.0f;
125 threshold /= 32767.0f;
127 if (fraction <= attempts &&
rand_int(100) <= threshold * 100.0f) {
131 for (j = 0; j < attempts; j++) {
132 if (
rand_int(100) <= chance * 100.0f) {
149 if (dropCount != 0) {
150 itemToDrop = ITEM_HEART;
153 if (dropCount * 2 > availableRenderTasks) {
154 dropCount = availableRenderTasks / 2;
156 availableRenderTasks -= 2 * dropCount;
157 if (dropCount > availableShadows) {
158 dropCount = availableShadows;
161 availableShadows -= dropCount;
163 for (i = 0; i < dropCount; i++) {
168 if (spawnCounter >= 12) {
171 angle = angleMult * 8;
178 itemToDrop = ITEM_NONE;
189 attempts /= 32767.0f;
190 threshold /= 32767.0f;
192 if (fraction <= attempts &&
rand_int(100) <= threshold * 100.0f) {
196 for (j = 0; j < attempts; j++) {
197 if (
rand_int(100) <= chance * 100.0f) {
214 if (dropCount != 0) {
215 itemToDrop = ITEM_FLOWER_POINT;
218 if (dropCount * 2 > availableRenderTasks) {
219 dropCount = availableRenderTasks / 2;
221 availableRenderTasks -= 2 * dropCount;
222 if (dropCount > availableShadows) {
223 dropCount = availableShadows;
226 availableShadows -= dropCount;
228 for (i = 0; i < dropCount; i++) {
233 if (spawnCounter >= 12) {
236 angle = angleMult * 8;
242 itemToDrop = ITEM_COIN;
254 if (minCoinBonus < 0) {
255 dropCount =
rand_int(maxCoinBonus - minCoinBonus) + minCoinBonus;
257 dropCount = maxCoinBonus - minCoinBonus;
258 if (dropCount != 0) {
259 dropCount =
rand_int(dropCount) + minCoinBonus;
261 dropCount = minCoinBonus;
281 if (dropCount > 20) {
287 if (dropCount * 2 > availableRenderTasks) {
288 dropCount = availableRenderTasks / 2;
293 availableRenderTasks -= 2 * dropCount;
295 if (dropCount > availableShadows) {
296 dropCount = availableShadows;
299 for (i = 0; i < dropCount; i++) {
303 angle = angle + 30.0;
304 if (spawnCounter >= 12) {
307 angle = angleMult * 8;
325 if ((amt < 0) || (minTemp != 0)) {
366 if (enemy->
unk_BC != NULL) {
377 newScript->
owner1.enemy = enemy;
380 if (enemy->
unk_B8 != NULL) {
383 enemy->
unk_BC = newScript;
386 newScript->
owner1.enemy = enemy;
398 if (encounter != NULL) {
399 for (j = 0; j < encounter->
count; j++) {
418 dist1 =
dist2D(centerX, centerZ, pointX, pointZ);
419 return (sizeX < dist1);
421 dist1 =
dist2D(centerX, 0, pointX, 0);
422 dist2 =
dist2D(0, centerZ, 0, pointZ);
423 return ((sizeX < dist1) || (sizeZ < dist2));
435 s32 skipCheckForPlayer;
463 playerStatus->
pos.
x, playerStatus->
pos.
z,
487 skipCheckForPlayer = 0;
492 if (skipCheckForPlayer == 0) {
502 if (useWorldYaw & 0xFF) {
507 if (
dist2D(x, z, playerStatus->
pos.
x, playerStatus->
pos.
z) <= radius) {
521 s32 skipCheckForPlayer;
524 skipCheckForPlayer =
rand_int(chance + 1);
526 skipCheckForPlayer = 0;
529 if (skipCheckForPlayer == 0) {
534 if (
dist2D(posX, posZ, playerStatus->
pos.
x, playerStatus->
pos.
z) <= radius) {
547 if (upperSoundFlags & 1) {
563 script->AI_TEMP_STATE = state;
575 script->functionTemp[1] = 0;
583 enemy->
aiFlags &= ~AI_FLAG_NEEDS_HEADING;
584 enemy->
aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY;
591 s32 stillWithinTerritory = FALSE;
598 if (script->functionTemp[1] <= 0) {
609 enemy->
aiFlags &= ~AI_FLAG_NEEDS_HEADING;
610 enemy->
aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY;
621 script->functionTemp[1]--;
640 enemy->
aiFlags &= ~AI_FLAG_NEEDS_HEADING;
649 enemy->
aiFlags &= ~AI_FLAG_NEEDS_HEADING;
653 stillWithinTerritory = TRUE;
655 enemy->
aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY;
656 enemy->
aiFlags &= ~AI_FLAG_NEEDS_HEADING;
673 script->functionTemp[1] =
rand_int(1000) % 3 + 2;
722 script->functionTemp[1]--;
723 if (script->functionTemp[1]) {
764 npc->
flags &= ~NPC_FLAG_JUMPING;
772 s32 skipTurnAround = FALSE;
778 skipTurnAround = TRUE;
781 if (!skipTurnAround) {
787 if (deltaAngleToPlayer < 0.0f) {
859API_CALLABLE(BasicAI_Main) {
860 Enemy* enemy = script->owner1.enemy;
862 Bytecode* args = script->ptrReadPos;
882 npc->
flags &= ~NPC_FLAG_JUMPING;
885 npc->
flags &= ~NPC_FLAG_FLYING;
887 npc->
flags &= ~NPC_FLAG_GRAVITY;
898 enemy->
aiFlags &= ~AI_FLAG_SUSPEND;
899 enemy->
flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING;
902 switch (script->AI_TEMP_STATE) {
void ai_enemy_play_sound(Npc *npc, s32 soundID, s32 upperSoundFlags)
b32 is_point_outside_territory(s32 shape, f32 centerX, f32 centerZ, f32 pointX, f32 pointZ, f32 sizeX, f32 sizeZ)
void basic_ai_chase_init(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
void basic_ai_lose_player(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
void spawn_drops(Enemy *enemy)
s32 get_coin_drop_amount(Enemy *enemy)
b32 basic_ai_check_player_dist(EnemyDetectVolume *territory, Enemy *enemy, f32 radius, f32 fwdPosOffset, b8 useWorldYaw)
void ai_try_set_state(Evt *script, s32 state)
void basic_ai_wander(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void basic_ai_loiter(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void basic_ai_chase(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void basic_ai_found_player_jump_init(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
void basic_ai_wander_init(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
void basic_ai_found_player_jump(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
void func_80048E34(Enemy *enemy, s32 arg1, s32 arg2)
void basic_ai_loiter_init(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
s32 ai_check_player_dist(Enemy *enemy, s32 chance, f32 radius, f32 moveSpeed)
union Evt::@8 owner1
Initially -1.
union Evt::@9 owner2
Initially -1.
#define sfx_play_sound_at_position
@ AI_DETECT_SENSITIVE_MOTION
@ ITEM_SPAWN_MODE_BATTLE_REWARD
@ AI_FLAG_CANT_DETECT_PLAYER
@ AI_FLAG_OUTSIDE_TERRITORY
@ ENEMY_FLAG_NO_DELAY_AFTER_FLEE
@ ENEMY_FLAG_BEGIN_WITH_CHASING
@ COLLIDER_FLAG_IGNORE_PLAYER
@ COLLISION_IGNORE_ENTITIES
@ SOUND_AI_FOUND_PLAYER_JUMP
@ AI_TERRITORY_IGNORE_HIDING
@ AI_TERRITORY_IGNORE_ELEVATION
@ ACTION_STATE_USE_SPINNING_FLOWER
@ ACTION_STATE_HOP
Released A before apex of jump.
@ ACTION_STATE_BOUNCE
Used with Kooper.
@ AI_ACTION_LOOK_AROUND_DURING_LOITER
@ AI_ACTION_JUMP_WHEN_SEE_PLAYER
@ SOUND_SPACE_PARAMS_MASK
@ SOUND_PARAM_CLIP_OFFSCREEN_ANY
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
s32 evt_get_variable(Evt *script, Bytecode var)
s32 is_ability_active(s32 arg0)
Shadow * get_shadow_by_index(s32 index)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
s32 make_item_entity(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupVar)
b32 npc_test_move_simple_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void kill_script_by_ID(s32 id)
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
s32 ai_check_fwd_collisions(Npc *npc, f32 arg1, f32 *arg2, f32 *arg3, f32 *arg4, f32 *arg5)
f32 get_clamped_angle_diff(f32, f32)
void basic_ai_suspend(Evt *script)
enum TerritoryShape shape
enum TerritoryShape detectShape
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Encounter * encounterList[24]
s16 chancePerAttempt
% chance for a single heart/flower to be dropped from each attempt.
Npc * get_npc_unsafe(s32 npcID)
s16 generalChance
% chance for any hearts/flowers to be dropped at all from this StatDrop.
s16 attempts
Maximum number of hearts/flowers that can be dropped from this StatDrop.
NpcSettings * npcSettings
EncounterStatus gCurrentEncounter
enum TerritoryShape wanderShape
s16 cutoff
% of max HP/FP. If current HP/FP > cutoff, no hearts/flowers can be dropped.
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
s32 skipPlayerDetectChance
EnemyTerritoryWander wander
EnemyTerritory * territory
@ GF_SpawnedItemDrop_00
comes from the third u16 in the selected item entry for enemy's drop table
#define EVT_INDEX_OF_GAME_FLAG(v)
s16 turnAroundYawAdjustment
PlayerStatus * gPlayerStatusPtr
PartnerStatus gPartnerStatus
GameStatus * gGameStatusPtr
PlayerStatus gPlayerStatus
s32 set_global_flag(s32 index)
s32 get_global_flag(s32 index)