HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Spec Decorator Fields  (Read 1085 times)

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
[Resolved] Spec Decorator Fields
« on: Feb 19, 13, 05:15:54 PM »

I have an ItemSpec With a HoldableSpecDecorator which has fields
istwohanded       - bool
heldatslot            - enum holdatslots
soloweapontype - enum soloweapontypes
wdam                  - integer
wdelay                - timeinterval
For editing the spec I use a class that inhherits from _GuiNodePropertyEditor
it builds a gui for each decorator, when I save it I use OnGUINodePropertyEditorSubmit
which saves the fields to the spec
I can requestspecbykey on the server then \sn and it all looks good.

Now after the item is instantiated and in the players inventory and equipped,
I want to use the field info for damage calculations.
I check the players inventory and equip slot for the item
Code: [Select]
var inv = actor.GetMyInventory()
        meleew as NodeRef of Class SpecDerivedObject = inv.GetEquipSlotContents("Melee")
        where meleew is kindof Holdable
          println("MELEEWEAPON IS:"+meleew)
        println("MeleeWeaponDamage:"+meleew.wDam+"Delay"+meleew.wDelay+"Type"+meleew.SoloWeaponType)
I can \sn for meleew and it's the wepon, but the damage delay and weapontype are all 0
Where would I make sure the wepon fields are the same as the spec.

I tried adding in the Holdable spec decorator
Code: [Select]
shared function OnInstantiationFromSpec( specDerivedObject as NodeRef )
  if not ( specDerivedObject is kindof Holdable )
    GlomClass( "Holdable", specDerivedObject )
  .
.

method IsItemTwoHanded() as Boolean
// Twohanded held items merely indicate that both hands are occupied
//   any special animation needs are of course handled by the behaves that are sent.
//
  return me.isTwoHanded
.

shared function OnMarshalClassSpecifiedFields( n as NodeRef, marshalString references String )
// Called by the MarshalNodeWithClassSpecifiedFields and MarshalPrototypeWithClassSpecifiedFields in the classMethods
//   scripts for the node n.  Your class method script should use marshalNode/PrototypeAppendField to add the specific
//   fields you want.
//
  MarshalAppendField( marshalString, n, "isTwoHanded" )
  MarshalAppendField( marshalString, n, "HoldAtSlot" )
  MarshalAppendField( marshalString, n, "SoloWeaponType" )
  MarshalAppendField( marshalString, n, "wdam" )
  MarshalAppendField( marshalString, n, "wdelay" )
.
I have getter methods on the client HoldableSpecDecorator
getweapontype, setweapontype. Do these need to be on the server also?
Both Holdable and HoldableSpecDecorator have the same fields.


Once I finish this then add the combo chains and exp chains the combat system will be complete
« Last Edit: Mar 10, 13, 05:30:33 PM by HE-Cooper »
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Spec Decorator Fields
« Reply #1 on: Feb 21, 13, 04:58:43 PM »

In the function OnInstantiationFromSpec, after you glom your holdable class, then set the mutable fields on your holdable class with the values stored in the spec.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
Re: Spec Decorator Fields
« Reply #2 on: Feb 21, 13, 06:03:33 PM »

thanks TGSRofar, lol I don't know what I was thinking
I see it now in the stackable specdecorator
Code: [Select]
shared function OnInstantiationFromSpec( specDerivedObject as NodeRef )
  if not ( specDerivedObject is kindof stackable )
    GlomClass( "Stackable", specDerivedObject )
    where specDerivedObject is kindof stackable
      specDerivedObject.CurrentStackSize = 1
      mySpec as NodeRef of Class StackableSpecDecorator = specDerivedObject.getmyspec()
      specDerivedObject.MaxStackSize = mySpec.MaxStackSize
    .
  .
.
Logged