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.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f}},
21 {20.0f, 8.0f, 16.0f, 40, 80, {0.0f, 0.5f, 0.5f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 0.5f, 1.0f, 0.5f, 0.5f}},
22 {20.0f, 6.0f, 12.0f, 20, 40, {1.0f, 0.5f, 0.5f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f}},
23 {15.0f, 6.0f, 12.0f, 10, 30, {1.0f, 0.5f, 0.5f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f}},
24 {21.0f, 10.0f, 20.0f, 35, 70, {0.0f, 0.0f, 0.0f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
25 {21.0f, 8.0f, 16.0f, 15, 40, {0.0f, 0.0f, 0.0f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 1.0f, 0.5f, 0.5f, 0.0f}},
26 {20.0f, 8.0f, 20.0f, 20, 40, {0.0f, 0.0f, 0.0f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 0.5f, 1.0f, 0.5f, 0.0f}},
27 {20.0f, 8.0f, 14.0f, 20, 40, {0.0f, 0.0f, 0.0f, 0.2f, 0.2f, 0.2f, 0.0f, 0.2f, 0.0f, 0.5f, 0.5f, 1.0f, 1.0f}},
28 {21.0f, 10.0f, 30.0f, 600, 1000, {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f}},
36#include "collision.hpp"
41int rand_check(
float probability) {
43 float threshold = probability * 1000.0f;
45 return roll % 1000 < (int) threshold ? 1 : 0;
50 count += rand() % 100;
117 return rand_check(0.1f) != 0 ? 1 : 0;
125 return rand_check(0.1f) != 0 ? 1 : 0;
137 float next_position[4];
138 float hit_position[4];
146 float turn_step = 0.05f;
147 float speed_step = 0.01f;
154 case FISH_ACTION_NONE:
156 action = FISH_ACTION_APPROACH_FOOD;
160 case FISH_ACTION_APPROACH_FOOD:
162 action = FISH_ACTION_EAT_FOOD;
166 action = FISH_ACTION_LEAVE;
171 case FISH_ACTION_EAT_FOOD:
173 action = FISH_ACTION_BITE_HOOK;
177 action = FISH_ACTION_LEAVE;
181 case FISH_ACTION_BITE_HOOK:
182 action = FISH_ACTION_LEAVE;
185 case FISH_ACTION_LEAVE:
186 action = FISH_ACTION_NONE;
202 target_yaw = TWO_PI * ((float) rand() / 2147483648.0f);
205 target_speed = 0.2f + (0.5f * (float) rand() / 2147483648.0f);
209 if (
action == FISH_ACTION_APPROACH_FOOD) {
218 if (
action == FISH_ACTION_EAT_FOOD) {
223 if (
action == FISH_ACTION_BITE_HOOK) {
225 target_yaw = food_yaw + 0.2f * ((float) rand() / 2147483648.0f);
230 if (
action == FISH_ACTION_BATTLE) {
231 target_yaw = TWO_PI * ((float) rand() / 2147483648.0f);
238 if (
action == FISH_ACTION_LEAVE) {
268 velocity[0] =
speed * sinf(rotation[1]);
270 velocity[2] =
speed * cosf(rotation[1]);
285 if (
action == FISH_ACTION_BITE_HOOK ||
action == FISH_ACTION_BATTLE) {
299 sceVu0AddVector(next_position, position, velocity);
302 box.
max[0] = position[0] + 10.0f;
303 box.
max[1] = position[1] + 10.0f;
304 box.
max[2] = position[2];
305 box.
min[0] = position[0] - 10.0f;
306 box.
min[1] = position[1];
307 box.
min[2] = position[2] - 10.0f;
310 if (CheckHit(nearby_polys, count, position, next_position, hit_position, 0, 0) < 0) {
315 CheckWidth(nearby_polys, count, position, 2.0f *
angle_model_scale, next_position, 0);
320 float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
346 action = FISH_ACTION_ANGLE;
352 action = FISH_ACTION_BATTLE;
356 float deviation = nrnd();
359 if (deviation >= 0.0f) {
434 action = FISH_ACTION_NONE;
457static char *fish_file_01 =
"chara/f01a.chr";
458static char *fish_file_02 =
"chara/f02a.chr";
459static char *fish_file_03 =
"chara/f03a.chr";
460static char *fish_file_04 =
"chara/f04a.chr";
461static char *fish_file_05 =
"chara/f05a.chr";
462static char *fish_file_06 =
"chara/f06a.chr";
464void LoadFish(
CFish *fish,
int fish_kind,
int texture_slot,
CDataAlloc2<1> *alloc,
int loaded_before) {
465 if (fish_kind < 0 || fish_kind >= 18) {
469 LoadFile(
"chara/f00s.chr", read_buffer, NULL);
471 fish->
model.
LoadPackData3(read_buffer,
"info.cfg", alloc, texture_slot, alloc, loaded_before, 0);
472 memcpy(&fish->
info, &fish_info[fish_kind],
sizeof(
FishInfo));
477char *GetFishFileName(
int fish_kind) {
478 static char *name[18] = {
499 if (fish_kind < 0 || fish_kind >= 18) {
503 return name[fish_kind];
virtual void GetPosition(float *out_position)
virtual void SetScale(float x, float y, float z)
virtual void LoadPackData3(unsigned int *pack, char *name, CDataAlloc2< 1 > *alloc, int texture_block_no, CDataAlloc2< 1 > *image_alloc, int keep_textures, int visual_type)
virtual void SetRotation(float x, float y, float z)
virtual void Initialize()
virtual void SetPosition(float x, float y, float z)
void GetRotation(float *rotation)
void SetMotion(int motion_no, int flags)
void SetPosition(float *position)
void SetRotation(float *rotation)
void SetCPoly(CCPoly *polys, int count)
sceVu0FVECTOR food_position
void SetFoodPos(int kind, float *position, float radius)
void SetReference(CFrame *reference)
void GetPosition(float *position)
virtual void GetRotation(float *out_rotation)
float food_affinity[FISH_FOOD_KIND_COUNT]