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

Minor fixes to CombatController #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

devpitOne
Copy link

Fixes for:
-teamCount is never incremented
-Flee causes enemy mobs to be removed
-Combat Messages displaying after the look command from combatEnd

devpitOne added 2 commits September 1, 2019 16:16
…owned count was compared to team count combat would end.
-NPCs are only removed if the have the downed condition, prevents them from being removed if Flee is used
-combatEnd is queued so it doesn't happen before outer methods do. Previously the character would end up executing look before combat messages had finished displaying
Copy link

@seanohue seanohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good! A small formatting nitpick. Also I'm going to test this out tonight but I trust that it works.

}
else
//put downed players at 1 HP
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS Formatting: I would put the brace immediately after else, like else {, then the comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified to match the recommended format(5c344ea)

}
B.sayAt(p.character, '-> The battle is over.');
if (!p.character.isNpc) {
p.character.queueCommand({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting approach here. Why not just emit the combat end event directly?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see this must be the fix for the extra combat messages. I'd put a comment here explaining that. Seems like an odd side effect but glad you figured this one out.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this occurs on a ranvier using the standard bundles with turn-combat added. It might not be occurring on a ranvier using the full trpg-skeleton

@devpitOne
Copy link
Author

devpitOne commented Sep 2, 2019

The Bugfix for the attack command(ee9bd7b) will not work without a core change to Character.isInCombat()
My modified core adds a check for the CombatController.
Shawn recommends not using isInCombat at all. Instead the check could be changed to whether the target.combatController exists.

It shouldn't break anything as for trpg-skeleton that method will always return false, meaning the existing logic will happen.

@seanohue
Copy link

seanohue commented Sep 2, 2019

My workaround for that was to add a method, Combat.isInCombat, to the combat library (mostly custom but similar to the one found in the round-based combat bundle). That method checks for the combat controller.

command: state => (args, player) => {
const target = [...player.room.npcs][0];
const controller = new CombatController(state);
//TODO: Add pvp flag to this
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of keeping PRs small I would consider adding this fix as a separate PR particularly as it has several TODOs. Smaller PRs mean a higher chance for each individual one to get merged in sooner than later.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I just found another bug with it, so I'll back this one out of the PR

Copy link

@azigler azigler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes work great on my end. Good catch with adding this._teamCount[team]++; to addParticipant because otherwise those counts stay at 0. Removing Broadcast.prompt(p.character); gets rid of that duplicate prompt after a battle.

I'm not sure I understand why you're queuing a player emit in the command queue, however. combatEnd actually does nothing at the moment, but even if it did it wouldn't belong in the command queue. Why not fire it immediately?

@devpitOne
Copy link
Author

Hiya, It's to do with the order of commands. Calling it directly caused anything in combatEnd to occur before all the endCombat() was complete. This seems to be the wrong way round to me.

@azigler
Copy link

azigler commented Jun 6, 2020

I agree with that idea. The issue with this implementation, however, is the player events for commandQueued and updateTick are missing in this repo, so there's actually no functionality to execute the queued command. As a result, it would never fire.

You could solve this by adding p.character.commandQueue.execute(); at the end of that for loop block, but manually executing the command queue is messy. Alternatively, you could add the appropriate event handlers to your player-events.js in order to make the command queue function:

commandQueued: state => function (commandIndex) {
  const command = this.commandQueue.queue[commandIndex];
  const ttr = this.commandQueue.getTimeTilRun(commandIndex);
},

updateTick: state => function () {
  if (this.commandQueue.hasPending && this.commandQueue.lagRemaining <= 0) {
    B.sayAt(this);
    this.commandQueue.execute();
    B.prompt(this);
  }
}

And if you're going to be editing the player events, you might as well also add a handler for combatEnd since that's currently missing. I would do something like:

combatEnd: state => function () {
  Broadcast.sayAt(this, 'You leave combat.')
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants