Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respawn and heal player on death #82

Merged
merged 3 commits into from Jun 4, 2019

Conversation

6 participants
@darshan3
Copy link
Member

commented May 31, 2019

Project Card:
Handle respawn on death

How to test:

  1. Host a Light and Shadow game
  2. Join the game using one more client instance
  3. Choose one team with each of the players
  4. Kill one of the players by repeatedly attacking it through another one.

Expected outcome:
The killed player should get respawned at its home base with full health restored.

@e-aakash
Copy link
Member

left a comment

Tested, working as expected. Code not reviewed.

@iaronaraujo
Copy link
Contributor

left a comment

Code looks good, but remember to always create the class and public methods' javadoc so this module is always well documented!

event.consume();
logger.info(player.toFullDescription());
String team = player.getComponent(LASTeamComponent.class).team;
player.send(new DoHealEvent(100000, player));

This comment has been minimized.

Copy link
@llvieira

llvieira Jun 1, 2019

Member

@darshan3 what does the magic number 100000 mean? it would be better to use a constant.

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 2, 2019

Member

@darshan3 find out the value which restores the health completely and use that as a local constant for now.
Might ask @e-aakash to set that up as a constant somewhere in the health module and reference it later.

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 4, 2019

Contributor

The Health module should have a way to restoreToMax - not sure how/whether a constant can solve this.

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 4, 2019

Member

Sure, extracting the DoHeal event logic with the maxHealth value to such a method would be ideal.

This comment has been minimized.

Copy link
@e-aakash

e-aakash Jun 5, 2019

Member

If we make a constant in health component, we would anyway need to access the component to get the value. We can either use maxHealth for now or just this hack of arbitrarily large value.
restoreFullEvent is part of the present plan for the Restoration system. So, an event to restore to max health would be available when Restoration is complete (around the end of the second month of the coding period).

@nihal111
Copy link
Member

left a comment

Looks good overall, haven't tested though.
Would like a few changes.

public void beforeDestroy(BeforeDestroyEvent event, EntityRef player, CharacterComponent characterComponent, AliveCharacterComponent aliveCharacterComponent) {
if (player.hasComponent(PlayerCharacterComponent.class)) {
event.consume();
logger.info(player.toFullDescription());

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 2, 2019

Member

Remove this log before merge.

event.consume();
logger.info(player.toFullDescription());
String team = player.getComponent(LASTeamComponent.class).team;
player.send(new DoHealEvent(100000, player));

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 2, 2019

Member

@darshan3 find out the value which restores the health completely and use that as a local constant for now.
Might ask @e-aakash to set that up as a constant somewhere in the health module and reference it later.

logger.info(player.toFullDescription());
String team = player.getComponent(LASTeamComponent.class).team;
player.send(new DoHealEvent(100000, player));
player.send(new CharacterTeleportEvent(LASUtils.getTeleportDestination(team)));

This comment has been minimized.

Copy link
@nihal111

nihal111 Jun 2, 2019

Member

Ideally, we should not be using the exact location of the base. That would mean when multiple players die, they always land on top of each other. Since the base is big enough, we could teleport to a random position on the base as in LASUtils.getTeleportDestination(team)) + Vec3(random(-1, 1), random(-1, 1), 0).

Again, here make sure that the players always face the opponent team's base. Maybe extract the above completely into a method and use it in the team selection logic as well.

@skaldarnar skaldarnar dismissed stale reviews from nihal111 and iaronaraujo Jun 4, 2019

either addressed or follow-up issue

@skaldarnar skaldarnar merged commit aad9a39 into master Jun 4, 2019

@skaldarnar skaldarnar deleted the PlayerDeath branch Jun 4, 2019

@skaldarnar skaldarnar added this to In progress in GSOC 2019: Light & Shadows via automation Jun 4, 2019

@skaldarnar skaldarnar moved this from In progress to Done in GSOC 2019: Light & Shadows Jun 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.