Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PXshadow committed Sep 18, 2019
1 parent 10fab25 commit cbe8d9c
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ publish.n
OneLifeData7
EMOTEPROTOCOL.md
OpenLifeModTextures
src/Secret.hx
src/Secret.hx
temp
14 changes: 14 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
49 changes: 38 additions & 11 deletions src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
Expand All @@ -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{
Expand Down Expand Up @@ -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<Int,Int>();
objects.tileX = 0;
objects.tileY = 0;
Expand Down Expand Up @@ -557,17 +565,19 @@ 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;
}
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)
Expand Down Expand Up @@ -642,7 +652,7 @@ class Main #if openfl extends Sprite #end
#if openfl
var tile:Tile;
var id:Array<Int> = 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;
Expand All @@ -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]);
Expand All @@ -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);
Expand Down Expand Up @@ -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.

Expand All @@ -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

Expand Down
10 changes: 10 additions & 0 deletions src/Static.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 6 additions & 0 deletions src/client/Client.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "")
Expand Down
24 changes: 24 additions & 0 deletions src/console/Program.hx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@ class Program
{
return use();
}
public function baby(x:Null<Int>,y:Null<Int>):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)
Expand Down
6 changes: 5 additions & 1 deletion src/console/Util.hx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package console;
import lime.system.System;
import haxe.io.Path;
import sys.FileSystem;
import data.ObjectData;
Expand All @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions src/data/PlayerData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions src/game/Draw.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/game/Objects.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit cbe8d9c

Please sign in to comment.