User prompt
Replace the entire `getFixedLoot` function with this version that only handles normal difficulty safely: function getFixedLoot(mapNumber, difficulty, index) { var rarity = getMapRarity(mapNumber); if (difficulty === 'normal') { var orderKey = 'map' + mapNumber + '_normal_order'; var entryOrder = gameData.dungeonEntryOrder[orderKey] || []; var entryPosition = entryOrder.indexOf(index); if (entryPosition === 0) { return { type: 'boots', rarity: rarity }; } if (entryPosition === 1) { return { type: 'gloves', rarity: rarity }; } return null; } return null; }
Code edit (1 edits merged)
Please save this source code
User prompt
} else if (difficulty === 'normal') { // Loot based on entry order, not dungeon index var orderKey = 'map' + mapNumber + '_normal_order'; var entryOrder = gameData.dungeonEntryOrder[orderKey] || []; var entryPosition = entryOrder.indexOf(index); if (entryPosition === 0) { return { type: 'boots', rarity: rarity }; } if (entryPosition === 1) { return { type: 'gloves', rarity: rarity }; } // Third normal dungeon entered has no drop } else if (difficulty === 'hard') { // Loot based on entry order, not dungeon index var orderKey = 'map' + mapNumber + '_hard_order'; var entryOrder = gameData.dungeonEntryOrder[orderKey] || []; var entryPosition = entryOrder.indexOf(index); if (entryPosition === 0) { return { type: 'armor', rarity: rarity }; } if (entryPosition === 1) { return { type: 'ring', rarity: rarity }; kodları değiş alttaki kodlarla } else if (difficulty === 'normal') { // Loot based on entry order, not dungeon index var orderKey = 'map' + mapNumber + '_normal_order'; var entryOrder = gameData.dungeonEntryOrder[orderKey] || []; var entryPosition = entryOrder.indexOf(index); // Güvenlik: Ayakkabı asset'i tanımlı mı? var hasBootsAsset = LK.assets['boots'] !== undefined; var hasGlovesAsset = LK.assets['gloves'] !== undefined; if (entryPosition === 0 && hasBootsAsset) { return { type: 'boots', rarity: rarity }; } else if (entryPosition === 0 && !hasBootsAsset) { console.log("HATA: 'boots' asseti tanımlı değil!"); } if (entryPosition === 1 && hasGlovesAsset) { return { type: 'gloves', rarity: rarity }; } else if (entryPosition === 1 && !hasGlovesAsset) { console.log("HATA: 'gloves' asseti tanımlı değil!"); } // Eğer asset yoksa veya bilinmeyen pozisyon varsa loot verme return null;
Code edit (3 edits merged)
Please save this source code
User prompt
normal modda loot vermeyi kaldır
Code edit (2 edits merged)
Please save this source code
User prompt
restart butonu oyunu komple 0 dan başlatsın her şeyi 0 lasın ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
easy zindanlar geçildikten sonra oyun devam ediyor overworlde geçiş yapıyor item düştüyse gösteriyor ama normal mod zindanda düşmanlar bittikten sonra item düştüyse götermiyor ve overworlde devam etmiyor zindanın içinde takılı kalıyor
User prompt
normal mod zindandaki düşmanlar bittikten sonra overworlde devam etmiyor.ve düşen eşyayı karaktere işlemiyor. Lütfen bu sorunları düzelt
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.dungeonEntryOrder = gameData.dungeonEntryOrder;' Line Number: 1474 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
zindan içinde bazı düşmanlar farklı y kordinatında oldukları için ana karakterden hasar vermiyor.Hasar verme mantığını aynı x kordinatına denk geldiğinde ana karakter ile zindan içinde gelen düşman ; o zaman düşman hasar versin olarak değiştir.
User prompt
zindan içinde bazı düşmanlar farklı x kordinatında oldukları için ana karakterden hasar vermiyor.Hasar verme mantığını aynı y kordinatına denk geldiğinde ana karakter ile zindan içinde gelen düşman ; o zaman düşman hasar versin olarak değiştir.
Code edit (1 edits merged)
Please save this source code
User prompt
Common items give between 1–19 health, 1–9 damage, and 1–4 defense. Rare items give between 20–49 health, 7–19 damage, and 4–9 defense. Epic items give between 50–79 health, 15–29 damage, and 10–17 defense. Legendary items give between 79–179 health, 29–59 damage, and 17–29 defense. itemlerin random olarak verebileceği bonus aralığını bu şekilde değiştir
User prompt
sağ alttak stat textin y kordinatını 40 birim yukarıda gözükücek şekilde değiştir , ve arkasındaki statspanel in boyunu ona göre ayarla
User prompt
sağ altaki stat pointlerin olduğu yere her level seviyemizden dolayı kazandığımız bonuslarda yazılsın itemlerin verdiği bonuslar gibi örnek level 5;(her levelda kazandığı toplam ne ise ) , ona göre stat arkaplan görsel boyunu ve yerini tekrar düzenle sağ alt tarafta gözükecek şekilde
User prompt
sağ altaki stat pointlerin olduğu yere her level seviyemizden dolayı kazandığımız bonuslarda yazılsın itemlerin verdiği bonuslar gibi
User prompt
ch23 assetli düşmanların öldükten sonra verdiği her xp levvel barda gösterilsin ve ona göre artsın
User prompt
ch23 assetli düşmanlar her öldüğünde 1 exp versin
User prompt
zindanlardaki level barı ve textini overworldde sol altta gözükecek şekilde ekle
User prompt
enemytank assetli düşmanların y kordinatını 200 birim aşağıda gözükecek şekilde değiş
User prompt
enemyarcher assetli düşmanların y kordinatını 100 birim aşağıda gözükecek şekilde değiş
User prompt
enemyfast assetli düşmanların y kordinatını 130 birim yukarda gözükücek şekilde değiştir
User prompt
ch23 assetli canavarlar overworldde daha sık ortaya çıksın
User prompt
bazen overworlde öldürülen ch23 assetli her canavar can değerini 1 birim yenilemiyor bu sorunu düzelt her öldürülen ch23 assetli canavar 1 birim can yenilesin
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Arrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.velocityX = 1; // Default rightward direction
self.velocityY = 0;
self.target = null; // For homing behavior
self.isHoming = false; // Flag to enable homing
self.update = function () {
if (self.isHoming && self.target && self.target.parent) {
// Homing behavior for overworld combat
var dx = self.target.x - self.x;
var dy = self.target.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.velocityX = dx / distance * self.speed;
self.velocityY = dy / distance * self.speed;
}
}
// Move arrow
self.x += self.velocityX;
self.y += self.velocityY;
// Rotate arrow to face direction of movement
arrowGraphics.rotation = Math.atan2(self.velocityY, self.velocityX);
};
return self;
});
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
// Character stats
self.level = 1;
self.experience = 0;
self.health = 100;
self.maxHealth = 100;
self.damage = 12;
self.defense = 0;
// Equipment slots
self.equipment = {
helmet: null,
boots: null,
armor: null,
bow: null,
necklace: null,
ring: null,
gloves: null
};
self.calculateStats = function () {
self.maxHealth = 100 + self.level * 10;
self.damage = 12 + self.level * 2;
self.defense = 0 + self.level * 1;
// Add equipment bonuses
for (var slot in self.equipment) {
if (self.equipment[slot]) {
var item = self.equipment[slot];
self.maxHealth += item.healthBonus || 0;
self.damage += item.damageBonus || 0;
self.defense += item.defenseBonus || 0;
}
}
if (self.health > self.maxHealth) {
self.health = self.maxHealth;
}
// Update health bar if it exists
if (typeof updateHealthBar === 'function') {
updateHealthBar();
}
};
self.gainExperience = function (amount) {
self.experience += amount;
var levelUpThreshold = self.level * 100;
if (self.experience >= levelUpThreshold) {
self.level++;
self.experience -= levelUpThreshold;
self.calculateStats();
self.health = self.maxHealth;
LK.getSound('levelUp').play();
}
// Update level bar if in combat
if (currentState === 'combat') {
updateLevelBar();
}
};
return self;
});
var Dungeon = Container.expand(function (difficulty, index) {
var self = Container.call(this);
var dungeonGraphics = self.attachAsset('dungeon', {
anchorX: 0.5,
anchorY: 0.5
});
self.difficulty = difficulty;
self.index = index;
self.isHovered = false;
// Difficulty colors
var colors = {
easy: 0x90EE90,
normal: 0xFFD700,
hard: 0xFF8C00,
veryHard: 0xFF4500
};
dungeonGraphics.tint = colors[difficulty];
// Add difficulty text
var difficultyNames = {
easy: 'EASY',
normal: 'NORMAL',
hard: 'HARD',
veryHard: 'VERY HARD'
};
var difficultyText = new Text2(difficultyNames[difficulty], {
size: 50,
fill: 0xFFFFFF
});
difficultyText.anchor.set(0.5, 1);
difficultyText.x = 0;
difficultyText.y = -80;
self.addChild(difficultyText);
self.down = function (x, y, obj) {
// Track entry order for normal and hard dungeons
if (difficulty === 'normal' || difficulty === 'hard') {
var orderKey = 'map' + currentMap + '_' + difficulty + '_order';
// Ensure gameData exists and is an object
if (!gameData || _typeof(gameData) !== 'object') {
gameData = {};
}
// Ensure gameData.dungeonEntryOrder exists as an object
if (!gameData.dungeonEntryOrder || _typeof(gameData.dungeonEntryOrder) !== 'object') {
gameData.dungeonEntryOrder = {};
}
// Ensure the specific order key exists as an array - with additional safety checks
try {
if (!gameData.dungeonEntryOrder[orderKey] || !Array.isArray(gameData.dungeonEntryOrder[orderKey])) {
gameData.dungeonEntryOrder[orderKey] = [];
}
// Add this dungeon index to entry order if not already present
if (gameData.dungeonEntryOrder[orderKey].indexOf(index) === -1) {
gameData.dungeonEntryOrder[orderKey].push(index);
}
} catch (e) {
// Fallback: reinitialize dungeonEntryOrder if there's any error
gameData.dungeonEntryOrder = {};
gameData.dungeonEntryOrder[orderKey] = [index];
}
}
currentState = 'combat';
currentDungeon = self;
setupCombat();
};
return self;
});
var Enemy = Container.expand(function (difficulty, enemyType) {
var self = Container.call(this);
// Select appropriate asset based on enemy type
var assetName = 'enemyBasic'; // default
if (enemyType === 'basic') {
assetName = 'enemyBasic';
} else if (enemyType === 'fast') {
assetName = 'enemyFast';
} else if (enemyType === 'tank') {
assetName = 'enemyTank';
} else if (enemyType === 'archer') {
assetName = 'enemyArcher';
} else if (enemyType === 'boss') {
assetName = 'enemyBoss';
}
var enemyGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.enemyType = enemyType || 'basic';
self.difficulty = difficulty;
// Base stats for different enemy types
var enemyStats = {
basic: {
health: 50,
speed: 1.6,
tint: 0xFFFFFF,
experience: 10,
damage: 20
},
fast: {
health: 30,
speed: 2.4,
tint: 0x00FF00,
experience: 15,
damage: 20
},
tank: {
health: 80,
speed: 1,
tint: 0xFF0000,
experience: 25,
damage: 30
},
archer: {
health: 40,
speed: 3,
tint: 0x0000FF,
experience: 20,
damage: 50
},
boss: {
health: 400,
speed: 1,
tint: 0xFF00FF,
experience: 50,
damage: 100
}
};
var stats = enemyStats[self.enemyType];
var healthMultiplier = {
easy: 1,
normal: 2,
hard: 4,
veryHard: 8
};
self.maxHealth = stats.health * healthMultiplier[difficulty];
self.health = self.maxHealth;
self.speed = stats.speed;
self.experienceReward = stats.experience;
self.damage = stats.damage;
// Apply visual tint based on enemy type
enemyGraphics.tint = stats.tint;
self.update = function () {
self.x -= self.speed;
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.die();
}
};
self.die = function () {
LK.getSound('enemyDeath').play();
playerCharacter.gainExperience(self.experienceReward);
};
return self;
});
var LootItem = Container.expand(function (type, rarity, x, y) {
var self = Container.call(this);
var lootGraphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.type = type;
self.rarity = rarity;
// Rarity colors
var rarityColors = {
common: 0x808080,
rare: 0x4169e1,
epic: 0x8a2be2,
legendary: 0xffd700
};
lootGraphics.tint = rarityColors[rarity];
// Generate random stats based on rarity with specific ranges
var statRanges = {
common: {
health: {
min: 1,
max: 19
},
damage: {
min: 1,
max: 9
},
defense: {
min: 1,
max: 4
}
},
rare: {
health: {
min: 20,
max: 49
},
damage: {
min: 7,
max: 19
},
defense: {
min: 4,
max: 9
}
},
epic: {
health: {
min: 50,
max: 79
},
damage: {
min: 15,
max: 29
},
defense: {
min: 10,
max: 17
}
},
legendary: {
health: {
min: 79,
max: 179
},
damage: {
min: 29,
max: 59
},
defense: {
min: 17,
max: 29
}
}
};
var ranges = statRanges[rarity];
self.healthBonus = Math.floor(Math.random() * (ranges.health.max - ranges.health.min + 1)) + ranges.health.min;
self.damageBonus = Math.floor(Math.random() * (ranges.damage.max - ranges.damage.min + 1)) + ranges.damage.min;
self.defenseBonus = Math.floor(Math.random() * (ranges.defense.max - ranges.defense.min + 1)) + ranges.defense.min;
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
collectLoot(self);
};
return self;
});
var OverworldMonster = Container.expand(function () {
var self = Container.call(this);
var monsterGraphics = self.attachAsset('ch23', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 1;
self.maxHealth = 1;
self.speed = 4; // Slow movement
self.lastX = 0;
self.lastY = 0;
self.update = function () {
// Track last position for collision detection
self.lastX = self.x;
self.lastY = self.y;
// Move slowly towards player
var dx = playerCharacter.x - self.x;
var dy = playerCharacter.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.die();
}
};
self.die = function () {
LK.getSound('enemyDeath').play();
playerCharacter.gainExperience(1);
// Update level bar if in overworld
if (currentState === 'overworld') {
updateLevelBar();
}
// Always heal player by 1 health point when ch23 monster dies, but don't exceed max health
if (playerCharacter.health < playerCharacter.maxHealth) {
playerCharacter.health += 1;
}
// Update health display every time a monster dies
if (typeof updateHealthBar === 'function') {
updateHealthBar();
}
if (healthText && healthText.parent) {
healthText.setText('Health: ' + playerCharacter.health + '/' + playerCharacter.maxHealth);
}
// Store monster position for ring drop
var monsterX = self.x;
var monsterY = self.y;
// Ring drop chances
var randomChance = Math.random();
if (randomChance < 0.000001) {
// 0.00000001 chance for legendary ring
createRingDrop('legendary', monsterX, monsterY);
} else if (randomChance < 0.00001) {
// 0.0000001 chance for epic ring
createRingDrop('epic', monsterX, monsterY);
} else if (randomChance < 0.0001) {
// 0.000001 chance for rare ring
createRingDrop('rare', monsterX, monsterY);
} else if (randomChance < 0.001) {
// 0.00001 chance for common ring
createRingDrop('common', monsterX, monsterY);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Sounds
// UI assets
// Loot assets
// Combat assets
// Character and world assets
// Game state
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
var currentState = 'overworld'; // 'overworld', 'combat', 'inventory'
var currentMap = 1;
var currentDungeon = null;
var playerCharacter = new Character();
var dungeons = [];
var arrows = [];
var enemies = [];
var lootItems = [];
var overworldMonsters = [];
var lastEnemySpawn = 0;
var lastArrowShot = 0;
var lastOverworldMonsterSpawn = 0;
var lastOverworldArrowShot = 0;
var combatTimer = 0;
var enemiesKilled = 0;
var targetKills = 15;
var totalEnemiesSpawned = 0;
var maxEnergy = 5;
var currentEnergy = 5;
var energyRegenTimer = 1;
var energyRegenDelay = 50; // 0.3 seconds at 60fps
var isRegeneratingEnergy = false;
var wasEnergyDepleted = false;
var energyBar = null;
var energyBarBg = null;
var levelBarBg = null;
var levelBarFill = null;
var experienceText = null;
var levelBarText = null;
var pendingNotifications = [];
var notificationTimer = 0;
var currentNotification = null;
var healthBar = null;
var healthBarBg = null;
var healthBarText = null;
// Aiming system variables
var isAiming = false;
var aimStartX = 0;
var aimStartY = 0;
var aimLine = null;
var maxAimDistance = 300;
// UI elements
var levelText = new Text2('Level: 1', {
size: 40,
fill: 0xFFFFFF
});
var healthText = new Text2('Health: 100/100', {
size: 40,
fill: 0xFFFFFF
});
var backButton = null;
var statsPanel = null;
var statsText = null;
// Initialize storage with defaults
var gameData = {
level: storage.level || 1,
experience: storage.experience || 0,
equipment: {
helmet: null,
boots: null,
armor: null,
bow: null,
necklace: null,
ring: null,
gloves: null
},
unlockedMaps: storage.unlockedMaps || 1,
completedDungeons: storage.completedDungeons || {},
givenLoot: storage.givenLoot || {},
dungeonEntryOrder: storage.dungeonEntryOrder || {}
};
// Load equipment from storage
if (storage.equipmentHelmetType) {
gameData.equipment.helmet = {
type: storage.equipmentHelmetType,
rarity: storage.equipmentHelmetRarity,
healthBonus: storage.equipmentHelmetHealthBonus,
damageBonus: storage.equipmentHelmetDamageBonus,
defenseBonus: storage.equipmentHelmetDefenseBonus
};
}
if (storage.equipmentBootsType) {
gameData.equipment.boots = {
type: storage.equipmentBootsType,
rarity: storage.equipmentBootsRarity,
healthBonus: storage.equipmentBootsHealthBonus,
damageBonus: storage.equipmentBootsDamageBonus,
defenseBonus: storage.equipmentBootsDefenseBonus
};
}
if (storage.equipmentArmorType) {
gameData.equipment.armor = {
type: storage.equipmentArmorType,
rarity: storage.equipmentArmorRarity,
healthBonus: storage.equipmentArmorHealthBonus,
damageBonus: storage.equipmentArmorDamageBonus,
defenseBonus: storage.equipmentArmorDefenseBonus
};
}
if (storage.equipmentBowType) {
gameData.equipment.bow = {
type: storage.equipmentBowType,
rarity: storage.equipmentBowRarity,
healthBonus: storage.equipmentBowHealthBonus,
damageBonus: storage.equipmentBowDamageBonus,
defenseBonus: storage.equipmentBowDefenseBonus
};
}
if (storage.equipmentNecklaceType) {
gameData.equipment.necklace = {
type: storage.equipmentNecklaceType,
rarity: storage.equipmentNecklaceRarity,
healthBonus: storage.equipmentNecklaceHealthBonus,
damageBonus: storage.equipmentNecklaceDamageBonus,
defenseBonus: storage.equipmentNecklaceDefenseBonus
};
}
if (storage.equipmentRingType) {
gameData.equipment.ring = {
type: storage.equipmentRingType,
rarity: storage.equipmentRingRarity,
healthBonus: storage.equipmentRingHealthBonus,
damageBonus: storage.equipmentRingDamageBonus,
defenseBonus: storage.equipmentRingDefenseBonus
};
}
if (storage.equipmentGlovesType) {
gameData.equipment.gloves = {
type: storage.equipmentGlovesType,
rarity: storage.equipmentGlovesRarity,
healthBonus: storage.equipmentGlovesHealthBonus,
damageBonus: storage.equipmentGlovesDamageBonus,
defenseBonus: storage.equipmentGlovesDefenseBonus
};
}
// Load saved data
playerCharacter.level = gameData.level;
playerCharacter.experience = gameData.experience;
playerCharacter.equipment = gameData.equipment;
playerCharacter.calculateStats();
// Update character appearance based on loaded equipment
updateCharacterAppearance();
// Load dungeon progression
gameData.completedDungeons = storage.completedDungeons || {};
gameData.givenLoot = storage.givenLoot || {};
currentMap = storage.unlockedMaps || 1;
// Setup overworld
function setupOverworld() {
game.removeChildren();
// Add background
var background = game.attachAsset('mapBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Add character at center
playerCharacter.x = 1024;
playerCharacter.y = 1366;
game.addChild(playerCharacter);
// Create health bar above character
createHealthBar();
// Create stats panel in bottom-right corner
createStatsPanel();
// Create dungeons in isometric grid
dungeons = [];
var allDifficulties = ['easy', 'easy', 'easy', 'easy', 'normal', 'normal', 'normal', 'hard', 'hard', 'veryHard'];
// Function to check if position is valid (at least 300 units away from existing dungeons and 300 from player)
function isValidPosition(x, y, existingDungeons) {
// Check distance from player starting position (1024, 1366)
var playerStartX = 1024;
var playerStartY = 1366;
var distanceFromPlayer = Math.sqrt(Math.pow(x - playerStartX, 2) + Math.pow(y - playerStartY, 2));
if (distanceFromPlayer < 300) {
return false;
}
// Check distance from existing dungeons using Euclidean distance
for (var i = 0; i < existingDungeons.length; i++) {
var dx = x - existingDungeons[i].x;
var dy = y - existingDungeons[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 300) {
return false;
}
}
return true;
}
// Create all 10 dungeons but control their interaction based on progression
var difficultyIndices = {
easy: 0,
normal: 0,
hard: 0,
veryHard: 0
};
for (var i = 0; i < allDifficulties.length; i++) {
var difficulty = allDifficulties[i];
var dungeonIndex = difficultyIndices[difficulty];
var completedCount = getCompletedDungeonsForDifficulty(currentMap, difficulty);
var isUnlocked = isDifficultyUnlocked(currentMap, difficulty);
var isCompleted = dungeonIndex < completedCount;
// Skip creating completed dungeons (they should disappear)
if (isCompleted) {
difficultyIndices[difficulty]++;
continue;
}
var dungeon = new Dungeon(difficulty, dungeonIndex);
difficultyIndices[difficulty]++;
// Apply visual effects based on lock status
if (!isUnlocked) {
// Dim locked dungeons
dungeon.children[0].tint = 0x666666;
dungeon.children[0].alpha = 0.5;
// Disable interaction for locked dungeons
dungeon.down = null;
}
// Find valid position with minimum distance requirement
var validPosition = false;
var attempts = 0;
while (!validPosition && attempts < 100) {
var testX = 150 + Math.random() * (2048 - 300); // 150 to 1898
var testY = 400 + Math.random() * (2732 - 800); // 400 to 2332
if (isValidPosition(testX, testY, dungeons)) {
dungeon.x = testX;
dungeon.y = testY;
validPosition = true;
}
attempts++;
}
// If no valid position found after 100 attempts, place anyway
if (!validPosition) {
dungeon.x = 150 + Math.random() * (2048 - 300);
dungeon.y = 400 + Math.random() * (2732 - 800);
}
dungeons.push(dungeon);
game.addChild(dungeon);
}
// Add level bar UI to overworld
levelBarBg = game.attachAsset('levelBarBg', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 2600
});
levelBarFill = game.attachAsset('levelBarFill', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 2600
});
experienceText = new Text2('XP: 0/100', {
size: 30,
fill: 0xFFFFFF
});
experienceText.x = 50;
experienceText.y = 2630;
game.addChild(experienceText);
// Add level text below the level bar
levelBarText = new Text2('Level: ' + playerCharacter.level, {
size: 30,
fill: 0xFFFFFF
});
levelBarText.x = 50;
levelBarText.y = 2660;
game.addChild(levelBarText);
updateLevelBar();
// Add UI
levelText.setText('Level: ' + playerCharacter.level);
levelText.x = 50;
levelText.y = 150;
game.addChild(levelText);
// Add map indicator
var mapText = new Text2('Map: ' + currentMap + ' (' + getMapRarity(currentMap) + ')', {
size: 40,
fill: 0xFFFFFF
});
mapText.x = 50;
mapText.y = 100;
game.addChild(mapText);
healthText.setText('Health: ' + playerCharacter.health + '/' + playerCharacter.maxHealth);
healthText.x = 50;
healthText.y = 200;
game.addChild(healthText);
// Add restart admin button
var restartButton = game.attachAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 - 100,
y: 100
});
}
// Setup combat
function setupCombat() {
game.removeChildren();
// Add combat background
var combatBg = game.attachAsset('combatBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Position character fixed on left side for side-scrolling
playerCharacter.x = 200;
playerCharacter.y = 1866;
game.addChild(playerCharacter);
// Create health bar above character
createHealthBar();
// Add back button
backButton = game.attachAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 50
});
// Reset combat variables
arrows = [];
enemies = [];
lootItems = [];
overworldMonsters = [];
lastEnemySpawn = 0;
lastArrowShot = 0;
lastOverworldMonsterSpawn = 0;
lastOverworldArrowShot = 0;
combatTimer = 0;
enemiesKilled = 0;
targetKills = 15;
totalEnemiesSpawned = 0;
// Add energy bar UI
energyBarBg = game.attachAsset('energyBarBg', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 2000
});
energyBar = game.attachAsset('energyBar', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 2000
});
// Reset energy system
currentEnergy = maxEnergy;
energyRegenTimer = 1;
isRegeneratingEnergy = false;
wasEnergyDepleted = false;
updateEnergyBar();
// Add level bar UI
levelBarBg = game.attachAsset('levelBarBg', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 2050
});
levelBarFill = game.attachAsset('levelBarFill', {
anchorX: 0,
anchorY: 0,
x: 50,
y: 2050
});
experienceText = new Text2('XP: 0/100', {
size: 30,
fill: 0xFFFFFF
});
experienceText.x = 50;
experienceText.y = 2080;
game.addChild(experienceText);
// Add level text below the level bar
levelBarText = new Text2('Level: ' + playerCharacter.level, {
size: 30,
fill: 0xFFFFFF
});
levelBarText.x = 50;
levelBarText.y = 2110;
game.addChild(levelBarText);
updateLevelBar();
// Add UI
updateCombatUI();
}
function updateEnergyBar() {
if (energyBar) {
var energyPercentage = currentEnergy / maxEnergy;
energyBar.width = 300 * energyPercentage;
// Change color based on energy level
if (energyPercentage > 0.6) {
energyBar.tint = 0xFFD700; // Green
} else if (energyPercentage > 0.3) {
energyBar.tint = 0xffff00; // Yellow
} else {
energyBar.tint = 0xff0000; // Red
}
}
}
function updateLevelBar() {
if (levelBarFill && experienceText) {
var levelUpThreshold = playerCharacter.level * 100;
var experiencePercentage = playerCharacter.experience / levelUpThreshold;
levelBarFill.width = 400 * experiencePercentage;
// Update experience text
experienceText.setText('XP: ' + playerCharacter.experience + '/' + levelUpThreshold);
// Update level text
if (levelBarText) {
levelBarText.setText('Level: ' + playerCharacter.level);
}
}
}
function updateHealthBar() {
if (healthBar && healthBarText) {
var healthPercentage = playerCharacter.health / playerCharacter.maxHealth;
healthBar.width = 200 * healthPercentage;
healthBarText.setText(playerCharacter.health + '/' + playerCharacter.maxHealth);
}
}
function createStatsPanel() {
if (statsPanel) {
statsPanel.destroy();
}
if (statsText) {
statsText.destroy();
}
// Create stats panel in bottom-right corner - enlarged to accommodate level bonuses
statsPanel = game.attachAsset('statsPanel', {
anchorX: 1,
anchorY: 1,
x: 2048 - 20,
y: 2732 - 20,
scaleX: 1.2,
scaleY: 1.6
});
// Calculate total bonuses from equipment
var totalHealthBonus = 0;
var totalDamageBonus = 0;
var totalDefenseBonus = 0;
for (var slot in playerCharacter.equipment) {
if (playerCharacter.equipment[slot]) {
var item = playerCharacter.equipment[slot];
totalHealthBonus += item.healthBonus || 0;
totalDamageBonus += item.damageBonus || 0;
totalDefenseBonus += item.defenseBonus || 0;
}
}
// Calculate level bonuses
var levelHealthBonus = playerCharacter.level * 10;
var levelDamageBonus = playerCharacter.level * 2;
var levelDefenseBonus = playerCharacter.level * 1;
// Create stats text with both equipment and level bonuses
var statsContent = 'Equipment Bonuses:\n' + 'Health: +' + totalHealthBonus + '\n' + 'Damage: +' + totalDamageBonus + '\n' + 'Defense: +' + totalDefenseBonus + '\n\n' + 'Level ' + playerCharacter.level + ' Bonuses:\n' + 'Health: +' + levelHealthBonus + '\n' + 'Damage: +' + levelDamageBonus + '\n' + 'Defense: +' + levelDefenseBonus;
statsText = new Text2(statsContent, {
size: 28,
fill: 0xFFFFFF
});
statsText.anchor.set(0.5, 0.5);
statsText.x = 2048 - 260;
statsText.y = 2732 - 180;
game.addChild(statsText);
}
function createHealthBar() {
if (healthBarBg) {
healthBarBg.destroy();
}
if (healthBar) {
healthBar.destroy();
}
if (healthBarText) {
healthBarText.destroy();
}
// Create health bar background
healthBarBg = game.attachAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5,
x: playerCharacter.x,
y: playerCharacter.y - 130
});
// Create health bar fill
healthBar = game.attachAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5,
x: playerCharacter.x,
y: playerCharacter.y - 130
});
// Create health text
healthBarText = new Text2(playerCharacter.health + '/' + playerCharacter.maxHealth, {
size: 30,
fill: 0xFFFFFF
});
healthBarText.anchor.set(0.5, 1);
healthBarText.x = playerCharacter.x;
healthBarText.y = playerCharacter.y - 150;
game.addChild(healthBarText);
updateHealthBar();
}
function updateCombatUI() {
if (levelText.parent) {
levelText.parent.removeChild(levelText);
}
if (healthText.parent) {
healthText.parent.removeChild(healthText);
}
levelText.setText('Level: ' + playerCharacter.level);
levelText.x = 50;
levelText.y = 150;
game.addChild(levelText);
healthText.setText('Health: ' + playerCharacter.health + '/' + playerCharacter.maxHealth);
healthText.x = 50;
healthText.y = 200;
game.addChild(healthText);
// Update level bar
updateLevelBar();
}
function collectLoot(loot) {
// Equip the item
playerCharacter.equipment[loot.type] = loot;
playerCharacter.calculateStats();
// Update character appearance
updateCharacterAppearance();
// Update stats panel if in overworld
if (currentState === 'overworld') {
createStatsPanel();
}
// Remove from game
loot.destroy();
var index = lootItems.indexOf(loot);
if (index > -1) {
lootItems.splice(index, 1);
}
// Save game data
saveGameData();
updateCombatUI();
}
function getMapRarity(mapNumber) {
var rarities = ['common', 'rare', 'epic', 'legendary'];
return rarities[Math.min(mapNumber - 1, 3)];
}
function getDungeonProgressionKey(mapNumber, difficulty) {
return 'map' + mapNumber + '_' + difficulty;
}
function getCompletedDungeonsForDifficulty(mapNumber, difficulty) {
var key = getDungeonProgressionKey(mapNumber, difficulty);
return gameData.completedDungeons[key] || 0;
}
function isDifficultyUnlocked(mapNumber, difficulty) {
if (difficulty === 'easy') {
return true;
}
if (difficulty === 'normal') {
return getCompletedDungeonsForDifficulty(mapNumber, 'easy') >= 4;
}
if (difficulty === 'hard') {
return getCompletedDungeonsForDifficulty(mapNumber, 'normal') >= 3;
}
if (difficulty === 'veryHard') {
return getCompletedDungeonsForDifficulty(mapNumber, 'hard') >= 2;
}
return false;
}
function completeDungeon(mapNumber, difficulty, index) {
var key = getDungeonProgressionKey(mapNumber, difficulty);
gameData.completedDungeons[key] = (gameData.completedDungeons[key] || 0) + 1;
// Give fixed loot based on difficulty and completion order
var lootKey = 'map' + mapNumber + '_' + difficulty + '_' + index;
if (!gameData.givenLoot[lootKey]) {
var loot = getFixedLoot(mapNumber, difficulty, index);
if (loot) {
giveLoot(loot.type, loot.rarity);
gameData.givenLoot[lootKey] = true;
// Add notification for awarded item
pendingNotifications.push({
type: loot.type,
rarity: loot.rarity,
message: 'Awarded: ' + loot.rarity + ' ' + loot.type
});
}
}
// Check if we should advance to next map or win the game
if (difficulty === 'veryHard' && getCompletedDungeonsForDifficulty(mapNumber, 'veryHard') >= 1) {
// Map 4 Very Hard completion wins the game
if (mapNumber === 4) {
LK.showYouWin();
return;
}
gameData.unlockedMaps = Math.max(gameData.unlockedMaps, mapNumber + 1);
currentMap = mapNumber + 1;
// Reset dungeon completion and loot tracking for new map
resetMapProgress(mapNumber + 1);
}
saveGameData();
}
function getFixedLoot(mapNumber, difficulty, index) {
var rarity = getMapRarity(mapNumber);
if (difficulty === 'easy') {
// Only 1 of the Easy dungeons drops helmet - use a fixed random selection per map
var helmetKey = 'map' + mapNumber + '_helmet_dungeon';
var helmetDungeonIndex = gameData.givenLoot[helmetKey];
if (helmetDungeonIndex === undefined) {
// First time determining which easy dungeon drops helmet
helmetDungeonIndex = Math.floor(Math.random() * 4);
gameData.givenLoot[helmetKey] = helmetDungeonIndex;
}
if (index === helmetDungeonIndex) {
return {
type: 'helmet',
rarity: rarity
};
}
} else if (difficulty === 'normal') {
// Loot based on entry order, not dungeon index
var orderKey = 'map' + mapNumber + '_normal_order';
var entryOrder = gameData.dungeonEntryOrder[orderKey] || [];
var entryPosition = entryOrder.indexOf(index);
if (entryPosition === 0) {
return {
type: 'boots',
rarity: rarity
};
}
if (entryPosition === 1) {
return {
type: 'gloves',
rarity: rarity
};
}
// Third normal dungeon entered has no drop
} else if (difficulty === 'hard') {
// Loot based on entry order, not dungeon index
var orderKey = 'map' + mapNumber + '_hard_order';
var entryOrder = gameData.dungeonEntryOrder[orderKey] || [];
var entryPosition = entryOrder.indexOf(index);
if (entryPosition === 0) {
return {
type: 'armor',
rarity: rarity
};
}
if (entryPosition === 1) {
return {
type: 'ring',
rarity: rarity
};
}
} else if (difficulty === 'veryHard') {
// VeryHard bow gets higher rarity than map base rarity
var rarities = ['common', 'rare', 'epic', 'legendary'];
var currentIndex = rarities.indexOf(rarity);
var bowRarity = rarities[Math.min(currentIndex + 1, 3)];
return {
type: 'bow',
rarity: bowRarity
};
}
return null;
}
function createRingDrop(rarity, x, y) {
// Create a proper loot item with stats
var statRanges = {
common: {
health: {
min: 1,
max: 19
},
damage: {
min: 1,
max: 9
},
defense: {
min: 1,
max: 4
}
},
rare: {
health: {
min: 20,
max: 49
},
damage: {
min: 7,
max: 19
},
defense: {
min: 4,
max: 9
}
},
epic: {
health: {
min: 50,
max: 79
},
damage: {
min: 15,
max: 29
},
defense: {
min: 10,
max: 17
}
},
legendary: {
health: {
min: 79,
max: 179
},
damage: {
min: 29,
max: 59
},
defense: {
min: 17,
max: 29
}
}
};
var ranges = statRanges[rarity];
var loot = {
type: 'ring',
rarity: rarity,
healthBonus: Math.floor(Math.random() * (ranges.health.max - ranges.health.min + 1)) + ranges.health.min,
damageBonus: Math.floor(Math.random() * (ranges.damage.max - ranges.damage.min + 1)) + ranges.damage.min,
defenseBonus: Math.floor(Math.random() * (ranges.defense.max - ranges.defense.min + 1)) + ranges.defense.min
};
// Create visual loot item at monster death position
var visualLoot = new LootItem('ring', rarity, x, y);
lootItems.push(visualLoot);
game.addChild(visualLoot);
LK.getSound('lootDrop').play();
}
function giveLoot(type, rarity) {
// Create a proper loot item with stats
var statRanges = {
common: {
health: {
min: 1,
max: 19
},
damage: {
min: 1,
max: 9
},
defense: {
min: 1,
max: 4
}
},
rare: {
health: {
min: 20,
max: 49
},
damage: {
min: 7,
max: 19
},
defense: {
min: 4,
max: 9
}
},
epic: {
health: {
min: 50,
max: 79
},
damage: {
min: 15,
max: 29
},
defense: {
min: 10,
max: 17
}
},
legendary: {
health: {
min: 79,
max: 179
},
damage: {
min: 29,
max: 59
},
defense: {
min: 17,
max: 29
}
}
};
var ranges = statRanges[rarity];
var loot = {
type: type,
rarity: rarity,
healthBonus: Math.floor(Math.random() * (ranges.health.max - ranges.health.min + 1)) + ranges.health.min,
damageBonus: Math.floor(Math.random() * (ranges.damage.max - ranges.damage.min + 1)) + ranges.damage.min,
defenseBonus: Math.floor(Math.random() * (ranges.defense.max - ranges.defense.min + 1)) + ranges.defense.min
};
// If we're in overworld and it's a ring, create a visual loot item
if (currentState === 'overworld' && type === 'ring') {
// Find the last killed monster position or use a default position
var dropX = playerCharacter.x + (Math.random() - 0.5) * 200;
var dropY = playerCharacter.y + (Math.random() - 0.5) * 200;
// Create visual loot item
var visualLoot = new LootItem(type, rarity, dropX, dropY);
lootItems.push(visualLoot);
game.addChild(visualLoot);
} else {
// For other cases or when in combat, equip directly
playerCharacter.equipment[type] = loot;
playerCharacter.calculateStats();
// Update character appearance
updateCharacterAppearance();
}
LK.getSound('lootDrop').play();
}
function resetMapProgress(mapNumber) {
// Don't reset progress, just ensure we're tracking the new map
}
function getCharacterAsset() {
// Count equipped gear pieces (excluding necklace and ring)
var hasHelmet = playerCharacter.equipment.helmet !== null;
var hasBoots = playerCharacter.equipment.boots !== null;
var hasGloves = playerCharacter.equipment.gloves !== null;
var hasArmor = playerCharacter.equipment.armor !== null;
var hasBow = playerCharacter.equipment.bow !== null;
// Get helmet rarity (determines the set's base tier)
var helmetRarity = hasHelmet ? playerCharacter.equipment.helmet.rarity : null;
var bowRarity = hasBow ? playerCharacter.equipment.bow.rarity : null;
// If no helmet, use default character
if (!hasHelmet) {
return 'character';
}
// Define rarity levels
var rarityLevels = {
'common': 0,
'rare': 1,
'epic': 2,
'legendary': 3
};
var helmetLevel = rarityLevels[helmetRarity];
var bowLevel = bowRarity ? rarityLevels[bowRarity] : -1;
// Map 1: Common set (helmet=common, bow=rare)
if (helmetLevel === 0) {
if (hasHelmet && !hasBoots && !hasGloves && !hasArmor && !hasBow) {
return 'ch1';
}
if (hasHelmet && hasBoots && !hasGloves && !hasArmor && !hasBow) {
return 'ch2';
}
if (hasHelmet && hasBoots && hasGloves && !hasArmor && !hasBow) {
return 'ch3';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && !hasBow) {
return 'ch4';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && hasBow && bowLevel === 1) {
return 'ch5';
}
}
// Map 2: Rare set (helmet=rare, bow=epic)
if (helmetLevel === 1) {
if (hasHelmet && !hasBoots && !hasGloves && !hasArmor && hasBow && bowLevel === 2) {
return 'ch6';
}
if (hasHelmet && hasBoots && !hasGloves && !hasArmor && hasBow && bowLevel === 2) {
return 'ch7';
}
if (hasHelmet && hasBoots && hasGloves && !hasArmor && hasBow && bowLevel === 2) {
return 'ch8';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && hasBow && bowLevel === 2) {
return 'ch9';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && hasBow && bowLevel === 3) {
return 'ch10';
}
}
// Map 3: Epic set (helmet=epic, bow=legendary)
if (helmetLevel === 2) {
if (hasHelmet && !hasBoots && !hasGloves && !hasArmor && hasBow && bowLevel === 3) {
return 'ch11';
}
if (hasHelmet && hasBoots && !hasGloves && !hasArmor && hasBow && bowLevel === 3) {
return 'ch12';
}
if (hasHelmet && hasBoots && hasGloves && !hasArmor && hasBow && bowLevel === 3) {
return 'ch13';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && hasBow && bowLevel === 3) {
return 'ch14';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && hasBow && bowLevel === 3) {
return 'ch15';
}
}
// Map 4: Legendary set (helmet=legendary, bow=legendary)
if (helmetLevel === 3) {
if (hasHelmet && !hasBoots && !hasGloves && !hasArmor && hasBow && bowLevel === 3) {
return 'ch16';
}
if (hasHelmet && hasBoots && !hasGloves && !hasArmor && hasBow && bowLevel === 3) {
return 'ch17';
}
if (hasHelmet && hasBoots && hasGloves && !hasArmor && hasBow && bowLevel === 3) {
return 'ch18';
}
if (hasHelmet && hasBoots && hasGloves && hasArmor && hasBow && bowLevel === 3) {
return 'ch19';
}
}
// Fallback to default character
return 'character';
}
function updateCharacterAppearance() {
// Get the appropriate asset based on equipment
var assetName = getCharacterAsset();
// Remove current character graphics
if (playerCharacter.children.length > 0) {
playerCharacter.removeChildAt(0);
}
// Add new character graphics
var characterGraphics = playerCharacter.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
}
function showNotification(notification) {
if (currentNotification) {
// Remove existing notification
currentNotification.destroy();
currentNotification = null;
}
// Create notification text
var notificationText = new Text2(notification.message, {
size: 60,
fill: 0xFFFFFF
});
notificationText.anchor.set(0.5, 0.5);
notificationText.x = 1024;
notificationText.y = 400;
// Add background for notification
var notificationBg = game.attachAsset('inventorySlot', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 400,
scaleX: 8,
scaleY: 1.5
});
notificationBg.tint = 0x000000;
notificationBg.alpha = 0.8;
game.addChild(notificationBg);
game.addChild(notificationText);
currentNotification = {
text: notificationText,
bg: notificationBg,
destroy: function destroy() {
if (this.text.parent) {
this.text.parent.removeChild(this.text);
}
if (this.bg.parent) {
this.bg.parent.removeChild(this.bg);
}
}
};
// Auto-remove after 3 seconds
LK.setTimeout(function () {
if (currentNotification) {
currentNotification.destroy();
currentNotification = null;
}
}, 3000);
}
function saveGameData() {
storage.level = playerCharacter.level;
storage.experience = playerCharacter.experience;
storage.unlockedMaps = gameData.unlockedMaps;
storage.completedDungeons = gameData.completedDungeons;
storage.givenLoot = gameData.givenLoot;
storage.dungeonEntryOrder = gameData.dungeonEntryOrder;
// Save equipment properties individually - only save if equipment exists
if (playerCharacter.equipment.helmet) {
storage.equipmentHelmetType = playerCharacter.equipment.helmet.type;
storage.equipmentHelmetRarity = playerCharacter.equipment.helmet.rarity;
storage.equipmentHelmetHealthBonus = playerCharacter.equipment.helmet.healthBonus;
storage.equipmentHelmetDamageBonus = playerCharacter.equipment.helmet.damageBonus;
storage.equipmentHelmetDefenseBonus = playerCharacter.equipment.helmet.defenseBonus;
} else {
storage.equipmentHelmetType = null;
}
if (playerCharacter.equipment.boots) {
storage.equipmentBootsType = playerCharacter.equipment.boots.type;
storage.equipmentBootsRarity = playerCharacter.equipment.boots.rarity;
storage.equipmentBootsHealthBonus = playerCharacter.equipment.boots.healthBonus;
storage.equipmentBootsDamageBonus = playerCharacter.equipment.boots.damageBonus;
storage.equipmentBootsDefenseBonus = playerCharacter.equipment.boots.defenseBonus;
} else {
storage.equipmentBootsType = null;
}
if (playerCharacter.equipment.armor) {
storage.equipmentArmorType = playerCharacter.equipment.armor.type;
storage.equipmentArmorRarity = playerCharacter.equipment.armor.rarity;
storage.equipmentArmorHealthBonus = playerCharacter.equipment.armor.healthBonus;
storage.equipmentArmorDamageBonus = playerCharacter.equipment.armor.damageBonus;
storage.equipmentArmorDefenseBonus = playerCharacter.equipment.armor.defenseBonus;
} else {
storage.equipmentArmorType = null;
}
if (playerCharacter.equipment.bow) {
storage.equipmentBowType = playerCharacter.equipment.bow.type;
storage.equipmentBowRarity = playerCharacter.equipment.bow.rarity;
storage.equipmentBowHealthBonus = playerCharacter.equipment.bow.healthBonus;
storage.equipmentBowDamageBonus = playerCharacter.equipment.bow.damageBonus;
storage.equipmentBowDefenseBonus = playerCharacter.equipment.bow.defenseBonus;
} else {
storage.equipmentBowType = null;
}
if (playerCharacter.equipment.necklace) {
storage.equipmentNecklaceType = playerCharacter.equipment.necklace.type;
storage.equipmentNecklaceRarity = playerCharacter.equipment.necklace.rarity;
storage.equipmentNecklaceHealthBonus = playerCharacter.equipment.necklace.healthBonus;
storage.equipmentNecklaceDamageBonus = playerCharacter.equipment.necklace.damageBonus;
storage.equipmentNecklaceDefenseBonus = playerCharacter.equipment.necklace.defenseBonus;
} else {
storage.equipmentNecklaceType = null;
}
if (playerCharacter.equipment.ring) {
storage.equipmentRingType = playerCharacter.equipment.ring.type;
storage.equipmentRingRarity = playerCharacter.equipment.ring.rarity;
storage.equipmentRingHealthBonus = playerCharacter.equipment.ring.healthBonus;
storage.equipmentRingDamageBonus = playerCharacter.equipment.ring.damageBonus;
storage.equipmentRingDefenseBonus = playerCharacter.equipment.ring.defenseBonus;
} else {
storage.equipmentRingType = null;
}
if (playerCharacter.equipment.gloves) {
storage.equipmentGlovesType = playerCharacter.equipment.gloves.type;
storage.equipmentGlovesRarity = playerCharacter.equipment.gloves.rarity;
storage.equipmentGlovesHealthBonus = playerCharacter.equipment.gloves.healthBonus;
storage.equipmentGlovesDamageBonus = playerCharacter.equipment.gloves.damageBonus;
storage.equipmentGlovesDefenseBonus = playerCharacter.equipment.gloves.defenseBonus;
} else {
storage.equipmentGlovesType = null;
}
}
// Game input handlers
var draggedCharacter = null;
var dragOffset = {
x: 0,
y: 0
};
game.down = function (x, y, obj) {
if (currentState === 'overworld') {
// Check if clicking on restart button (positioned at top right)
if (x >= 2048 - 160 && x <= 2048 - 40 && y >= 70 && y <= 130) {
// Reset all game data
storage.level = 1;
storage.experience = 0;
storage.unlockedMaps = 1;
storage.completedDungeons = {};
storage.givenLoot = {};
storage.dungeonEntryOrder = {};
storage.equipmentHelmetType = null;
storage.equipmentBootsType = null;
storage.equipmentArmorType = null;
storage.equipmentBowType = null;
storage.equipmentNecklaceType = null;
storage.equipmentRingType = null;
storage.equipmentGlovesType = null;
// Reset game state
currentMap = 1;
playerCharacter.level = 1;
playerCharacter.experience = 0;
playerCharacter.health = 100;
playerCharacter.maxHealth = 100;
playerCharacter.equipment = {
helmet: null,
boots: null,
armor: null,
bow: null,
necklace: null,
ring: null,
gloves: null
};
playerCharacter.calculateStats();
gameData.level = 1;
gameData.experience = 0;
gameData.unlockedMaps = 1;
gameData.completedDungeons = {};
gameData.givenLoot = {};
gameData.dungeonEntryOrder = {};
gameData.equipment = playerCharacter.equipment;
setupOverworld();
return;
}
// Check if clicking on character
var localPos = playerCharacter.toLocal({
x: x,
y: y
});
if (localPos.x >= -40 && localPos.x <= 40 && localPos.y >= -40 && localPos.y <= 40) {
draggedCharacter = playerCharacter;
dragOffset.x = x - playerCharacter.x;
dragOffset.y = y - playerCharacter.y;
} else {
// Start aiming in overworld
isAiming = true;
aimStartX = x;
aimStartY = y;
// Create aiming line
aimLine = game.attachAsset('aimLine', {
anchorX: 0.5,
anchorY: 0,
x: playerCharacter.x,
y: playerCharacter.y
});
}
} else if (currentState === 'combat' && backButton) {
// Check if obj and obj.position exist, otherwise use x,y coordinates
var localPos;
if (obj && obj.position) {
localPos = backButton.toLocal(obj.position);
} else {
// Convert game coordinates to local coordinates
localPos = backButton.toLocal({
x: x,
y: y
});
}
if (localPos.x >= -60 && localPos.x <= 60 && localPos.y >= -30 && localPos.y <= 30) {
currentState = 'overworld';
setupOverworld();
} else {
// Start aiming if energy available
var canAim = currentEnergy > 0 && (!wasEnergyDepleted || currentEnergy === maxEnergy);
if (canAim) {
isAiming = true;
aimStartX = x;
aimStartY = y;
// Create aiming line
aimLine = game.attachAsset('aimLine', {
anchorX: 0.5,
anchorY: 0,
x: playerCharacter.x,
y: playerCharacter.y
});
}
}
}
};
game.move = function (x, y, obj) {
if (currentState === 'overworld' && draggedCharacter) {
draggedCharacter.x = x - dragOffset.x;
draggedCharacter.y = y - dragOffset.y;
// Update health bar position
if (healthBarBg) {
healthBarBg.x = draggedCharacter.x;
healthBarBg.y = draggedCharacter.y - 50;
}
if (healthBar) {
healthBar.x = draggedCharacter.x;
healthBar.y = draggedCharacter.y - 50;
}
if (healthBarText) {
healthBarText.x = draggedCharacter.x;
healthBarText.y = draggedCharacter.y - 60;
}
}
// Check for loot hover collection in overworld
if (currentState === 'overworld') {
for (var i = lootItems.length - 1; i >= 0; i--) {
var loot = lootItems[i];
var dx = x - loot.x;
var dy = y - loot.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// If mouse is hovering over loot item (within 40 pixels)
if (distance <= 40) {
// Collect the loot
playerCharacter.equipment[loot.type] = loot;
playerCharacter.calculateStats();
updateCharacterAppearance();
// Update stats panel
createStatsPanel();
// Remove from game
loot.destroy();
lootItems.splice(i, 1);
saveGameData();
break;
}
}
}
// Update aiming line in combat
if (currentState === 'combat' && isAiming && aimLine) {
var dx = x - aimStartX;
var dy = y - aimStartY;
var distance = Math.sqrt(dx * dx + dy * dy);
// Limit aiming distance
if (distance > maxAimDistance) {
dx = dx / distance * maxAimDistance;
dy = dy / distance * maxAimDistance;
distance = maxAimDistance;
}
// Update aim line position and rotation
aimLine.x = playerCharacter.x;
aimLine.y = playerCharacter.y;
aimLine.height = distance;
aimLine.rotation = Math.atan2(dy, dx) + Math.PI / 2;
}
};
game.up = function (x, y, obj) {
if (currentState === 'overworld' && draggedCharacter) {
// Check if character is dropped on any dungeon
for (var i = 0; i < dungeons.length; i++) {
var dungeon = dungeons[i];
if (draggedCharacter.intersects(dungeon)) {
currentState = 'combat';
currentDungeon = dungeon;
setupCombat();
break;
}
}
// Fire arrow in overworld if aiming
if (isAiming) {
// Calculate aim direction and power
var dx = x - aimStartX;
var dy = y - aimStartY;
var distance = Math.sqrt(dx * dx + dy * dy);
// Only fire if there's sufficient drag distance
if (distance > 20) {
// Limit maximum distance for power calculation
if (distance > maxAimDistance) {
dx = dx / distance * maxAimDistance;
dy = dy / distance * maxAimDistance;
distance = maxAimDistance;
}
// Calculate arrow velocity based on aim distance
var power = distance / maxAimDistance;
var baseSpeed = 8;
var arrowSpeed = baseSpeed * (0.5 + power * 0.5);
// Create and fire arrow
var arrow = new Arrow();
arrow.x = playerCharacter.x;
arrow.y = playerCharacter.y;
// Set arrow velocity based on aim direction and power
arrow.velocityX = dx / distance * arrowSpeed;
arrow.velocityY = dy / distance * arrowSpeed;
arrows.push(arrow);
game.addChild(arrow);
LK.getSound('shoot').play();
}
// Clean up aiming
isAiming = false;
if (aimLine) {
aimLine.destroy();
aimLine = null;
}
}
draggedCharacter = null;
} else if (currentState === 'combat' && isAiming) {
// Calculate aim direction and power
var dx = x - aimStartX;
var dy = y - aimStartY;
var distance = Math.sqrt(dx * dx + dy * dy);
// Only fire if there's sufficient drag distance
if (distance > 20) {
// Limit maximum distance for power calculation
if (distance > maxAimDistance) {
dx = dx / distance * maxAimDistance;
dy = dy / distance * maxAimDistance;
distance = maxAimDistance;
}
// Calculate arrow velocity based on aim distance
var power = distance / maxAimDistance;
var baseSpeed = 8;
var arrowSpeed = baseSpeed * (0.5 + power * 0.5); // Speed between 4 and 8
// Create and fire arrow
var arrow = new Arrow();
arrow.x = playerCharacter.x;
arrow.y = playerCharacter.y;
// Set arrow velocity based on aim direction and power
arrow.velocityX = dx / distance * arrowSpeed;
arrow.velocityY = dy / distance * arrowSpeed;
arrows.push(arrow);
game.addChild(arrow);
LK.getSound('shoot').play();
// Consume energy
currentEnergy--;
if (currentEnergy === 0) {
wasEnergyDepleted = true;
}
// Reset regeneration timer
energyRegenTimer = 0;
isRegeneratingEnergy = false;
updateEnergyBar();
}
// Clean up aiming
isAiming = false;
if (aimLine) {
aimLine.destroy();
aimLine = null;
}
}
};
// Main game update loop
game.update = function () {
if (currentState === 'overworld') {
// Process pending notifications
if (pendingNotifications.length > 0 && !currentNotification) {
var notification = pendingNotifications.shift();
showNotification(notification);
}
// Spawn overworld monsters more frequently (every 2 seconds)
if (LK.ticks - lastOverworldMonsterSpawn > 120) {
var monster = new OverworldMonster();
// Initialize targeting flag
monster.hasBeenTargeted = false;
// Spawn at random position around the edges
var spawnSide = Math.floor(Math.random() * 4);
if (spawnSide === 0) {
// Top
monster.x = Math.random() * 2048;
monster.y = 200;
} else if (spawnSide === 1) {
// Right
monster.x = 1900;
monster.y = 200 + Math.random() * 2332;
} else if (spawnSide === 2) {
// Bottom
monster.x = Math.random() * 2048;
monster.y = 2532;
} else {
// Left
monster.x = 100;
monster.y = 200 + Math.random() * 2332;
}
overworldMonsters.push(monster);
game.addChild(monster);
lastOverworldMonsterSpawn = LK.ticks;
}
// Auto-shooting system for overworld monsters
if (LK.ticks - lastOverworldArrowShot > 30) {
// Shoot every 0.5 seconds
// Find closest ch23 enemy within 1000 unit range
var closestMonster = null;
var closestDistance = 1000; // Max range
for (var j = 0; j < overworldMonsters.length; j++) {
var monster = overworldMonsters[j];
var dx = monster.x - playerCharacter.x;
var dy = monster.y - playerCharacter.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= 1000 && distance < closestDistance) {
closestMonster = monster;
closestDistance = distance;
}
}
// Shoot arrow at closest monster
if (closestMonster) {
var arrow = new Arrow();
arrow.x = playerCharacter.x;
arrow.y = playerCharacter.y;
arrow.target = closestMonster;
arrow.isHoming = true;
arrow.speed = 8;
arrows.push(arrow);
game.addChild(arrow);
LK.getSound('shoot').play();
lastOverworldArrowShot = LK.ticks;
}
}
// Update overworld monsters
for (var i = overworldMonsters.length - 1; i >= 0; i--) {
var monster = overworldMonsters[i];
// Check collision with player
if (monster.intersects(playerCharacter)) {
playerCharacter.health -= 10;
monster.destroy();
overworldMonsters.splice(i, 1);
if (playerCharacter.health <= 0) {
LK.showGameOver();
}
// Update health display
healthText.setText('Health: ' + playerCharacter.health + '/' + playerCharacter.maxHealth);
updateHealthBar();
continue;
}
}
// Update arrows in overworld
for (var i = arrows.length - 1; i >= 0; i--) {
var arrow = arrows[i];
// Remove arrows that go off screen
if (arrow.x > 2100 || arrow.x < -100 || arrow.y > 2800 || arrow.y < -100) {
arrow.destroy();
arrows.splice(i, 1);
continue;
}
// Check collision with overworld monsters
for (var j = overworldMonsters.length - 1; j >= 0; j--) {
var monster = overworldMonsters[j];
if (arrow.intersects(monster)) {
monster.takeDamage(playerCharacter.damage);
arrow.destroy();
arrows.splice(i, 1);
if (monster.health <= 0) {
monster.destroy();
overworldMonsters.splice(j, 1);
}
break;
}
}
}
} else if (currentState === 'combat') {
combatTimer++;
// Energy regeneration system
if (currentEnergy < maxEnergy) {
energyRegenTimer++;
if (energyRegenTimer >= energyRegenDelay && !isRegeneratingEnergy) {
isRegeneratingEnergy = true;
}
if (isRegeneratingEnergy) {
// Regenerate energy over time using tween
tween(this, {}, {
duration: 200,
onFinish: function onFinish() {
if (currentEnergy < maxEnergy) {
currentEnergy++;
updateEnergyBar();
// Continue regenerating if not at max
if (currentEnergy < maxEnergy) {
energyRegenTimer = energyRegenDelay;
} else {
isRegeneratingEnergy = false;
wasEnergyDepleted = false; // Reset depletion flag when fully regenerated
}
}
}
});
isRegeneratingEnergy = false;
}
}
// Arrows are now fired on click instead of automatically
// Spawn enemies from right side
if (combatTimer - lastEnemySpawn > 120 && totalEnemiesSpawned < 15) {
// Define enemy types available for each difficulty
var enemyTypesByDifficulty = {
easy: ['basic', 'fast'],
normal: ['basic', 'fast', 'tank'],
hard: ['basic', 'fast', 'tank', 'archer'],
veryHard: ['basic', 'fast', 'tank', 'archer', 'boss']
};
var availableTypes = enemyTypesByDifficulty[currentDungeon.difficulty];
var randomType = availableTypes[Math.floor(Math.random() * availableTypes.length)];
var enemy = new Enemy(currentDungeon.difficulty, randomType);
enemy.x = 1900;
enemy.y = 1800;
// Adjust Y position for enemyFast type enemies
if (randomType === 'fast') {
enemy.y = 1800 - 130;
}
// Adjust Y position for enemyArcher type enemies
if (randomType === 'archer') {
enemy.y = 1800 + 100;
}
// Adjust Y position for enemyTank type enemies
if (randomType === 'tank') {
enemy.y = 1800 + 200;
}
enemies.push(enemy);
game.addChild(enemy);
totalEnemiesSpawned++;
lastEnemySpawn = combatTimer;
}
// Update arrows
for (var i = arrows.length - 1; i >= 0; i--) {
var arrow = arrows[i];
// Remove arrows that go off screen in any direction
if (arrow.x > 2100 || arrow.x < -100 || arrow.y > 2800 || arrow.y < -100) {
arrow.destroy();
arrows.splice(i, 1);
continue;
}
// Check collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (arrow.intersects(enemy)) {
enemy.takeDamage(playerCharacter.damage);
// Add visual feedback with tween
tween(enemy.children[0], {
tint: 0xFF0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(enemy.children[0], {
tint: 0xFFFFFF
}, {
duration: 200
});
}
});
arrow.destroy();
arrows.splice(i, 1);
if (enemy.health <= 0) {
enemy.destroy();
enemies.splice(j, 1);
enemiesKilled++;
// Check win condition
if (totalEnemiesSpawned >= 15 && enemies.length === 0) {
completeDungeon(currentMap, currentDungeon.difficulty, currentDungeon.index);
LK.setTimeout(function () {
currentState = 'overworld';
setupOverworld();
}, 1000);
}
}
break;
}
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.x < -100) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
// Check if enemy and player are at same X coordinate for damage
if (Math.abs(enemy.x - playerCharacter.x) < 50) {
// Allow small tolerance for X coordinate matching
playerCharacter.health -= Math.max(1, enemy.damage - playerCharacter.defense);
enemy.destroy();
enemies.splice(i, 1);
if (playerCharacter.health <= 0) {
playerCharacter.health = 1;
currentState = 'overworld';
setupOverworld();
updateHealthBar();
}
updateCombatUI();
updateHealthBar();
}
}
// Update loot items (simple gravity effect)
for (var i = 0; i < lootItems.length; i++) {
var loot = lootItems[i];
if (loot.y < 1366) {
loot.y += 2;
}
}
}
};
// Initialize the game
setupOverworld(); ===================================================================
--- original.js
+++ change.js
@@ -416,14 +416,14 @@
/****
* Game Code
****/
-// Game state
-// Character and world assets
-// Combat assets
-// Loot assets
-// UI assets
// Sounds
+// UI assets
+// Loot assets
+// Combat assets
+// Character and world assets
+// Game state
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
@@ -1949,10 +1949,11 @@
enemy.destroy();
enemies.splice(i, 1);
continue;
}
- // Check collision with player - only damage if at same Y coordinate
- if (enemy.intersects(playerCharacter) && Math.abs(enemy.y - playerCharacter.y) < 50) {
+ // Check if enemy and player are at same X coordinate for damage
+ if (Math.abs(enemy.x - playerCharacter.x) < 50) {
+ // Allow small tolerance for X coordinate matching
playerCharacter.health -= Math.max(1, enemy.damage - playerCharacter.defense);
enemy.destroy();
enemies.splice(i, 1);
if (playerCharacter.health <= 0) {
arrow. In-Game asset. 2d. High contrast. No shadows
pixel necklace. In-Game asset. 2d. High contrast. No shadows
mağaranın hafif üstünden görünüşü olsun
brown pixel 2dd game boots. In-Game asset. 2d. High contrast. No shadows
pixel brown game helmet. In-Game asset. 2d. High contrast. No shadows
pixel brown gloves. In-Game asset. 2d. High contrast. No shadows
pixel gold ring for 2d game. In-Game asset. 2d. High contrast. No shadows
blue pixel bow for 2d game archer. In-Game asset. 2d. High contrast. No shadows
brown pixel light armor for 2d games. In-Game asset. 2d. High contrast. No shadows
kahve rengi kask ekle karaktere
karaktere kahverengi bot giydir bileklerine kadar
kahverengi eldiven giydir karaktere
kahverengi hafif zırh giydir karaktere
karakter elinde tuttuğu yayı mavi yap
kaskı mavi yap
adamın sadece ayakakbılarını mavi renge çevirir misin
adamın eldivenlerini mavi renge çevirir misin
koyu kahverengi olan bütün zırhı kaskı yayı ayakkabıyı eldiveni mavi renk yapar mısın
yayı parlak mor renk yapar mısın
kaskıda parlak mor renk yapar mısın
ayakkabıları da parlak mor renk yapar mısın
koyu kahverengi olan bütün zırhı kaskı yayı ayakkabıyı eldiveni parlak mor renk yapar mısın
yayı parlak altın rengi yapar mısın
kaskını parlak altın rengine çevirir misin
ayakkabılarını parlak altın rengine çevirir misin
eldivenlerini parlak altın rengine çevirir misin
koyu kahverengi olan bütün zırhını kaskını ayakkabısını eldivenini parlak yayını altın rengine çevirir misin
eldivenlerini parlak mor renk yapar mısın
demon rabbit with red eyes. In-Game asset. 2d. High contrast. No shadows
sağ üst köşeye çevresinde eski tahta çitler olan çok küçük bir köy ekle
sağ üst köşeye bir kasaba ekle
sağ üst köşeye surla çevrili bir şehir ekle
sağ üstteki şehrin grafik açısından boyutunu çok değiştirmeden belki sadece biraz daha uzaktan bakar gibi ama çok daha gelişmiş bir şehre dönüştürür müsün
bu zindan girişini bir tık daha korkutucu göster mesela etrafındaki taşlarında üstünde kemikler en üst ortadaki taşında kemikten bir hayvvan başı gibi
mağaranın grafik ayarları ve boyutunu bozmadan taşların üzerinden lavlar akıyor gibi gözüksün zindan girişinin ortasındada kırmızı korkutucu bir sihirli geçit olsun
zindan girişi taşlarının üstüne mavi maden damarları gibi çizgiler ekle
kemik görünümünde bir kurt. In-Game asset. 2d. High contrast. No shadows
kemikten bir şovalye istiyorum biraz kambur dursun. In-Game asset. 2d. High contrast. No shadows
yıldırımlarla kaplı bir canavar istiyorum hafif kambur duruşlu biraz zombi gibi. In-Game asset. 2d. High contrast. No shadows
lavlarla kaplı bir canavar istiyorum kambur ve biraz iri yapılı. In-Game asset. 2d. High contrast. No shadows
kemikten oluşsun
yıldırımdan bir kartala dönüştür
sağdan sola doğru uçuyor gibi bir görüntü olsun
sağdan sola yürüyen bir cehennem şeytanı. In-Game asset. 2d. High contrast. No shadows
güçlü ve iri yapılı şeytan kral sağdan sola yürüyormuş gibi. In-Game asset. 2d. High contrast. No shadows
ölümsüz kemikler kralı sağdan sola yürüyor gibi. In-Game asset. 2d. High contrast. No shadows
aslan ve insan karışımı yıldırımla kaplı bir canavar kralı sağdan sola yürüyen. In-Game asset. 2d. High contrast. No shadows
Images Sounds Music Images › map1man map1man Size 200 × 200 Aspect Ratio Preserve Aspect Ratio Shape Box Color #365bb5 bastonlu yaşlı uzun sakallı kambur kel bir dede sağdan sola yürüyen üstünde ortaçağ fakir köylerinde köyün muhtarı kıyafeti olsun. In-Game asset. 2d. High contrast. No shadows. In-Game asset. 2d. High contrast. No shadows
şovalye kıyafetli orta yaşlı bir adam belinde kılıcıyla sağdan sola yürür gibi. In-Game asset. 2d. High contrast. No shadows
bir orta çağ şehrinin soylu dükü görünümünde yap orta yaşlarda sağdan solda yürür gibi. In-Game asset. 2d. High contrast. No shadows
bir imparatorluğun kralı , sağdan sola yürür gibi. In-Game asset. 2d. High contrast. No shadows