Ok. We will now create a "Cow" and make it produce milk.
I dont have any cow sprites so we improvise a little.
Sprites>Mobiles>Enemies
Create group Cow Scorpion
Create group Walk
Create group Idle
Create group Attack
Create group Stagger
Duplicate sprScorpionBones to sprCowScorpionBones
Move it to the new group
Duplicate all the other sprites and move them to the new group. Put the word "Cow" before the Scorpion.
Edit sprCowScorpionBones
Images>Intensity
Value 132
Saturation 0
Check Apply to all images
Do this to all the "Cow" sprites
Sprites>Avatars
Duplicate sprAvatarForestScorpion to sprAvatarForestCowScorpion
Images>Intensity
Use last settings.
Scripts>Sprite Sets
Duplicate SetSpritesScorpion to SetSpritesCowScorpion
Put "Cow" before Scorpion in the sprite names
But set spriteDeathBits = sprProduceBits;
Ok. We also need sprites for the pickup object and inventory.
Duplicate sprCowScorpionIdleWest to sprCowScorpion_Object
origin x=0 y=0
Transform>Resize canvas
Uncheck keep apsect
Position center
size 90x90
Transform>Shift
Horisontal 6
Duplicate sprCowScorpion_Object to sprCowScorpion_Inventory
Go back to sprCowScorpion_Object
Transform>Stretch
Set size 32x32
Go to sprChicken_Inventory
Transform>stretch
size 160x160
Ok. Now for the actual walking "cow"
Duplicate objScorpion_Once to objCowScorpion_Once
Set sprite to sprCowScorpionWalkWest
Set parent to parMortal.
Crete event
scr_Multiplayer_Producer_Init(0);
SetSpritesCowScorpion();
life = 40;
Add a alarm 0 event and add a code block
/// Check livestock
scr_Multiplayer_Check_Livestock(multiplayer_data, objMapAI_livestock, false, Produce_LastTool);
scr_Multiplayer_Producer_Alarm();
These will check when the product is ready.
Add collision event with objPlayerStrike and add a code block
/// Check for tool
scr_Multiplayer_Producer_Detect_Tool(other.item_data);
Add a draw event and a code block.
/// Draw
scr_Multiplayer_Producer_Draw();
A new object goes in the array.
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[55]=objCowScorpion_Once;
Ok. Now for the milk.
Duplicate sprBottleBlue to sprScorpionMilk_Object
Images>Colorize partial
Select the blue in the bottle
New Hue 125
Duplicate sprScorpionMilk_Object to sprScorpionMilk_Inventory
Transform>stretch
160x160
Duplicate objEgg to objScorpionMilk
Set sprite to sprScorpionMilk_Object
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[56]=sprScorpionMilk_Object;
Duplicate ItemGetEgg to ItemGetScorpionMilk
_item[ITEM_NAME] = "Scorpion milk";
_item[ITEM_OBJECT] = objScorpionMilk;
_item[ITEM_ICON] = sprScorpionMilk_Inventory;
_item[ITEM_VALUE] = 20;
objPlayerCharacter>parCollectible_Products
case objScorpionMilk: item=ItemGetScorpionMilk(); break;
scr_Multiplayer_ON_PLAYER_REQUEST_OBJECT_GRANTED
case objScorpionMilk: var item=ItemGetScorpionMilk(); // Set data fom pickup item item=scr_Multiplayer_Data_Get(data_,item); InventoryAdd(item); break;
We also need a tool to milk the cow.
I wanted something fancy like a milk extractor thing. But I only got a bowl.
Duplicate sprBowl4 to sprMilkExtractor_Object
Duplicate sprMilkExtractor_Object to sprMilkExtractor_Inventory
Transform>stretch
160x160
Duplicate objHoe to objMilkExtractor
Set sprite to sprMilkExtractor_Object
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[57]=objMilkExtractor;
Duplicate ItemGetHoe to ItemGetMilkExtractor
_item[ITEM_NAME] = "Milk Extractor";
_item[ITEM_OBJECT] = objMilkExtractor;
_item[ITEM_DESCRIPTION] = "Extract milk from livestock";
_item[ITEM_ICON] = sprMilkExtractor_Inventory;
_item[ITEM_EFFECT] = 0;
_item[ITEM_SPRITESET] = SetWeapon_WoodenSword;
_item[ITEM_VALUE] = 300;
_item[ITEM_DURABILITY] = 50;
_item[ITEM_DURABILITY_MAX] = 50;
In lack of milking animations we use SetWeapon_WoodenSword.
objPlayerCharacter>parCollectible_Products
case objMilkExtractor: item=ItemGetMilkExtractor(); break;
scr_Multiplayer_ON_PLAYER_REQUEST_OBJECT_GRANTED
case objMilkExtractor: var item=ItemGetMilkExtractor(); // Set data fom pickup item item=scr_Multiplayer_Data_Get(data_,item); InventoryAdd(item); break;
We need a sprite that show when the cow is ready to eat and be milked.
Duplicate sprScorpionMilk_Object to sprScorpionMilk_Status
Cut out the image.
Draw a circle.
Paste it back
Ok. We need to be able to equip the cow so we can place it. So the cow need to parent the weapon.
Duplicate objSeeds_Carrot to objCowScorpion_Object
Sprite sprCowScorpion_Object
scr_Multiplayer_OBJECT_ARRAY_Enviroment
Enviroment_Object_array[58]=objCowScorpion_Object;
Scripts>Tutorial Series>Multiplayer>Envirment>Livestock
Move the script to the Livestock Script Group
Edit the script
var default_name="CowScorpion";
Is the name of the Livestock, The name is used in the handler script
var default_livestock_object=objCowScorpion_Once;
Is the walking cow that produce the milk
var default_production_time=20;
Is the time to produce milk
var default_tool_description_needed="Extract milk from livestock";
Is the description of the tool needed to extract the product. We set this description on our milk extractor.
var default_production_object=objScorpionMilk;
Is the milk pickup object
var default_food_source=objGrass;
Is the food the cow eat to produce milk
var default_specific_food_source=objGrass; var default_specific_production_object=objScorpionMilk;
Is more specific food. If the cow eat it. It produce another object. And the object to produce if eat a specific food.
var default_allow_retroactive=false;
Say we exit the current location. Cow will be paused. And return 40 minutes later. The cow should produce 2 milk.
1 milk 20 minutes 2 milk 40 minutes... So do we allow that or do we only allow one milk to be produced. For now no.
If we milk the cow we will only get one milk. We lost the other 20 minutes.
var default_remove_count_from_tool=false;
We use a bowl so we remove durability from it. If we would use bottles. Then we would remove count instead. It just make sense.
var default_sprite_process=noone;
You can have a timer showing over the livestock when its soon ready to produce again.
var default_sprite_ready=sprScorpionMilk_Status;
If you need a tool you will see the "I am ready" sprite over the livestock. Lets just show the milk sprite.
Ok. Now for the item data.
Duplicate ItemGetChicken to ItemGetCowScorpion
_item[ITEM_NAME] = "Cow Scorpion";
_item[ITEM_OBJECT] = objCowScorpion_Once;
_item[ITEM_DESCRIPTION] = "Produce milk.";
_item[ITEM_ICON] = sprCowScorpion_Inventory;
_item[ITEM_VALUE] = 500;
_item[ITEM_DATA] = "LiveStock;CowScorpion;0;scr_CowScorpion";
Ok. Lets make us pick it up.
objPlayerCharacter>parCollectible_Weapons
case objCowScorpion_Object: item=ItemGetCowScorpion(); break;
scr_Multiplayer_ON_PLAYER_REQUEST_OBJECT_GRANTED
case objCowScorpion_Object: var item=ItemGetCowScorpion(); // Set data fom pickup item item=scr_Multiplayer_Data_Get(data_,item); InventoryAdd(item); break;
Lets place a cow object on the map
Add some grass as fence.
Add a "cow"
Creation code
multiplayer_data=scr_Multiplayer_Get_Livestock_Data("CowScorpion","0","scr_CowScorpion");
As you know this will create a "Wild" Cow. It only produce when the player is in the area and can be milked depending on what time the local player enter the area. Use the objCowScorpion_Object to place "Tame" cows.
We also need to place a milk extractor.
Ok. Lets try it.
Equip the milk extractor
Ok. Lets wait here for 20 minutes...
And the "Cow" is now ready to be milked.
As you see the "Cow" ate one grass and produced one milk.It will now take 20 minutes to produce again.
And here is the milk.
Không có nhận xét nào:
Đăng nhận xét