HeroEngine Support > Scripting & Programming

Parents replicate for kids?


E_commonCharacter is a parent for both E_playerCharacter and E_nonPlayerCharacter

When I add a field to E_playerCharacter class and set it to replicate, it will replicate from server to client side, and it shows in the _OnReplicationFieldUpdated() function.

When I add a field to E_nonPlayerCharacter class it works the same way.

When I add the field to E_commonCharacter (the parent of both) and set it to replicate,  it does not replicate to the child class.

class Buffs has fields in it: displayname, speckey, statsEffected, buffername

BuffSaveList as list of class Buffs, has replication set to client side

This field is added to E_commonCharacter and set to replicate and the BuffSaveList should replicate to clientside
I can see the bufflist on the server side with the buff added, but the buff wont show in the bufflist on the client side.

I have added replicate with the class Buffs to client side also, and the fields in the buffs class.

Still not replicating :(

hmm client crash (might be internet here) then restart and parts now seem working, buff show on buffbar, but not in list

--- Code: ---
// fields getting updated
shared function _OnReplicationFieldUpdated(updateNode as NodeRef, updateField as String)
  println("Field updated:"+updateNode+ " name:"+updateField)
  when toLower(updateField)
    is "eo_buffsavelist"
      $LightweightEvents.raiseLightweightEvent(updateNode, "buffsUpdated", 0)

// check for values changing
method lightweightEventRaised(subject as ID, eventType as String, data as NodeRef)
  char as NodeRef of Class E_CommonCharacter = subject
  println("lightweightEventRaised  subject:"+subject+ " eventType:"+eventType)

  if char != None
    when eventType
      is "buffsUpdated"
        me.SettTargetBuffs(char, char.EO_BuffSaveList)

// show buffs of npcs in target buff area
method SettTargetBuffs(target as NodeRef of Class E_CommonCharacter, buffs as List of Class EO_Buff)
  var info = E_playerAccountClassMethods:getSkillSpecInfo()

  var buff = getTargBuffs()
  buff.EO_BuffSaveList = buffs     // save info on GUI
  key as ID

  // check all of player buffs
  loop i from 1 to 12
    if buffs[i].displayName <> "none"
      key = buffs[i].SpecKey
      if key <> 0
        println("buff "+i+"  name "+buffs[i].displayName+"   key "+key)

        var skill = getTargBuffSlot(i)                   // get current slot
        skill.setSkillTexture(info[key].EO_skillIconID)  // set texture
        skill.SpecKey = info[key].SpecKey                // save key for tooltip

// target buffs
function getTargBuffs() as NodeRef of Class TMP_Buffs
  return FindGuiControlByName(None, "game.Targbuffbar")

// pointer to the skill in slot
function getTargBuffSlot(slot as Integer) as NodeRef of Class EO_SkillIcon
  return FindGuiControlByName(None, "game.Targbuffbar.slot"+slot+".skillPic")

--- End code ---

In the wiki i found this -> "When a class inherits from another class, it also inherits the replication parameters of its parent class. "
which is good knowing it should work. I am just missing something.

though i do not see the replication triggering the Println() functions to show the info.

isolate and force value for a check.


[0] Message Index

Go to full version