HeroEngine Forums

HeroEngine Support => Scripting & Programming => Topic started by: keeperofstars on Feb 02, 14, 06:28:38 PM

Title: anyone spend much time with prop system
Post by: keeperofstars on Feb 02, 14, 06:28:38 PM
I've been glancing over the prop system and it seems like a sound way to make great use of lots of customized means for interactions with objects in the game world. Much like the quest example where only acorns can get picked up if the player is on the acorn quest etc.

Just thinking it has a ton of options etc but was wondering if others had used it and hammered through a lot of it and if so if there are any gotchas to be aware of. The wiki is a tad flat on the overall system, but covers it just enough to get someone roughly started with it.

Title: Re: anyone spend much time with prop system
Post by: AWW_boss on Feb 03, 14, 12:59:06 AM
instead of using a prop i just spawn a npc. i'm more comfortable with the npc code.

(i wonder if that is a bad idea ...)
Title: Re: anyone spend much time with prop system
Post by: AWW_boss on Feb 03, 14, 03:17:21 AM
What i mean is, i am too scared to introduce another system to my game with all its potential quirks and bugs.
A npc "prop" so far covered all my needs.
Title: Re: anyone spend much time with prop system
Post by: feredfn on Feb 03, 14, 06:54:29 AM
Quote
i am too scared to introduce another system to my game with all its potential quirks and bugs
  ;D
You mean u create an npc with 3d model of for example a box? to be used as an object?

Well ,I didn't go deep into Prop system , but seems its as usefull as any other systems , you really should give it a try ,..

what i have tried so far, was a quest chain which in the 3rd quest , players who are in that quest can see an object in the specified location while no other player can see it ,... and the object is going to be lootable object for those who see it.
Title: Re: anyone spend much time with prop system
Post by: AWW_boss on Feb 03, 14, 08:13:55 AM
Code: [Select]
You mean u create an npc with 3d model of for example a box? to be used as an object?

Exactly. Of course, it has its own spec decorator which adds/removes some of the processing/functionality.
Title: Re: anyone spend much time with prop system
Post by: feredfn on Feb 03, 14, 08:54:36 AM
Not bad idea at all  ;)

But i think if your object spec or derived object classes  are inherited from _nonePlayerCharacter as parent class , then this idea might not be best comparing to Prop system in case of game objects.
Title: Re: anyone spend much time with prop system
Post by: Amarak on Aug 03, 14, 02:11:44 PM
Bringing up an old but important topic:

I've finally figured out the Prop system and I will say it is very nice! It took me a week just to get Mouse Events to work but now that they do, I can see this as a major part of my interactive elements in game.

If anyone needs to know how to make this work feel free to post here. I am more than happy to share what I learned.
Title: Re: anyone spend much time with prop system
Post by: Amanda_Brooks on Aug 03, 14, 04:44:27 PM
If you have the time, you could put together a basic tutorial for it.
Title: Re: anyone spend much time with prop system
Post by: Amarak on Aug 09, 14, 03:46:28 AM
My tutorial (for now) is based off of some other posts and some other testing. To make Props usable in my game here is what I dd:

A. Folowing the post by NestEggs https://community.heroengine.com/forums/index.php/topic,5267.0.html (https://community.heroengine.com/forums/index.php/topic,5267.0.html) you
1.  create a class My_SystemNodes
Code: [Select]
method HE_GetRegisteredServerSystemNodeNames( systemNodeNames references List of String ) as Boolean
  add back "_PROPS" to systemNodeNames
 
  // Return true if you do not want the default system node names added to the list
  return false
.
2. Use it to add the _Props to your SystemNodes and then Glom it to the Servers SYSTEMNODES in the Utilities GUI by:
 a. F5
 b. Tools
 c. System Nodes Configuration GUI
 d. Select Server
 e. Under System select SYSTEMNODES
 f. Enter class name: My_SystemNodes
 g. Click Add

This will add _Props (server side) to your System Nodes. I already had a _Props system node on my client side, just not the server side.

3. To make it so you can Glom your own Spec Decorators to Props, create a new class "My_Props".

Code: [Select]
method HE_PropsSpecOracleGetSpecDecoratorClasses(valid references List of String) as Boolean

  add back "My_TestSpecDecorator" to valid

  return false
.

In this class you put all the custom Prop Spec Decorators. (I am currently working on a Crafting system so I want to be able to click on a crafting station to open a GUI.)

Using the F5 method above, Glom your "My_Props" class onto System node "_Props".

At this point if you go to F5 > Tools > Props, you should be able to glom your new "My_TestSpecDecorator" onto a prop spec. This is where the existing "_PropMouseTargetableDecorator" and "_PropVisualizationDecorator" are, so if you see these along with your own, then you've done it right.

B. Next step thanks go to Sands_Dethston.  Mouse events! https://community.heroengine.com/forums/index.php/topic,3922.msg21758.html#msg21758 (https://community.heroengine.com/forums/index.php/topic,3922.msg21758.html#msg21758)

I created, using the method above, a class called "My_CraftingStationSpecDecorator", added it to my "My_Props" class. This Decorator is used to Glom in my Mouse Events class on instantiation. First, the code for  "My_CraftingStationSpecDecorator"
Code: [Select]
shared function OnInstantiationFromSpec( specDerivedObject as NodeRef )
  if not ( specDerivedObject is kindof My_CraftingStationMouseEvents )
    GlomClass( "My_CraftingStationMouseEvents", specDerivedObject )
  .
.


Then I copied this same class and script to the client side, since that is where my mouse events will actually take place.

Now to make  "My_CraftingStationMouseEvents" class, both client and server side. The server side script is empty for now. I'll work in rco's and callbacks later.

On the class  "My_CraftingStationMouseEvents" on the Client side, make the script:
Code: [Select]
shared function _OnPropMouseEvent(prop as NodeRef of Class _Prop, args references Class _MouseEvent)
  //ensure shared function exists
  Println ("Entered _OnPropMouseEvent")
  where prop is kindof _MouseTargetableProp
    Println ("prop is kindof _MouseTargetableProp")
    when args.MouseEventType
      is Enter
        println("onMouseEnter for " + Prop)
        println("Click to Target")
        println("DoubleClick to open Menu")
        ///change cursor using $Cursor - have to create a new cursor spec and add a graphic
      .
      is Click
        println ("Trying to set the target to: "+Prop)
       
      . 
      is DoubleClick
        Println("onMouseDoubleClick for "+prop)
               
        myTestWindow as NodeRef of Class GUIControl = createNodeFromPrototype("My_CraftingStationGUI")
        myTestWindow.build = true
       
        screen as Vector3 = getViewPortSize()
        myTestWindow.position.x = (screen.x - myTestWindow.size.x) / 2
        myTestWindow.position.y = (screen.y - myTestWindow.size.y) / 2
      . 
     default
        // Allow other events to fall through, doing a println
     println(args.MouseEventType)
      .
    .
  .
.

And you need to make your "My_CraftingStationGUI". I used the GUIEditor and made a placeholder to test functionality.

C. Now to instantiate it from the Asset Library, so it is a persistent node and any player can open their own crafting station gui, which I plan to have their known recipes and such in as well as animated crafting stations. That's the next thing I have to figure out :)

Ok, in F5 > Tools > Props, Glom your "_PropMouseTargetableDecorator" and "_PropVisualizationDecorator", as well as your own "My_CraftingStationSpecDecorator" onto a new spec. Mine is spec number 4 at the moment. I am using a default white cube as the crafting station. Ok, open the Asset Library, find where you want your new asset (I made a test directory on mine), Right Click and New Command. This opens a new window where you put your command. The one I am using is:

Code: [Select]
/heprops library #spec='4'  #fqn='\engine\cleangame\resources\common\utility_box_white01.gr2' #position='$POSITION' #lod='10'
If everything went right, this will spawn a white box, that if you double click, will open up your GUI.
This node is persistent, and will make it easy to add crafting stations all around your world. :)