You may need to update to MultiplayerAddOnToYoYoRPG 1.1.8 or above. But use the Update_1_1_7_to_1_1_8.bat to preserve the tutorial changes.
You need ExtraForYouAreNotAlone version 1.1.3 or above. Pause and check if you need to update.
In this tutorial we will create a pickaxe and rocks that the player can place. But you can use this tutorial to create all sort of placeable things.
We need to upgrade a script before we can continue.
objPlayerStrike>Animation End
scr_Multiplayer_Do_Farming_2(item_data[ITEM_DATA],objField_Once,objPlant_Once);
Scripts>ItemGetHoe
_item[ITEM_DATA] = "PlowTool";
This will alow us to use the hoe animations to other weapons. Because we need one for this.
The stone will work as an obstacle. We will set it so we cant destroy it with a sword.
So we will create a pickaxe to handle rocks.
Duplicate sprWeapon6 to sprPickaxe_Object
Transform>stretch
32x32
Duplicate sprWeapon6 to sprPickaxe_Inventory
Transform>stretch
160x160
Duplicate objHoe to objPickaxe
Set sprite to sprPickaxe_Object
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[59]=objPickaxe;
Duplicate ItemGetHoe to ItemGetPickaxe
_item[ITEM_NAME] = "Pickaxe";
_item[ITEM_OBJECT] = objPickaxe;
_item[ITEM_DESCRIPTION] = "Remove rocks";
_item[ITEM_ICON] = sprPickaxe_Inventory;
_item[ITEM_VALUE] = 200;
_item[ITEM_DATA] = "";
Ok. Lets make us pick it up.
objPlayerCharacter>parCollectible_Weapons
case objPickaxe: item=ItemGetPickaxe(); break;
scr_Multiplayer_ON_PLAYER_REQUEST_OBJECT_GRANTED
case objPickaxe: var item=ItemGetPickaxe(); // Set data fom pickup item item=scr_Multiplayer_Data_Get(data_,item); InventoryAdd(item); break;
Ok. We now have a pickaxe. Lets make a rock. That we can use the pickaxe on.
We start with the sprites.
Sprites>Other
Create a new sprite and call it sprStone
Load sprite
Find the current project folder>background>images>bckDungeon.png
Edit and cut out the stone to the clipboard
Remove the old image and create a new one 32x32
Paste the stone
Center it.
Duplicate sprStone to sprStone_Object
Transform>Stretch
16x16
Duplicate sprStone to sprStone_Inventory
Transform>Stretch
160x160
Sprites>Interactables
Duplicate sprChestSmash to sprStoneSmash
Images>Intensity
Value 106 Saturation 0
Duplicate sprStoneSmash to sprStoneStump
Transform>Stretch
32x32
Remove all images except the last one
Origin 0x0
To place stones we need to set them as a weapon.
Duplicate objSeeds_Carrot to objStone_Object
Set sprite to sprStone_Object
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[60]=objStone_Object;
Duplicate ItemGetHoe to ItemGetStone
_item[ITEM_NAME] = "Stone";
_item[ITEM_OBJECT] = objStone_Object;
_item[ITEM_DESCRIPTION] = "A stone";
_item[ITEM_ICON] = sprStone_Inventory;
_item[ITEM_VALUE] = 1;
_item[ITEM_DURABILITY] = -1; _item[ITEM_DURABILITY_MAX] = -1;
_item[ITEM_DATA] = "PlaceAbleGrid;objStone_Once;json";
objStone_Once will be the object that the player place when equipping this in the inventory.
Ok. Lets make us pick it up.
objPlayerCharacter>parCollectible_Weapons
case objStone_Object: item=ItemGetStone(); break;
scr_Multiplayer_ON_PLAYER_REQUEST_OBJECT_GRANTED
case objStone_Object: var item=ItemGetStone(); // Set data fom pickup item item=scr_Multiplayer_Data_Get(data_,item); InventoryAdd(item); break;
Ok. Now for the stone obstacle.
Duplicate objGrass to objStone. Yes we use objGrass because this is a totally new obstacle.
Set sprite to sprStone
Depth to -1
Create event
dropChance = 100;
Step event
Change to drop the stone object
var _newGem = instance_create(x+16, y+16, objStone_Object);
scr_Multiplayer_Object_SyncCreate(0, objStone_Object, room, x+16, y+16);
In // Create an instance to show the cut animation
_inst.sprite_index = sprStoneSmash;
In // Create an instance to show the stump
_inst.sprite_index = sprStoneStump;
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[61]=objStone;
We will also create a once object
Duplicate objStone to objStone_Once
Set parent to objStone
Create event
scr_Multiplayer_ONCE_Enviroment();
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[62]=objStone_Once;
The stone is a new type of object so we need to make the multiplayer code handle it.
scr_Multiplayer_ON_DESTROY_Enviroment
Copy the CheckObject=objGrass; chunk and paste it below
CheckObject=objStone;
scr_Multiplayer_ON_PLAYER_REQUEST_OBJECT_GRANTED
Copy CheckObject=objGrass; chunk and paste it below
CheckObject=objStone;
Stone
Player>objPlayer
Room start event
In // Activate all "hidden" objects
instance_activate_object(objStone);
Ok. The engine can now handle this new type of obstacle.
We will now make so the pickaxe can remove rocks
objPlayerStrike
Duplicate objPot Collision event to objStone
Edit the objStone collision code
We now check if the item used can smash rocks.
if string_pos("Remove rocks",item_data[ITEM_DESCRIPTION])>0
{ }
Remember that we set: _item[ITEM_DESCRIPTION] = "Remove rocks"; in ItemGetPickaxe
So you can make other special items that can interact with specific world objects.
We need to make so the player can place stones.
objPlayerStrike>Animation End
// Place Objects scr_Multiplayer_Do_PlaceAbleGrid(item_data[ITEM_DATA]);
We can now add some stones in the room.
Stones that will regenerate or only exist once.
We also need to add a pickaxe.
Ok. Lets test it.
Equip pickaxe.
Smash.
Collect.
Equip stones
Place.
A wall a fence ... whatever it rocks
Không có nhận xét nào:
Đăng nhận xét