function createCharacters(playerStartingPositions, game) { var characters = new Array(); for(var i = 0;i=LEVEL_EXPERIENCE[this.level-1]) { // this.experience-=LEVEL_EXPERIENCE[this.level-1]; while(this.experience>=this.experienceToLevelUp) { this.experience-=this.experienceToLevelUp; // console.log("experience: " + this.experience); this.levelUp(map); } // } } this.levelUp = function(map) { this.level++; // increase HP, MP, etc. /* if (this.max_mp == 0) { this.max_hp += 4; this.hp += Math.max(4,this.max_hp/2); if (this.hp>=this.max_hp) this.hp = this.max_hp; } else { this.max_hp += 3; this.max_mp += 2; this.hp += 3; this.mp = this.max_mp; this.hp += Math.max(3,this.max_hp/2); if (this.hp>=this.max_hp) this.hp = this.max_hp; } this.attack++; this.defense++; */ for(var key in this.levelupadd) { var v = parseStringValue(this.levelupadd[key]); if (key=="hp") { this.max_hp+=v; this.hp += Math.floor(this.max_hp/2); if (this.hp>=this.max_hp) this.hp = this.max_hp; } else if (key=="mp") { this.max_mp+=v; this.hp += Math.floor(this.max_hp/2); if (this.mp>=this.max_mp) this.mp = this.max_mp; } else { this[key]+=v; } } for(var key in this.levelupmultiply) { this[key] *= parseStringValue(this.levelupmultiply[key]); var v = parseStringValue(this.levelupmultiply[key]); if (key=="hp") { this.max_hp = Math.floor(this.max_hp*v); this.hp += Math.floor(this.max_hp/2); if (this.hp>=this.max_hp) this.hp = this.max_hp; } else if (key=="mp") { this.max_mp = Math.floor(this.max_mp*v);; this.mp += Math.floor(this.max_mp/2); if (this.mp>=this.max_mp) this.mp = this.max_mp; } else { this[key] = Math.floor(this[key]*v);; } } map.pushTextOverlay("Level up!", this.x, this.y, 255,255,0); } this.update = function(character, map, game) { if (this.onStart.length>0) { var retVal = executeRuleEffect(this.onStart[0], this, map, game, null); if (retVal!=undefined) this.onStart.splice(0,1); } var old_state = this.state; var ret_val = PlayerCharacter.prototype.update.call(this, character, map, game); if (this.state==0 && old_state==1) { // check for messages: var msg = map.getMessage(this.x,this.y); if (msg!=null) { if (msg.bubble) { map.pushTextBubble(msg.text, this, 200); } game.pushMessage(msg.text); if (!msg.repeat) map.removeMessage(msg); if (msg.topic!=null) { game.conversationTopics.push([msg.topic,msg.topictext]); } } // check for triggers: var trigger = map.getTrigger(this.x,this.y); if (trigger!=null) { for(var i = 0;i0) { var retVal = executeRuleEffect(this.scriptsToExecute[0], this, map, game, null); if (retVal!=undefined) this.scriptsToExecute.splice(0,1); } return ret_val; } // Given another 'character' returns the available set of talk performatives to interact with him/her this.availableTalkPerformatives = function(character, map, game) { var performatives = []; performatives.push({type:TALK_HI, target:character}); performatives.push({type:TALK_BYE, target:character}); // No/yes should only be available if the character just asked a question: // ... // performatives.push({type:TALK_YES, target:character}); // performatives.push({type:TALK_NO, target:character}); performatives.push({type:TALK_TRADE, target:character}); for(var i=0;i