Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type='text/javascript' src='http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js'></script>
- <style>
- body {
- font-family: "arial";
- font-size: 14;
- color:#FFFFFF;
- }
- </style>
- <!-- The HTML goes here -->
- <div id="Test_Window" class="" style="position:relative; top:0px;; left:0px; width:500px; height:320px; background-color: #43423C;">
- <p style="position:absolute; font-size: 8; left:7px; top: -6px;"><abbr title="Created and managed by Xavion. Created 6/2/13. Last updated 13/2/13.">CREDITS</abbr></p>
- <div id="header" style="text-align: center; height:60px; margin-top:0px;">
- <h4 style="margin-top:0px;">The all purpose spell for any situation<abbr title="Note: Usefulness not guaranteed."><sup style="font-size:8">*</sup></abbr>.</h4>
- </div>
- <form id="Fields" style="float:left; width:250px; height:100px; margin-top: -32px;">
- <div style="display: table; float:left;">
- <!-- The Spell Type Options. Vis:Always -->
- <div id="Type" style="display: table-row; height:22px;" data-bind="visible: visType">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Type
- </span>
- <span style="display: table-cell; float:left;">
- <select style="width:100px;height:20px;" data-bind="options: availableTypes, value: chosenType"></select>
- </span>
- </div>
- <!-- The Elemental Options. Vis:Type==Elemental -->
- <div id="Element" style="display: table-row; height:22px;" data-bind="visible: visElement">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Element
- </span>
- <span style="display: table-cell; float:left;">
- <select style="width:100px;height:20px;" data-bind="options: availableElements, value: chosenElement"></select>
- </span>
- </div>
- <div id="Form" style="display: table-row; height:22px;" data-bind="visible: visForm">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Form
- </span>
- <span style="display: table-cell; float:left;">
- <select style="width:100px;height:20px;" data-bind="options: availableForms, value: chosenForm"></select>
- </span>
- </div>
- <!-- The Illusion Options. Vis:Type==Illusion -->
- <div id="Illusion" style="display: table-row; height:22px;" data-bind="visible: visIllusion">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Illusion
- </span>
- <span style="display: table-cell; float:left;">
- <select style="width:100px;height:20px;" data-bind="options: availableIllusions, value: chosenIllusion"></select>
- </span>
- </div>
- <!-- The Utility Options. Vis:Type==Utility -->
- <div id="Utility" style="display: table-row; height:22px;" data-bind="visible: visUtility">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Utility
- </span>
- <span style="display: table-cell; float:left;">
- <select style="width:100px;height:20px;" data-bind="options: availableUtilities, value: chosenUtility"></select>
- </span>
- </div>
- <!-- Target Vis:Type is chosen -->
- <div id="Target" style="display: table-row; height:22px;">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Target
- </span>
- <span style="display: table-cell; float:left;">
- <select style="width:100px;height:20px;" data-bind="options: availableTargets, value: chosenTarget"></select>
- </span>
- </div>
- <!-- Name Vis:Type is chosen -->
- <div id="Name" style="display: table-row; height:22px;">
- <span style="display: table-cell; float:left; width:60px; margin-top:3px;">
- Name
- </span>
- <span style="display: table-cell; float:left; overflow:hidden; width:100px; height:20px; border: 1px solid #2C2C2C; background-color: #33322B; margin-top:1px;">
- <input style="padding: 5px; width:107px; height:37px; position:relative; top:-10px; margin-left:-3px; margin-top:1px; background: transparent; border-style: none; color:white;" data-bind="value: spellName, valueUpdate: 'afterkeydown'"></input>
- </span>
- </div>
- </div>
- <div id="Power" style="float:right; width:90px; text-align:center;" data-bind='visible: numAttrVis(), style:{"marginTop":numAttrName()=="Power" ? "-110px" : "-87px"}'>
- <span data-bind="text:numAttrName"></span>
- <span style="float:right; overflow:hidden; width:50px; height:20px; border: 1px solid #2C2C2C; background-color: #33322B; margin-top:1px; margin-right:20px;">
- <input style="padding: 5px; width:57px; height:37px; position:relative; top:-10px; margin-left:-3px; margin-top:1px; background: transparent; border-style: none; color:white;" id="Power" data-bind="value: spellPower, valueUpdate: 'afterkeydown'"></input>
- </span>
- </div>
- </form>
- <div id="skillsDiv" style="float:left; margin-top: 10px; margin-left:10px; width:100px; height: 101px;">
- <p style="margin-top:0px;">Required Skills</p>
- <select id="skillsSelect" style="margin-top:-10px; width: 100px; height:80px;" id="skills" data-bind="options: requiredSkills, value: selectedSkill" size="2"></select>
- </div>
- <div id="reagentsDiv" style="float:left; margin-top: 10px; margin-left:10px; width:128px; height: 100px;">
- <p style="margin-top:0px;">Required Reagents</p>
- <select id="reagentsSelect"style="margin-top:-10px; width: 100px; height:80px;" id="reagents" data-bind="options: requiredReagents, value: selectedReagent" size="2"></select>
- </div>
- <div style="clear:both; margin-top:10px;">
- <p style="margin-top:0px;">Code:</p>
- <!--<div id="editor" style="margin-top:-10px; margin-left:2px; width:496px; height: 160px; border: 2px solid #4D4D4D;"></div>-->
- <textarea id="code" style="margin-top:-10px; margin-left:2px; border: 4px solid gray; border-radius: 3px; width:496px; resize: none; height:160px;" data-bind="text: scriptCode"></textarea>
- </div>
- <!-- The JavaScript goes here -->
- <script>
- //$(function(){Topia.showWindow("Omnispell");});
- var skillPairs = {
- "Pyromancy":["Element", "Fire"],
- "Hydromancy":["Element", "Water"],
- "Geomancy":["Element","Earth"],
- "Aeromancy":["Element", "Air"],
- "Illusion":["Type", "Illusion"],
- "Teleportation":["Utility","Teleport"],
- "Healing":["Utility", "Heal"]
- };
- var reagentPairs = {
- "Brimstone":["Element", "Fire"],
- "Teleport Rune":["Utility", "Teleport"],
- "Wolf Figurine":["Illusion", "Wolf"],
- "Dragon Statue":["Illusion", "Dragon"],
- "Action Figure":["Illusion", "Human"],
- "Heartwood":["Illusion", "Tree"]
- };
- function model() {
- var self = this;
- /*General*/
- self.availableTypes = ko.observableArray(["Elemental", "Illusion", "Utility", "Summoning"]);
- self.chosenType = ko.observable("Elemental");
- self.availableElements = ko.observableArray(["Fire", "Water", "Earth", "Air"]);
- self.chosenElement = ko.observable("Fire");
- self.availableForms = ko.observableArray(["Shot", "Beam", "Wall", "Shockwave", "Aura", "Remote Bomb"]);
- self.chosenForm = ko.observable("Shot");
- self.availableUtilities = ko.observable(["Heal", "Teleport"])
- self.chosenUtility = ko.observable("Heal");
- self.availableIllusions = ko.observableArray(["Wolf", "Dragon", "Human", "Tree"]);
- self.chosenIllusion = ko.observable("Wolf");
- self.spellName = ko.observable("Awesome Spell");
- self.spellPower = ko.observable(10);
- self.codeHeight = ko.observable(160);
- self.selectedReagent = ko.observable();
- self.selectedSkill = ko.observable();
- self.availableTargets = ko.observableArray(["Me", "Click", "Nearest Enemy", "Nearest Ally"]);
- self.chosenTarget = ko.observable("Me");
- /* Computed/Special */
- self.numAttrName = ko.computed(function(){
- switch (self.chosenType()) {
- case "Elemental":
- return "Power";
- break;
- case "Illusion":
- return "Duration";
- break;
- default:
- return "ERROR"
- break;
- }
- });
- self.requiredSkills = ko.computed(function() {
- var rSkills = [];
- for (skill in skillPairs) {
- try {
- if (self["chosen"+skillPairs[skill][0]]() == skillPairs[skill][1] && self["vis"+skillPairs[skill][0]]()) {
- rSkills.push(skill);
- } else if (rSkills.indexOf(skill) != -1) {
- rSkills.splice(rSkills.indexOf(skill), 1);
- }
- } catch(err) {}
- }
- return rSkills;
- });
- self.requiredReagents = ko.computed(function() {
- var rReagents = [];
- for (reagent in reagentPairs) {
- try {
- if (self["chosen"+reagentPairs[reagent][0]]() == reagentPairs[reagent][1] && self["vis"+reagentPairs[reagent][0]]()) {
- rReagents.push(reagent);
- } else if (rReagents.indexOf(reagent) != -1) {
- rReagents.splice(rReagents.indexOf(reagent), 1);
- }
- } catch(err) {}
- }
- return rReagents;
- });
- /* Visibility*/
- self.visElement = ko.computed(function(){return self.chosenType() == "Elemental"});
- self.visForm = ko.computed(function(){return self.chosenType() == "Elemental"});
- self.visUtility = ko.computed(function(){return self.chosenType() == "Utility"});
- self.visIllusion = ko.computed(function(){return self.chosenType() == "Illusion"});
- self.visType = ko.computed(function(){return true});
- self.numAttrVis = ko.computed(function(){
- if (["Elemental","Illusion"].indexOf(self.chosenType()) != -1) {
- return true;
- } else {
- return false;
- }
- });
- /* The code*/
- self.skillType = function(){
- };
- self.targetCode = function(){
- };
- self.scriptCode = ko.computed(function () {
- var code = ["UsePower(function(power) {\n",
- "\tvar target = " + self.chosenTarget() + ";\n\n",
- "\tpower.Invoke(target, '" + self.chosenType().toLowerCase()/*self.skill_type()*/ + "', function(effect) {\n\n"];
- switch (self.chosenType()) {
- case "Illusion":
- code.push(["\t\tif (target.race != '"+self.chosenIllusion().toLowerCase()+"') {\n",
- "\t\t\teffect.duration = "+self.spellPower()+";\n",
- "\t\t\ttarget.race = '"+self.chosenIllusion().toLowerCase()+"';\n",
- "\t\t}\n\n",
- "\t\teffect.FX(function(fx) {\n",
- "\t\t\tfx.animation = 'smoke';\n",
- "\t\t\tfx.x = target.x;\n",
- "\t\t\tfx.y = target.y;\n",
- "\t\t});\n"].join(""));
- break;
- default:
- code.push("//Only Illusion Spells are currently coded\n");
- break;
- };
- code.push("\t});\n});");
- return code.join("");
- });
- /* Subscribers */
- self.scriptCode.subscribe(function(newValue) {
- editor.setValue(newValue);
- editor.getSession().selection.clearSelection();
- });
- }
- </script>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement