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

Creature kill and corpse spawn #238

Closed
wants to merge 4 commits into from

Conversation

Lidefeath
Copy link
Contributor

As discussed with fantom, I'll resubmit it as a real PR so everyone can play around with it.
Usage: target drudge, type /smite -> drudge dead and corpse spawns

Copy link
Member

@LtRipley36706 LtRipley36706 left a comment

Choose a reason for hiding this comment

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

Good stuff!! just adding what I was talking about per our discord discussions yesterday based on my findings this evening

session.Network.EnqueueSend(creatureDeathEvent);

// 2. step in retail: SoundEvent: sound 48 (HitFlesh1), volume 0,5
session.Player.ActionApplySoundEffect(Sound.HitFlesh1, Guid);
Copy link
Member

Choose a reason for hiding this comment

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

Step 2 comes from something else, likely the player getting hit by the drudge, but possibly the drudge getting hit by the player, either way would be handled in another place, not in death

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the pcap I was analyzing that sound effect had the objectID of the drudge. But I am with you that this has to come from executing a combat action.

session.Player.ActionApplySoundEffect(Sound.HitFlesh1, Guid);

// 3. step in retail: SoundEvent: sound 14 (Wound3), volume 1
session.Player.ActionApplySoundEffect(Sound.Wound3, Guid);
Copy link
Member

Choose a reason for hiding this comment

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

Step 3 comes from something else, likely the player getting hit by the drudge, but possibly the drudge getting hit by the player, either way would be handled in another place, not in death

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as step 2: Found in pcap, but belongs to combat hit

// 4. step in retail: MovementEvent: (Hand-)Combat to Death
// TODO: this isn't really working yet, we need more work on the motion stuff
GeneralMotion motion1 = new GeneralMotion(MotionStance.Standing, new MotionItem(MotionCommand.Dead));
session.Network.EnqueueSend(new GameMessageUpdateMotion(this, session, motion1));
Copy link
Member

Choose a reason for hiding this comment

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

I expect this method to change again after some more refactoring but for now...

change session.Network.EnqueueSend(new GameMessageUpdateMotion(this, session, motion1)); to session.Player.EnqueueMovementEvent(motionDeath, this.Guid);

I renamed motion1 to motionDeath in my coding.

Copy link
Member

Choose a reason for hiding this comment

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

animation fires, sound plays.. drudge dies good.

// 5. step in retail: Play Script to show wound depending on where the last hit was
// TODO: this is not showing yet, guess we need to give all the sounds and scripts some time to actually play
var effectEvent = new GameMessageScript(Guid, Network.Enum.PlayScript.SplatterMidRightFront);
session.Network.EnqueueSend(effectEvent);
Copy link
Member

Choose a reason for hiding this comment

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

Again, I feel like this would be handled by another function tracking hits but maybe the final blow would or should be handled by kill...

session.Network.EnqueueSend(effectEvent);

// 6. step in retail: UpdatePosition: gotta verify this on more examples
// I guess it lowers the z axis, so the corpse isn't hovering in about the midth of a usual drudge
Copy link
Member

Choose a reason for hiding this comment

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

see below

@@ -45,6 +45,11 @@ public sealed class Player : MutableWorldObject
public bool IsOnline { get; private set; }

/// <summary>
/// ObjectId of the currently selected Target (only players and creatures)
/// </summary>
public uint SelectedTarget { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

seems like this would be anything you can target, not just players or creatures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if you are right: if you target a creature or player a QueryHealth message is fired with the objectID of the targeted creature or player. If you target an item like a lifestone a QueryHealth message is fired too, but with an objectID of 0. The same happens if you press the ESC key to deselect your target,

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but does/should the server track it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed the server to track it, so I could issue the smite command to the selected target. In retail there are even messages which lead to store the target as last attacker in the properties of a character

@@ -45,6 +45,11 @@ public sealed class Player : MutableWorldObject
public bool IsOnline { get; private set; }

/// <summary>
/// ObjectId of the currently selected Target (only players and creatures)
/// </summary>
public uint SelectedTarget { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Also later in Player.cs, I changed the following code in TrackObject:

            log.Debug($"Telling {Name} about {worldObject.Name} - {worldObject.Guid.Full.ToString("X")}");

            // if (sendUpdate)
            //    Session.Network.EnqueueSend(new GameMessageUpdateObject(worldObject));
            // else
                Session.Network.EnqueueSend(new GameMessageCreateObject(worldObject));

Copy link
Member

Choose a reason for hiding this comment

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

It's not right, but the UpdateObject messages are doing more harm than good at this point and we'll be needing to address this soon to find the right sequence and way for handling this part

if (o.Guid.IsCreature())
{
if ((o as Creature).IsAlive)
(wo as Player).TrackObject(o);
Copy link
Member

Choose a reason for hiding this comment

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

smite the drudge in holtburg, logout, don't reset the server, log back in, crash the server.. didn't check into this further.

Writer.WriteString16L(message);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

new line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You meant add a new line in the message?

Copy link
Member

Choose a reason for hiding this comment

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

files need to end on a new line per code style


// TODO: Find the correct motionstate to create a corpse with. For now only the dead motionstate works
// wo.PhysicsData.CurrentMotionState = new GeneralMotion(MotionStance.Standing);
wo.PhysicsData.CurrentMotionState = new GeneralMotion(MotionStance.Standing, new MotionItem(MotionCommand.Dead));
Copy link
Member

Choose a reason for hiding this comment

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

to me this feels like the only way it would ever work

Copy link
Member

Choose a reason for hiding this comment

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

would need to compare pcaps to verify of course

// TODO: output
if (parameters?.Length > 0)
{
if (parameters[0] == "all")
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're not going to implement it, don't bother with the special-case logic.

// 8. step in retail: Create Corpse (dead for now - but guess is standing or in combat should be right)
// TODO: set text of killer in description
var corpse = CorpseObjectFactory.CreateCorpse(this, this.Location);
LandblockManager.AddObject(corpse);
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use a Threading Timer. sleeping a thread that long is a big no-no :)


// 9. step in retail: Death Animation of corpse
GeneralMotion motion2 = new GeneralMotion(MotionStance.Standing, new MotionItem(MotionCommand.Dead));
session.Network.EnqueueSend(new GameMessageUpdateMotion(corpse, session, motion2));
Copy link
Contributor

Choose a reason for hiding this comment

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

but if it works, leave it :)

@@ -45,6 +45,11 @@ public sealed class Player : MutableWorldObject
public bool IsOnline { get; private set; }

/// <summary>
/// ObjectId of the currently selected Target (only players and creatures)
/// </summary>
public uint SelectedTarget { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but does/should the server track it?

@Lidefeath
Copy link
Contributor Author

I fixed and improved this according to your suggestions and will submit a new PR. Thanks all for the help!

@Lidefeath Lidefeath closed this Apr 15, 2017
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.

None yet

3 participants