Skip to content

Commit cbe8d9c

Browse files
committed
fixes
1 parent 10fab25 commit cbe8d9c

File tree

11 files changed

+148
-36
lines changed

11 files changed

+148
-36
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ publish.n
1212
OneLifeData7
1313
EMOTEPROTOCOL.md
1414
OpenLifeModTextures
15-
src/Secret.hx
15+
src/Secret.hx
16+
temp

notes.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
- Notes on 2hol testing
2+
3+
//floors can never display in front of the player
4+
need a way to quickly disconnect and reconnect
5+
need a way to debug objects in game quickly
6+
//Dying crashes the game
7+
baby holding nees to be a thing
8+
//ast name if not present should be absent rather than null
9+
cache reset via console -> cache reset player still turns into a white box
10+
11+
12+
13+
114
SlotVert handles rotation of slotted objects
215

316
Animations
@@ -9,6 +22,7 @@ rock is a rocking animation rotation back and fourth
922
offsets go back and fourth
1023
-thanks Mr_XIX
1124

25+
1226
If you walk far enough off screen from an item it can't fully decay if it has multiple transitions.
1327
The classic being something like fires. Slow large fire > small fire > hot coals > ashes.
1428
-thanks Tarr

src/Main.hx

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ class Main #if openfl extends Sprite #end
243243
if (player.follow)
244244
{
245245
//set camera to middle
246-
objects.group.x = Math.round(lerp(objects.group.x,-player.x * objects.scale + objects.width/2 ,0.05));
247-
objects.group.y = Math.round(lerp(objects.group.y,-player.y * objects.scale + objects.height/2,0.05));
246+
objects.group.x = Math.round(lerp(objects.group.x,-player.x * objects.scale + objects.width/2 ,0.08));
247+
objects.group.y = Math.round(lerp(objects.group.y,-player.y * objects.scale + objects.height/2,0.08));
248248
}
249249
//set ground
250250
ground.x = objects.group.x;
@@ -361,8 +361,14 @@ class Main #if openfl extends Sprite #end
361361
trace("kill");
362362
program.kill(selectX,selectY);
363363
}else{
364+
if (player.instance.age < 3)
365+
{
366+
program.jump();
367+
}
364368
//use action if within range
365369
program.use(selectX,selectY);
370+
//check if player pickup
371+
program.pickup();
366372
}
367373
}
368374
}
@@ -374,7 +380,7 @@ class Main #if openfl extends Sprite #end
374380
{
375381
if (player != null)
376382
{
377-
if (player.instance.o_id > 0)
383+
if (player.instance.o_id != 0)
378384
{
379385
program.drop(selectX,selectY);
380386
}else{
@@ -417,8 +423,10 @@ class Main #if openfl extends Sprite #end
417423
objects.clear();
418424
trace("clear " + Std.string(Timer.stamp() - time));
419425
time = Timer.stamp();
426+
//clear cache
420427
if (objects.getFill() > 0.90 || objects.clearBool)
421428
{
429+
trace("clear cache!");
422430
objects.cacheMap = new Map<Int,Int>();
423431
objects.tileX = 0;
424432
objects.tileY = 0;
@@ -557,17 +565,19 @@ class Main #if openfl extends Sprite #end
557565
//set message reader function to game
558566
Main.client.message = message;
559567
Main.client.end = end;
568+
client.login.accept = null;
560569
//Main.client.login = null;
561570
Main.client.tag = null;
562571
index = 0;
563572
}
564573
client.login.reject = function()
565574
{
566575
trace("reject");
576+
client.login.reject = null;
567577
//Main.client.login = null;
568578
}
569579
client.message = Main.client.login.message;
570-
trace("connect " + Main.client.ip + " email " + Main.client.login.email);
580+
//trace("connect " + Main.client.ip + " email " + Main.client.login.email);
571581
client.connect();
572582
}
573583
public function message(input:String)
@@ -642,7 +652,7 @@ class Main #if openfl extends Sprite #end
642652
#if openfl
643653
var tile:Tile;
644654
var id:Array<Int> = change.floor > 0 ? [change.floor] : change.id;
645-
trace("change id: " + id);
655+
//trace("change id: " + id);
646656
var move:Bool = change.speed > 0 ? true : false;
647657
//removal location
648658
var rx:Int = change.speed > 0 ? change.oldX : change.x;
@@ -663,7 +673,7 @@ class Main #if openfl extends Sprite #end
663673
if (array != null) for (tile in array) objects.group.removeTile(tile);
664674
//add new
665675
add(id,rx,ry,move,!move);
666-
if (move)
676+
if (move && objects.object != null)
667677
{
668678
//add to new location
669679
data.tileData.object.set(change.x,change.y,[objects.object]);
@@ -680,7 +690,7 @@ class Main #if openfl extends Sprite #end
680690
Main.client.tag = null;
681691
index = 0;
682692
case FOOD_CHANGE:
683-
trace("food change " + input);
693+
//trace("food change " + input);
684694
var array = input.split(" ");
685695
food.graphics.clear();
686696
food.graphics.beginFill(0);
@@ -718,10 +728,7 @@ class Main #if openfl extends Sprite #end
718728
//p_id first_name last_name last_name may be ommitted.
719729
var array = input.split(" ");
720730
var name:String = array[1] + (array.length > 1 ? " " + array[2] : "");
721-
draw.username(Std.parseInt(array[0]),name);
722-
case DYING:
723-
//p_id isSick isSick is optional 1 flag to indicate that player is sick (client shouldn't show blood UI overlay for sick players)
724-
731+
draw.username(Std.parseInt(array[0]),name);
725732
case HEALED:
726733
//p_id player healed no longer dying.
727734

@@ -730,7 +737,27 @@ class Main #if openfl extends Sprite #end
730737

731738
case GRAVE:
732739
//x y p_id
740+
var array = input.split(" ");
741+
var x:Int = Std.parseInt(array[0]);
742+
var y:Int = Std.parseInt(array[1]);
743+
var id:Int = Std.parseInt(array[2]);
744+
if (player.instance.p_id != id)
745+
{
733746

747+
}else{
748+
//main player died disconnect
749+
client.close();
750+
var timer = new Timer(2 * 1000);
751+
timer.run = function()
752+
{
753+
trace("attempt to reconnect");
754+
connect();
755+
timer.stop();
756+
}
757+
}
758+
case DYING:
759+
//p_id isSick isSick is optional 1 flag to indicate that player is sick (client shouldn't show blood UI overlay for sick players)
760+
trace("dying " + input);
734761
case GRAVE_MOVE:
735762
//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
736763

src/Static.hx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ class Static
2828
}
2929
http.request(false);
3030
}
31+
public static function execute(url:String)
32+
{
33+
switch (Sys.systemName())
34+
{
35+
case "Linux", "BSD": Sys.command("xdg-open", [url]);
36+
case "Mac": Sys.command("open", [url]);
37+
case "Windows": Sys.command("start", [url]);
38+
default:
39+
}
40+
}
3141
//get object list number
3242
public static function number():Int
3343
{

src/client/Client.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ class Client
7272
if(end != null) end();
7373
index = 0;
7474
tag = data.substring(1,data.length);
75+
//login
76+
if(login != null)
77+
{
78+
if (tag == ACCEPTED && login.accept != null) login.accept();
79+
if (tag == REJECTED && login.reject != null) login.reject();
80+
}
7581
if (tag != FRAME && tag != HEAT_CHANGE) return;
7682
}
7783
if(tag == "")

src/console/Program.hx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,30 @@ class Program
213213
{
214214
return use();
215215
}
216+
public function baby(x:Null<Int>,y:Null<Int>):Program
217+
{
218+
//USE action taken on a baby to pick them up.
219+
if (x != null && y != null)
220+
{
221+
send(BABY, x + " " + y);
222+
}else{
223+
if (Main.player != null) send(BABY,Main.player.instance.x + " " + Main.player.instance.y);
224+
}
225+
return this;
226+
}
227+
public function jump():Program
228+
{
229+
send(JUMP,"0 0");
230+
return this;
231+
}
232+
public function ubaby(x:Int,y:Int,index:Int=-1):Program
233+
{
234+
//special case of SELF applied to a baby (to feed baby food or add/remove clothing from baby)
235+
//UBABY is used for healing wounded players.
236+
//UBABY x y i id#
237+
send(UBABY,x + " " + y + " " + index);
238+
return this;
239+
}
216240
public function self(index:Int=-1):Program
217241
{
218242
//use action on self (eat)

src/console/Util.hx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package console;
2+
import lime.system.System;
23
import haxe.io.Path;
34
import sys.FileSystem;
45
import data.ObjectData;
@@ -11,7 +12,10 @@ import openfl.display.Shader;
1112
class Util
1213
{
1314
//util for hscript
14-
15+
public static function object(i:Int)
16+
{
17+
Static.execute(Static.dir + "objects/" + i + ".txt");
18+
}
1519
#if openfl
1620
public static function shader(name:String):Shader
1721
{

src/data/PlayerData.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class PlayerType
4444
public var forced:Int = -1;
4545
public var x:Int = 0;
4646
public var y:Int = 0;
47-
public var age:Int = 0;
48-
public var age_r:Int = 0;
47+
public var age:Float = 0;
48+
public var age_r:Float = 0;
4949
public var move_speed:Float = 0;
5050
public var clothing_set:String = "";
5151
public var just_ate:Int = 0;
@@ -114,9 +114,9 @@ class PlayerInstance extends PlayerType
114114
case 15:
115115
y = Std.parseInt(value);
116116
case 16:
117-
age = Std.parseInt(value);
117+
age = Std.parseFloat(value);
118118
case 17:
119-
age_r = Std.parseInt(value);
119+
age_r = Std.parseFloat(value);
120120
case 18:
121121
move_speed = Std.parseInt(value);
122122
case 19:

src/game/Draw.hx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ class Draw extends Sprite
2424
{
2525
for (object in objects)
2626
{
27-
//bottom right corner
28-
object.x = Main.objects.group.x + ((data.playerMap.get(object.id).x + object.dx) * Main.objects.scale);
29-
object.y = Main.objects.group.y + ((data.playerMap.get(object.id).y + object.dy) * Main.objects.scale) - object.height;
30-
if (object.alive == 0)
27+
if (object.alive == 0 || !data.playerMap.exists(object.id))
3128
{
3229
removeChild(object);
3330
objects.remove(object);
3431
object = null;
32+
continue;
3533
}else{
3634
object.alive--;
35+
//bottom right corner
36+
object.x = Main.objects.group.x + ((data.playerMap.get(object.id).x + object.dx) * Main.objects.scale);
37+
object.y = Main.objects.group.y + ((data.playerMap.get(object.id).y + object.dy) * Main.objects.scale) - object.height;
3738
}
3839
}
3940
}

src/game/Objects.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,18 @@ class Objects extends TileDisplay
200200
{
201201
if (containing > 0)
202202
{
203+
//pos
203204
//pos
204205
var pos = getObjectData(containing).slotPos[index];
205206
sprite.x += pos.x;
206207
sprite.y += pos.y;
208+
/*var d = getObjectData(containing);
209+
if (d != null)
210+
{
211+
var pos = d.slotPos[index];
212+
sprite.x += pos.x;
213+
sprite.y += pos.y;
214+
}*/
207215
}
208216
object.addTile(sprite);
209217
sprites.push(sprite);

0 commit comments

Comments
 (0)