UDN
Search public documentation:

MOBAKitHeroes
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Unreal Development Kit Gems > MOBA Starter Kit > Heroes

MOBA Starter Kit - Heroes


Last tested against UDK May, 2012

Overview


Heroes are specialized pawns that players control. They are specialized in the sense that they allow players to cast spells, purchase and use items, can be respawned when they die, along with other things.

UDKMOBAHeroAIController


This is the AI controller which receives commands from the player, and then performs the actions based on those commands. Since players are not given directly control of their hero, this class is needed to acts is the bridge between players and their heroes.

Functions

  • StartMoveCommand() - This function tells the hero AI controller to move the hero to somewhere in the world. It will automatically adjust the final destination in case the player tells the hero to move to an invalid location.
  • StartAttackCommand() - This function tells the hero AI controller to attack an enemy. The enemy can be an enemy creep, hero or tower.
  • StartFollowCommand() - This function tells the hero AI controller to follow an actor. This can be a friendly creep, hero or tower.

States

  • MovingToDestination - In this state, the hero is moving towards a destination point. By using the ReachedPreciseDestination(), native code is used to keep track of when the hero reaches a way point or the final destination. The state latent code is simply set up to loop while it is waiting for ReachedPreciseDestination() and then periodically checking if it can reach the destination directly or if it needs to perform a path find to get the next way point.
  • FollowingAnActor - In this state, the hero is moving towards an actor. This state is very similar to MovingToDestination.

UDKMOBAHeroPawn


This is the base template class used by all heroes.

Functions

  • PostBeginPlay() - This is called when the pawn is first instanced within the world. This function caches the water volumes, sets up the stats modifier to set the main stat and sets HealthFloat to BaseHealth.
  • PhysicsVolumeChange() - This is called when the physics volume that the pawn is in has changed. This is used for detecting when the hero pawn enters a shop volume that belongs to the player.
  • NotifyTeamChanged() - This is called when the player replication info or the player replication info's team property has changed. This gives a chance for the player controller to detect when a hero pawn has changed teams.
  • NotifyPlayerColorChanged() - This is called when the player's color has been replicated. This updates the heroes light and occlusion color.
  • GetTeamNum() - This returns the team that the hero is currently on.
  • StartMoveCommand() - This forwards the start move command to the hero AI controller.
  • StartAttackCommand() - This forwards the start attack command to the hero AI controller.
  • StartFollowCommand() - This forwards the start follow command to the hero AI controller.
  • LevelUpStats() - This allows heroes to level up their stats. If this is called on the client, then it will be replicated through to the server.
  • ServerLevelUpStats() - This is called from LevelUpStats() via replication. This just calls DoLevelUpStats().
  • DoLevelUpStats() - This function performs the actual stat calculations by asking the stats modifier to increment the relevant stats.
  • LevelUpSpell() - This allows heroes to level up their spells. If this is called on the client, then it will be replicated through to the server.
  • ServerLevelUpSpell() - This is called from LevelUpSpell() via replication. This just calls PerformLevelUpSpell().
  • PerformLevelUpSpell() - This function performs the actual spell level up by asking the spell to increment in level.
  • CanLevelUpSpell() - This returns true/false depending if a spell can be leveled up or not. If the spell can't be leveled up, then the player is informed.
  • GetMinimapLayer() - This returns the enum of where on the mini map layer a heroes mini map icon should be.
  • UpdateMinimapIcon() - This updates the mini map icon, specifically its appearances and size.
  • GetTouchPriority() - This returns the touch priority of heroes, this is set to a very high number as heroes should always have importance over most other things.
  • HasMana() - Returns true, as heroes are always capable of having mana.
  • GetManaPercentage() - Returns the amount of mana that the hero has as a percentage.

Variables

  • SpellArchetypes - Array of spell archetypes that this hero has.
  • HeroName - Name of the hero that is shown on the HUD and in other places.
  • HeroPortrait - Reference to the texture that is used for the Mobile HUD, since the real time portraits are not supported on Mobile devices.
  • Light - Light component that is used by the hero pawn. This is just a visual effect which makes it easier to see heroes in the game.
  • MainStat - This is the main stat used by the hero, and works the same as most other MOBA games.

UDKMOBAHeroPawn_Cathode, UDKMOBAHeroPawn_DemoGuy

These are empty classes that hero archetypes are created from. Unfortunately, it is difficult to change an archetype's class after it has been created. Thus by creating empty classes for archetypes to derive from, if in the future new hero logic is required then it can be added in these classes rather than in the base class.

UDKMOBAHeroPawnReplicationInfo


Functions

  • ProgressToNextLevel() - Returns how far through to the next level we are - 0.f is not at all, while 1.f indicates that the player has the needed experience required for the next level.
  • ProgressToLevel() - Needed to test how far you are towards the next (not necessarily 'applied') level. So if you have the experience for level 4, you can test how far to level 3 you are (1.f).
  • TriangleNumber() - Returns the N'th Triangle Number (sum of integers from 1 to N).
  • GiveExperience() - Gives this hero some experience.
  • ApplyLevel() - Called when a hero has their level 'applied' by choosing something to upgrade.