Page 1 of 1

How do I create a new object?

Posted: Tue Aug 18, 2020 8:37 pm
by Bamhalazam
Hello, absolutely clueless and hopeless 'coder' here.

I don't know anything about coding. I want to add two objects to the game: a fencing epee and bag. I have made the sprites but I do not know how to even start the process of converting the sprites into objects.

Any help would be appreciated!

Re: How do I create a new object?

Posted: Tue Aug 18, 2020 8:39 pm
by Bamhalazam
I also would like to know whether or not there is a test server since I am sure that no one would merge spaghetti code just for some test.

Re: How do I create a new object?

Posted: Tue Aug 18, 2020 8:55 pm
by oranges

Re: How do I create a new object?

Posted: Wed Aug 19, 2020 1:15 am
by wesoda25
Honestly I think the best short-term resource is looking at PRs on github. Look at prs that add items to the game, should give you some insight as to how you should go about it without attempting to navigate a large and potentially confusing guide.

Re: How do I create a new object?

Posted: Wed Aug 19, 2020 1:18 am
by PKPenguin321
You'll want to fire up a test server on your own.
BYOND, which you need to have in order to play the game in the first place, comes with its own development environment called Dream Maker and a hosting tool called Dream Daemon. If you're running Windows you can just search for them in your taskbar and they should pop up.
Download our source code here: https://github.com/tgstation/tgstation/ ... master.zip
Then when you unzip it, open tgstation.dme to open the game code in Dream Maker. The code should be ready to go by default, and you can compile it by click Build > Compile. This will output a .dmb file in the same folder as the .dme, which you can double click to run or properly host with Dream Daemon.
Once you have a test server that you locally host, you'll automatically get access to admin tools. Among these tools is the ability to View Variables. Right click ANYTHING and find View Variables in the right click menu to open up a handy window that shows you the values of everything on an object/mob/whatever. For example, view the variables of a fire extinguisher and you can find the "force" variable to see exactly how much damage it does. Learning by experience like this is really handy for newbies.
Once you've played around with it for a bit, check out our code here: https://github.com/tgstation/tgstation You'll notice a search bar up at the top which you will probably make a lot of use of. If I search for fire extinguisher, my top result is extinguisher.dm, where you can see the object definition (line 1), variables being set (lines 2 through 18), new variables being declared and set (lines 19-28)... You'll notice that "force" is defined on line 13, and is equal to what the in-game View Variables window said! Also some variables are defined in weird ways, like "icon", which points to a ".dmi" file... If you open up that .dmi file in Dream Maker, you'll find where we store icons! Poke around a bit in there and you'll quickly find Dream Makers sprite editor.

Basically just poke around, see how things work, and go off of example. A new object that's just a weapon should be really easy, and what I've shown you here should be enough to help you figure out how to do it.
If you want to actually merge your code into our live codebase, you'll want to set up git, but that's a whole different tutorial. Cross that bridge when you get to it, it'll make your life easier if you're just starting out.

Re: How do I create a new object?

Posted: Wed Aug 19, 2020 1:37 am
by cacogen
make it a child of an existing sword so it inherits that object's code and then modify its damage

you can see how a sabre is created here:
https://github.com/tgstation/tgstation/ ... isc.dm#L55

so like

Code: Select all

/obj/item/melee/sabre/epee
	name = "fencing epee"
	desc = "This is used to fence."
	icon_state = "epee"
   icon = 'icons/obj/items_and_weapons.dmi' //object sprite should go in this file, named as above (e.g. epee)
	inhand_icon_state = "epee"
	lefthand_file = 'icons/mob/inhands/weapons/swords_lefthand.dmi' //left inhand sprite should go in this file, named as above (e.g. epee)
	righthand_file = 'icons/mob/inhands/weapons/swords_righthand.dmi' //right inhand sprite should go in this file, named as above (e.g. epee)
	force = 2 //melee damage
	sharpness = SHARP_EDGED //i assume there's a define in the code for not sharp somewhere which you'd replace here to prevent embedding
	throwforce = 5 //thrown damage
	armour_penetration = 0 //i don't know how this works but i'm guessing you'd want it at 0 for a fencing sword