diff --git a/code/game/g_breakable.c b/code/game/g_breakable.c index f2f0a25..a9d8497 100644 --- a/code/game/g_breakable.c +++ b/code/game/g_breakable.c @@ -245,7 +245,7 @@ void breakable_spawn_trigger(gentity_t *ent) { //RPG-X | GSIO01 | 09/05/2009 EOE -/*QUAKED func_breakable (0 .8 .5) ? x x x x INVINCIBLE x x x REPAIRABLE +/*QUAKED func_breakable (0 .8 .5) ? x x x x INVINCIBLE x x x REPAIRABLE NOORIGIN INVINCIBLE - can only be broken by being used REPAIRABLE - con be repaired with hyperspanner diff --git a/code/game/g_combat.c b/code/game/g_combat.c index e9ea2cb..647a136 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -1576,13 +1576,18 @@ void G_Repair(gentity_t *ent, gentity_t *tr_ent, float rate) { } // check if player is near the breakable - VectorSubtract(tr_ent->s.origin, ent->r.currentOrigin, help); - distance = VectorLength(help); - for(i = 0; i < 3; i++) { - if(tr_ent->r.maxs[i] > max) { - max = tr_ent->r.maxs[i]; + if(tr_ent->spawnflags & 512) { + VectorSubtract(tr_ent->s.angles2, ent->r.currentOrigin, help); + max = tr_ent->n00bCount; + } else { + VectorSubtract(tr_ent->s.origin, ent->r.currentOrigin, help); + for(i = 0; i < 3; i++) { + if(tr_ent->r.maxs[i] > max) { + max = tr_ent->r.maxs[i]; + } } } + distance = VectorLength(help); //G_Printf("goodDst=%f, curDst=%f\n", 80 + max, distance); if(distance > 80 + max) { @@ -1591,7 +1596,6 @@ void G_Repair(gentity_t *ent, gentity_t *tr_ent, float rate) { // check if the player is facing it AngleVectors(ent->client->ps.viewangles, forward, NULL, NULL); - VectorSubtract(tr_ent->s.origin, ent->client->ps.origin, help); if(DotProduct(help, forward) < 0.4) { return; } diff --git a/code/game/g_weapon.c b/code/game/g_weapon.c index d6a1878..f95dc26 100644 --- a/code/game/g_weapon.c +++ b/code/game/g_weapon.c @@ -116,7 +116,7 @@ static void WP_FireHyperspanner(gentity_t *ent, qboolean alt_fire) { int i, nearest = -1; float nearestd = 65000; vec3_t dVec, end; - vec3_t mins = { -40, -40, -40 }, maxs = { 40, 40, 40 }; + vec3_t mins = { -40, -40, 0 }, maxs = { 40, 40, 0 }; char* classnames[] = { "func_breakable", "misc_model_breakable" }; /* find all vlaid entities in range */ @@ -126,15 +126,25 @@ static void WP_FireHyperspanner(gentity_t *ent, qboolean alt_fire) { trace_t tr; for(i = 0; i < count; i++) { // TODO: fix problems with small distance - VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.origin, dVec); - VectorMA(validEnts[i]->s.origin, 1024, dVec, end); + if(validEnts[i]->spawnflags & 512) { + VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.angles2, dVec); + VectorMA(validEnts[i]->s.angles2, 1024, dVec, end); + trap_Trace(&tr, validEnts[i]->s.angles2, mins, maxs, end, validEnts[i]->s.number, MASK_SHOT); + } else { + VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.origin, dVec); + VectorMA(validEnts[i]->s.origin, 1024, dVec, end); + trap_Trace(&tr, validEnts[i]->s.origin, mins, maxs, end, validEnts[i]->s.number, MASK_SHOT); + } //G_Printf("Checking entity: %d\n", i); - trap_Trace(&tr, validEnts[i]->s.origin, mins, maxs, end, validEnts[i]->s.number, MASK_SHOT); if(tr.entityNum != ent->s.number) { continue; } //G_Printf("Nothing is blocking view ...\n"); - VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.origin, dVec); + if(validEnts[i]->spawnflags & 512) { + VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.angles2, dVec); + } else { + VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.origin, dVec); + } if(VectorLength(dVec) < nearestd) { nearest = validEnts[i]->s.number; nearestd = VectorLength(dVec); diff --git a/code/game/lua_mover.c b/code/game/lua_mover.c index d2337ac..14c596f 100644 --- a/code/game/lua_mover.c +++ b/code/game/lua_mover.c @@ -203,6 +203,51 @@ static int Mover_SetAngles(lua_State * L) return 0; } +// mover.SetAngles2(entity ent, vector angles) or +// mover.SetAngles2(entity ent, float y, float z, float x) +// Sets the angles of ent to the specified value(s). +// Values are sorted Pitch (around Y-Axis), Yaw (around Z-Axis) and +// Roll (around X-Axis). These can also be stowed in a vector angles. +static int Mover_SetAngles2(lua_State * L) +{ + vec3_t newAngles; + lent_t *lent; + gentity_t *ent = NULL; + vec_t *target; + int id = 0; + + if(lua_isnumber(L, 1)) { + id = luaL_checkint(L, 1); + if(id < 0 || id > MAX_GENTITIES - 1) return 1; + ent = &g_entities[id]; + if(!ent) return 1; + } else { + lent = Lua_GetEntity(L, 1); + if(!lent || !lent->e) return 1; + ent = lent->e; + } + + if(Lua_IsVector(L, 2)) + { + target = Lua_GetVector(L, 2); + VectorCopy(target, newAngles); + } + else + { + newAngles[0] = luaL_checkint(L, 2); + newAngles[1] = luaL_checkint(L, 3); + newAngles[2] = luaL_checkint(L, 4); + } + LUA_DEBUG("Mover_SetAngles2 - start: ent=%d angles=%s", ent->s.number, vtos(newAngles)); + if(ent) + { + VectorCopy(newAngles, ent->s.angles2); + trap_LinkEntity(ent); + LUA_DEBUG("Mover_SetAngles2 - return: moved"); + } + return 0; +} + // mover.SetPosition(entity ent, vector pos) or // mover.SetPosition(entity ent, float x, float y, float z) // Set the position of ent to the specified value(s). Can also be stowed in a vector pos. @@ -369,6 +414,7 @@ static const luaL_Reg lib_mover[] = { {"SetOrigin", Mover_SetPosition}, {"ToPosition", Mover_ToPosition}, {"SetAngles", Mover_SetAngles}, + {"SetAngles2", Mover_SetAngles2}, {"ToAngles", Mover_ToAngles}, {NULL, NULL} };