Mythruna

Modder's Workbench => Scripting => Topic started by: nh_99 on April 10, 2013, 03:43:12 PM



Title: Battle Mod v0.1
Post by: nh_99 on April 10, 2013, 03:43:12 PM
Whoa, hold it there. A battle mod? And no AI? Well, technically it isn't a battle mod then. It is just a rough implementation of a combat system. Once you install this mod and go into game mode you get a sword and a dummy. You place the dummy and you can hit it with your sword and watch it's health go down. Here are some screenshots.

(http://i.imgur.com/zqwuRWE.jpg)

(http://i.imgur.com/EDWNLTc.jpg)

(http://i.imgur.com/wln6zXS.jpg)

(http://i.imgur.com/wBSHArR.jpg)

(http://i.imgur.com/sYAApAm.jpg)

(http://i.imgur.com/xLdW5YS.jpg)

Commands:
~adddummy - Gives the player a dummy in their inventory
~addsword - Gives the player a sword in their inventory

Download: http://www.mediafire.com/download.php?laqbgyg78z03oa2 (http://www.mediafire.com/download.php?laqbgyg78z03oa2)


Title: Re: Battle Mod v0.1
Post by: Michael on April 10, 2013, 04:26:15 PM
is there a single player version?


Title: Re: Battle Mod v0.1
Post by: pspeed on April 10, 2013, 06:19:39 PM
Heheh... pretty cool.


Title: Re: Battle Mod v0.1
Post by: pspeed on April 10, 2013, 06:25:57 PM
Heheh... pretty cool.

Also, it's kind of motivating to see my little inventory window in someone else's screen shot.  If I have time tonight, redoing that as a Lemur component (with some small redesigns) is one of the things I may play with.


Title: Re: Battle Mod v0.1
Post by: BigredRm on April 10, 2013, 06:39:13 PM
nice


Title: Re: Battle Mod v0.1
Post by: nh_99 on April 11, 2013, 06:30:40 AM
is there a single player version?
This does work in single player because that is what I use to test it. I have not tested it on a server yet but I would assume it works.
Heheh... pretty cool.

Also, it's kind of motivating to see my little inventory window in someone else's screen shot.  If I have time tonight, redoing that as a Lemur component (with some small redesigns) is one of the things I may play with.
I am not quite sure why nobody has made a mod for game mode, it isn't that hard. I was extremely surprised when I used the API to see that it was so easy and nobody had done it before.


Title: Re: Battle Mod v0.1
Post by: pspeed on April 11, 2013, 07:01:17 AM
is there a single player version?
This does work in single player because that is what I use to test it. I have not tested it on a server yet but I would assume it works.
Heheh... pretty cool.

Also, it's kind of motivating to see my little inventory window in someone else's screen shot.  If I have time tonight, redoing that as a Lemur component (with some small redesigns) is one of the things I may play with.
I am not quite sure why nobody has made a mod for game mode, it isn't that hard. I was extremely surprised when I used the API to see that it was so easy and nobody had done it before.

Glad it worked well for you. :)  There are maybe only one or two others who have tried it so far.


Title: Re: Battle Mod v0.1
Post by: nh_99 on April 11, 2013, 08:47:37 AM
Really?! It isn't really that hard. But then again, I do application programming in java and groovy on the side for part of my latest project  :)


Title: Re: Battle Mod v0.1
Post by: BigredRm on April 11, 2013, 02:18:46 PM
I've entertained the idea of taking some night classes just to mod for Mythruna. Then I had a beer.


Title: Re: Battle Mod v0.1
Post by: pspeed on April 11, 2013, 02:25:17 PM
I've entertained the idea of taking some night classes just to mod for Mythruna. Then I had a beer.

LOL.  That reminds me of guys who used to say things like "I would have studied programming in school but I could date girls." or somesuch.


Title: Re: Battle Mod v0.1
Post by: Michael on April 11, 2013, 03:04:49 PM
Hey Paul, remember when I was first learning to code back in August? Thank you for the help by the way;
I have been holding back on learning groovy overall for months because I want to learn java and get that handy to learn Groovy A LOT easier.


Title: Re: Battle Mod v0.1
Post by: Moonkey on April 11, 2013, 03:55:01 PM
Hey Paul, remember when I was first learning to code back in August? Thank you for the help by the way;
I have been holding back on learning groovy overall for months because I want to learn java and get that handy to learn Groovy A LOT easier. (and it also isn't easy to learn all this stuff when there is a girl that you are trying to date xD) <-- ignore the italicized && bold text..
I remember when there was someone I liked in school. But then I went to an online-school in 7th grade and learned much more. (Feels like I just reversed bigred's joke)


Title: Re: Battle Mod v0.1
Post by: Michael on April 11, 2013, 04:05:23 PM
lol I'm too smart for online schools :P


Title: Re: Battle Mod v0.1
Post by: Moonkey on April 11, 2013, 04:41:34 PM
lol I'm too smart for online schools :P
^ This is not true. Online schools teach harder things than public schools. I learned it the hard way. LITERALLY, GWAHAHA.


Title: Re: Battle Mod v0.1
Post by: nh_99 on April 11, 2013, 05:47:00 PM
Off topic much? Lol, this always happens :D


Title: Re: Battle Mod v0.1
Post by: Michael on April 11, 2013, 06:10:58 PM
Off topic much? Lol, this always happens :D
Eh, you know me.
Yea, I get things off topic, but I cannot get them ON topic x(


Title: Re: Battle Mod v0.1
Post by: BenKenobiWan on April 11, 2013, 06:29:10 PM
lol I'm too smart for online schools :P
^ This is not true. Online schools teach harder things than public schools. I learned it the hard way. LITERALLY, GWAHAHA.
I'm in distance-learning college, which is basically online. High-five!

And cool mod. I'll test it out soon.


Title: Re: Battle Mod v0.1
Post by: Moonkey on April 11, 2013, 07:38:52 PM
lol I'm too smart for online schools :P
^ This is not true. Online schools teach harder things than public schools. I learned it the hard way. LITERALLY, GWAHAHA.
I'm in distance-learning college, which is basically online. High-five!

And cool mod. I'll test it out soon.
That sounds cool, if not difficult to work out since it's on the internet, which isn't always reliable.


Title: Re: Battle Mod v0.1
Post by: BenKenobiWan on April 11, 2013, 08:03:46 PM
lol I'm too smart for online schools :P
^ This is not true. Online schools teach harder things than public schools. I learned it the hard way. LITERALLY, GWAHAHA.
I'm in distance-learning college, which is basically online. High-five!

And cool mod. I'll test it out soon.
That sounds cool, if not difficult to work out since it's on the internet, which isn't always reliable.
The tests are taken at a local college I'm not enrolled in, and the studying is done at home, mainly online.

Edit: The tests are CLEPs. The program I'm enrolled in is CollegePlus. You can google both of those (or PM me if you prefer, but let's try and keep this thread somewhat on topic).


Title: Re: Battle Mod v0.1
Post by: Toboi on April 20, 2013, 12:58:56 PM
Sorry that I'm ontopic... :D
Nice mod, makes me think about doing some scripting myself again... ;)
Just one little thing about your code:
Code:
		if(hp > 0) {
hp = hp-takeaway;

if(hp == 0) {
self.setModel("win")
echo("You won!");
} else {
echo("Health is now " + Integer.toString(hp) + "!");
}

}
is probably better done this way if anyone is going to use and extend this:
Code:
		hp = hp-takeaway;

if(hp <= 0) {
self.setModel("win")
echo("You won!");
} else {
echo("Health is now " + Integer.toString(hp) + "!");
}
Else you could come to a point wher the hp are below zero, but never get noticed as won.


Title: Re: Battle Mod v0.1
Post by: nh_99 on April 20, 2013, 07:38:52 PM
Sorry that I'm ontopic... :D
Nice mod, makes me think about doing some scripting myself again... ;)
Just one little thing about your code:
Code:
		if(hp > 0) {
hp = hp-takeaway;

if(hp == 0) {
self.setModel("win")
echo("You won!");
} else {
echo("Health is now " + Integer.toString(hp) + "!");
}

}
is probably better done this way if anyone is going to use and extend this:
Code:
		hp = hp-takeaway;

if(hp <= 0) {
self.setModel("win")
echo("You won!");
} else {
echo("Health is now " + Integer.toString(hp) + "!");
}
Else you could come to a point wher the hp are below zero, but never get noticed as won.
Thanks for picking that up. I will work on an update.


Title: Re: Battle Mod v0.1
Post by: Michael on May 18, 2013, 12:02:31 PM
/* Adjusts to back on topic, hopefully. */

nh_99, I was wondering, when you code in Groovy do you use a simple text-editor or do you use an IDE?


Title: Re: Battle Mod v0.1
Post by: nh_99 on May 19, 2013, 03:50:31 PM
/* Adjusts to back on topic, hopefully. */

nh_99, I was wondering, when you code in Groovy do you use a simple text-editor or do you use an IDE?
Text editors work, but I tend to use an IDE just to keep the code organized. I used Eclipse to make my mods.


Title: Re: Battle Mod v0.1
Post by: Michael on May 19, 2013, 04:41:29 PM
/* Adjusts to back on topic, hopefully. */

nh_99, I was wondering, when you code in Groovy do you use a simple text-editor or do you use an IDE?
Text editors work, but I tend to use an IDE just to keep the code organized. I used Eclipse to make my mods.
Do you grab the jar from the linux version? or do you use specific jars from the windows/mac version?


Title: Re: Battle Mod v0.1
Post by: Sean on May 19, 2013, 07:01:51 PM
/* Adjusts to back on topic, hopefully. */

nh_99, I was wondering, when you code in Groovy do you use a simple text-editor or do you use an IDE?
Text editors work, but I tend to use an IDE just to keep the code organized. I used Eclipse to make my mods.
Do you grab the jar from the linux version? or do you use specific jars from the windows/mac version?
Errm the point of a jar is that it will run on any platform as long as the correct libraries are in place.


Title: Re: Battle Mod v0.1
Post by: Michael on May 19, 2013, 07:58:11 PM
Also, can you help me with setting up the environment nh_99? I added the jars and it gives me an error with this:
Code:

println 'MyMod by Shzylo'

class MyClass {  // <-- Error Here
                       // Says the class is already defined.
}                     // <-- Stupid thing.

on( [PlayerConnected] ) {

}

If i remove the println statement at the tom, and the on( [PlayerConnected] ) { } it works just fine.


Title: Re: Battle Mod v0.1
Post by: nh_99 on May 20, 2013, 02:30:48 PM
Also, can you help me with setting up the environment nh_99? I added the jars and it gives me an error with this:
Code:

println 'MyMod by Shzylo'

class MyClass {  // <-- Error Here
                       // Says the class is already defined.
}                     // <-- Stupid thing.

on( [PlayerConnected] ) {

}

If i remove the println statement at the tom, and the on( [PlayerConnected] ) { } it works just fine.
Funny thing, if you rename that class it will work. You are going to want to call PlayerConnected outside of that class though. The println call says that there is an implied class there basically so it's name is already taken. Only use a class if you are planning on having a sort of API for your mod though, else you can do it all in the script.


Title: Re: Battle Mod v0.1
Post by: Michael on May 20, 2013, 02:34:24 PM
Also, can you help me with setting up the environment nh_99? I added the jars and it gives me an error with this:
Code:

println 'MyMod by Shzylo'

class MyClass {  // <-- Error Here
                       // Says the class is already defined.
}                     // <-- Stupid thing.

on( [PlayerConnected] ) {

}

If i remove the println statement at the tom, and the on( [PlayerConnected] ) { } it works just fine.
Funny thing, if you rename that class it will work. You are going to want to call PlayerConnected outside of that class though. The println call says that there is an implied class there basically so it's name is already taken. Only use a class if you are planning on having a sort of API for your mod though, else you can do it all in the script.
Oh cool :) I am still trying to figure out how the API is working, and understanding the unique-ness and algorithm of Groovy. Thank you!


Title: Re: Battle Mod v0.1
Post by: Teknonick on May 20, 2013, 03:56:50 PM
AWESOME MOD! Suggestion: How about making up your own AI, where the 'bot' will move forward until it touches something, then turn ETC. Maybe if there's a player nearby, it will face it and move towards it until it's like two feet in front, then randomly move forward, back, left, right and maybe jump, to dodge the player's attacks. :3


Title: Re: Battle Mod v0.1
Post by: Michael on May 20, 2013, 04:03:11 PM
AWESOME MOD! Suggestion: How about making up your own AI, where the 'bot' will move forward until it touches something, then turn ETC. Maybe if there's a player nearby, it will face it and move towards it until it's like two feet in front, then randomly move forward, back, left, right and maybe jump, to dodge the player's attacks. :3
Hehe, that would take his mod and multiply the amount of code by somewhere between 20 and 100. And plus, is would be kind of hard in Groovy I think, along with it being a Mod in mythruna..


Title: Re: Battle Mod v0.1
Post by: nh_99 on May 20, 2013, 07:14:24 PM
AWESOME MOD! Suggestion: How about making up your own AI, where the 'bot' will move forward until it touches something, then turn ETC. Maybe if there's a player nearby, it will face it and move towards it until it's like two feet in front, then randomly move forward, back, left, right and maybe jump, to dodge the player's attacks. :3
I do think that this could be possible but it would take an extremely long amount of time to get all of the AI programmed in.


Title: Re: Battle Mod v0.1
Post by: Michael on May 20, 2013, 07:16:14 PM
AWESOME MOD! Suggestion: How about making up your own AI, where the 'bot' will move forward until it touches something, then turn ETC. Maybe if there's a player nearby, it will face it and move towards it until it's like two feet in front, then randomly move forward, back, left, right and maybe jump, to dodge the player's attacks. :3
I do think that this could be possible but it would take an extremely long amount of time to get all of the AI programmed in.
But will Mythruna be able to support it via Groovy, or would you make a groovy-shell and program it in java?


Title: Re: Battle Mod v0.1
Post by: pspeed on May 20, 2013, 08:34:49 PM
It could be done either way but it's a lot of work no matter which route you choose.

The AI framework is my top priority after this next release.  Nearly all of my extra-curricular reading has been in preparation for it.


Title: Re: Battle Mod v0.1
Post by: Michael on May 20, 2013, 08:41:18 PM
It could be done either way but it's a lot of work no matter which route you choose.

The AI framework is my top priority after this next release.  Nearly all of my extra-curricular reading has been in preparation for it.
:D! Paul I wish you the BEST OF LUCK!!


Title: Re: Battle Mod v0.1
Post by: Michael on July 05, 2013, 01:25:47 PM
So nh_99, I found you a nice error that you get on a server with the mod. Here are my steps on receiving the error:

1.) Installs (puts all the files in my /scripts folder)
2.) Starts console (all good, no errors)
3.) Joins (all good, no errors)
4.) Gets into game mode, opens inventory (all good, no errors)
5.) Puts the dummy in my hand (wait for it)
6.) Attempts to place (Stack trace below)

Code:
Todo:[ActionReference[1, BaseItem, Drop]]
java.lang.RuntimeException: Error serializing message
        at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol
.java:82)
        at com.jme3.network.base.DefaultServer$Connection.send(DefaultServer.jav
a:499)
        at mythruna.server.HostedEntityData.sendData(HostedEntityData.java:201)
        at mythruna.server.HostedEntityData.sendChanges(HostedEntityData.java:39
2)
        at mythruna.server.StateSender.run(StateSender.java:106)
        at mythruna.sim.GameSimulation.run(GameSimulation.java:153)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)

        at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$301(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: com.jme3.network.serializing.SerializerException: Error writing objec
t for field:private mythruna.msg.EntityDataMessage$ComponentData[] mythruna.msg.
EntityDataMessage.data
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:181)
        at com.jme3.network.serializing.Serializer.writeClassAndObject(Serialize
r.java:392)
        at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol
.java:74)
        ... 13 more
Caused by: com.jme3.network.serializing.SerializerException: Error writing objec
t for field:private mythruna.es.EntityComponent[] mythruna.msg.EntityDataMessage
$ComponentData.components
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:181)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeArray(A
rraySerializer.java:125)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeObject(
ArraySerializer.java:110)
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:174)
        ... 15 more
Caused by: com.jme3.network.serializing.SerializerException: Error writing objec
t for field:private com.jme3.math.Vector3f mythruna.script.ContextActions.pos
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:181)
        at com.jme3.network.serializing.Serializer.writeClassAndObject(Serialize
r.java:392)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeArray(A
rraySerializer.java:128)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeObject(
ArraySerializer.java:110)
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:174)
        ... 18 more
Caused by: java.lang.NullPointerException
        at com.jme3.network.serializing.serializers.Vector3Serializer.writeObjec
t(Vector3Serializer.java:24)
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:174)
        ... 22 more


Title: Re: Battle Mod v0.1
Post by: nh_99 on July 10, 2013, 08:39:39 AM
So nh_99, I found you a nice error that you get on a server with the mod. Here are my steps on receiving the error:

1.) Installs (puts all the files in my /scripts folder)
2.) Starts console (all good, no errors)
3.) Joins (all good, no errors)
4.) Gets into game mode, opens inventory (all good, no errors)
5.) Puts the dummy in my hand (wait for it)
6.) Attempts to place (Stack trace below)

Code:
Todo:[ActionReference[1, BaseItem, Drop]]
java.lang.RuntimeException: Error serializing message
        at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol
.java:82)
        at com.jme3.network.base.DefaultServer$Connection.send(DefaultServer.jav
a:499)
        at mythruna.server.HostedEntityData.sendData(HostedEntityData.java:201)
        at mythruna.server.HostedEntityData.sendChanges(HostedEntityData.java:39
2)
        at mythruna.server.StateSender.run(StateSender.java:106)
        at mythruna.sim.GameSimulation.run(GameSimulation.java:153)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)

        at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$301(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: com.jme3.network.serializing.SerializerException: Error writing objec
t for field:private mythruna.msg.EntityDataMessage$ComponentData[] mythruna.msg.
EntityDataMessage.data
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:181)
        at com.jme3.network.serializing.Serializer.writeClassAndObject(Serialize
r.java:392)
        at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol
.java:74)
        ... 13 more
Caused by: com.jme3.network.serializing.SerializerException: Error writing objec
t for field:private mythruna.es.EntityComponent[] mythruna.msg.EntityDataMessage
$ComponentData.components
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:181)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeArray(A
rraySerializer.java:125)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeObject(
ArraySerializer.java:110)
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:174)
        ... 15 more
Caused by: com.jme3.network.serializing.SerializerException: Error writing objec
t for field:private com.jme3.math.Vector3f mythruna.script.ContextActions.pos
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:181)
        at com.jme3.network.serializing.Serializer.writeClassAndObject(Serialize
r.java:392)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeArray(A
rraySerializer.java:128)
        at com.jme3.network.serializing.serializers.ArraySerializer.writeObject(
ArraySerializer.java:110)
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:174)
        ... 18 more
Caused by: java.lang.NullPointerException
        at com.jme3.network.serializing.serializers.Vector3Serializer.writeObjec
t(Vector3Serializer.java:24)
        at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(
FieldSerializer.java:174)
        ... 22 more

Hmmmm... I am not sure if this is mod side, or if this is an issue with the serialization in game mode. Paul?


Title: Re: Battle Mod v0.1
Post by: pspeed on July 10, 2013, 08:49:41 AM
Some component has a null Vector3f.  This is a known bug in JME but usually avoided by making sure not to have null positions.


Title: Re: Battle Mod v0.1
Post by: Rayblon on September 14, 2014, 08:31:02 PM
Hmm... If you could create a tag or some reference value, couldn't you apply a pseudo health system to players and teleport them somewhere when they reach '0 health' in terms of the reference value? Just thinking we could have some sort of pvp so long as the mod takes into account some sort of hitbox... Just throwing some ideas out there...