User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1765
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1765
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1765
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1760
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1760
User prompt
Please fix the bug: 'VillagerConversation is not defined' in or related to this line: 'VillagerConversation.prototype.initiateConversation = function (villager, otherVillager) {' Line Number: 1616
User prompt
reduce the size of the code a lot with optimisation
User prompt
reduce the size of the code with great optimisation
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1760
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1760
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 1760
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 3050
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2395
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2385
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2385
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2375
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2370
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2370
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2365
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2360
User prompt
Please fix the bug: 'TypeError: villager.initiateConversation is not a function' in or related to this line: 'villager.initiateConversation(otherVillager);' Line Number: 2355
===================================================================
--- original.js
+++ change.js
@@ -1168,20 +1168,8 @@
self.iq = iq;
self.mood = 'flirty';
self.flirtiness = 0;
self.psychopathy = 0;
- self.moveTowardsTarget = function (targetX, targetY) {
- var dx = targetX - this.x;
- var dy = targetY - this.y;
- var distance = Math.hypot(dx, dy);
- if (distance > this.speed) {
- this.x += dx / distance * this.speed;
- this.y += dy / distance * this.speed;
- } else {
- this.x = targetX;
- this.y = targetY;
- }
- };
LK.setInterval(function () {
game.villagers.forEach(function (villager) {
if (villager.behaviorManager && villager.behaviorManager instanceof VillagerBehaviorManager) {
villager.behaviorManager._update_migrated();
@@ -1213,23 +1201,8 @@
speechBubble.destroy();
}, 3000);
}
};
- Villager.prototype.talkTo = function (otherVillager) {
- if (otherVillager && otherVillager instanceof Villager) {
- var message = this.conversationStarters['flirty'][Math.floor(Math.random() * this.conversationStarters['flirty'].length)];
- var speechBubble = new Text2(message, {
- size: 50,
- fill: 0xFFFFFF
- });
- speechBubble.x = (this.x + otherVillager.x) / 2;
- speechBubble.y = (this.y + otherVillager.y) / 2;
- this.parent.addChild(speechBubble);
- LK.setTimeout(function () {
- speechBubble.destroy();
- }, 3000);
- }
- };
});
var VillagerBehavior = Container.expand(function (villager) {
var self = Container.call(this);
self.villager = villager;
@@ -1307,10 +1280,76 @@
var VillagerBehaviorManager = Container.expand(function (villager) {
var self = Container.call(this);
self.villager = villager;
self.decideNextAction = function () {
- self.villager.behavior.decideNextAction();
+ if (!self.cachedNeeds || !self.cachedActions || LK.ticks % 10 === 0) {
+ self.cachedNeeds = self.calculateNeeds();
+ self.cachedActions = self.defineActions();
+ }
+ var needs = self.cachedNeeds;
+ var actions = self.cachedActions;
+ var highestPriorityAction = Object.entries(needs).filter(function (_ref) {
+ var _ref2 = _slicedToArray(_ref, 2),
+ _ = _ref2[0],
+ needMet = _ref2[1];
+ return needMet;
+ }).map(function (_ref3) {
+ var _ref4 = _slicedToArray(_ref3, 2),
+ need = _ref4[0],
+ _ = _ref4[1];
+ return need;
+ }).shift();
+ if (highestPriorityAction) {
+ var _self$villager$speech;
+ (_self$villager$speech = self.villager.speechBubble) === null || _self$villager$speech === void 0 || _self$villager$speech.destroy();
+ self.villager.speechBubble = null;
+ actions[highestPriorityAction]();
+ } else {
+ actions['wander']();
+ }
};
+ self.calculateNeeds = function () {
+ return {
+ 'rest': self.villager.energy < 20 || self.villager.tiredness >= 80,
+ 'work': self.villager.energy >= 20 && self.villager.workplace && self.villager.tiredness < 80,
+ 'food': self.villager.gameResources.food.amount < 20,
+ 'wood': self.villager.gameResources.wood.amount < 20,
+ 'rock': self.villager.gameResources.rock.amount < 20
+ };
+ };
+ self.defineActions = function () {
+ return {
+ 'rest': function rest() {
+ self.villager.targetX = self.villager.home.x;
+ self.villager.targetY = self.villager.home.y;
+ self.villager.state = 'goingHomeToRest';
+ },
+ 'work': function work() {
+ self.villager.targetX = self.villager.workplace.x;
+ self.villager.targetY = self.villager.workplace.y;
+ self.villager.state = 'goingToWork';
+ },
+ 'food': function food() {
+ self.villager.state = 'seekingFood';
+ },
+ 'wood': function wood() {
+ self.villager.state = 'seekingWood';
+ },
+ 'rock': function rock() {
+ self.villager.state = 'seekingRock';
+ },
+ 'trade': function trade() {
+ self.villager.state = 'trading';
+ self.villager.targetX = self.villager.marketplace.x;
+ self.villager.targetY = self.villager.marketplace.y;
+ },
+ 'wander': function wander() {
+ self.villager.targetX = Math.random() * 2048;
+ self.villager.targetY = Math.random() * 2732;
+ self.villager.state = 'wandering';
+ }
+ };
+ };
self._update_migrated = function () {
self.villager.buildHome();
};
});
@@ -1548,15 +1587,8 @@
if (Array.isArray(arr)) {
return arr;
}
}
-VillagerConversation.prototype.initiateConversation = function (villager, otherVillager) {
- villager.speed = 0;
- LK.setTimeout(function () {
- villager.speed = villager.baseSpeed;
- }, 1000);
-};
-Lumberjack.prototype.initiateConversation = function (message, otherLumberjack) {};
game.weatherSystem = new WeatherSystem();
ResourceDisplay.prototype.positionDisplays = function () {
this.woodDisplay.position.set(100, 50);
this.rockDisplay.position.set(300, 50);
A background of a paysage with plain and without tree or montainbut no water see from the top in the air 100m by 100m Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One human medieval villager in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a house in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree a rock and crambery in a RTS style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A heart comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cloud in a comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A market in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An Inn in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An school in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An bakery in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A well in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An apple in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A rock in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A home in a RTS and fantasy style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A brewery in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lumberjack in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a marketplace in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a festival in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.