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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - RicoTheMad

Pages: [1] 2 3
Scripting & Programming / Re: Projectiles - Are they possible?
« on: Apr 06, 12, 08:03:44 AM »
Thanks for the post Legacy.

Regarding your method, have you tried using the Raycast3D functions on the client, and then casting the projectile node to an HBNode and accessing its position properties to execute your method client-side?

Scripting & Programming / Re: Projectiles - Are they possible?
« on: Apr 05, 12, 01:26:23 PM »
Hey Cooper,

Yeah I know the burden of projectiles wouldn't be on the server. I'm thinking more along the lines of, does HeroEngine have any sort of collision functions we can tap into? Most engines have some sort of collision detection functions you can call up, for example, in XNA you can call the .Intersects(rectangle) function on a rectangle, which you can use to check for collision between two bounding boxes.

Similarly, Unity has an OnCollision method.

I know these reside client-side, I'm just asking since based on my searches on the wiki I couldn't find similar methods for HE.

I mean I know we could potentially write these ourselves, but I figured this is pretty basic engine stuff. HE obviously has something in place, but is it exposed for us to use in scripts, or are we left to write our own functions?

I've been thinking about different ways of implementing shooting mechanics in the engine. Of course, I have looked at Raycasting as per the FPS reference, and that may work in some ways. However, shooters usually have different mechanics for different weapons.

Consider a game like UT, you have raycasted weapons (hitscan, like a machinegun) and you have projectile weapons as well (Rocket launcher, grenade launcher). Now, I haven't found much in the way of documentation regarding projectiles or detecting collision between objects.

Does anyone have any ideas on how this could be achieved? Can the engine even handle projectiles like this?

I can understand that, I guess my question now is this: Is there any way to do a hard association to a spec derived object?

The reason I ask is because if the character the items are associated to is deleted or destroyed, I definitely want those nodes destroyed as well. From my understanding the prototypes are used to instantiate the object, but after that the object should be like any other node. Or am I understanding spec derived objects wrong?

Is replication not the right approach to take for a spec based item system then?

I have run into this error and I'm having trouble understanding how to fix it.

The short of it: I am working on my basic item system using specs, spec derived objects, and decorators. I am experimenting with the best way of visualizing these items on the client. Up until now, I had good success marshaling the nodes from server to client. However, I want to learn replication better and I believe it is the preferred method anyways, so this would be a good chance to try it.

Below is the relevant code on the server. This chunk creates the weapon from the spec and attaches it to the player character. It then attempts to do the same on the client through replication, then remote calls each client to make sure they visualize the weapon:

Code: [Select]
// Adds a sample weapon
function SpawnWeapon(account as NodeRef)
  var oracle = $SPECORACLEUTILS._GetOracleFromType("ItemSpecOracle")
  //breakable item spec
  var newItemSpec = oracle.GetSpecByKey(8)
  newItem as NodeRef of Class CQ_Weapon
  newItem = newItemSpec.CreateFromSpec()
//  where newItem is kindof Equippable
//    newItem.CQ_equipLocation = RightWeapon
//  .
  println("new spec derived weapon created: " + newItem.SpecKey)
  acct as NodeRef of Class E_playerAccount = account
  // tie item to character
  AddAssociation(account.GetMyChar(), "cq_character_inventory", newItem)
  // remote call to client
  println("char id:" + account.GetMyChar())
  println("item id:" + newItem)
  nearby_clients as List of ID = OnlinePlayers()
  foreach client in nearby_clients
    // send to all nearby clients(including owner)
    //MarshalUtils:SendNodeWithClassToClient(newItem, c)
    rg as NodeRef of Class _ReplicationGroup = createNodeFromClass("_replicationGroup")
    //rg._replicationPrimaryNode = newItem
    rg._AddClientDestination(client, None)

    call client client CQ_CharacterNewClassMethods:EquipClientWeapon(account.GetMyChar(), newItem)


This code then calls up my remote client function, below:

Code: [Select]
// Remote call from server, associate item to client
remote function EquipClientWeapon(char as ID, item as ID)
  character as NodeRef of Class CQ_CharacterNew = char
  inventoryItem as NodeRef of Class CQ_Weapon = item

  println("char id:" + character)
  println("item id:" + inventoryItem)

  AddAssociation(char, "cq_character_inventory", inventoryItem)

I get the following error when I attempt to spawn my weapon:

Code: [Select]
22:37:23: !ERROR!System:SCRIPT ERROR: In function addAssociation: GOM::addAssociation (8046): Cannot hard associate a target node which is indestructible!
03/28/2012 22:37:20
Call trace:
  Script CQ_CharacterNewClassMethods line 109 me[0]
starting method/function EQUIPCLIENTWEAPON
starting me[id=0 invalid]

remote call from originating script CmdRicoClassMethods function SpawnWeapon node 9223372056755859514

Any thoughts? Of course I could try removing the hard association to the client, but then the node won't be associated to the client, which means it will be impossible for me to find again. How can I work around this? Does this mean I need to switch to a soft association in this case?

Hi Jay,

Thanks for the reply, it really always helps to read staff replies as they are usually all very informative.

I think the thing still confusing me is the last bullet point

The node is at some point replicated to the client

This is really what is at the core of my questions regarding specs and replication. When I create a spec derived object, is it automatically set to replicate to the client?  If not, what would the process be to have that spec derived object replicate to the client.

Assuming this object is a weapon, of type weaponspec (spec derived object). How would you go about replicating this node to the client?

Scripting & Programming / Re: Help me understand HBNodes
« on: Mar 26, 12, 02:59:04 PM »
Great! That makes things a lot clearer to me now. Thanks so much for the support!

Scripting & Programming / Re: Help me understand HBNodes
« on: Mar 26, 12, 02:26:46 PM »
Thanks for the reply Christopher. I believe that with your post I finally am starting to understand what they are.

Basically HBNodes allow us to modify through script, what you would usually only be able to modify using the properties panel in HeroBlade?

For anyone trying to understand these nodes better, this link along with the info above,  helped me put two and two together.


Notice that my "Spec" field is found on the "Type" category in the properties panel, which indicates the location of the object on the server (repository). In my case it is the path to a weapon model, so by setting the HBNode "Spec" property to this, I am able to specify the weapon to render on the client.

Now here's another question that comes to mind: How do I know whether a node on the server will have an associated HBNode on the client? That is, when is an HBNode created exactly, and what triggers its creation? 

I'd also like to see an answer to this. Client/server communication within the spec system is something that interests me. I am also unsure what gets communicated to the client when it comes to spec derived object instances.

I don't know if this will help you but what I have done with specs instances I need the client to know about, is use MarshalUtils to marshal the newly created spec derived node to the client, then use a remote call to pass the node ID and the char's ID to which the node is associated to. I then associate the node using a hard association to the character on the client.

The problem I have run into with this, however, is that when you log off and then log on again, the spec derived node on the client is gone, and so is the client hard association to it. I imagine it has something to do with the server not replicating my items to the client because they are not set up for replication. I guess maybe I'd have to tie them into the player replication group somehow?

Like I said, a lot of uncertainty, but I know marshaling works to an extent. It may not be the right way to do it though, but it was the only way I could get the client to recognize the node IDs I sent from the server

Scripting & Programming / Re: Help me understand HBNodes
« on: Mar 26, 12, 11:47:13 AM »
Thanks Cooper, that's what I figured. I am currently writing a basic item/inventory system from scratch, and I have gotten as far as visualizing things using some clean engine code adaptation. For the prop bucket weapon visualization, I pass in my own string pointing to the model to load for the player through my own weapon spec. The issue is that while I can get it to "work" by simply replacing the string in the clean engine script for the weapon, I still don't quite understand the "how" of how that is working. Where is this "Spec" property coming from? I have spotted other properties in other HBNodes (like for character appearance) that work, but I have no idea of how or why since I have been unable to trace where the properties are coming from.

Once I figure this out, I think it will clear things up a lot for me when it comes to client code. I looked through the forums and the wiki quite a bit, but the documentation on the wiki is a bit lacking in this area, and I did not find anyone asking similar questions on the forum. Maybe I'm unique in my lack of understanding here :-/

So I have a decent grasp of the server side of things, but one thing throwing me for a loop every time are HBNodes on the client. I thought they would be sort of like server nodes, as in, if I have a class called Player on both server and client, and it has a "health" field, on the server I could set it by doing:

player.health = X

On the client I thought it would translate to something like

where player is HBNode
player["health"] = x

Is this the correct way of thinking about this? The reason I ask is because when I glanced at the E_equipmentPropBucket class on the client (and the name may not be 100% correct since I'm not typing this from my dev machine) I noticed when the weapon in the clean engine is attached to the player, there's a property called "Spec" that I simply could not place where its coming from. 

I really want to understand HBNodes as I feel like there's a gap there that I need to fill in order for me to continue developing proper client/server code.

I would recommend creating a game specific NPC system node and overriding the current one with it. That way you have full control over the functionality

Design & World Building / Re: Dynamic Lighting and Skyboxes
« on: Mar 19, 12, 09:37:27 PM »

From the work I've been doing with specs and spec decorators, here's the way I understand it.

- Spec oracles manage your specs with Base X

- Spec X can have SpecDec XY glommed onto it, or not, based on your choice for any particular spec of type X

- When Spec X is instantiated, it notifies all decorators glommed onto it that it is being created

- SpecDec XY receives notification, and thus gloms its own class Decorator XY onto Base X

- Your end result is a node composed of the composition of Decorator XY and Base X through glomming.

Developer Job Board / Re: Project Conquest
« on: Mar 14, 12, 10:16:28 AM »
Updated OP. Recruitment open again for modelers and world builders

Pages: [1] 2 3