Skip to content

Commit

Permalink
fix spiketrap wizardary..
Browse files Browse the repository at this point in the history
  • Loading branch information
tedpark217 committed Jun 7, 2024
1 parent 9f4e194 commit b6704d6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"maze": {
"directory": "maps",
"procedural": true,
"maze_file": "test/itemRoom.maze"
"maze_file": "test/big.maze"
},
"disable_enemies": true
},
Expand All @@ -14,9 +14,9 @@
"server": {
"lobby_name": "Hope you're doing well!",
"lobby_broadcast": true,
"max_players": 4,
"max_players": 2,
"disable_dm": false,
"skip_intro": false
"skip_intro": true
},
"client": {
"default_name": "Conan O'Brien",
Expand Down
15 changes: 2 additions & 13 deletions maps/test/big.maze
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####[##########################################
#...-.-.1...1..-...............................#
#..............................................#
#..............................................#
#...@..*.......................................#
#...@..*.....T.................................#
#..............................................#
{..............................................#
#...........{..............{.......{...........#
Expand All @@ -28,15 +28,4 @@
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
#..............................................#
################################################
15 changes: 8 additions & 7 deletions src/server/game/servergamestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ void ServerGameState::updateMovement() {
currentPosition = object->physics.shared.corner;
}

const float spike_low_y = 3.0f;
const float spike_low_y = 2.9f;
if (object->type == ObjectType::SpikeTrap && object->physics.shared.corner.y < spike_low_y) {
object->physics.shared.corner.y = spike_low_y;
object->physics.feels_gravity = false;
Expand Down Expand Up @@ -1078,6 +1078,7 @@ bool ServerGameState::hasObjectCollided(Object* object, glm::vec3 newCornerPosit
otherObj->type == ObjectType::Orb ||
otherObj->type == ObjectType::WeaponCollider ||
otherObj->type == ObjectType::Slime ||
otherObj->type == ObjectType::TeleporterTrap ||
otherObj->type == ObjectType::Torchlight) {
continue;
}
Expand Down Expand Up @@ -1717,7 +1718,7 @@ Trap* ServerGameState::placeTrapInCell(GridCell* cell, CellType type) {
if (cell->type != CellType::Empty)
return nullptr;

const float HEIGHT_SHOWING = 0.5;
const float HEIGHT_SHOWING = 0.4;
glm::vec3 dimensions(
Grid::grid_cell_width,
MAZE_CEILING_HEIGHT,
Expand Down Expand Up @@ -1806,9 +1807,9 @@ Trap* ServerGameState::placeTrapInCell(GridCell* cell, CellType type) {
return nullptr;

glm::vec3 corner(
cell->x * Grid::grid_cell_width,
cell->x * Grid::grid_cell_width + 1,
0.0f,
cell->y * Grid::grid_cell_width
cell->y * Grid::grid_cell_width + 1
);

TeleporterTrap* teleporterTrap = new TeleporterTrap(corner);
Expand Down Expand Up @@ -2097,7 +2098,7 @@ void ServerGameState::loadMaze(const Grid& grid) {
break;
}
case CellType::SpikeTrap: {
const float HEIGHT_SHOWING = 0.5;
const float HEIGHT_SHOWING = 0.4;
glm::vec3 dimensions(
Grid::grid_cell_width,
MAZE_CEILING_HEIGHT,
Expand Down Expand Up @@ -2159,9 +2160,9 @@ void ServerGameState::loadMaze(const Grid& grid) {

case CellType::TeleporterTrap: {
glm::vec3 corner(
cell->x * Grid::grid_cell_width,
cell->x * Grid::grid_cell_width + 1,
0.0f,
cell->y * Grid::grid_cell_width
cell->y * Grid::grid_cell_width + 1
);

this->objects.createObject(new TeleporterTrap(corner));
Expand Down
5 changes: 4 additions & 1 deletion src/server/game/spiketrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const std::chrono::seconds SpikeTrap::TIME_UNTIL_RESET = 10s;
SpikeTrap::SpikeTrap(glm::vec3 corner, glm::vec3 dimensions):
Trap(ObjectType::SpikeTrap, true, corner, Collider::Box, ModelType::Cube, dimensions)
{
this->dropped_time = std::chrono::system_clock::now() - TIME_UNTIL_RESET;
this->dropped_time = std::chrono::system_clock::now() - 100000s;
this->physics.feels_gravity = false;
}

Expand Down Expand Up @@ -86,8 +86,11 @@ void SpikeTrap::doCollision(Object* other, ServerGameState& state) {
auto creature = dynamic_cast<Creature*>(other);
if (creature == nullptr) return; // not a creature, so don't really care

std::cout << this->physics.velocity.y << "\n";
std::cout << this->physics.shared.corner.y << "\n";
// if it is falling
if (this->physics.velocity.y < 0 && this->physics.shared.corner.y != 0) {
std::cout << "in docollision" << "\n";
creature->stats.health.decrease(DAMAGE);
}
}
Expand Down

0 comments on commit b6704d6

Please sign in to comment.