HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: 1 2 3 [4] 5

Author Topic: Simple mana system  (Read 18954 times)

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Simple mana system
« Reply #45 on: Feb 09, 13, 07:07:41 PM »

The current manaPoints is set to update the value at 100 mana. If you are raising mana above this, using percent will change the slider to show the actual percent. Take a look at the expBar, it uses the percent in checking how much the bar should show on screen.
Logged

Lithis

  • World Owners
  • ****
  • Posts: 4
    • View Profile
Re: Simple mana system
« Reply #46 on: Feb 10, 13, 10:10:57 AM »

The current manaPoints is set to update the value at 100 mana. If you are raising mana above this, using percent will change the slider to show the actual percent. Take a look at the expBar, it uses the percent in checking how much the bar should show on screen.

Im only using 100 mana and i cant get the mana bar to change atall, only way it changes is when i retab on myself the bar refreshing in the target gui each time i reselect.
Logged

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Re: Simple mana system
« Reply #47 on: Feb 10, 13, 02:37:20 PM »

Did you set Change Callback of your mana points to 'true'?
Logged

Lithis

  • World Owners
  • ****
  • Posts: 4
    • View Profile
Re: Simple mana system
« Reply #48 on: Feb 11, 13, 11:31:49 AM »

Did you set Change Callback of your mana points to 'true'?

Yes still no luck =/
Logged

Higler

  • World Owners
  • ****
  • Posts: 13
    • View Profile
Re: Simple mana system
« Reply #49 on: Mar 29, 13, 06:42:26 PM »

I have tried redoing this script from scratch three times in the past two days and I can't figure out where im messing up, maybe its really simple but i don't know im new to HSL. im getting two errors when trying to compile the commoncharacterclassmethod script

they are the same errors

 1. field 'manaPoints' not found in database:GOM;;lookupClassDefID (799): definition not found:manaPoints
 2. field 'manaPoints' not found in database:GOM;;lookupClassDefID (799): definition not found:manaPoints

I'm also getting a compile error when adding the mana to spells like abfireball

 1. Method 'AdjustMana' not found.

« Last Edit: Mar 29, 13, 07:17:58 PM by Higler »
Logged

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Re: Simple mana system
« Reply #50 on: Dec 12, 13, 03:30:17 PM »

I had a small error in step 6,
me.manaPoints should've been me.E_manaPoints.

it's fixed now
Logged

Eagleheart

  • General Accounts
  • *
  • Posts: 27
    • View Profile
Re: Simple mana system
« Reply #51 on: Feb 25, 14, 01:23:48 PM »

btw great tutorial only took me a couple hours to convert to something like what i want.
any ways i saw a few people wanting to know how to stop the function from working if your under the usable amount of mana.

to do this you just have to add these lines to your AbilityClassMethods on the server.
small fix just  in case you have not made  separate type for melee versus spells

Code: [Select]

   if ( me.E_script:GetAbilityType() == "Spell" )and ( me.E_script:GetManaCost() >= owner.E_manaPool)
      return ResultUtils:ErrorWithMessage( "Not Enough Mana to cast." )
  .

then in your abfireball ruby fire or any other spell just add server side
Code: [Select]

shared function GetAbilityType() as String
  return "Spell"
.

this would allow you to use the spells without having any costs setup in your melee abilities then you could add ones that would do the same checks for energy or stamina usage using the same basic setup this tutorial has done for mana
« Last Edit: Feb 25, 14, 01:53:32 PM by Eagleheart »
Logged

xSystems

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: Simple mana system
« Reply #52 on: Mar 14, 14, 07:08:59 AM »

Hello, im new here and here is my first question...

How i have to setup the "GUI Bar" for this? Name? Whateva.... the script works without any errors but i dont understand how i have to setup the bar ...
Logged

Eagleheart

  • General Accounts
  • *
  • Posts: 27
    • View Profile
Re: Simple mana system
« Reply #53 on: Mar 14, 14, 08:18:28 AM »

find the E_Statusbar in the gui controls double click will open it

then do a search for _panel add it to the parent class at the top of the tree
then add another _panel under it

name the first panel manaPanel
name the one under that one manaSlider

set the sizes to match the health one then  you can either set a texture for the mana bar ina gui  texture file or you can do like the base health one and set the color useing the rgba values listed about for what ever color you wish.

use the health bar as a example how to setup the mana
Logged

xSystems

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: Simple mana system
« Reply #54 on: Mar 14, 14, 10:59:27 AM »

Hmmm then I've done right but it don't works :(

The bar is 50% full but don't move...

//Edit: oh i forgot a class :X

//EDIT: ok dont work ... dont understand why ... no errors but the bar don't move...

When i set the ManaCost of 100 then i can use and have to wait. It's for me: it works... (sry for ma bad english ^^)
« Last Edit: Mar 14, 14, 01:49:38 PM by xSystems »
Logged

xSystems

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: Simple mana system
« Reply #55 on: Mar 18, 14, 05:23:40 AM »

Sorry for new Post but i need help.... the System works, when i set the cost to 100 for fireball then i can cast it and have to wait. But the Manabar.... dont work :(
Logged

Eagleheart

  • General Accounts
  • *
  • Posts: 27
    • View Profile
Re: Simple mana system
« Reply #56 on: Mar 18, 14, 05:23:57 PM »

post your code snypits from E_common Character(server)  and also status bar client and if you made any of the other suggested changes i made. those will help us help you.
Logged

xSystems

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: Simple mana system
« Reply #57 on: Mar 19, 14, 03:07:50 PM »

Code: [Select]
method InitCommonCharacter()
  // initialize abilities
  clear me.E_abilities destroy 
  foreach abilityGrant in me.GetAbilityGrants()   
    ability as NodeRef of Class E_Ability = MiscUtils:CreateNode( "E_Ability", IsPersistentNode( me ) )
    ability.E_script = abilityGrant
    me.AddAbility( ability )
  .
 
  // initialize stats
  me.E_hitPoints = 100
  me.E_manaPoints = 100
  me.E_isDead = false
 
  // start regen tick
  if( me.E_regenTimer.timerState == ON )
    me.E_regenTimer.stop()
  .
  me.E_regenTimer.fireRate = 00:00:01
  me.E_regenTimer.start()
.

method GetAbilityGrants() as List of ScriptRef
  // override to define ability grants
  abilityGrants as List of ScriptRef
  return abilityGrants
.

method AddAbility( ability as NodeRef of Class E_Ability ) 
  // add ability, association, etc
  add back ability to me.E_abilities
  AddAssociation( me, "base_hard_association", ability )
.

method FindAbilityByScript( script as ScriptRef ) as NodeRef of Class E_Ability
  // find ability by customization script
  foreach ability in me.E_abilities
    if( ability.E_script == script )
      return ability
    .
  .
  return None
.

method IsAttackable() as Boolean
  if me.E_isDead
    return false
  .
  if me.E_IsImmune
    return false
  .
  return true
.

method IsInCombat() as Boolean
  return false
.

method IsDead() as Boolean
  return me.E_isDead
.

method AdjustHealth( healthDelta as Integer, attacker as NodeRef, ability as NodeRef of Class E_Ability, isCritical as Boolean )
 
  // apply damage
  me.E_hitPoints = MiscUtils:Min( me.E_hitPoints + healthDelta, 100 )
 
  // raise remote event 
  interestSet as List of ID
  MiscUtils:QueryRemoteInterestSet( me.GetInterestSetSubjectNode(), interestSet )
  foreach accountID in interestSet   
    call client accountID E_CommonCharacterClassMethods:OnCombatEvent( ability.E_script, attacker, me, healthDelta, isCritical )
  .
 
  // handle death
  if( me.E_hitPoints <= 0 )
    me.ApplyDeath( attacker )   
  .
.

method ApplyDeath( killer as NodeRef of Class E_CommonCharacter ) as Boolean
  if me.E_isDead
    // how do you kill what is already dead?
    return false
  .
 
  me.E_isDead = true
  me.E_hitPoints = 0
  me.E_manaPoints = 0
  // TODO: play death animation
 
  // prep messaging
  exclude as List of ID
 
  where killer is kindof E_playerCharacter
    msg as String = "You killed " + me.name + "."
    where me is kindof E_nonPlayerCharacter
      // player killed a creature, so give him/her rewards
      xp as Integer = 10 + me.E_level
      killer.E_experiencePoints = killer.E_experiencePoints + xp
      msg = msg + "  You gain " + xp + "xp and "
     
      wealth as Integer = RandomInteger( 12, 22 )
      killer.E_wealth = killer.E_wealth + wealth
      msg = msg + " collect " + wealth + " gold from it!"
    .
   
    // do messaging to the killer
    $CHAT.ChatPlayer( killer, "System", msg )
    add back killer to exclude
  .
 
  // do messaging to target if appropriate
  if me is kindof E_playerCharacter
    $CHAT.ChatPlayer( me, "System", killer.name + " killed you!" )
    add back me to exclude
  .
 
  // do messaging to everyone else
  $CHAT.ChatExcludeList( exclude, "System", killer.name + " killed " + me.name + "." )
 
  // check for level up after other messaging is complete
  if killer is kindof E_playerCharacter
    killer.ProcessXPGain()
  .
  me.E_deathTimer.fireRate = me.GetDeathTime()
  me.E_deathTimer.start()
  where me is kindof E_AiAgent
    $E_CharDriver._DriverClearPoints( me, true )
  .
  return true
.

method ApplyLife() as Boolean
  if not me.E_isDead
    return false
  .
  me.E_isDead = false
  me.E_hitPoints = 100
  me.E_manaPoints = 100
  me._TeleportCharacter( me.GetRezzPosition(), me.GetRezzRotation() )
  where me is kindof E_playerCharacter
    target as Class _Target
    target._tgtID = me.GetMyAccount()
    clients as List of ID
    MiscUtils:QueryRemoteInterestSet(me.GetInterestSetSubjectNode(), clients)
    foreach c in clients
      $FXSYSTEM.SendFxToClient(c, 10, target, target)
    .
  .
  return true
.

method GetDeathTime() as TimeInterval
  return 0:0:05
.

method GetRezzPosition() as Vector3
  return me.GetPosition()
.

method GetRezzRotation() as Vector3
  return me.GetRotation()
.

method GetInterestSetSubjectNode() as NodeRef
  // return the subject node used by the spatial awareness system
  return me
.

method E_regenTimer_tick()
  if me.IsDead()
    return
  .
  if me.IsInCombat()
    return
  .
  me.E_hitPoints = MiscUtils:Min( me.E_hitPoints + 10, 100 )
  me.E_manaPoints = MiscUtils:Min(me.E_manaPoints + 10, 100)
.

method E_deathTimer_tick()
  me.ApplyLife()
  me.E_deathTimer.stop()
.

method AdjustMana(manaDelta as Integer, ability as NodeRef of Class E_Ability)
  me.E_manaPoints = MiscUtils:Min(me.E_manaPoints + manaDelta, me.E_manaPoints) 
.

Code: [Select]
method lightweightEventRaised(subject as ID, eventType as String, data as NodeRef)
  when eventType
    is "nameUpdated"
      char as NodeRef of Class E_CommonCharacter = subject
      if char != None
        me.SetName(char.name)
      .     
    .
    is "hpUpdated"
      char as NodeRef of Class E_CommonCharacter = subject
      if char != None
        me.SetHP(char.E_hitPoints)
      . 
    .
    is "mpUpdated"
      char as NodeRef of Class E_CommonCharacter = subject
      if char != None
        me.SetMP(char.E_manaPoints)
      . 
    .
  .
.
method SetName(name as String)
  nameLabel as NodeRef of Class GUILabel = FindGUIControlByName(me,"nameLabel")
  nameLabel.text = name
.
method SetHP(hp copies Integer)
  if hp < 0
    hp = 0
  .
  healthSlider as NodeRef of Class GUIControl = FindGUIControlByName(me, "healthPanel.healthSlider")
  healthSlider.removeAnimations()
  var size = -1.0 * hp
  //1 field(string), the field on the GUIControl to such as size.x or defaultStatePresentation.color.a
  //2 min(float) (this is NOT the start value for the animation. That is the current value of the field to which you are applying the min/max values)
  //3 max(float)
  //4 duration in seconds(float)
  //5 repeat count(integer) (0=repeat infinitely, 1-n do animation that number of times)
  //6 reverse(boolean), forward and backward(true), or just forward(false)
  //7 curve(Enum of type interpolation curve), LINEAR, HOLD, EASE_IN, EASE_OUT, SMOOTH
  //8 restore(boolean), restores the orignal value after the animation is finished
  //9 delay in seconds(float), the amount of time to wait before actually starting the animation
  //10 id(string), the ID of the animation
  animationString as String = "size.x,"
  animationString = animationString + healthSlider.size.x + ","
  animationString = animationString + size +","
  animationString = animationString + .1 + ","
  animationString = animationString + 1 + ","
  animationString = animationString + "false,"
  animationString = animationString + "LINEAR," 
  animationString = animationString + "false,"
  animationString = animationString + "0,"
  animationString = animationString + "slide"
 
  GUIAnimation:addAnimation(healthSlider, "Interpolate", animationString)
.

method SetMP(mp copies Integer)
  if mp < 0
    mp = 0
  .
  manaSlider as NodeRef of Class GUIControl = FindGUIControlByName(me, "manaPanel.manaSlider")
  manaSlider.removeAnimations()
  var size = -1.0 * mp
 
  animationString as String = "size.x,"
  animationString = animationString + manaSlider.size.x + ","
  animationString = animationString + size +","
  animationString = animationString + .1 + ","
  animationString = animationString + 1 + ","
  animationString = animationString + "false,"
  animationString = animationString + "LINEAR," 
  animationString = animationString + "false,"
  animationString = animationString + "0,"
  animationString = animationString + "slide"
 
  GUIAnimation:addAnimation(manaSlider, "Interpolate", animationString)
.

The Manabar is a copy of the Healthbar with name manaPanel and manaSlider.
« Last Edit: Mar 19, 14, 03:23:17 PM by xSystems »
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Simple mana system
« Reply #58 on: Mar 19, 14, 09:02:09 PM »

In method InitCommonCharacter()  did you add the E_regenTimer for the mana?

Also might need a method E_regenTimer_tick() for mana there too.

Logged

xSystems

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: Simple mana system
« Reply #59 on: Mar 20, 14, 06:24:33 AM »

Problem is fix, thx for help. :)
« Last Edit: Mar 20, 14, 11:43:01 AM by xSystems »
Logged
Pages: 1 2 3 [4] 5