- Treballant en el push, els reactius i la gravetat :P
This commit is contained in:
@@ -40,6 +40,7 @@ namespace actor
|
||||
act->prev = act->next = nullptr;
|
||||
act->anim_wait = act->anim_wait_count = 0;
|
||||
act->anim_frame=0;
|
||||
act->react_mask = act->react_push = 0;
|
||||
return act;
|
||||
}
|
||||
|
||||
@@ -299,7 +300,7 @@ namespace actor
|
||||
act->mov_push = act->mov_push==PUSH_YP ? PUSH_YN : PUSH_YP;
|
||||
break;
|
||||
case MOV_Z:
|
||||
act->mov_push = act->mov_push==PUSH_ZP ? PUSH_ZN : PUSH_ZP;
|
||||
act->mov_push = act->mov_push==PUSH_ZN ? PUSH_ZP : PUSH_ZN;
|
||||
break;
|
||||
case MOV_CW:
|
||||
switch (act->mov_push)
|
||||
@@ -335,8 +336,28 @@ namespace actor
|
||||
act->orient = act->mov_push;
|
||||
}
|
||||
|
||||
void updateReactive(actor_t *act)
|
||||
{
|
||||
if (act->push & act->react_mask)
|
||||
{
|
||||
actor_t *other = nullptr;
|
||||
|
||||
if (act->push == PUSH_XP) { act->pos.x-=2; other = get_collision(act); act->pos.x+=2; }
|
||||
else if (act->push == PUSH_XN) { act->pos.x++; other = get_collision(act); act->pos.x--; }
|
||||
else if (act->push == PUSH_YP) { act->pos.y--; other = get_collision(act); act->pos.y++; }
|
||||
else if (act->push == PUSH_YN) { act->pos.y++; other = get_collision(act); act->pos.y--; }
|
||||
else if (act->push == PUSH_ZN) { act->pos.z++; other = get_collision(act); act->pos.z--; }
|
||||
|
||||
if (other) {
|
||||
other->push |= act->react_push;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updatePushable(actor_t *act)
|
||||
{
|
||||
if (act->flags & FLAG_REACTIVE) { updateReactive(act); return; }
|
||||
|
||||
vec3_t min = room::getMin();
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
@@ -353,9 +374,12 @@ namespace actor
|
||||
actor_t *now = act;
|
||||
do {
|
||||
actor::actor_t *other = actor::any_above_me(now);
|
||||
now->pos.z++;
|
||||
//if (other) other->pos.z++;
|
||||
if (!other || (other->flags & FLAG_PUSHABLE)) now->pos.z++;
|
||||
now = other;
|
||||
if (now && !(now->flags & FLAG_PUSHABLE)) {
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
now = nullptr;
|
||||
}
|
||||
} while (now);
|
||||
|
||||
actor::setDirty(act);
|
||||
@@ -367,7 +391,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( act->pos.x<min.x && ( !(room::getDoors()&DOOR_XN) || (act->pos.y!=28) || (act->pos.z!=room::getDoor(XN)*4) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XN;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_XN;
|
||||
act->pos.x++;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -397,7 +421,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || (act->pos.x>max.x && ( !(room::getDoors()&DOOR_XP) || (act->pos.y!=28) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_XP;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_XP;
|
||||
act->pos.x--;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -427,7 +451,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( act->pos.y<min.y && ( !(room::getDoors()&DOOR_YN) || (act->pos.x!=28) || (act->pos.z!=room::getDoor(XN)*4) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YN;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_YN;
|
||||
act->pos.y++;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -457,7 +481,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || ( act->pos.y>max.y && ( !(room::getDoors()&DOOR_YP) || (act->pos.x!=28) || !(act->flags&FLAG_HERO) ) ))
|
||||
{
|
||||
if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_YP;
|
||||
if (other && other->flags & FLAG_SENSIBLE) other->push |= PUSH_YP;
|
||||
act->pos.y--;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -487,7 +511,7 @@ namespace actor
|
||||
actor::actor_t *other = actor::get_collision(act);
|
||||
if (other || act->pos.z<0 || act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y)
|
||||
{
|
||||
//if (other && other->flags & FLAG_PUSHABLE) other->push |= PUSH_ZN;
|
||||
if (other && other->flags & FLAG_REACTIVE) other->push |= PUSH_ZN;
|
||||
act->pos.z++;
|
||||
if (act->flags & FLAG_MOVING) changeMoving(act);
|
||||
}
|
||||
@@ -499,21 +523,6 @@ namespace actor
|
||||
|
||||
}
|
||||
|
||||
void updateReactive(actor_t *act)
|
||||
{
|
||||
if (act->push & act->react_mask)
|
||||
{
|
||||
actor_t *other = nullptr;
|
||||
|
||||
if (act->push == PUSH_XP) { act->pos.x--; other = get_collision(act); act->pos.x++; }
|
||||
else if (act->push == PUSH_XN) { act->pos.x++; other = get_collision(act); act->pos.x--; }
|
||||
else if (act->push == PUSH_YP) { act->pos.y--; other = get_collision(act); act->pos.y++; }
|
||||
else if (act->push == PUSH_YN) { act->pos.y++; other = get_collision(act); act->pos.y--; }
|
||||
|
||||
if (other) other->push |= act->react_push;
|
||||
}
|
||||
}
|
||||
|
||||
void updateGravity(actor_t *act)
|
||||
{
|
||||
if (act->pos.z == 0) return;
|
||||
@@ -526,6 +535,11 @@ namespace actor
|
||||
actor_t *below = any_below_me(act);
|
||||
if (below)
|
||||
{
|
||||
if (below->flags & FLAG_REACTIVE) {
|
||||
below->push |= PUSH_ZN;
|
||||
updateReactive(below);
|
||||
if (act->push) updatePushable(act);
|
||||
}
|
||||
act->below = below;
|
||||
below->above = act;
|
||||
return;
|
||||
@@ -553,7 +567,7 @@ namespace actor
|
||||
//if (act->flags & FLAG_PUSHABLE)
|
||||
updatePushable(act);
|
||||
if (act->flags & FLAG_GRAVITY) updateGravity(act);
|
||||
if (act->flags & FLAG_REACTIVE) updateReactive(act);
|
||||
//if (act->flags & FLAG_REACTIVE) updateReactive(act);
|
||||
|
||||
act->push = PUSH_NONE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user