Skip to content

Commit

Permalink
New command projectile_position_<axis>. Adjust launch position of pro…
Browse files Browse the repository at this point in the history
…jectile spawns.
  • Loading branch information
DCurrent committed Dec 9, 2019
1 parent 311f66c commit 9dcd966
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
30 changes: 25 additions & 5 deletions engine/openbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -10303,6 +10303,9 @@ s_model *load_cached_model(char *name, char *owner, char unload)
newanim->projectile.shootframe = FRAME_NONE;
newanim->projectile.throwframe = FRAME_NONE;
newanim->projectile.tossframe = FRAME_NONE; // this get 1 of weapons numshots shots in the animation that you want(normaly the last)by tails
newanim->projectile.position.x = 0;
newanim->projectile.position.y = 70;
newanim->projectile.position.z = 0;
newanim->flipframe = FRAME_NONE;
newanim->attack_one = 0;
newanim->subject_to_gravity = 1;
Expand All @@ -10319,9 +10322,9 @@ s_model *load_cached_model(char *name, char *owner, char unload)
newanim->cancel = ANIMATION_CANCEL_DISABLED; // OX. For cancelling anims into a freespecial.
newanim->hit_count = 0; //OX counts hits on a per anim basis for cancels.
newanim->sub_entity_model_index = newanim->projectile.bomb = newanim->projectile.knife =
newanim->projectile.star = newanim->projectile.flash = -1;
newanim->projectile.star = newanim->projectile.flash = MODEL_INDEX_NONE;
newanim->quakeframe.framestart = 0;
newanim->sync = -1;
newanim->sync = FRAME_NONE;

if((ani_id = translate_ani_id(value, newchar, newanim, &attack)) < 0)
{
Expand Down Expand Up @@ -10455,6 +10458,15 @@ s_model *load_cached_model(char *name, char *owner, char unload)
case CMD_MODEL_CUSTSTAR:
newanim->projectile.star = get_cached_model_index(GET_ARG(1));
break;
case CMD_MODEL_PROJECTILE_POSITION_X:
newanim->projectile.position.x = GET_INT_ARG(1);
break;
case CMD_MODEL_PROJECTILE_POSITION_Y:
newanim->projectile.position.y = GET_INT_ARG(1);
break;
case CMD_MODEL_PROJECTILE_POSITION_Z:
newanim->projectile.position.z = GET_INT_ARG(1);
break;

// Legacy dive attacks. Turn off animation level subject_to_gravity
// and then use jumpframe to fly down at an angle.
Expand Down Expand Up @@ -18147,6 +18159,12 @@ void update_frame(entity *ent, unsigned int f)
// Perform jumping if on a jumpframe.
check_jumpframe(self, f);

int position_x = anim->projectile.position.x;

if (self->direction == DIRECTION_LEFT)
{
position_x = -position_x;
}

if(anim->projectile.throwframe == f)
{
Expand All @@ -18156,8 +18174,10 @@ void update_frame(entity *ent, unsigned int f)
// then if the entity is jumping, check star first, if failed, try knife instead
// well, try knife at last, if still failed, try star, or just let if shutdown?



#define __trystar star_spawn(self->position.x + (self->direction == DIRECTION_RIGHT ? 56 : -56), self->position.z, self->position.y+67, self->direction)
#define __tryknife knife_spawn(NULL, -1, self->position.x, self->position.z, self->position.y + anim->projectile.position.y, self->direction, 0, 0)
#define __tryknife knife_spawn(NULL, -1, self->position.x + position_x, self->position.z + anim->projectile.position.z, self->position.y + anim->projectile.position.y, self->direction, 0, 0)

if(anim->projectile.knife >= 0 || anim->projectile.flash >= 0)
{
Expand All @@ -18183,13 +18203,13 @@ void update_frame(entity *ent, unsigned int f)

if(anim->projectile.shootframe == f)
{
knife_spawn(NULL, -1, self->position.x, self->position.z, self->position.y, self->direction, 1, 0);
knife_spawn(NULL, -1, self->position.x + position_x, self->position.z + anim->projectile.position.z, self->position.y + anim->projectile.position.y, self->direction, 1, 0);
self->deduct_ammo = 1;
}

if(anim->projectile.tossframe == f)
{
bomb_spawn(NULL, -1, self->position.x, self->position.z, self->position.y + anim->projectile.position.y, self->direction, 0);
bomb_spawn(NULL, -1, self->position.x + position_x, self->position.z + anim->projectile.position.z, self->position.y + anim->projectile.position.y, self->direction, 0);
self->deduct_ammo = 1;
}

Expand Down
3 changes: 3 additions & 0 deletions engine/source/openborscript/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ List *createModelCommandList(void)
LIST_ADD(CMD_MODEL_PLAYSHOTW, "playshotw");
LIST_ADD(CMD_MODEL_PRIORITY, "priority");
LIST_ADD(CMD_MODEL_PROJECT, "project");
LIST_ADD(CMD_MODEL_PROJECTILE_POSITION_X, "projectile_position_x");
LIST_ADD(CMD_MODEL_PROJECTILE_POSITION_Y, "projectile_position_y");
LIST_ADD(CMD_MODEL_PROJECTILE_POSITION_Z, "projectile_position_z");
LIST_ADD(CMD_MODEL_PROJECTILEHIT, "projectilehit");
LIST_ADD(CMD_MODEL_PSHOTFRAME, "pshotframe");
LIST_ADD(CMD_MODEL_PSHOTFRAMENO, "pshotframeno");
Expand Down
5 changes: 4 additions & 1 deletion engine/source/openborscript/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ typedef enum modelCommand
CMD_MODEL_PLAYSHOTW,
CMD_MODEL_PRIORITY,
CMD_MODEL_PROJECT,
CMD_MODEL_PROJECTILEHIT,
CMD_MODEL_PROJECTILE_POSITION_X,
CMD_MODEL_PROJECTILE_POSITION_Y,
CMD_MODEL_PROJECTILE_POSITION_Z,
CMD_MODEL_PROJECTILEHIT,
CMD_MODEL_PSHOTFRAME,
CMD_MODEL_PSHOTFRAMENO,
CMD_MODEL_PSHOTFRAMEW,
Expand Down

0 comments on commit 9dcd966

Please sign in to comment.