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

Author Topic: Simple mana system  (Read 17778 times)

Jarvis

  • World Owners
  • ****
  • Posts: 16
    • View Profile
Re: Simple mana system
« Reply #60 on: Apr 10, 14, 03:58:43 PM »

@Lithis - Hello had the same issue as you. After a while of freelance coding it all just to see if I could I fixed it myself. This is after duping and adding the manaPanel/manaSlider.

This is what I did:

On the Client Side for scripts, I had to edit: "E_playerAccountClassMethods", "E_playerCharacterClassMethods", "E_StatusBarClassMethods", "E_TargetCircleClassMethods".

In E_playerAccountClassMethod:

Under:

Code: [Select]
$LightweightEvents.addLightweightEventListener(addedNode, "hpUpdated", statusBar)
Add:

Code: [Select]
$LightweightEvents.addLightweightEventListener(addedNode, "mpUpdated", statusBar)
In E_playerCharacterClasMethod:

Under:

Code: [Select]
is "e_hitpoints"     
      $LightweightEvents.raiseLightweightEvent(updateNode, "hpUpdated", 0)
    .

Add:

Code: [Select]
is "e_manapoints"     
      $LightweightEvents.raiseLightweightEvent(updateNode, "mpUpdated", 0)
    .

Note: Notice how e_hitpoints and e_manapoints are all lowercase. Even though it is infact e_manaPoints. it needs to be all lower case for some reason in this case.

In E_StatusBarClassMethods:

Under:

Code: [Select]
is "hpUpdated"
      char as NodeRef of Class E_CommonCharacter = subject
      if char != None
        me.SetHP(char.E_hitPoints)
      . 
    .

Add:

Code: [Select]
is "mpUpdated"
      char as NodeRef of Class E_CommonCharacter = subject
      if char != None
        me.SetMP(char.E_manaPoints)
      . 
    .

AND at the bottom of that class add:

Code: [Select]
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
  //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," + manaSlider.size.x + "," + size +"," + .1 + "," + 1 + "," + "false," + "LINEAR," + "false," + "0," + "slide"
 
  GUIAnimation:addAnimation(manaSlider, "Interpolate", animationString)
.

In E_TargetCircleClassMethods:

Under:

Code: [Select]
$LightweightEvents.addLightweightEventListener(realtarget, "hpUpdated", statusbar)
Add:

Code: [Select]
$LightweightEvents.addLightweightEventListener(realtarget, "mpUpdated", statusbar)
Under:

Code: [Select]
statusbar.SetHP(realtarget.E_hitPoints)
Add:

Code: [Select]
statusbar.SetMP(realtarget.E_manaPoints)
//Updated to reflect changes. 26-04-14
« Last Edit: Apr 26, 14, 09:24:22 PM by Jarvis »
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Simple mana system
« Reply #61 on: Apr 11, 14, 03:19:19 PM »

Once you have the output and comments in 1 section, you could save some space by creating the string into 1 long value. Just like C++ a string can be any length, just make sure to keep the values added in, rather than inside the quotes, and a comma between each value.

animationString as String = "size.x,"+ manaSlider.size.x + "," + size +", 0 .1, 1, false, LINEAR, false, 0, slide"
Logged
Pages: 1 ... 3 4 [5]