Monster Breeding/Genetics/Farming Game

Ciez17

Member
Tying in with my previous thread, I'd like help in other ways for my desired game, and will, from now on, post my things here. I'm still relatively new to GMS2, and have a lot to learn. SO I'd appreciate any and all advice! :)

My game will essentially be a mix between Stardew Valley, and various monster breeding games, including Spore and Impossible Creatures. Except FAR more extensive with the traits. Like essentially building your own food chain from scratch. And instead of having two creatures having a completely random child, their spawn would actually resemble them with various traits, or even mutations!
What I especially want focus on, is mix/matching body parts in a genetic lab when the "old-fashioned" way isn't cutting it out! >:)

I know it's complicated, but I'm willing to learn.

Now that I've broken in the concept of arrays a bit for the randomizing of genes, I do want to start taking other important aspects under way. Like how to program a basic feeding action for a creature? Any tips or tutorials?

Thanks in advance!
 

Niels

Member
I think you have to narrow your question down to a single mechanic at the time, that way we have help you better:)
 

Ciez17

Member
I agree! Sorry if that didn't come out as clear enough! I guess what I want to learn first, is a basic feeding action. Like say I have a piece of food, and want to give it to a beast to heal it. How would I go about that? There are already plenty basic moving, collisions, etc tutorials out there, even some for farming rpgs directly, but none I've seen address this. I'd like help on this basic feeding action please!
 
G

Guest User

Guest
i think you're asking about how to make two objects interact with one another.

easiest way take a look at those movement and collision tutorials you keep finding then put the concepts discussing in them together, more or less. if you are controlling a player character then your feeding mechanic probably goes something like this:
> get if 'Interact' key is pressed
> if yes, get direction character is facing
> check position in front of character (using direction they are facing) for 'monster' object
> if monster object found, play give food animation
> once food animation is over (or however you want to do it), restore monster object's HP stat

and here is a pseudo-code example:
Code:
    if(keyboard_check_pressed(/* interact key */)) {
        var _x = x + _xdir; /* whether we are looking left or right */
        var _y = y + _ydir; /* whether we are looking up or down */

        /* check if monster is in front of us */
        var _inst = instance_place(_x, _y, EntityMonster);
        if(_inst != noone) {
            /* monster found, so give it health */
            _inst.hitpoints = clamp(_inst.hitpoints + food_value, 0, _inst.max_hitpoints); }
(oh, i didn't include animation handling and such b/c that's not my forte. but you can totally do that too as mentioned earlier).

meanwhile, if you feed monsters by just clicking on them with a mouse (like in some aquarium games and stuff) then you just do the same thing but with the mouse (x, y) coordinates.
pseudo-code example:
Code:
    if(mouse_check_button_pressed(mb_left)) {
        var _inst = instance_place(mouse_x, mouse_y, EntityMonster);
        if(_inst != noone) {
            _inst.hitpoints = clamp(_inst.hitpoints + food_value, 0, _inst.max_hitpoints); }
hope this gives you ideas on how to handle it in your game.
 

Ciez17

Member
Thanks so much! Now from the beast's side, how exactly would we code it's health being affected? I know it'd involve the same principles of a standard heal up from a shooter game, but would the fact that it's being given by an NPC affect the coding?

*Nevermind. I just noticed. Whoops!
 
Last edited:
D

Deleted member 13992

Guest
IMO I think you need to worry about/prototype the core of your game first, the breeding/genetics part, before worrying about feeding. For a prototype, you can just auto-feed them with debug commands. You don't even have to have graphics or collisions. Just stats, monsters as arrays/variables, and text output.

Reason is that your whole game will revolve around that genetics mechanic. If you can get it working, great! But if you can't, or not like you want, then you'll just have a monster-feeding game with nowhere to go from there.

Build around your core mechanic. Build the foundation first. Especially because it's a potentially complex one.
 

Ciez17

Member
I know, that's why I'm making absolutely simple test subjects to experiment with. I believe I have enough info to do some kind of system now. I just have one more obstacle, how to I get the game to recognize two parents having a child? Not the coding language, but actual monsters having a baby. I know it involves arrays and such, but I'm a bit lost on how to handle this specific function.

For example, let's say that I have a blue monster with a big body, a beak, spots and a cow tail breed with a small, snakelike monster with bunny ears? I just listed traits to turn into arrays which will look something like this: monsterTrait[0]=patternSpot, monsterTrait[1]=noseBeak, etc. I know how make to make the game pick from them randomly (with help from YouTube), but how could I get it to recognize a specific set traits from a male parent and a female parent? That's kind of why I jumped to feeding a bit. Like how Minecraft gets two cows to breed by feeding them hay....unless that was changed, but I hope you get the idea. Thanks for your advice though and I'll be sure to remember that!
 

Rob

Member
Code:
chanceForTrait == 0; //Chance for the child to get this trait

if (parent1.traitX == true) or (parent2.traitX == true){
   chanceForTrait == 50;
}

if (parent1.traitX == true) and (parent2.traitX == true){
   chanceForTrait == 100;
}

roll = irandom(100);

if roll <= chanceForTrait trait = true; //Still around a 1% chance for the child to get a trait even if the chanceForTrait variable is 0.
Something like this would work for SOME traits. Others might work better on a sliding scale. For example, if you wanted to measure their laziness, it could be out of a score of 10, with the child's score being the mean of the parents.

[EDIT] I don't know how confident/experienced a coder you are so I'd just like to add that condensing the above code in a for loop that checks through all the traits would be more efficient (for your fingers at least!)
 
Last edited:

Ciez17

Member
Also, chance for trait being a variable, how is this going to be implemented? It'd help to start from scratch I guess. Like I mentioned in my last thread, I'm a beginner, but I can learn quickly.

*I know what the code means, but how shall I get the game to recognize two creatures picked as parents when in breeding mode? Man, I really do need to write this down. :/
 
Last edited:

Ciez17

Member
Also, does anyone understand binary flags as suggested in the other thread? It was said that it could help with identifying genes, and involve if, and, or & xor statments.
 

Ciez17

Member
I found a script that I could possibly piggyback off of, but it's JavaScript. I found it on this rpgmaker forum: https://forums.rpgmakerweb.com/index.php?threads/monster-breeding-system.51624/

  1. var COLD = COLD || {};

  2. COLD.BREED = COLD.BREED || {};

  3. /*:
  4. * @plugindesc Makes a breeding system.
  5. * @author Jeremy Cannady
  6. *
  7. * @param StatsIncrease
  8. * @desc How much to increase the base stats. Number not percentage.For now...
  9. * @default 10
  10. *
  11. * @param Hatch Animation
  12. * @desc Animation to play when hatching an egg.
  13. * @default 1
  14. *
  15. * @param Hatch Final Animation
  16. * @desc Animation to play after the main hatching animation.
  17. * @default 2
  18. *
  19. * @param Hatch Ani Repeats
  20. * @desc How many times to repeat the animation.
  21. * @default 2
  22. *
  23. * @param Notification Text
  24. * @desc Text to notify that your egg is about to hatch.
  25. * @default Oh...?
  26. *
  27. * @param Second Notification Text
  28. * @desc Text indicating that your egg is hatching.
  29. * @default Your egg appears to be hatching!
  30. *
  31. * @param Third Notification Text
  32. * @desc Text to notify that your egg hatched.
  33. * @default Your egg hatched! Would you like to name it?
  34. *
  35. * @param First Egg Text
  36. * @desc Egg description of a new egg.
  37. * @default A new egg.
  38. *
  39. * @param Second Egg Text
  40. * @desc Egg description of egg not close to hatching.
  41. * @default The egg is nowhere close to hatching.
  42. *
  43. * @param Third Egg Text
  44. * @desc Egg description of egg near hatching
  45. * @default The egg moves occasionally.
  46. *
  47. * @param Fourth Egg Text
  48. * @desc Egg description of egg very close to hatching.
  49. * @default Sounds can be heard inside!
  50. *
  51. * @param Monster Races
  52. * @desc List of races and there egg Icon index,and steps to hatch, each separated by a comma.
  53. * @default Dragon,150,10,Elf,160,50
  54. *
  55. * @param Breeding Pairs
  56. * @desc List of monsters that can breed with each other.
  57. * @default {"Dragon":"Elf","Elf":"Dragon,Elf"}
  58. *
  59. * @help
  60. * Version 1.0
  61. Note tag <race:Dragon> Everything is case sensitive.
  62. PluginCommand: makeEgg 1 3, where 1 is actor id of the father and 3 is actor id of mother.
  63. *
  64. */

  65. aliasDM_extractSaveContents = DataManager.extractSaveContents;
  66. DataManager.extractSaveContents = function(contents) {
  67. aliasDM_extractSaveContents.call(this,contents)
  68. for(var i = 0; i < $gameSystem.generatedActors.length;i++){
  69. $dataActors.push($gameSystem.generatedActors);
    [*] };
    [*] for(var i = 0; i < $gameSystem.generatedItems.length;i++){
    [*] $dataItems.push($gameSystem.generatedItems);
    [*] };
    [*]};
    [*]

    [*]COLD.BREED.Parameters = PluginManager.parameters('BreedingSystem');
    [*]COLD.Param = COLD.Param || {};
    [*]COLD.Param.BSystemStatsIncrease = Number(COLD.BREED.Parameters['StatsIncrease'] || 10);
    [*]COLD.Param.BSystemAnimation = Number(COLD.BREED.Parameters['Hatch Animation'] || 1);
    [*]COLD.Param.BSystemAnimationR = Number(COLD.BREED.Parameters['Hatch Ani Repeats'] || 2);
    [*]COLD.Param.BSystemFAnimation = Number(COLD.BREED.Parameters['Hatch Final Animation'] || 2);
    [*]COLD.Param.BSystem1Text = COLD.BREED.Parameters['Notification Text'];
    [*]COLD.Param.BSystem2Text = COLD.BREED.Parameters['Second Notification Text'];
    [*]COLD.Param.BSystem3Text = COLD.BREED.Parameters['Third Notification Text'];
    [*]COLD.Param.BSystem1EggText = COLD.BREED.Parameters['First Egg Text'];
    [*]COLD.Param.BSystem2EggText = COLD.BREED.Parameters['Second Egg Text'];
    [*]COLD.Param.BSystem3EggText = COLD.BREED.Parameters['Third Egg Text'];
    [*]COLD.Param.BSystem4EggText = COLD.BREED.Parameters['Fourth Egg Text'];
    [*]COLD.Param.BSystemRaces = COLD.BREED.Parameters['Monster Races'].split(',');
    [*]COLD.Param.BSystemPairs = JSON.parse(COLD.BREED.Parameters['Breeding Pairs']);
    [*]
    [*](function(){
    [*]
    [*] COLD.Param.BSystemConvertedPairs = {};
    [*]

    [*] for(var key in COLD.Param.BSystemPairs) {
    [*] COLD.Param.BSystemConvertedPairs[key] = (COLD.Param.BSystemPairs[key].split(','));
    [*] }
    [*]
    [*] COLD.BREED.storeGenerated = Game_System.prototype.initialize;
    [*] Game_System.prototype.initialize = function() {
    [*] COLD.BREED.storeGenerated.call(this);
    [*] this.generatedActors = [];
    [*] this.generatedItems = [];
    [*] };
    [*]
    [*] var newEgg_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    [*] Game_Interpreter.prototype.pluginCommand = function(command, args) {
    [*] newEgg_pluginCommand.call(this, command, args);
    [*] if (command === "newEgg") {
    [*] COLD.BREED.makeEgg($dataActors[(args[0])], $dataActors[(args[1])]);
    [*] };
    [*] };
    [*]
    [*] COLD.BREED.makeChild = function(egg){
    [*] var mother = $dataActors[egg.meta.mother];
    [*] var father = $dataActors[egg.meta.father];
    [*] var sex = (egg.sex === "female") ? true : false;
    [*]
    [*] child = {
    [*] "id":$dataActors.length,
    [*] "traits":[],
    [*] "initialLevel":1,
    [*] "maxLevel":99,
    [*] "profile":"",
    [*] "mother":{"id":mother.id,"lvl":egg.motherLvl, "stats":egg.motherStats},
    [*] "father":{"id":father.id,"lvl": egg.fatherLvl, "stats":egg.fatherStats},
    [*] "sex":egg.sex,
    [*] "battlerName":(sex) ? mother["battlerName"] : father["battlerName"],
    [*] "characterIndex":(sex) ? mother["characterIndex"]:father["characterIndex"],
    [*] "characterName": (sex) ? mother["characterName"]:father["characterName"],
    [*] "faceIndex":(sex) ? mother["faceIndex"]:father["faceIndex"],
    [*] "faceName":(sex) ? mother["faceName"]:father["faceName"],
    [*] "name":(sex) ? mother["name"]:father["name"],
    [*] "nickname":(sex) ? mother["nickname"]:father["nickname"],
    [*] "note":(sex) ? mother["note"]:father["note"],
    [*] "classId":(sex) ? mother["classId"]:father["classId"],
    [*] "equips": [],
    [*] "intialStatBoost":false
    [*] };
    [*] $dataActors.push(child)
    [*] $gameSystem.generatedActors.push(child);
    [*] return child;
    [*] };
    [*]
    [*] COLD.BREED.makeSex = function(){
    [*] var sex = (Math.random() < 0.5) ? "female":"male";
    [*] return sex;
    [*] };
    [*]
    [*] COLD.BREED.makeEgg = function(father, mother){
    [*]
    [*] if( COLD.Param.BSystemConvertedPairs[mother.meta.race].indexOf(father.meta.race) != -1 ||
    [*] COLD.Param.BSystemConvertedPairs[father.meta.race].indexOf(mother.meta.race) != -1 ||
    [*] father.meta.race == mother.meta.race){
    [*] egg = {"id":null,
    [*] "animationId":120,
    [*] "consumable":false,
    [*] "damage":{"critical":false,"elementId":0,"formula":"0","type":0,"variance":0},
    [*] "steps":0,
    [*] "effects":[{"code":11, "dataId":0, "value1":0, "value2":0}],
    [*] "hitType":0,
    [*] "itypeId":1,
    [*] "name":"Egg",
    [*] "meta":{
    [*] "hatchEgg":true,
    [*] "father" :father.id,
    [*] "mother":mother.id
    [*] },
    [*] "note":"",
    [*] "occasion":0,
    [*] "price":0,
    [*] "repeats":1,
    [*] "scope":0,
    [*] "speed":0,
    [*] "successRate":100,
    [*] "sex":COLD.BREED.makeSex(),
    [*] "motherLvl": mother._level,
    [*] "fatherLvl": father._level,
    [*] "tpGain":0,
    [*] "maxItem":99};
    [*] var iconIfFemale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(mother.meta.race) + 1)];
    [*] var iconIfMale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(father.meta.race) + 1)];
    [*] var stepsIfFemale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(mother.meta.race) + 2)];
    [*] var stepsIfMale = COLD.Param.BSystemRaces[(COLD.Param.BSystemRaces.indexOf(father.meta.race) + 2)];
    [*] egg.stepsToHatch = egg.sex ? stepsIfFemale : stepsIfMale;
    [*] egg["id"] = $dataItems.length;
    [*] egg["description"] = COLD.BREED.hatchStatus(egg);
    [*] egg["iconIndex"] = egg.sex ? iconIfFemale : iconIfMale;
    [*] $dataItems.push(egg);
    [*] $gameSystem.generatedItems.push(egg);
    [*] $gameParty.gainItem($dataItems[egg.id],1);
    [*] };
    [*] };
    [*]
    [*] COLD.BREED.hatchStatus = function(egg){
    [*] var text;
    [*] var progress = egg.steps / egg.stepsToHatch;
    [*] if(progress > 0.75){
    [*] text = COLD.Param.BSystem4EggText;
    [*] }else if(progress > 0.50){
    [*] text = COLD.Param.BSystem3EggText;
    [*] }else if(progress > 0.25){
    [*] text = COLD.Param.BSystem2EggText;
    [*] }else{
    [*] text = COLD.Param.BSystem1EggText;
    [*] }
    [*] egg.description = text;
    [*] }
    [*]
    [*] Object.defineProperties(Game_BattlerBase.prototype, {
    [*] // Maximum Hit Points
    [*] mhp: { get: function() {if(this.hatched == true){
    [*] return Math.round(this.param(0) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(0); }, configurable: true },
    [*] // Maximum Magic Points
    [*] mmp: { get: function() { if(this.hatched == true){
    [*] return Math.round(this.param(1) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(1); }, configurable: true },
    [*] // ATtacK power
    [*] atk: { get: function() { if(this.hatched == true){
    [*] return Math.round(this.param(2) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(2); }, configurable: true },
    [*] // DEFense power
    [*] def: { get: function() { if(this.hatched == true){
    [*] return Math.round(this.param(3) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(3);}, configurable: true },
    [*] // Magic ATtack power
    [*] mat: { get: function() {if(this.hatched == true){
    [*] return Math.round(this.param(4) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(4); }, configurable: true },
    [*] // Magic DeFense power
    [*] mdf: { get: function() { if(this.hatched == true){
    [*] return Math.round(this.param(5) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(5); }, configurable: true },
    [*] // AGIlity
    [*] agi: { get: function() { if(this.hatched == true){
    [*] return Math.round(this.param(6) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(6); }, configurable: true },
    [*] // LUcK
    [*] luk: { get: function() { if(this.hatched == true){
    [*] return Math.round(this.param(7) + COLD.Param.BSystemStatsIncrease);
    [*] }else return this.param(4); }, configurable: true }
    [*] });
    [*]

    [*] COLD.BREED.aliasSMapIsBusy = Scene_Map.prototype.isBusy;
    [*]
    [*] COLD.BREED.newisBusy = function(){
    [*] return $gameMessage.isBusy();
    [*] };
    [*]
    [*] COLD.BREED.changeSMapisBusy = function(value){
    [*] if(value == true){
    [*] Scene_Map.prototype.isBusy = COLD.BREED.newisBusy;
    [*] }else{
    [*] Scene_Map.prototype.isBusy = COLD.BREED.aliasSMapIsBusy;
    [*] };
    [*] };
    [*]
    [*] COLD.BREED.hatchEgg = function(egg){
    [*] var child = this.makeChild(egg);
    [*] COLD.BREED.hatchingActorID = child.id;
    [*] COLD.BREED.hatchEggCurrent = egg;
    [*] $gameParty.gainItem(egg, -1);
    [*] COLD.BREED.changeSMapisBusy(true);
    [*] $gameMessage.add(COLD.Param.BSystem1Text);
    [*] SceneManager.push(COLD.BREED.Scene_Hatch);
    [*] };
    [*]

    [*] COLD.BREED.hatchEggCurrent = null;
    [*] COLD.BREED.hatchingActorID = null;
    [*]
    [*] Game_Party.prototype.increaseSteps = function() {
    [*] this._steps++;
    [*] var items = $gameParty.items().length;
    [*] for(var i = 0; i < items ; i++){
    [*] if($gameParty.items().meta.hatchEgg == true){
    [*] COLD.BREED.hatchStatus($gameParty.items());
    [*] if($gameParty.items().steps >= $gameParty.items().stepsToHatch ){
    [*] COLD.BREED.hatchEgg($gameParty.items());
    [*] break;
    [*] };
    [*] $gameParty.items().steps += 1;
    [*] };
    [*] };
    [*] };
    [*]
    [*] /**
    [*] * Create a scene for hatching.
    [*] */
    [*]

    [*] COLD.BREED.Scene_Hatch = function() {
    [*] this.initialize.apply(this, arguments);
    [*] }
    [*]

    [*] COLD.BREED.Scene_Hatch.prototype = Object.create(Scene_MenuBase.prototype);
    [*] COLD.BREED.Scene_Hatch.prototype.constructor = COLD.BREED.Scene_Hatch;
    [*]

    [*] COLD.BREED.Scene_Hatch.prototype.initialize = function() {
    [*] Scene_MenuBase.prototype.initialize.call(this);
    [*] };
    [*] COLD.BREED.Scene_Hatch.prototype.create = function() {
    [*] Scene_MenuBase.prototype.create.call(this);
    [*] this.createBackground();
    [*] this.createAnimation();
    [*] this.createNewActor();
    [*] this.createWindowLayer();
    [*] this.createAllWindows();
    [*] };
    [*]

    [*] COLD.BREED.Scene_Hatch.prototype.createAllWindows = function() {
    [*] this.createMessageWindow();
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.createMessageWindow = function() {
    [*] this._messageWindow = new Window_Message();
    [*] this.addWindow(this._messageWindow);
    [*] this._messageWindow.subWindows().forEach(function(window) {
    [*] this.addWindow(window);
    [*] }, this);
    [*] };
    [*]

    [*] COLD.BREED.Scene_Hatch.prototype.isBusy = function(){
    [*] return $gameMessage.isBusy();
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.counter = 0;
    [*] COLD.BREED.Scene_Hatch.prototype.startCounter = false;
    [*] COLD.BREED.Scene_Hatch.prototype.startAnimation = false;
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.update = function() {
    [*] Scene_Base.prototype.update.call(this);
    [*] if(this.counter == 0 && this.startCounter == false){
    [*] $gameMessage.add(COLD.Param.BSystem2Text)
    [*] this.startCounter = true;
    [*] this.startAnimation = true;
    [*] };
    [*]
    [*] if(this.startAnimation == true && !this.isBusy()){
    [*] this.activateAnimations()
    [*] this.startAnimation = false;
    [*] };
    [*]
    [*] if(this.startCounter == true && !this.isBusy()){
    [*] if(this.counter == this.hatchTime){
    [*] this.startCounter = false;
    [*] this.bitmap3.opacity = 255;
    [*] var actorId = $gameActors._data.length - 1
    [*] $gameParty.addActor(actorId);
    [*] $gameActors.actor(actorId)["hatched"] = true;
    [*] $gameMessage.add(COLD.Param.BSystem3Text)
    [*] this.activateNameChange();
    [*] }
    [*] this.counter++;
    [*] };
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.createBackground = function() {
    [*] this._backSprite1 = new Sprite(ImageManager.loadBattleback1($gameMap.battleback1Name()));
    [*] this._backSprite2 = new Sprite(ImageManager.loadBattleback2($gameMap.battleback2Name()));
    [*] this.addChild(this._backSprite1);
    [*] this.addChild(this._backSprite2);
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.createNewActor = function() {
    [*] var characterName = $gameActors.actor(COLD.BREED.hatchingActorID)._characterName;
    [*] var characterIndex = $gameActors.actor(COLD.BREED.hatchingActorID)._characterIndex;
    [*] this.bitmap3 = new Sprite(ImageManager.loadCharacter(characterName));
    [*] this.bitmap3.move(Graphics.width / 2 - 24,Graphics.height / 2 -24);
    [*] var n = characterIndex;
    [*] var sx = (n % 4 * 3 + 1) * 48;
    [*] var sy = (Math.floor(n / 4) * 4) * 48;
    [*] this.bitmap3.setFrame(sx, sy, 48, 48);
    [*] this.bitmap3.opacity = 0;
    [*] this.addChild(this.bitmap3);
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.createAnimation = function() {
    [*] this._animation = new Sprite_Base();
    [*] this._animation.x = Graphics.width / 2;
    [*] this._animation.y = Graphics.height / 2;
    [*] this.addChild(this._animation);
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.activateAnimations = function(){
    [*] var animation = $dataAnimations[COLD.Param.BSystemAnimation];
    [*] var finishingAnimation = $dataAnimations[COLD.Param.BSystemFAnimation];
    [*] var animationFrames = animation.frames.length;
    [*] var fAnimationFrames = finishingAnimation.frames.length;
    [*] var repeats = COLD.Param.BSystemAnimationR;
    [*] for(var i = 0; i < repeats; i++){
    [*] this._animation.startAnimation(animation, false, i * animationFrames * 4);
    [*] };
    [*] this._animation.startAnimation(finishingAnimation, false, (4 * repeats * animationFrames))
    [*] this.hatchTime = (4 * repeats * animationFrames) + (4 * fAnimationFrames);
    [*] };
    [*]
    [*] COLD.BREED.Scene_Hatch.prototype.activateNameChange = function(){
    [*] SceneManager.goto(Scene_Name);
    [*] SceneManager.prepareNextScene(COLD.BREED.hatchingActorID, 8);
    [*] COLD.BREED.changeSMapisBusy(false);
    [*] };
    [*]
    [*]})();

 

Rob

Member
If that script woks for you then awesome ;)

*I know what the code means, but how shall I get the game to recognize two creatures picked as parents when in breeding mode?
The code I wrote could be used as a script and called whenever you're ready to breed 2 monsters.

Breeding monsters could be something as simple as the player clicking on a male and then a female and then a "Breed" button. When the player presses the breed button, it calls the script to determine what traits/stats etc the offspring will have. You could also run the script multiple times for twins/triplets etc which can give different results if the parents have different traits/stats.

Also, chance for trait being a variable, how is this going to be implemented?
The first way that springs to mind is an array. You could have just 1 big super array that stores everything from the type of creature, its stats, traits and everything else to have separate arrays that only deal with certain things.

With this type of game it's important to make an excel sheet to track everything (important for me at least!). It's useful to use as a reference guide whilst coding so you don't forget which trait is in which place in the array.

For an example, a trait array could look like this:

Code:
//Each creature could have its own "a_traits" array and each trait will either be True or False.

a_traits[0] = true; //Ice Type
a_traits[1] = false; //Fire Type
a_traits[2] = false; //Earth Type
a_traits[3] = true; //Scaly Skin
The example script I first showed you would compare the arrays of both parents to determine the chance of the child getting a True or False on its own array.

Code:
//Another type of array would store numbers for traits like this:

a_traits_multi[0] = 3; //Number of Eyes
a_traits_multi[1] = 4; //Number of Arms
a_traits_multi[2] = 0.75; //Multiplier to Fire Damage (works as resistance)
a_traits_multi[3] = 120; //Hit Points
For this type of array you could just use the mean of the two parents to determine the child's stats

How you want to store the information and how you want the breeding to work is entirely up to you and making sure everything is written down and easily traced by you will save you a lot of headache later on, especially when the arrays have dozens or even hundreds of variables.

Arrays are great for this kind of thing and I'd also recommend taking a look at data structures (the functions that start with ds_) as they will save you a lot of time when you want to manipulate data. You can do everything that you want without data structures but they can save you a lot of time and I know that if I'd dipped my toe into them before I worked on my slime breeding/fighting game, it would of made things easier.

You can use data structures to sort arrays/data by priority, randomly shuffle them and anything else you can think of.
 

Ciez17

Member
Thanks for all your help so far! As well as your patience. I'd love to find more tutorials on this subject more, but they seem to not exist, or are hidden. :/ Another thing, is it possible to translate that JavaScript into GMS2? I was hoping to learn from it and use that as prototype.
 

Rob

Member
Thanks for all your help so far! As well as your patience. I'd love to find more tutorials on this subject more, but they seem to not exist, or are hidden. :/ Another thing, is it possible to translate that JavaScript into GMS2? I was hoping to learn from it and use that as prototype.
I don't know if it's possible to convert JavaScript into GMS2 but you could always use it as a basis for your own code (try and create similar steps in GMS2).

I'm gonna make a video tutorial on it so I'll post the link when it's done - I'll record on Monday hopefully.
 

Ciez17

Member
I managed to find another example of a breeding system script from a Dragon City wiki. http://dragoncity.wikia.com/wiki/Breeding/System

So hopefully this could help too. Obviously, for my first game I'm not involving everything they have.....yet.

I've also been studying more tutorials in order to familiarize myself with scripts and arrays more. So my knowledge is growing. I take it that the act of breeding two creatures would load a script that runs checks in order to search for what traits (or arrays) the creatures have. Then would randomize from the selection that way? It sounds like what Rob once suggested. I need to look into both lists and scripts more.
 

Ciez17

Member
Also, using FriendlyCosmonaut's Cutscenes Tutorials vids as a basis, could I essentially trigger the breeding script as a cutscene? Or does it involve another way? I'd hate to repeat it more than once, unless I was a special event (assuming it behaves as a true visual cutscene).
 

Ciez17

Member
IMG_7315.JPG As a note, I'm essentially breaking both creatures and in game animals into pieces. In the case of animals, they will ALWAYS have a certain group of locked in features. Like how a snake will always have a long, legless body that has scales with a small head and reptile eyes. Others on the thread before this suggested a tree and that spunds like I'll need nested arrays specifically. As a I'm breaking bodies down, like this:

Heads--->Small, Medium, or Large--->Feathered, furry, fluffy, spiked
(The photo above has all current available features. I might cut out some for simplicity.)

That way, the game can get a specific sprite I made just for that selection, i.e. a small, spiked head. If anyone else is has any questions on what the heck I'm trying to do, so they can help, I'll do my best to answer.

Also, hi Posh Indie!
 
Last edited:
G

Guest User

Guest
I take it that the act of breeding two creatures would load a script that runs checks in order to search for what traits (or arrays) the creatures have. Then would randomize from the selection that way?
yes, this would work. you would pass the parent's trait arrays into the script and have it run through to create a new creature based off the two you already have, then spawn that new creature nearby at a valid location, or w/e it is you will be doing.

Also, using FriendlyCosmonaut's Cutscenes Tutorials vids as a basis, could I essentially trigger the breeding script as a cutscene? Or does it involve another way? I'd hate to repeat it more than once, unless I was a special event (assuming it behaves as a true visual cutscene).
it can be done this way or any other way you can come up with. off the top of my head...
full-on cutscenes every time you breed a monster will likely get tiresome and repetative as you've already figured out, so it's definitely not advised unless there's a good reason for it. another option would be to only have the cutscene play the very first time, so the player doesn't miss any visual cues that signify a successful breeding, and after that they can simply identify their success and move on to other things or stick around and watch whatever animations you've come up with for the event. or you can skip the cutscene completely and just have the monsters play their animations, without ever forcing the player to sit there and wait.
 

Posh Indie

That Guy
Also, hi Posh Indie!
Hey there! The topic of this thread is way too vast and has infinite possibilities of implementation.

I can give some constructive criticism, though: Your rough document shows the right idea with breaking things up by physical part, but there are some glaring design issues I would resolve if I were you.
  1. I noticed you have the leg length tied to the "body" part. You should probably rethink that and make it an attribute of the legs.
  2. The "mouth" part seems to cover too many things. You could easily split that up and make your life a lot easier in the future as combinations increase.
That said, I would also rethink how the "head" parts are composed. Currently, the setup only allows for distinct materials on the heads, whereas if the heads were shape based, and material was an additional layer of genetics you would allow yourself more combinations with less overall work.

The hard part about combination based games (games involving genetics, games like Alchemy, etc) is that for every trait you add the combinations increase dramaticly. You want to plan around this to reduce redundant and excessive work. Games based on genetics are even harder because optimally you are going to want to allow any combination to feasibly happen (Whereas in games like Alchemy, non-combinations are part of the aggrava-er... "fun"... haha). You are opening the full can of worms in 2D since you want body parts to be involved in the equation. What if you want arbitrary number of legs or arms? What if you want uniquely shaped bodies? How will every other part interact with one another in these situations? Will the parts look awkward in any of these cases? How you handle these situations (And many others) now will determine how much you hate your past self in the future.
 

Rob

Member
Looking forward to it! :)
It's getting late here so I won't be posting today. I've done 80% of the work though, just the video editing to do ;) It's longer than I expected but if you already know the things that I'm drivelling on about then you can skip it obviously.
 

Ciez17

Member
Hey there! The topic of this thread is way too vast and has infinite possibilities of implementation.

I can give some constructive criticism, though: Your rough document shows the right idea with breaking things up by physical part, but there are some glaring design issues I would resolve if I were you.
  1. I noticed you have the leg length tied to the "body" part. You should probably rethink that and make it an attribute of the legs.
  2. The "mouth" part seems to cover too many things. You could easily split that up and make your life a lot easier in the future as combinations increase.
That said, I would also rethink how the "head" parts are composed. Currently, the setup only allows for distinct materials on the heads, whereas if the heads were shape based, and material was an additional layer of genetics you would allow yourself more combinations with less overall work.

The hard part about combination based games (games involving genetics, games like Alchemy, etc) is that for every trait you add the combinations increase dramaticly. You want to plan around this to reduce redundant and excessive work. Games based on genetics are even harder because optimally you are going to want to allow any combination to feasibly happen (Whereas in games like Alchemy, non-combinations are part of the aggrava-er... "fun"... haha). You are opening the full can of worms in 2D since you want body parts to be involved in the equation. What if you want arbitrary number of legs or arms? What if you want uniquely shaped bodies? How will every other part interact with one another in these situations? Will the parts look awkward in any of these cases? How you handle these situations (And many others) now will determine how much you hate your past self in the future.
1. I totally agree and have even come up with some "rules" to program when I can in order to prevent complications. Believe it or not, I'm trying to keep things simple, but I guess I'll have to cut it down some more. I figured the mouth section was a bit clunky. So I guess I could reorganize that, maybe break the fangs/tongues into another array. I could program a "check" that could sort things out better.

2. When I make the sprites, I have multiple bases for each part including bodies. In order to get the right height of the body/sprite, I find the leg length instead of the other way around as I thought it would prevent more issues. Sort of building from the ground up. I have thought of multiple parts like limbs and I could implement that. In hindsight, I guess I could've done something simpler, but I'm merely working on a prototype now. So the max legs are just four.

It's getting late here so I won't be posting today. I've done 80% of the work though, just the video editing to do ;) It's longer than I expected but if you already know the things that I'm drivelling on about then you can skip it obviously.
No such thing as learning too much! Thanks for taking the time to film!
 
Last edited:

Ciez17

Member
I just remembered the game Hybrid Animals and how they handle differing body types and mixing them. Maybe this can help?
 

Rob

Member
So I finally finished the video... it's a little long but it's not very code heavy, it's mainly type then explain, type then explain.
 

Ciez17

Member
Bless you from the top of your head to the soles of your feet! This was SO helpful and extremely easy to follow! I'm totally using this as a backbone for my projects. I look forward to the next one! Cheers mate!
 

Rob

Member
Bless you from the top of your head to the soles of your feet! This was SO helpful and extremely easy to follow! I'm totally using this as a backbone for my projects. I look forward to the next one! Cheers mate!
I'm amazed you made it through the whole thing lol. I think I'll do a short video covering the basics of arrays and make_colour_rgb and then just do the next video with minimal explanation - the idea being to reduce the length of the vid
 

Ciez17

Member
Oh, I don't mind the video length. I spend more time watching tutorials than coding anyway. ;) BTW:

1. How much trouble would it cause if I made seperate sprites for the physical traits? Like each eye was a sprite. Because I want to one day animate some movement (idle bobbing, eye blinking, etc). I'm pretty sure it would take a bit more coding as I'd have to code a way for the program to call a specific sprite.

2. Another goal I'd like to work towards is getting the game to recognize a trait, and have a chance to apply it to various places.

For example: Parent 1 has feathers. Meaning the child already has a 50% chance of getting feathers anywhere else on their body. The "irandom_range" function is definitely going to come handy ror the following. Taking that already 50% chance, let's say I have another roll of 16. If a range of (0, 4) is rolled they get a feathered head. If a range of (5, 8) is rolled they get feathered legs. (9, 12) gets a feathered body. (13, 16) gets a feathered tail.

But of course I'd have the feathered bits separated from the other body bits. The only things is, would I have to assume a "phantom trait"? Like instead of assigned a particular feather body part, would I have to rope them all under a blanket term to better access them?

Looking forward to your next video!
 

Rob

Member
Well there's nothing stopping you separating the graphics and having them blink, it's just more work. I'd highly recommend getting the game into a functional state before going overboard with the graphical work though, that's just my opinion though ;)

The next video I post will explain arrays and you'll see how you can put all the sprites into arrays and access them when needed.
 

Ciez17

Member
Just finished making my own game of your vid. It's essentially the same with 72 x 72 sprites and different colors and art; but all is running just as smoothly as yours!

Sorry if the pic is crappy.

FirstGameScreenshot.JPG
 

Ciez17

Member
I just discovered a glitch where I try to breed using the same two parents or reuse the current selection of monsters, the children just stack onto each other. Now, I know I need to insert a destroy/clean up event, but where exactly?
 

Rob

Member
Yeah it's more of a "Feature" for now. What we really want is some kind of storage facility to store the monsters after breeding. Adding that in to the first vid would make it way too long I think. It's something that will be covered in subsequent videos though.

I just uploaded a short video about arrays a while ago which will be helpful in understanding what's going on in part 2!

I think part 3 will cover taking the game forward from where it's at.

 

Ciez17

Member
Yay! Part 2! Out of curiosity, are you from the U.K.? I noticed your accent and the way you spell "color". It'd also explain our differing timezones.
 

Rob

Member
Yay! Part 2! Out of curiosity, are you from the U.K.? I noticed your accent and the way you spell "color". It'd also explain our differing timezones.
Yeah I'm from the UK but I'm actually living in California atm
 

Ciez17

Member
Awesome! Thanks for uploading! And I like that you included the mistakes because I learn from them too, especially when you explain them. I look forward to your next vid! Also, is it possible to include multiple number ranges for a random roll like: 1-12, 13-24, 25-36, etc?
 
  • Like
Reactions: Rob

Rob

Member
Part 3:

There's no reason why you can't substitute where I've put:

Code:
a_features[i] = irandom(3);
with something like this:

Code:
a_features[i] = irandom_range(12-30);
I've tried to keep things very basic at the moment which I'm sure is throttling your game design. As long as you're keeping track of the size of your arrays, and hat feature goes where then you should be fine!

Part 4 should be pretty short and will just cover adding and removing monsters to storage but part 5 should be a lot more interesting because I want to start taking monsters out into the world beyond and have random encounters. Once that's done, I'll start adding more stats to the monsters and it may include attacks that are based on some features (like a "Gore" attack if the monster has horns).
 

Rob

Member
I cut the video short before getting to the juicy stuff but part 6.... I'm sure I can do it!
 

Rob

Member
Thanks for the help again! I see you've added three more vis on your channel. Keep up the good work.
Thanks Ciez! My intention is to get the series to a level where making a game from it just means adding more content and the "how to's" are mostly eliminated.

This next part is taking me a while for a few reasons and the aim is to tie everything together that we've done so far. Whether that can be achieved in one video remains to be seen!
 

Ciez17

Member
I'm always grateful for your help. Take as much time as you need, as I'm juggling a few things myself. Still looking forward to it!
 

Rob

Member
I'm always grateful for your help. Take as much time as you need, as I'm juggling a few things myself. Still looking forward to it!
Hopefully I'll have a chance to record today as I'll be home alone!

Finding some decent sprites to use was a pain in the bum. If all goes well I'll have something soon!
 

Rob

Member
Still loving the vids! They're helpful as ever. :)
I finally bought a USB hub for my 7 yr old potato. Its USB ports are messed up and I wasn't able to use more than 1 device at a time for the last week or two. This means I now have no excuse not to do the next part whenever I have a room to myself!

The next part will focus on making some of the code better (like room teleports - there's really no need for multiple objects and for bigger projects it would be a nightmare!) and probably some collision detection so you can't walk on top of buildings and walls/roofs that go transparent and draw on top of the player.

Considering I started this tutorial series based on your topic, I'd really welcome some more suggestions/things you'd like to see. I don't think I have enough ideas for more than 1/2 more episodes of it!
 

Ciez17

Member
Hey! First off sorry for not keeping in touch more. College started and I'm juggling some things. Second, I'll rewatch the series and see what can be added. Thank you SO much for all your hard work and your patience! I truly do treasure this since it's such a rare topic in the GMS community.
 

Rob

Member
I've kinda been sidetracked these last few weeks working on an RPG and I have some more footage to upload - collisions finally. I much prefer how I did collision and movement in my rpg game though so I wanna do a video on that afterwards.

[Edit] I uploaded the collisions video and I've just recorded capturing monsters - it's about six lines of code lol.
I'm just thinking about how to incorporate levelling into the game. I think we'll go for just a basic increase in stats and then wok out some way to learn new abilities etc.

What do you think?
 
Last edited:

Ciez17

Member
1. After looking at what you've already done, I must say you did a great job in covering a lot of basics and extras. Even
2. Can we try a more sophisticated feeding system? One thing I struggle with wrapping my head around still, is getting food to be recognized and having it improve health/stats.
 
Top