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

Is there any proper way to get time of every hero spawn? #118

Open
inShu opened this issue Apr 27, 2020 · 3 comments
Open

Is there any proper way to get time of every hero spawn? #118

inShu opened this issue Apr 27, 2020 · 3 comments

Comments

@inShu
Copy link

inShu commented Apr 27, 2020

Actually can't find any proper way to get exactly hero spawn time. Not just initial spawn but respawn as well. At this moment I came to this code:

	p.parser.OnEntity(func(e *manta.Entity, o manta.EntityOp) error {
		player := p.manager.FindPlayerByCDOTA(e.GetClassName())

		if player != nil {
			v, _ := e.GetFloat32("m_flSpawnedAt")
			p.manager.UpdateSpawnTimeForPlayer(player, v)
		}

At every Entity action I'm catching m_flSpawnedAt value and remembering it. EntityOp.Entered is not about exactly spawn moment so can't filter by it.
Also I have a pretty interesting mechanics around monkey king. His m_flSpawnedAt never changed + he have about ~30 m_flSpawnedAt changes with +1 second each. I think it's kind hack to work around with ultimate since every monkey king instance in his ultimate is separated hero.

Maybe there is some special event/moment when hero is spawning and all my stuff is just mess ?

@inShu inShu changed the title Is there any proper why to get time of every hero spawn? Is there any proper way to get time of every hero spawn? Apr 27, 2020
@inShu
Copy link
Author

inShu commented Apr 27, 2020

Okay, just for descendants:

	p.parser.Callbacks.OnCMsgDOTACombatLogEntry(func(le *dota.CMsgDOTACombatLogEntry) error {
		switch(le.GetType()) {
			case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_MODIFIER_ADD:
				player := p.manager.FindPlayerByNpcId(p.getCombatLogTableString("CombatLogNames", le.GetTargetName()))

				if player != nil {
					if p.getCombatLogTableString("CombatLogNames", le.GetAttackerName()) == "dota_fountain" {
						if player.dead {
							player.dead = false
							player.spawnTime = p.manager.GetGameTime()
						}
					}
				}
			case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DEATH:
				if le.GetIsTargetHero() && !le.GetIsTargetIllusion() {
					p.manager.EventHeroDeath(
						p.getCombatLogTableString("CombatLogNames", le.GetTargetName()),
						p.getCombatLogTableString("CombatLogNames", le.GetAttackerName()))
				}
		}

If my hero was dead and I got modifier from dota_fountain -> it's respawn moment. Got to check what would be with skeleton king ultimate >_>

@inShu
Copy link
Author

inShu commented Apr 28, 2020

As I expected: we catch DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DEATH as wraith king dying before reborn with his ultimate. Got to dig in that direction.
Also we have problems: brewmaster, meepo, vengeful spirit. Got to check.

@inShu
Copy link
Author

inShu commented Apr 29, 2020

Ok, just in case someone will need it: If you want to know exactly moment when someone was actually dead and goes to tavern then you need to find a moment when "deaths" counter increments.
You can track counters through Entity CDOTA_PlayerResource.m_iDeaths

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

No branches or pull requests

1 participant