Discuss Scratch

Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements




TDSGBV (Tower defense survival game by Vadik1) - is a 3D multiplayer survival game, where your goal is to collect resources, build a base and survive for as many in-game days as you can. At night you will be attacked by different types of enemies. Each night their amount and variety increases. You can only respawn, if you craft and place a bed, but be careful, because enemies will try to destroy it too. To help you protect it there are turrets and other traps which you can make.

This game has 137 items and 102 crafting recipes and on average contains a bit over an hour of gameplay (if you manage to survive for that long of course)
GIF Gallery





Frequently asked questions

Q: What is the best way to play the game?
A: On TurboWarp or Forkphorus with some non-default settings included in those links.

Q: Can you make it less laggy?
A: Sadly, no. I already did what I could to make current 3D implementation fast. It can be made faster if I remake it completely, but it's too late for that since the code is very interconnected and the entire game relies on what it there right now.

Q: How do I start?
A: Collect sticks, stones and grass, then open inventory by pressing E, switch to crafting tab and craft what you can. You should be able to figure out the rest.

Q: Can I play on mobile?
A: Yes. Mobile controls should auto-enable themselves, but if they don't, you can go into settings and do it manually.

Q: Is the progressbar when joining real or is it just for show?
A: It's real. There is this big interactable world and there are cloud variables which can only contain 256 characters at once. When you join, you somehow need to obtain the world data which is usually about 11000 characters in length. It is split into pieces and sent to you piece by piece.

Q: After pressing “Play” it tells me that I'm waiting in a queue. Why can't I just join right away?
A: People need to get world data. World data is large, so it is sent in form of many 256 character long pieces. There is quite a sophisticated system in place that ensures integrity of the received world data even under the most extreme conditions. It only works with 1 sender and 1 receiver, and the rest of people have to wait.

Q: Why for me this game becomes unplayable at night on Forkphorus?
A: Hardware acceleration not working properly. Try enabling webgl mode, using different browser, different device or play it on TurboWarp

Q: Can I pause this game?
A: Yes, stop the project. Then press green flag it to resume. Your progress should be fine.

Q: Does the game save my progress?
A: It doesn't, but pressing green flag doesn't reset it either. Temporarily stopping the project should be fine, but leaving or reloading the page will reset your progress.

Q: Can you add ability to save?
A: It would defeat main goal of the game, so no. Read this for more info.

Q: Is there chat?
A: No, and it's unlikely to ever be added.

Q: Can I advertise in the comments of TDSGBV 3D?
A: You can, but only projects related to TDSGBV 3D. Other ads are not allowed and will be either deleted or reported.

Q: Game crashes after being paused using pause button in Forkphorus, TurboWarp or the popular scratch related browser extension. Is it a bug?
A: It's intentional. Otherwise it would really mess up multiplayer synchronization and cause some other issues.

Q: Why the game isn't updated often anymore?
A: It's not popular anymore, so there is no insentive to prioritize updating this project over everything else. Instead I want to make new projects, maintain other old projects or spend free time in interesting ways outside scratch.

Changelog

2.1-2.25
2.26 January 24, 2021
2.27 February 1, 2021
2.28 February 7, 2021
April fools 2021 April 1, 2021
2.29 April 11, 2021
2.30 April 18, 2021
2.31 May 7, 2021
2.32 May 15, 2021
2.33 June 6-9, 2021
2.34 August 30, 2021
2.35 November 19, 2021
Snow experiment December 5, 2021
Countdown until 2022 December 31, 2021
2.36 March 5, 2022
April fools 2022 April 1, 2022
2.37 December 9, 2022

Last edited by Vadik1 (Aug. 25, 2023 13:25:05)

Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

Modding tutorial

Before you start, it is recomended that you do all of the editing on TurboWarp.org because there are a lot of scripts in this projct and TurboWarp has a searchbar for scripts. There is a way to add this same searchbar to Scratch website itself, but I can't tell you how to do it because of this. Then after editing it on TurboWarp you can download the edited project to your computer and upload it to Scratch website inside of your remix and confirm replaceing existing project.

Items

1.Adding new items
This is probably one of the easiest things to do. Each item has an id - a number between 1 and 255 used to identify it everywhere within the code. If you want to add a new item you would need to find an unused id for it. To do it, hold space bar and press “Remixing” button in the main menu. This is going to show you a list of all 255 possible items. Clicking on any of the items there shows it's id. Unused ids are shown as question marks. You need to pick any unused id for your new item.

When doing so, please don't always just pick the first unused id avalible. Instead, try to find a spot in the id grid in a spot closely to similar items.

Once you have picked an id, switch to “Inventory” sprite, switch to “Costumes” tab, find a cosume of any item that has “item” in it's name and duplicate it. Rename duplicate to include item id you picked earlier and now you can redraw it.
After you are done, view the list of all items in the main menu again to ensure that you did everything correctly.

The next thing to do is to give it a name. Show ItemNames list and scroll until you find a list item at the same position as the item id you picked. Then set that item element to the name of the item. But be careful not to add or delete any elements in that list, which should always remain 255 items in length.

In order to test new items, press “Erase saves” while holding space bar. Start singleplayer, open inventory and in the new inventory tab with ∞ sign, scroll until you find your new item.
IMPORTANT!
Items only show up there if they have names.
2.Changing the way items look in hand
Go to “Inventory” sprite and switch to “Costumes” tab. Find the item you want to change. Make a duplicate of it's costume. Normally items are named as item_ITEMIDHERE. You need to rename the duplicate to hand_ITEMIDHERE. Then modify it in a way you want it to look in the hand.
3.Adding crafting recipes
Tick a checkbox near the CraftingRecipes list. Create a new list element in it. Then fill in the crafting recipe by following the documentation below. In documentation numbers at the beggining represent the character location. Numbers you need to put in crafting recipe codes are not in decimal (0-9), but in hexadecimal (0-9 A-F) so you might need to find some online converter. “0x” is omited.
A feature added to help with this conversion is the hexadecimal markings border in the item grid. You first need to take character from the left and then from the top relatively to where the item is.

The thing below describes at what positions characters are responsible for what.
1 - Crafting station(0-normal 1-loom 2-cauldron 3-furnace 4-anvil)
2-3 - Ingredient 1 id in hexadecimal
4 - Amount of ingrediant 1 in hexadecimal
5-6 - Ingredient 2 id in hexadecimal
7 - Amount of ingrediant 2 in hexadecimal
8-9 - Ingredient 3 id in hexadecimal
10 - Amount of ingrediant 3 in hexadecimal
11-12 - Result id in hexadecimal
13+ - Amount of result in hexadecimal / Special data
Crafting recipes are locked by default. Normally you need to collect all of the correct resources to unlock them. However you can unlock all of them by pressing “Erase saves” while holding space bar pressed.
Example:
For example you want to add ability to craft 3 wooden planks and 8 sticks into 9 strings.
For it you will need to add this code:
00130280000e9

where:
0 01 3 02 8 00 0 0e 9
0 - crafted normally
01 - hexadecimal id of planks. Also in the item list plank is located at 0th row, 1st column
3 - hexadecimal amount of planks
02 - hexadecimal id of sticks. Also in the item list stick is located at 0th row, 2nd column
8 - hexadecimal amount of sticks
00 - hexadecimal id of nothing
0 - hexadecimal amount of nothing
0e - hexadecimal id of string because 14 in decimal is 0x0e in hexadecimal. Also in the item list string is located at 0th row, E-th(14th) column
9 - amount of strings
4.Item hints
When you hold some items in hand, you can see some text above your hotbar. It is easy to add. Go to “3D engine” sprite and switch to “Costumes” tab. Some of the costumes there start with the word “tip” followed by an item id. If you add your own costume like that with id of the item you want it will just work. No need to edit scripts or lists.
5.Durability and other special data
Along with a normal items, which can be stacked up to 10 in a single slot, there are also non-stackable items with special data. Item has special data if it has negative durability. Special data can be used for anything, but most common built in use of it is item durability. It is described below:
1 - misus sign
2 - number 1 indcicating that special data repreents durability
3-5 - uses left
6-8 - max uses
Example would be an item with the amount of -1045060. It has 45 uses left and it's max uses is 60.
If you payed close attention, in the crafting recipes list amount of result doen't have a fixed length allowing creation of crafting recipes for such items.

Adding item durability is only half of the task. You also need to add a code to decrease it's durability. How to do it is described later in this tutorial.
6.Custom item renderer
There is a way to modify the way item and it's amount is diplayed depending on it's real id and amount or special data.
This is the first time you are going to need to use a searchbar. Go to “Inventory” sprite and type “display” in the searchbar near the “Code”, “Costumes” and “Sounds” tabs. You are going to see Count display and Item display in the search results below. You can click on them to quickly move to their definition. There you are going to see and easly modify all of the code for it. Dpending on different conditions you can change cotumes, apply graphical effect, etc. Animated items are also fully supported.

Ingame objects

This game is running on a partially modified 3D engine 2.8. Tutorial for 3D engine 2.6.2 can be found here. Basically there are 3D objects. By default they consist of nothing, so they are invisible. You can attach 3D polygons to them, put a 2D stamped sprite or a dot drawn with pen in the center of them. They can be moved at any location. They have a type which defines their behavior. They also have health(when 0 - it disappears, when “n” it is invinsible), velocity (when “n” it is unmovable), ID which is a number between 100 and 9999 used to identify it in multiplayer. 1-99 is used for players. They also have “tmp” which can be used for anything(e.g. bushes use it to determine their growth, enemies - to save their state, etc).

Behavior of the ingame objects is defined in Handle logic custom block. It runs for each object every tick. The game runs at 20 ticks per second(like minecraft). The game tracks time in ticks in currentGameTick variable.

1.Changing world generation
World generation is defined in when I recieve “New world” in “Game logic” sprite.
At first it clears everything, then adds new object of a type “ground”, makes it invinsible and adds 2 polygons to it. Then it activates custom block called Add objects which populates world with trees, stones and other things. You can look into both of them and modify them however you like. Be creative with it.

2.Death drop
When health of an object reaches 0 an Object death drop custom block in “Game logic” sprite gets activated and data about it's death is sent through the cloud to other players. The first half of the definition is located inside [if (_myid) = (_hostid) then]. If multiple people are playing together, the code inside will only run for one of the players (player who is marked by the game as a main player). It is usefull to make things that one player does and sends to everyone else (e.g. when object is killed, one of the players generates a randomized item drop and sends it to everyone else). The things outside of that “if” run for every player(e.g. particles, sounds).
If you want to make something drop something, it sould not be hard to follow other code there as an example. The main block used to generate drop is:
Createitemxyzidamount

If you don't want to make it, so that items are sent through the cloud when they die(e.g. particles) you can use Client-side death custom block inside of the object behavior in Handle logic.

3.Lighting
Every game tick the lists responsible for light sources get cleared. If you want to make an ingame object glow, in the part of Handle logic responsible for that object type use light (x)(y)(z)(radius) or you can add numbers directly to the correponding lists.

3D sounds

To play 3D sound you can either use
soundsoundnameatobjectlocationislists
OR
add sound name to the 3D sounds list
add x coordinate to the 3D sounds list
add y coordinate to the 3D sounds list
add z coordinate to the 3D sounds list
add empty string or GroupID of the object to which sounds need to be attached to to the 3D sounds list
and then broadcast “Sound update”

Messages

You can display messages in “chat” using:
replaceitem1ofTextwithThis is an example messagebroadcastchat
Those messages are entirely client-side and are not sent to other players.
Use handling

When user clicks, a custom block Use item is activated. It is located in “Use handler” sprite. “item” argument is and id of an item that player currently has in their hand. “on” argument is a type of an object on which user clicked. “on2” argument is a location in lists of that object.

1.Edible items
As you can see in the beginning of Use item there are Eat custom blocks.
Their arguments are:
Eatidapplieseffecttimeintickshexadecimalparticlecolorconvertedtodecimalwithminussign
2.Equipable items
Equipidslot
3.Melee damage dealing items
Damageiddamagetoalivethingsdamagetowooddamagetostone
Note: it also automatically decreases durability if possible.
IMPORTANT
Also please note that by default if you add a new object, you can't damage it with mele weapons. To add ability to do so, go to definition of “Damage” cutom block in “Use handler” and add “Take damage” cutom block

Takedamageobjecttypeformulaforcalculatingdamage
4.Everything else
Handling for clicks on and with everything else is usually done using something like:
ifitem=1then. . .clicking with wooden planksifon=treethen. . . clicking on tree
While describing what is inside you may find those custom blocks uefull:
Damageiteminventoryslotreduces durability Giveitemitemiditemamount/specialdatagive itemLaunchingameobjectlocationinlistpowerLaunches object in direction player is looking atRandomvelocityingameobjectlocationinlistrangeApplies random velocity on an objectSubtract1itemReduces amount of items in a currently selected slotSendmultiplayerhaspolygonalmode?0-no1-yesSends data about last created object to all other players
If clicking creates a new object with a polygonal model, don't just define it in the “Use item”. Instead define it in “Model for” custom block and call Model for from “Use item”. That, along with “Send multiplayer” custom block with “1” in the input will allow object's polygonal models to work in multiplayer.

Multiplayer

There are 2 types of data and there are 2 ways to send it.
1.Ways to send data
There are 2 lists: ☁Send Fast and ☁Send Important
You just simply add new list elements to them to send data.

Data sent through ☁Send Fast will be delivered as quickly as possible, but there is a high chance that it will get lost. That list gets clecread every GameTick so it is best to put data in it from Handle logic
Data sent through ☁Send Important can take multiple seconds to get delivered, but it is very reliable. It will not get lost or duplicated. Try not to spam it or else the multiplayer will become very slow and unresponsive.

2.Types of data
First and most simple type of data is type : value. To send data like that at first just add type, and then add value to one of 2 lists.
To recieve that data, go to “Multiplayer” sprite, to “recieve” custom block's definition and add handling for what is supposted to happen.
There are already a lot of built-in things you can send.
For example if you do:
addchatto☁Send ImportanaddHello worldto☁Send Importan
then everyone except you will see “Hello world” message.

The second type of data is “mob” data.
To send it, add 3 elements to one of 2 lists:
1.“mob”
2.Id of the ingame object stored in GroupId
3.Properties you want to send
Properties you want to send is a number. To get that number, look at the table below, pick properties you want to send and add their numbers together.
Position and velocity = 1
GroupTmp = 2
GroupDisp = 4
GroupName = 8
GroupHealth = 16

Inventory

Inventory is stored in InventoryId and InventoryCount lits. There are 30 list elements in those lists.
1-8 are hotbar slots
9-23 inventory
24-29 armour slots
30 item that player drags
A variable selected stores data about currently selected slot in the hotbar(1-8) or currently selected craft(9+)

Other usefull variables, lists, broadcasts etc.

whenIreceiveConnected activates when player starts playingwhenIreceiveConnect status activates when status of connection changes. The status can be found in "menu" variablebroadcastactivate engine starts 3d rendering enginebroadcaststop engine stops 3d rendering enginebroadcastInventory update Causes all of the slots in the inventory to refresh their valuesbroadcastNew world Resets savesbroadcastOpen chest Opens chest with the offset located at "chestOffset" variablebroadcastOpen craft Opens crafting menu of type from "crafttSation" variablebroadcastSound update Causes project to play all of the 3D sounds from 3D sound listbroadcastUpdate effects Causes effect display to refresh_myidcloud slot player is using_hosstidcloud slot main player is usingangleXcamera rotationangleYcamera rotationangleZcamera rotationcamXcamera positioncamYcamera positioncamZcamera positionmenucontains a value that describes that is currently on screenDistFOVhealthhealthmpmanamaxManamax manaLook_distdistance towards the point player is looking atLook_TriPolyon player is looking at if positive, 2.5D sprite/ingame object if negativeLook_X position of point player is looking atLook_Y position of point player is looking atLook_Z position of point player is looking at

Last edited by Vadik1 (Sept. 30, 2021 06:31:24)

dozer8383
Scratcher
100 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

How do I pick up things?
Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

dozer8383 wrote:

How do I pick up things?
Look at them, so that they are highlighted and then click.
GeckoWar
Scratcher
1 post

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

hey can you help me make a 3d game multiplayer?
Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

BUMP
Also I finally added a modding tutorial!
Tiger_Person
Scratcher
100+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

Hey, this is very cool! You obviously work hard on your projects, they're really great.
l3oomVirus
Scratcher
1 post

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

I have a glitch to report, whenever i try to chop down a tree or mine a rock when im done it drops nothing. I am playing on turbowarp and i can't do much without stone, ore, copper, or wood.
Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

l3oomVirus wrote:

I have a glitch to report, whenever i try to chop down a tree or mine a rock when im done it drops nothing. I am playing on turbowarp and i can't do much without stone, ore, copper, or wood.
It should automatically fix itself after 10 seconds. When you break something, information about it disappearing gets set to every other player. Then, the player who is assigned to be the main one is supposted to spawn a drop and send it to everyone else. That is why when you are the main player, dying objects drop items instantly, but in other cases it happens with the delay. The thing you are currently describing was probably caused by main player in reality leaving the game, but their character wasn't removed yet as it takes 10 seconds of inactivity to do so. If the issue persists for over 10 seconds than something is definetly wrong and you should try stopping and restarting the project.
happypig1256
Scratcher
30 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

happypig1256
Scratcher
30 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

Hi

Last edited by happypig1256 (Jan. 4, 2021 08:00:46)

happypig1256
Scratcher
30 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

Hi

Last edited by happypig1256 (Nov. 12, 2021 06:40:05)

happypig1256
Scratcher
30 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

Last edited by happypig1256 (Jan. 4, 2021 08:28:41)

D_Scratch_Acount
Scratcher
10 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

How do you put stuff in the treasure chest and furnace
Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

D_Scratch_Acount wrote:

How do you put stuff in the treasure chest and furnace
Click on the bottom of it. When you hover over the correct spot it gets hightlighted
D_Scratch_Acount
Scratcher
10 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

what can you put in the furnace for now?
Wingsflyer123
Scratcher
3 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

Can you add more mobs like enderman.
Wingsflyer123
Scratcher
3 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

how to break a wood from a tree?
Vadik1
Scratcher
500+ posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

D_Scratch_Acount wrote:

what can you put in the furnace for now?
Copper ore -> Copper ingot
Iron ore -> Iron ingot
Potato -> Cooked potatoe

Ores are obtained by breaking stone.
Potatoes have a low drop chance from zombies.

Wingsflyer123 wrote:

Can you add more mobs like enderman.
If you mean teleporting enemy - maybe.
If you mean adding black tall thing with purple glowing eyes, and purple particles - no, I don't want to copy minecraft.

Wingsflyer123 wrote:

how to break a wood from a tree?
Collect sticks, stones and grass that are laying on the ground.
Recraft grass to strings.
Craft an axe.
EE3EE3EE3EE
Scratcher
6 posts

TDSGBV 3D - Large 3D ☁Multiplayer survival game with base building and tower defense elements

all i remember is that u need a bow to make a turret and i also think iron but when i make a bow it doesnt show the recipe to make a turret

Powered by DjangoBB