From cb5e8dd8e708a8f6b966b73b9e2c2853ae11a149 Mon Sep 17 00:00:00 2001 From: Pregmodder <pregmodder@gmail.com> Date: Fri, 11 May 2018 15:43:26 -0400 Subject: [PATCH] Initial identical twins generation --- devNotes/VersionChangeLog-Premod+LoliMod.txt | 9 +++++ src/js/wombJS.tw | 40 ++++++++++++++++++-- src/pregmod/csec.tw | 20 +++++++++- src/pregmod/widgets/seBirthWidgets.tw | 22 ++++++++++- 4 files changed, 84 insertions(+), 7 deletions(-) diff --git a/devNotes/VersionChangeLog-Premod+LoliMod.txt b/devNotes/VersionChangeLog-Premod+LoliMod.txt index 57ccadd175d..d14b2d97c4e 100644 --- a/devNotes/VersionChangeLog-Premod+LoliMod.txt +++ b/devNotes/VersionChangeLog-Premod+LoliMod.txt @@ -2,6 +2,15 @@ 0.10.7.1-0.1.x +5/10/2018 + + 93 + -fixes to vector art and potential custom image issues in RESS + -fixes + + 91 - 92 + -more tweaks to anon's quick find slave index ui + 5/08/2018 90 diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index a261844a97d..0727794d917 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -23,6 +23,7 @@ $children = WombBirth($slave, $birth_ready_age) - for actual birth. Return array WombFlush($slave) - clean womb (array). Can be used at broodmother birthstorm or abortion situations in game. But birthstorm logically should use WombBirth($slave, 35) or so before - some children in this event is live capable, others is not. $slave.bellyPreg = WombGetWolume($slave) - return double, with current womb volume in CC - for updating $slave.bellyPreg, or if need to update individual fetuses sizes. + */ window.WombInit = function(actor) //Init womb system. @@ -86,6 +87,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) tf.fatherID = fatherID; //We can store who is father too. tf.sex = Math.round(Math.random())+1; // 1 = male, 2 = female. For possible future usage, just as concept now. tf.volume = 1; //Initial, to create property. Updated with actual data after WombGetVolume call. + tf.indentical = 0; //Initial, to create property. Updated with actual data during fetalSplit call. try { if (actor.womb.length == 0) @@ -124,7 +126,7 @@ window.WombProgress = function(actor, ageToAdd) window.WombBirth = function(actor, readyAge) { try{ - actor.womb.sort(function (a, b){return b.age - a.age}); //For normal processing fetuses that more old should be first. Now - they are. + WombSort(actor); //For normal processing fetuses that more old should be first. Now - they are. }catch(err){ WombInit(actor); alert("WombBirth warning - " + actor.slaveName+" "+err); @@ -214,7 +216,7 @@ window.WombGetVolume = function(actor) //most code from pregJS.tw with minor ada window.WombUpdatePregVars = function(actor) { - actor.womb.sort(function (a, b){return b.age - a.age}); + WombSort(actor); if (actor.womb.length > 0) { if (actor.preg > 0 && actor.womb[0].age > 0) @@ -232,7 +234,7 @@ window.WombUpdatePregVars = function(actor) { window.WombMinPreg = function(actor) { - actor.womb.sort(function (a, b){return b.age - a.age}); + WombSort(actor); if (actor.womb.length > 0) return actor.womb[actor.womb.length-1].age; @@ -242,7 +244,7 @@ window.WombMinPreg = function(actor) window.WombMaxPreg = function(actor) { - actor.womb.sort(function (a, b){return b.age - a.age}); + WombSort(actor); if (actor.womb.length > 0) return actor.womb[0].age; else @@ -325,3 +327,33 @@ window.WombZeroID = function(actor, id) WombNormalizePreg(actor); } + +/* Sorts the womb object by age with oldest and thus soonest to be born, first. This will be needed in the future once individual fertilization is a possiblity.*/ +window.WombSort = function(actor) +{ + actor.womb.sort(function (a, b){return b.age - a.age}); +} + +window.fetalSplit = function(actor) +{ + var i, ft, nft; + + try{ + for (i in actor.womb) + { + ft = actor.womb[i]; + if (jsRandom(1,1000) == 1000 && ft.indentical !== 1) + nft = {}; + nft.age = ft.age; + nft.fatherID = ft.fatherID; + nft.sex = ft.sex; + nft.volume = ft.volume; + actor.womb.push(nft); + ft.indentical = 1; + } + WombNormalizePreg(actor); + }catch(err){ + WombInit(actor); + alert("no fetus count warning - " + actor.slaveName + " " + err); + } +} diff --git a/src/pregmod/csec.tw b/src/pregmod/csec.tw index bef18c32d15..5063f6fed9b 100644 --- a/src/pregmod/csec.tw +++ b/src/pregmod/csec.tw @@ -114,9 +114,27 @@ Performing a cesarean section is trivial for the remote surgery to carry out. $a <<set _incubated = 1>> <</if>> <<set $mom = $activeSlave>> + <<set _indenticalChildGen = 0>> <<for _cb = 0; _cb < _cToIncub; _cb++>> /* if there is no reserved children, code in loop will not trigger */ - <<include "Generate Child">> + <<if _indenticalChildGen == 0>> + <<if _cb == $mom.curBabies.length-1 && $mom.curBabies.length > 1 && $mom.curBabies[_cb].identical == 1>> /* catch for improperly placed indentical twin flag to still generate*/ + <<set _twin = clone($activeSlave)>> + <<set $activeSlave = _twin>> + <<set $activeSlave.ID = $IDNumber++>> + <<else>> + <<include "Generate Child">> + <</if>> + <<else>> + <<set _twin = clone($activeSlave)>> + <<set $activeSlave = _twin>> + <<set $activeSlave.ID = $IDNumber++>> + <</if>> <<include "Incubator Workaround">> + <<if $mom.curBabies[_cb].identical === 1>> + <<set _indenticalChildGen = 1>> + <<else>> + <<set _indenticalChildGen = 0>> + <</if>> <<set $mom.curBabies.shift()>> /*for now child generation method for incubator not changed. But here children for incubator removed from array of birthed babies. If we decide later - we can use them for incubator as real objects here. For now they just discarded silently */ <<set $reservedChildren-- >> <</for>> diff --git a/src/pregmod/widgets/seBirthWidgets.tw b/src/pregmod/widgets/seBirthWidgets.tw index 937bfc86946..7878f88e59f 100644 --- a/src/pregmod/widgets/seBirthWidgets.tw +++ b/src/pregmod/widgets/seBirthWidgets.tw @@ -767,11 +767,29 @@ All in all, <<set $slaves[$i].reservedChildren = 0, _cToIncub = _curBabies>> <</if>> <<set $mom = $slaves[$i]>> + <<set _indenticalChildGen = 0>> <br><br> Of $possessive _curBabies child<<if $slaves[$i].pregType > 1>>ren<</if>>; _cToIncub <<if $slaves[$i].reservedChildren > 1>>were<<else>>was<</if>> taken to $incubatorName. - <<for _k = _cToIncub; _k != 0; _k-->> - <<include "Generate Child">> + <<for _k = 0; _k < _cToIncub; _k-->> + <<if _indenticalChildGen == 0>> + <<if _k == $slaves[$i].curBabies.length-1 && $slaves[$i].curBabies.length > 1 && $slaves[$i].curBabies[_k].identical == 1>> /* catch for improperly placed indentical twin flag to still generate*/ + <<set _twin = clone($activeSlave)>> + <<set $activeSlave = _twin>> + <<set $activeSlave.ID = $IDNumber++>> + <<else>> + <<include "Generate Child">> + <</if>> + <<else>> + <<set _twin = clone($activeSlave)>> + <<set $activeSlave = _twin>> + <<set $activeSlave.ID = $IDNumber++>> + <</if>> <<include "Incubator Workaround">> + <<if $slaves[$i].curBabies[_k].identical === 1>> + <<set _indenticalChildGen = 1>> + <<else>> + <<set _indenticalChildGen = 0>> + <</if>> <<set $slaves[$i].curBabies.shift()>> /*for now child generation metod for incubator not changed. But here children for incubator removed from array of birthed babies. If we decide later - we can use them for incubator as real objects here. For now they just discarded silently */ <</for>> <<set _curBabies = $slaves[$i].curBabies.length>> -- GitLab