Official Community Forums
 
HomeHome  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log in  The Wiki  Website  github Project  

Share | 
 

 Placing objects (i.e. buildings) in-game

View previous topic View next topic Go down 
Go to page : 1, 2, 3  Next
AuthorMessage
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Placing objects (i.e. buildings) in-game   Sat 24 Mar - 7:23

I'm not sure whether this should go in the Server or Client section, so I'll just put it here Laughing

I'd like players to be able to place objects in the environment. For example, someone could place a defence turret for a settlement, various buildings, walls etc.

Firstly, is it possible to drop inventory objects? I should imagine there's something in place that lets players drop inventory items, that can then be picked by other players (e.g. unwanted loot items).

If there is, then is there a way to make that 'dropped' item into a static object, perhaps with a StaticAnim value.

In the future, I'd like things like Turrets to automatically engage players who are from a rival faction, or just those that have a poor faction reputation, plus any mobs that come within the engagement radius.
Before that, I'd like players to be able to place objects wherever they want (in buildable regions). I guess it would be like a conventional RTS, where a partially transparent model is displayed, and you click where you want the building to be built.
Then, the buildings would take a set amount of time to be constructed. Initially, it would just be partially transparent until the timer is done, but eventually I'd like there to be different visible stages of the building, again like in some RTSs, where you can see the different construction stages.

Thoughts?
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Thu 29 Mar - 3:01

Currently there is nothing in place for dropping items on the ground. I believe you can delete objects that way but I am not sure.

It is possible to make something that when activated will place the object at the players cursor and move it around and then place it but it is pretty complicated.

These are the main things you would need to cover:

Server side
Extend MarsAbility to have a CreateWorldObject
You would need to grab the player info - location, instance
You would then need to check to make sure that the location/instance is a valid build space
(I am not sure how you would want to implement it)


Then Create a template of the object pull from the back pack item properties
You might want to add
template.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_PERSISTENT, true);
so that the object is persisted through server resets. But if it is disposable set it to false.

You would also probably want to add who the owner is.


Then Generate the object
ObjectManagerClient.generateObject(template,override);

Then spawn the object


After spawned you might want to add any behaviors you want the object to perform

I would also send the oid of the object you just spawned to the player that spawned it so that they can move it
Or you can require it to be placed where the player is standing. But if you do I would not recommend putting physics on the object as that will cause the player to become stuck.


You would also need to write something to allow the movement of the object - I would recommend writing this as
a proxy extension that gets the objects WorldNode and then set the position/ orientation and the updates the WorldNode

Client Side:
You would need to have some way of moving the object the easiest way is to handle it in MarsCursor when the mouse moves to move the object using something like this:

Code:
mousePos = ClientAPI.GetMousePosition()
    pos = ClientAPI.World.PickTerrain(int(mousePos[0]), int(mousePos[1]))
    heldObj.Position = pos

And setting the heldObj to the object that was spawned by the item

And then once they have finalized the position update the object position with a message to the proxy server.

Like I said complex but it is doable I created a version for our game so it is possible.
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sat 31 Mar - 6:16

hmm, that does sound pretty complicated. Makes sense, but sounds complicated Suspect
Perhaps that's something I'll tackle once I get someone else to help me with the programming.
Back to top Go down
http://www.3dmodeller.info
zoot686
Foundation Donor
avatar

Posts : 78
Join date : 2012-02-15
Location : USA

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sat 31 Mar - 9:15

Quote :
Like I said complex but it is doable I created a version for our game so it is possible.

Don't know exactly how to ask this question, so I'll just ask this question.*grins*

Delurin........what do you suppose it might cost..........to hire a programmer such as yourself.........to do this work, knowing that the results of this work would be donated to the multiverse community for it's use?
Back to top Go down
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sat 31 Mar - 12:02

The hard part is that I have already programmed a version of this for my employer so he technically owns the code to it. I will take a look and see if I can come up with a different way to write it so that there is no overlap.

Back to top Go down
zoot686
Foundation Donor
avatar

Posts : 78
Join date : 2012-02-15
Location : USA

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sat 31 Mar - 14:19

Er uh............just don't risk getting in trouble with your employer.

If you discover a way though let me know.............and let me know what it's going to cost..........and "if" I can afford it.......well...........let's just say I'll contribute to this project.

Speaking of which, I gotta' talk to scfischer about the work he's doing too............because there's real value to that too..............

Now don't get me wrong..............but I like multiverse.............it has a neat little toolkit............get these few little loose ends taken care of...........and get some good user experience "how I did it" docs...........and it's ready for prime time...............and THEN you'll get your big time development teams............in addition to we small time indies............and THEN your "revenue stream" start flowing.............
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 2:00

zoot686 wrote:

If you discover a way though let me know.............and let me know what it's going to cost..........and "if" I can afford it.......well...........let's just say I'll contribute to this project.

Ditto.
If it'll more require than Zoot can afford by himself, I'd be more than happy to contribute towards the cost. This is a big feature, one that I would very much like the Platform to have, and it's one that I will want to use in my own project.

zoot686 wrote:

Now don't get me wrong..............but I like multiverse.............it has a neat little toolkit............get these few little loose ends taken care of...........and get some good user experience "how I did it" docs...........and it's ready for prime time...............and THEN you'll get your big time development teams............in addition to we small time indies............and THEN your "revenue stream" start flowing.............

Yes, there certainly are some serious loose ends to tie up. And yes, unfortunately we'll only be looking at individuals or very small groups for the next few months, but once we get the Platform moving in the right direction, with some killer features, we'll hopefully begin attracting some bigger teams.




Last edited by Tristan on Sun 1 Apr - 7:01; edited 1 time in total
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 5:17

I posted a tutorial on how to add objects to the game from an inventory item. This is a simpler version of what I coded for our game and what I think anyone who tried to make it would come up with the same code since it just pulls all of the code from various parts of the engine. I have not tested to make sure that it works so someone will have to try to implement it and I will be happy to fix any problems.

http://www.multiversemmo.com/wiki/Creating_World_Objects_from_Inventory
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 5:34


cheers

Jono, you're an absolute star!

I'll see if I can get it working Very Happy
Back to top Go down
http://www.3dmodeller.info
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 7:00

Ok, so I followed the tutorial to the letter, but was given this error on startup (it got to the second splash screen, so it was doing pretty well until then.)

Here's the error I've got from my proxy_1.out file:
Code:

ERROR [2012-03-31 20:46:07,148] main                ScriptManager.runPYFile: file=..\config\gloryofrome\extensions_proxy.py Traceback (innermost last):
  (no code object) at line 0
SyntaxError: ('invalid syntax', ('..\\config\\gloryofrome\\extensions_proxy.py', 83, 5, '    playerOid = cmdEvent.getObjectOid()'))
 Traceback (innermost last):
  (no code object) at line 0
SyntaxError: ('invalid syntax', ('..\\config\\gloryofrome\\extensions_proxy.py', 83, 5, '    playerOid = cmdEvent.getObjectOid()'))

      at org.python.core.parser.fixParseError(Unknown Source)
      at org.python.core.parser.parse(Unknown Source)
      at org.python.core.Py.compile_flags(Unknown Source)
      at multiverse.server.engine.ScriptManager.runPYFile(ScriptManager.java:181)
      at multiverse.server.engine.ScriptManager.runFile(ScriptManager.java:94)
      at multiverse.server.engine.Engine.processPostScripts(Engine.java:541)
      at multiverse.server.engine.Engine.main(Engine.java:396)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at multiverse.server.marshalling.Trampoline.main(Trampoline.java:150)


Here's what's at line 83:



Code:

playerOid = cmdEvent.getObjectOid()



And here's the error from instance.out:

Code:

ERROR [2012-03-31 20:46:08,043] Instance-2          ScriptManager.runPYFile: file=..\config\gloryofrome/instance_load.py Traceback (innermost last):
  File "..\config\gloryofrome/instance_load.py", line 11, in ?
AttributeError: 'NoneType' object has no attribute 'clone'
 Traceback (innermost last):
  File "..\config\gloryofrome/instance_load.py", line 11, in ?
AttributeError: 'NoneType' object has no attribute 'clone'

      at org.python.core.Py.AttributeError(Unknown Source)
      at org.python.core.PyObject.noAttributeError(Unknown Source)
      at org.python.core.PyObject.__getattr__(Unknown Source)
      at org.python.core.PyObject.invoke(Unknown Source)
      at org.python.pycode._pyx6.f$0(..\config\gloryofrome/instance_load.py:11)
      at org.python.pycode._pyx6.call_function(..\config\gloryofrome/instance_load.py)
      at org.python.core.PyTableCode.call(Unknown Source)
      at org.python.core.PyCode.call(Unknown Source)
      at org.python.core.Py.runCode(Unknown Source)
      at multiverse.server.engine.ScriptManager.runPYFile(ScriptManager.java:181)
      at multiverse.server.engine.ScriptManager.runFileWithThrow(ScriptManager.java:121)
      at multiverse.server.objects.Instance.runInitScript(Instance.java:91)
      at multiverse.server.plugins.InstancePlugin$CreateInstanceHook.processMessage(InstancePlugin.java:288)
      at multiverse.server.engine.EnginePlugin.handleMessageImpl(EnginePlugin.java:406)
      at multiverse.server.engine.EnginePlugin$QueuedMessage.run(EnginePlugin.java:440)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
ERROR [2012-03-31 20:46:08,043] Instance-2          CreateInstanceHook: init world script failed fileName=..\config\gloryofrome/instance_load.py

Line 11 of instance_load.py is just a marker for a wolf spawn. This hasn't been changed from the original sampleworld files, although I haven't created a wolf spawn in the blank world I created (with a player spawn marker and a building asset). Surely that's not the problem though?

Tristan


Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 7:14

If a marker is listed in the instance_load it has to be in the world or else it throws and error so that is probably the problem with the instance load
try either commenting that out or putting in the marker
Back to top Go down
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 7:18

Also there might be a spacing issue so you might want to delete the whitespace and redo it...
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 8:38

Ok, so I sorted all that out, and I was able to prance around my somewhat barren landscape.

The Barrel (with the book icon) was in my starting inventory, which was fine, as I had defined that in the charactor factory (I'm finally learning, yay!)

I could left click on it, so the icon was attached to my mouse.
But that was it. No other functionality. No barrel appears or anything when I right and left clicked on the terrain in front of the character.


So I checked the logs, and found the following:

In proxy_1.out:
Code:

ERROR [2012-03-31 22:09:15,329] SQ-Event-1          processExtensionMessageEvent: key 'mv.SWAP_ITEM' has no corresponding MessageType
This same error occurs 4 times throughout the log, being SQ-Event-1, 2, 5 and 6.


Then, in the combat.out log:
Code:

ERROR [2012-03-31 22:32:10,621] main                ScriptManager.runPYFile: file=..\config\gloryofrome\ability_db.py Traceback (innermost last):
  File "..\config\gloryofrome\ability_db.py", line 286, in ?
NameError: CreateWorldObjectAbility
 Traceback (innermost last):
  File "..\config\gloryofrome\ability_db.py", line 286, in ?
NameError: CreateWorldObjectAbility

      at org.python.core.Py.NameError(Unknown Source)
      at org.python.core.PyFrame.getglobal(Unknown Source)
      at org.python.core.PyFrame.getname(Unknown Source)
      at org.python.pycode._pyx6.f$0(..\config\gloryofrome\ability_db.py:286)
      at org.python.pycode._pyx6.call_function(..\config\gloryofrome\ability_db.py)
      at org.python.core.PyTableCode.call(Unknown Source)
      at org.python.core.PyCode.call(Unknown Source)
      at org.python.core.Py.runCode(Unknown Source)
      at multiverse.server.engine.ScriptManager.runPYFile(ScriptManager.java:181)
      at multiverse.server.engine.ScriptManager.runFile(ScriptManager.java:94)
      at multiverse.server.engine.Engine.processPostScripts(Engine.java:541)
      at multiverse.server.engine.Engine.main(Engine.java:396)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at multiverse.server.marshalling.Trampoline.main(Trampoline.java:150)


ERROR [2012-03-31 22:35:48,041] Combat-4            handleMessageImpl java.lang.NullPointerException java.lang.NullPointerException
      at multiverse.mars.core.MarsAbility.startAbility(MarsAbility.java:733)
      at multiverse.mars.plugins.CombatPlugin$StartAbilityHook.processMessage(CombatPlugin.java:247)
      at multiverse.server.engine.EnginePlugin.handleMessageImpl(EnginePlugin.java:406)
      at multiverse.server.engine.EnginePlugin$QueuedMessage.run(EnginePlugin.java:440)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
DEBUG [2012-03-31 22:35:49,231] Scheduled-1          BasicInterpolator.run: interpolating all objects
DEBUG [2012-03-31 22:35:49,398] MessageIO            handleMessageData from objmgr,168 type=mv.START_ABILITY len=57 class=multiverse.mars.plugins.CombatClient$StartAbilityMessage
DEBUG [2012-03-31 22:35:49,506] MessageIO            deliverMessage to multiverse.mars.plugins.CombatPlugin@65b7ff10
DEBUG [2012-03-31 22:35:49,508] MessageIO            deliverMessage to org.python.proxies.mvmodule$SampleWorldClassAbilityPlugin$0@1c4233fd
DEBUG [2012-03-31 22:35:49,517] Combat-5            EnginePlugin.handleMessage: got msg id 168, matching 1 hooks for msgtype MessageType['mv.START_ABILITY', 104]
DEBUG [2012-03-31 22:35:49,517] Combat-5            CombatPlugin, StartAbilityHook.processMessage: oid=38219, targetOid=38219 ability=make barrel
ERROR [2012-03-31 22:35:49,517] Combat-5            handleMessageImpl java.lang.NullPointerException java.lang.NullPointerException
      at multiverse.mars.core.MarsAbility.startAbility(MarsAbility.java:733)
      at multiverse.mars.plugins.CombatPlugin$StartAbilityHook.processMessage(CombatPlugin.java:247)
      at multiverse.server.engine.EnginePlugin.handleMessageImpl(EnginePlugin.java:406)
      at multiverse.server.engine.EnginePlugin$QueuedMessage.run(EnginePlugin.java:440)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)



So yeah
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 8:55

Sorry I am guessing that you didnt put the ability in the ability_db.py I will change the wiki to specify that
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 9:08

Delurin wrote:
Sorry I am guessing that you didnt put the ability in the ability_db.py I will change the wiki to specify that

I did, it's in config/gloryofrome/ability_db.py beginning at line 286 :
Code:

ability = CreateWorldObjectAbility("make barrel")
ability.setTargetType(MarsAbility.TargetType.SELF)
ability.setActivationTime(0)
ability.addReagent("Barrel Object")
ability.setWorldObjectTemplate("Barrel")
Mars.AbilityManager.register(ability.getName(), ability)

I've just had a thought...

When you say to create the CreateWorldObjectAbility.java file, I literally created a file called CreatWorldObjectAbility.java at c:/multiverse/src/multiverse/mars/abilities/, alongside CombatAbility, CreateItemAbility and EffectAbility, and pasted the java you put on the tutorial, into the java file.
Could that be the problem? Is it supposed to be officially registered with the Mars code?
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 10:01

Did you export the jar for mars?
Back to top Go down
zoot686
Foundation Donor
avatar

Posts : 78
Join date : 2012-02-15
Location : USA

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 11:33

Well I'll tell ya' there folks........................the reason why minecraft is so successful, even though it's laggy as hell and has terrible graphics, is because folks can make their mark in those worlds


Back to top Go down
AWM Mars
Well-Known Member
Well-Known Member
avatar

Posts : 78
Join date : 2012-02-23
Location : Wiltshire, United Kingdom

PostSubject: Re: Placing objects (i.e. buildings) in-game   Sun 1 Apr - 17:26

I'd like to slip in a question, into the procedings. Is the inventory database dynamically updated? Say I was in a live environment with other users and I wanted to show them a model as WIP. Can I upload the revisions to the database and have it update into the inventory, for displaying into the environment?
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 1:55

AWM Mars wrote:
I'd like to slip in a question, into the procedings. Is the inventory database dynamically updated? Say I was in a live environment with other users and I wanted to show them a model as WIP. Can I upload the revisions to the database and have it update into the inventory, for displaying into the environment?

At the moment that isn't possible, because when the server is loaded, it loads acopy of all the assets and scripts. It would require a restart of the server in order to add new assets to the world.
However, it is certainly something I'd like to see made poossible. It would just require some reprogramming of the server loading.

And that's the outer edge of my knowledge, right there!
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 3:39

Also you would have to patch the client so that the asset is sent to them. It wouldnt be hard to write a function that when specified would look for updates and add them to the inventory (or it could be timer based)
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 4:23

Just going back to the previous issue,

Delurin wrote:
Did you export the jar for mars?

What do you mean by that? Did I use an IDE to export it?

All I did was create a .txt file in the abilities section of the mars source, pasted your code in, then changed the extension to .JAR.

I can imagine that could be the problem...
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 5:04

Yes that would be a problem...the jar file needs to be recompiled I believe there is a guide on the sourceforge site to how to setup eclipse to create a jar with multiverse.

Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 5:16

Delurin wrote:
Yes that would be a problem...the jar file needs to be recompiled I believe there is a guide on the sourceforge site to how to setup eclipse to create a jar with multiverse.


Where can I find that? I can't see anything in the Multiverse project area
Back to top Go down
http://www.3dmodeller.info
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 5:28

Sorry it was in the wiki not the sourceforge
http://www.multiversemmo.com/wiki/Developing_With_Eclipse

or http://www.multiversemmo.com/wiki/Setting_Up_a_Development_Environment
if you dont want to use eclipse.
Back to top Go down
Tristan
Administrator
Administrator
avatar

Posts : 306
Join date : 2011-08-03
Location : Liverpool, UK

PostSubject: Re: Placing objects (i.e. buildings) in-game   Mon 2 Apr - 6:16

Ok, so I've gone through the tutorial, and the CreateWorldObjectAbility.java file is there.
I attempted to export the whole package according to the tutorial, to overwrite the mars.jar file, but there are like 20 errors that don't allow me to export, including the CreatWorldObjectAbility.java file.

I looked into the error, and found this
Code:

The value of the local variable result is not used   CreateWorldObjectAbility.java   /multiverse/src/multiverse/mars/abilities   line 45   Java Problem

Line 45 is this:
Code:

Integer result = WorldManagerClient.spawn(OID);
      //Spawns the 3D Object

Thoughts?
Back to top Go down
http://www.3dmodeller.info
Sponsored content




PostSubject: Re: Placing objects (i.e. buildings) in-game   

Back to top Go down
 
Placing objects (i.e. buildings) in-game
View previous topic View next topic Back to top 
Page 1 of 3Go to page : 1, 2, 3  Next
 Similar topics
-
» Game Tips!
» This game sure can be adamant about wanting players to take certain weapons
» The "Who would win?" game
» problem with the game : no control over the moves of the pc
» Luck O' the Bearish Instant Win Game

Permissions in this forum:You cannot reply to topics in this forum
 :: Development :: Client Scripting and Development-
Jump to: