diff --git a/.gitignore b/.gitignore index 98583779..d42c8e86 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ publish.n OneLifeData7 EMOTEPROTOCOL.md OpenLifeModTextures -src/Secret.hx \ No newline at end of file +src/Secret.hx +temp \ No newline at end of file diff --git a/notes.txt b/notes.txt index d198709c..3d8de2b9 100644 --- a/notes.txt +++ b/notes.txt @@ -1,3 +1,16 @@ +- Notes on 2hol testing + +//floors can never display in front of the player +need a way to quickly disconnect and reconnect +need a way to debug objects in game quickly +//Dying crashes the game +baby holding nees to be a thing +//ast name if not present should be absent rather than null +cache reset via console -> cache reset player still turns into a white box + + + + SlotVert handles rotation of slotted objects Animations @@ -9,6 +22,7 @@ rock is a rocking animation rotation back and fourth offsets go back and fourth -thanks Mr_XIX + If you walk far enough off screen from an item it can't fully decay if it has multiple transitions. The classic being something like fires. Slow large fire > small fire > hot coals > ashes. -thanks Tarr diff --git a/src/Main.hx b/src/Main.hx index 1bdb13dc..f14bbf95 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -243,8 +243,8 @@ class Main #if openfl extends Sprite #end if (player.follow) { //set camera to middle - objects.group.x = Math.round(lerp(objects.group.x,-player.x * objects.scale + objects.width/2 ,0.05)); - objects.group.y = Math.round(lerp(objects.group.y,-player.y * objects.scale + objects.height/2,0.05)); + objects.group.x = Math.round(lerp(objects.group.x,-player.x * objects.scale + objects.width/2 ,0.08)); + objects.group.y = Math.round(lerp(objects.group.y,-player.y * objects.scale + objects.height/2,0.08)); } //set ground ground.x = objects.group.x; @@ -361,8 +361,14 @@ class Main #if openfl extends Sprite #end trace("kill"); program.kill(selectX,selectY); }else{ + if (player.instance.age < 3) + { + program.jump(); + } //use action if within range program.use(selectX,selectY); + //check if player pickup + program.pickup(); } } } @@ -374,7 +380,7 @@ class Main #if openfl extends Sprite #end { if (player != null) { - if (player.instance.o_id > 0) + if (player.instance.o_id != 0) { program.drop(selectX,selectY); }else{ @@ -417,8 +423,10 @@ class Main #if openfl extends Sprite #end objects.clear(); trace("clear " + Std.string(Timer.stamp() - time)); time = Timer.stamp(); + //clear cache if (objects.getFill() > 0.90 || objects.clearBool) { + trace("clear cache!"); objects.cacheMap = new Map(); objects.tileX = 0; objects.tileY = 0; @@ -557,6 +565,7 @@ class Main #if openfl extends Sprite #end //set message reader function to game Main.client.message = message; Main.client.end = end; + client.login.accept = null; //Main.client.login = null; Main.client.tag = null; index = 0; @@ -564,10 +573,11 @@ class Main #if openfl extends Sprite #end client.login.reject = function() { trace("reject"); + client.login.reject = null; //Main.client.login = null; } client.message = Main.client.login.message; - trace("connect " + Main.client.ip + " email " + Main.client.login.email); + //trace("connect " + Main.client.ip + " email " + Main.client.login.email); client.connect(); } public function message(input:String) @@ -642,7 +652,7 @@ class Main #if openfl extends Sprite #end #if openfl var tile:Tile; var id:Array = change.floor > 0 ? [change.floor] : change.id; - trace("change id: " + id); + //trace("change id: " + id); var move:Bool = change.speed > 0 ? true : false; //removal location var rx:Int = change.speed > 0 ? change.oldX : change.x; @@ -663,7 +673,7 @@ class Main #if openfl extends Sprite #end if (array != null) for (tile in array) objects.group.removeTile(tile); //add new add(id,rx,ry,move,!move); - if (move) + if (move && objects.object != null) { //add to new location data.tileData.object.set(change.x,change.y,[objects.object]); @@ -680,7 +690,7 @@ class Main #if openfl extends Sprite #end Main.client.tag = null; index = 0; case FOOD_CHANGE: - trace("food change " + input); + //trace("food change " + input); var array = input.split(" "); food.graphics.clear(); food.graphics.beginFill(0); @@ -718,10 +728,7 @@ class Main #if openfl extends Sprite #end //p_id first_name last_name last_name may be ommitted. var array = input.split(" "); var name:String = array[1] + (array.length > 1 ? " " + array[2] : ""); - draw.username(Std.parseInt(array[0]),name); - case DYING: - //p_id isSick isSick is optional 1 flag to indicate that player is sick (client shouldn't show blood UI overlay for sick players) - + draw.username(Std.parseInt(array[0]),name); case HEALED: //p_id player healed no longer dying. @@ -730,7 +737,27 @@ class Main #if openfl extends Sprite #end case GRAVE: //x y p_id + var array = input.split(" "); + var x:Int = Std.parseInt(array[0]); + var y:Int = Std.parseInt(array[1]); + var id:Int = Std.parseInt(array[2]); + if (player.instance.p_id != id) + { + }else{ + //main player died disconnect + client.close(); + var timer = new Timer(2 * 1000); + timer.run = function() + { + trace("attempt to reconnect"); + connect(); + timer.stop(); + } + } + case DYING: + //p_id isSick isSick is optional 1 flag to indicate that player is sick (client shouldn't show blood UI overlay for sick players) + trace("dying " + input); case GRAVE_MOVE: //xs ys xd yd swap_dest optional swap_dest parameter is 1, it means that some other grave at destination is in mid-air. If 0, not diff --git a/src/Static.hx b/src/Static.hx index ae532a21..89c6ad22 100644 --- a/src/Static.hx +++ b/src/Static.hx @@ -28,6 +28,16 @@ class Static } http.request(false); } + public static function execute(url:String) + { + switch (Sys.systemName()) + { + case "Linux", "BSD": Sys.command("xdg-open", [url]); + case "Mac": Sys.command("open", [url]); + case "Windows": Sys.command("start", [url]); + default: + } + } //get object list number public static function number():Int { diff --git a/src/client/Client.hx b/src/client/Client.hx index 9904ad0e..5a2382ab 100644 --- a/src/client/Client.hx +++ b/src/client/Client.hx @@ -72,6 +72,12 @@ class Client if(end != null) end(); index = 0; tag = data.substring(1,data.length); + //login + if(login != null) + { + if (tag == ACCEPTED && login.accept != null) login.accept(); + if (tag == REJECTED && login.reject != null) login.reject(); + } if (tag != FRAME && tag != HEAT_CHANGE) return; } if(tag == "") diff --git a/src/console/Program.hx b/src/console/Program.hx index 133ba7c7..c559cb01 100644 --- a/src/console/Program.hx +++ b/src/console/Program.hx @@ -213,6 +213,30 @@ class Program { return use(); } + public function baby(x:Null,y:Null):Program + { + //USE action taken on a baby to pick them up. + if (x != null && y != null) + { + send(BABY, x + " " + y); + }else{ + if (Main.player != null) send(BABY,Main.player.instance.x + " " + Main.player.instance.y); + } + return this; + } + public function jump():Program + { + send(JUMP,"0 0"); + return this; + } + public function ubaby(x:Int,y:Int,index:Int=-1):Program + { + //special case of SELF applied to a baby (to feed baby food or add/remove clothing from baby) + //UBABY is used for healing wounded players. + //UBABY x y i id# + send(UBABY,x + " " + y + " " + index); + return this; + } public function self(index:Int=-1):Program { //use action on self (eat) diff --git a/src/console/Util.hx b/src/console/Util.hx index bffa017b..f7ea4052 100644 --- a/src/console/Util.hx +++ b/src/console/Util.hx @@ -1,4 +1,5 @@ package console; +import lime.system.System; import haxe.io.Path; import sys.FileSystem; import data.ObjectData; @@ -11,7 +12,10 @@ import openfl.display.Shader; class Util { //util for hscript - + public static function object(i:Int) + { + Static.execute(Static.dir + "objects/" + i + ".txt"); + } #if openfl public static function shader(name:String):Shader { diff --git a/src/data/PlayerData.hx b/src/data/PlayerData.hx index 1d5219ba..38bf5d91 100644 --- a/src/data/PlayerData.hx +++ b/src/data/PlayerData.hx @@ -44,8 +44,8 @@ class PlayerType public var forced:Int = -1; public var x:Int = 0; public var y:Int = 0; - public var age:Int = 0; - public var age_r:Int = 0; + public var age:Float = 0; + public var age_r:Float = 0; public var move_speed:Float = 0; public var clothing_set:String = ""; public var just_ate:Int = 0; @@ -114,9 +114,9 @@ class PlayerInstance extends PlayerType case 15: y = Std.parseInt(value); case 16: - age = Std.parseInt(value); + age = Std.parseFloat(value); case 17: - age_r = Std.parseInt(value); + age_r = Std.parseFloat(value); case 18: move_speed = Std.parseInt(value); case 19: diff --git a/src/game/Draw.hx b/src/game/Draw.hx index f757d365..dbd032ed 100644 --- a/src/game/Draw.hx +++ b/src/game/Draw.hx @@ -24,16 +24,17 @@ class Draw extends Sprite { for (object in objects) { - //bottom right corner - object.x = Main.objects.group.x + ((data.playerMap.get(object.id).x + object.dx) * Main.objects.scale); - object.y = Main.objects.group.y + ((data.playerMap.get(object.id).y + object.dy) * Main.objects.scale) - object.height; - if (object.alive == 0) + if (object.alive == 0 || !data.playerMap.exists(object.id)) { removeChild(object); objects.remove(object); object = null; + continue; }else{ object.alive--; + //bottom right corner + object.x = Main.objects.group.x + ((data.playerMap.get(object.id).x + object.dx) * Main.objects.scale); + object.y = Main.objects.group.y + ((data.playerMap.get(object.id).y + object.dy) * Main.objects.scale) - object.height; } } } diff --git a/src/game/Objects.hx b/src/game/Objects.hx index cdf0ec71..cd219ac9 100644 --- a/src/game/Objects.hx +++ b/src/game/Objects.hx @@ -200,10 +200,18 @@ class Objects extends TileDisplay { if (containing > 0) { + //pos //pos var pos = getObjectData(containing).slotPos[index]; sprite.x += pos.x; sprite.y += pos.y; + /*var d = getObjectData(containing); + if (d != null) + { + var pos = d.slotPos[index]; + sprite.x += pos.x; + sprite.y += pos.y; + }*/ } object.addTile(sprite); sprites.push(sprite); diff --git a/src/game/Player.hx b/src/game/Player.hx index 05483344..75e19480 100644 --- a/src/game/Player.hx +++ b/src/game/Player.hx @@ -114,7 +114,8 @@ class Player #if openfl extends TileContainer #end } public function move(mx:Int,my:Int) { - pathfind(mx,my); + //pathfind(mx,my); + step(mx,my); } public function step(mx:Int,my:Int):Bool { @@ -240,6 +241,10 @@ class Player #if openfl extends TileContainer #end if (object != null) { removeTile(object); + if (Std.is(object,Player)) + { + objects.group.addTile(object); + } object = null; } if (instance.o_id == 0) return; @@ -247,40 +252,51 @@ class Player #if openfl extends TileContainer #end { //object objects.add(instance.o_id,0,0,true,false); + object = objects.object; }else{ //player - trace("player holding object"); - objects.add(instance.o_id * -1,0,0,true,false); + var player = gdata.playerMap.get(instance.o_id); + trace("player holding id " + instance.o_id + " player " + player); + if (player != null) + { + objects.group.removeTile(player); + object = player; + //trace("player holding object " + instance.o_id); + //objects.add(instance.o_id * -1,0,0,true,false); + } + } + if (object != null) + { + object.x = -instance.o_origin_x + Static.GRID/4; + object.y = -instance.o_origin_y - Static.GRID/1.5; + if (!contains(object)) addTile(object); } - object = objects.object; - object.x = -instance.o_origin_x + Static.GRID/4; - object.y = -instance.o_origin_y - Static.GRID/1.5; - if (!contains(object)) addTile(object); #end } public function force() { - #if openfl Actuate.pause(this); + moving = false; //local position x = instance.x * Static.GRID; y = (Static.tileHeight - instance.y) * Static.GRID; - #end + moves = []; } public function sort() { var diff:Int = 0; var object:Array = gdata.tileData.object.get(instance.x,instance.y); + //floor if (object == null) { - object = gdata.tileData.object.get(instance.x,instance.y + 1); - diff = 1; - } - if (object == null) - { - object = gdata.tileData.object.get(instance.x,instance.y - 1); + object = gdata.tileData.floor.get(instance.x,instance.y); diff = -1; } + /*if (object == null) + { + object = gdata.tileData.object.get(instance.x,instance.y + 1); + diff = 1; + }*/ if (object == null || object[0] == null) return; objects.group.setTileIndex(this,objects.group.getTileIndex(object[0]) + diff); } @@ -291,6 +307,7 @@ class Player #if openfl extends TileContainer #end for(i in 0...sprites.length) { sprites[i].visible = true; + if (ageRange[i] == null) continue; if((ageRange[i].min > instance.age || ageRange[i].max < instance.age) && ageRange[i].min > 0) { sprites[i].visible = false;