1#include "shot_effect.hpp"
6#include "collisiondata.hpp"
8#include "dun/gameloop.hpp"
9#include "hit_machingun_effect.hpp"
10#include "itembombeffect.hpp"
16#include "shot_effect_pack.hpp"
17#include "shot_utils.hpp"
21int GetWeaponElementAttr(
int element);
31 for (
int shot = 0; shot < 12; shot++) {
32 if (
used[shot] != 0) {
33 int texture_cell = NowWeaponHave->
item_no - 299;
36 if (texture_cell <= 0) {
40 int x = (texture_cell % 4) << 5;
41 int y = (texture_cell / 4) << 5;
42 set3DCellModel(
pos[shot],
"basefx01",
size[shot], x, y, 32, 32, 128);
55 sceVu0FVECTOR hit_position;
57 for (
int shot = 0; shot < 12; shot++) {
58 if (
used[shot] == 0) {
63 SHOT_COLLISION_RESULT result = checkCollision(hit_position,
pos[shot],
vector[shot], 2, 2.0f);
65 if (result == SHOT_COLLISION_NONE) {
70 NowColData->
Set(
pos[shot],
damage[shot], 1, 3.0f, 0.0f, 2, 2, 0, 0);
72 s8 weapon_element = NowWeaponHave->
best_elem;
74 attr_col->
hit[attr_col->
now_hit].
flags = GetWeaponElementAttr(weapon_element);
83 if (
life[shot] <= 0) {
96 for (
int slot = 0; slot < 8; slot++) {
99 sceVu0FVECTOR position;
100 sceVu0FVECTOR jittered;
108 jittered[0] = position[0] + 2.0f * (spread * (float) rand()) / 2147483648.0f - spread;
110 jittered[1] = position[1] + 2.0f * (spread * (float) rand()) / 2147483648.0f - spread;
112 jittered[2] = position[2] + 2.0f * (spread * (float) rand()) / 2147483648.0f - spread;
127 for (
int slot = 0; slot < 8; slot++) {
135 float end = (float) info[motion].end;
138 if (
loop[slot] != -1) {
139 if (
phase[slot] <
loop[slot] && time >= end - 1.0f && time <= end) {
148 if (
phase[slot] == 0 && time >= end - 1.0f && time <= end) {
161 sceVu0FVECTOR hit_position;
162 sceVu0FVECTOR position;
166 SHOT_COLLISION_RESULT result = SHOT_COLLISION_NONE;
168 if (
phase[slot] < 2) {
193 sceVu0FVECTOR player;
194 sceVu0FVECTOR direction;
195 sceVu0CopyVector(player, CharaMain.
pos);
196 direction[0] = player[0] - position[0];
198 direction[2] = player[2] - position[2];
200 sceVu0Normalize(direction, direction);
214 if (result == SHOT_COLLISION_NONE) {
232 case SHOT_END_EFFECT_BOMB:
240 if (
phase[slot] != -1) {
252 }
else if (
phase[slot] == 1) {
261 case SHOT_END_EFFECT_BOMB:
286 case SHOT_END_EFFECT_BOMB:
295 for (
int slot = 0; slot < 8; slot++) {
314 for (s32 i = 0; i < 8; i++) {
326 sprintf(name,
"dun/effect/%s.chr", description->
model_name);
327 LoadFile(name, pack, NULL);
328 wait_now_loading_vsync();
330 sprintf(name,
"%s.cfg", description->
model_name);
337 for (
int slot = 0; slot < slots; slot++) {
354 sprintf(name,
"%s.cfg", description->
model_name);
361 for (
int slot = 0; slot < slots; slot++) {
372 for (
int slot = 0; slot <
slot_count; slot++) {
388 this->loop[slot] =
loop;
398 printf(
"******** shot err ***********\n");
420 phase[slot] = start_phase;
422 if (initial_phase != -1) {
423 phase[slot] = initial_phase;
429 sceVu0SubVector(
velocity[slot], target, position);
432 if (parent == NULL) {
434 sceVu0FMATRIX rotation;
435 LookAtMatrixZ(rotation,
velocity[slot]);
449 if (
phase[slot] == 0) {
457 if (parent == NULL) {
487 this->wait[slot] = (u8)
wait;
538 this->damage[slot] =
damage;
581 for (s32 i = 0; i < 8; i++) {
592 for (
int index = 0; index < 5; index++) {
593 if (
effect[index].effect_data == description) {
598 for (
int index = 0; index < 5; index++) {
599 if (
effect[index].
Entry(description, resource, texture_block, allocator, slots) != 0) {
629 for (
int i = 0; i < 16; i++) {
630 if (this->
age[i] == 0) {
640 sceVu0CopyVector(this->
position[slot], origin);
641 sceVu0CopyVector(this->
velocity[slot], direction);
642 this->damage[slot] =
damage;
657 SHOT_COLLISION_RESULT result;
662 for (slot = 0; slot < 16; slot++) {
663 if (
age[slot] <= 0) {
669 if (
age[slot] >= 240) {
675 result = checkCollision(pos, pos,
velocity[slot], 2, 2.0f);
677 if (result == SHOT_COLLISION_MAP) {
678 OzumondShotEffect.
Set(pos);
682 if (result == SHOT_COLLISION_MONSTER) {
683 NowColData->
Set(pos,
damage[slot], 2, 4.0f, 1.0f, 2, 2, 0, 0);
684 weapon_element = NowWeaponHave->
best_elem;
void SetMotion(int no, int mode, float speed=-1.0f)
virtual void GetPosition(float *out_position)
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)
tagMOTION_TYPE motion_type
virtual void SetRotation(float x, float y, float z)
virtual void Initialize()
virtual void SetPosition(float x, float y, float z)
tagMOTION_TYPE * motion[CHARA_MOTION_MAX]
void SetVelocity(int index, float *direction, float scale)
int Set(float *position, int damage, int life, float radius, float scale_rate, int target_mask, int kind, int flags, int attribute)
void SetUserID(int id, int attack)
void Set(float *position)
int Entry(BT_SHOT_EFFECT *description, unsigned int *resource, int texture_block, CDataAlloc2< 1 > *allocator, int slots)
void SetVsMonster(char *effectiveness)
void SetWepStatus(int status)
BT_SHOT_EFFECT * effect_data
int ReEntry(BT_SHOT_EFFECT *description, CDataAlloc2< 1 > *allocator)
void SetEnemyAttr(int attribute)
int Entry(BT_SHOT_EFFECT *description, unsigned int *pack, int tex_block, CDataAlloc2< 1 > *allocator, int slots)
void SetRandomRate(float rate)
void SetLifeTime(int life_time)
CCharacter template_chara
int Entry2(BT_SHOT_EFFECT *description, unsigned int *pack, int tex_block, CDataAlloc2< 1 > *allocator, int slots)
void SetAttribute(int attribute)
sceVu0FVECTOR velocity[8]
int Set(float *position, float *target, int owner, int sub_id, int source, CFrame *parent, int initial_phase)
int Set(float *origin, float *direction, int damage, int element)
MOTION_INFO * motion_info