forked from Quasic/DragonBasher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.htm
1728 lines (1598 loc) · 73.2 KB
/
client.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html><head><title>Dragon Client</title>
<script src="[htmlurl]/jquery-1.11.2.min.js" language="JavaScript"></script>
<script language="JavaScript">
//
// Queville v11.0, Land of the Dragon Basher
// Quintrix and Crew Software
//
// Released as Creative Commons BY-NC, where
// 'non-commercial' includes games created meaning
// games cannot have money, coins, bank notes,
// credits, or any other economic system. See license.txt
//
// http://creativecommons.org/licenses/by-nc/2.0/
//
ShowServer=1;
CVer="v11-1l";//client version string
// Server filesystem structure
ServerPath="/cgi-bin/11-dragon/";
Server="[htmlurl]"+ServerPath+"11-dragon.cgi";
ServerName="11-dragon";
//[configuration];
// Timers
tick=1000;//target ping in ms
subtick=tick/5;//animation ms between frames
scroll_length=tick;//scroll animation speed
IdleLimit=60000*5;//ms before autologout
// Map
MapSizeX1=MapSizeX+1; // # of tiles across each screen
MapSizeY1=MapSizeY+1; // $ of tiles down each screen
//TopYPos=12;
//TopXPos=16;
TopXPos=2; // X position of map in px
TopYPos=2; // Y position of map in px
</script>
<script src="[htmlurl]/11-gfx/client-itemid.js" language="JavaScript"></script>
<script src="[htmlurl]/11-gfx/client-startscreen.js" language="JavaScript"></script>
<style>
body { margin: 0px 0px 0px 0px; background-color:#006000;color:navy }
#PopUp {
color: navy;
position:absolute;
top:100;
left:100;
visibility:visible;
z-index:254;
}
#fg{position:absolute;top:99;left:228;visibility:hidden;z-index:244;padding: 2px 2px 5px 2px}
#MH{position:absolute;top:0;left:0;visibility:hidden;z-index:255}
a{color:navy}
a:active{color:red}
.builddiv{height:100%}
</style>
</head>
<body bgcolor=006000 text=navy link=navy vlink=navy alink=red ondragstart="return false" onselectstart="return false">
<div background="[htmlurl]/11-gfx/POPUP4.png" id="PopUp" style="background-image:url([htmlurl]/11-gfx/POPUP4.png)" onMouseOver='PopUpVis="visible";AStamp();' onMouseOut='PopUpVis=PopForce; Keyboard=""; PUV=setTimeout("document.getElementById(\"PopUp\").style.visibility=PopUpVis;AStamp();",100);'> </div>
<div id="fg"> </div>
<img id=MH name=MH src="[htmlurl]/11-gfx/Cursor.gif">
<noscript><font color="white" style="color:white;background-color:black">Please allow this site to use JavaScript so you can play this game. (This setting is usually in your browser preferences.)</font></noscript>
<script language="JavaScript">
RefRPG=0;
servers=new Array();
SResults=new Array();
token=new Array();
characters={};
statics=new Array();
static0="";
static1="";
static2="";
static3="";
staticitems=["","","",""];
buildings=["","","",""];
items0="";
items1="";
items2="";
items3="";
IStamp=0;
CStamp=0;
function AStamp(){IStamp=+new Date;}
parent.document.body.onmousedown=document.body.onmousedown=AStamp;//function(){IStamp=CStamp;}
parent.document.body.onmouseup=document.body.onmouseup=AStamp;//function(){IStamp=CStamp;}
K=0;
VKey=0;
InputLine="";
KCap=0;
Retreat=0;
ShiftSet=0;
Shifted=0;
ChatLine="";
NewChatLine="";
SendChat="";
SendChatTo=0;
Chatting=0;
Admin=0;
Sysop=0;
scrollmap="";
scrollmap2="";
scrolling="";
loop=0;
ObjClass=0;
Moves="";
Move=1;
Que="";
PopX=0;
PopY=0;
PopZ=0;
PopClick=0;
PopHide="hidden";
PopAlign="center";
PopForce="hidden";
Flag="Quintrix";
LastFlag="";
TileMode=0;
TileFill="";
HittingIt=0;
RMap=0;
RPlayers=0;
RStatic=0;
RItems=0;
RChar=0;
RInven=0;
Map2X=MapSizeX1*32;
Map2Y=MapSizeY1*32;
TotalTiles=MapSizeY1*MapSizeX1;
MoveX=0;
MoveY=0;
MoveZ=0;
MovedZ=0;
ViewWide=MapSizeX1*2; // Width of Viewer
ViewHigh=MapSizeY1*2; // Height of Viewer
CharName="";
CharObj="new";
CharPObj={};
CharMapObj={};
Wearing="";
Bait="";
CharY=5;
CharX=2;
CharZ=0;
CharToken=CharName+" "+CharObj+" 0-"+CharZ;
CharMap="B2";
StartZ=0;
NumInven=24;
CharInven="Za000000";
CharMuted=false;
//map
zdivs=["builddiv","enemydiv","plyrdiv","itemdiv","sdiv"];
for(i=0;i<zdivs.length;i++){zdivs[zdivs[i]]=MapSizeY1*MapSizeX1+i;}
//errlog/welcome
if(window.$&&$("body")){}else{t=document.getElementById("PopUp");t.innerHTML='Sorry. This game requires jQuery version 1.11.2, but <a href="http://jquery.com/browser-support/">your browser doesn\'t support it</a>. :(';t.style.visibility="visible";}
//map
scroller=$($.parseHTML("<DIV />"))
.css({position:"absolute",width:Map2X*2+"px",height:Map2Y*2+"px",top:0,left:0,overflow:"hidden"})
.appendTo(document.body);
//map
if(typeof Tileset=="undefined"){Tileset=(function(){var r="",i,m=["Gg","Ge","Gb","Gd","Og","Re"];for(i=0;i<1120;i++){r+=m[Math.floor(Math.random()*100)]||"Ga";}return[r.substring(0,280),r.substring(280,560),r.substring(560,840),r.substring(840,1120)];})();}
screenV=SetTiles(0,1,Tileset[2]);
screenW=SetTiles(1,1,Tileset[3]);//reverse order to avoid IE zindex issues
screenT=SetTiles(0,0,Tileset[0]);
screenU=SetTiles(1,0,Tileset[1]);
PendingTileset=0;
//docBody=document.getElementsByTagName("body").item(0);
//util
Cookie=window.localStorage?{
set:function(k,v){localStorage.setItem(k,v);},
get:function(k){return localStorage.getItem(k);},
ready:1
}:window.openDatabase?{//Safari and a few others supported Web SQL before localStorage
ini:function(){Cookie.db2={};Cookie.db=openDatabase("C","","local cookies",999);Cookie.db.transaction(function(t){t.executeSql('CREATE TABLE IF NOT EXISTS cookies (key TEXT PRIMARY KEY unique ON CONFLICT REPLACE, value TEXT)',[],function(t){t.executeSql('SELECT * FROM cookies',[],function(t,r){for(var i=0;i<r.rows.length;i++){Cookie.db2[r.rows.item(i).key]=r.rows.item(i).value;}Cookie.ready=1;},function(x,e){console.log("SELECT",x,e);});},function(x,e){console.log("CREATE",x,e);});});},
set:function(k,v){var K=''+k,V=''+v;Cookie.db2[K]=V;Cookie.db.transaction(function(t){t.executeSql('INSERT INTO cookies (key,value) VALUES (?,?)',[K,V]);});},
get:function(k){if(Cookie.ready){return Cookie.db2[''+k]||null;}return console.error("!Cookie.ready in Cookie.get("+k+") using Web SQL");}//cached rather than trying to wait for callback
}:document.createElement&&document.body.addBehavior?{//userData for IE5-7 or 8 with localStorage disabled
b:document.createElement("B"),
ini:function(){Cookie.b.style.display="none";document.body.appendChild(Cookie.b);Cookie.b.addBehavior("#default#userData");Cookie.ready=1;},
k:function(a){return'_'+escape(a).replace(/\./g,".2e").replace(/%/g,".").replace(/\*/g,".2a").replace(/\+/g,".2b").replace(/\//g,".2f").replace(/\@/g,".40");},
set:function(k,v){Cookie.b.setAttribute(Cookie.k(k),v);Cookie.b.save("C");},
get:function(k){Cookie.b.load("C");return Cookie.b.getAttribute(Cookie.k(k));}
}:{//Cookie crumbs stored in one cookie named C as a last resort
e:window.encodeURIComponent||window.escape,
u:window.decodeURIComponent||window.unescape,
ini:function(){Cookie.db={};var a,i,m=document.cookie.match(new RegExp("(^|; *)C=([^;]*)(;|$)")),C=m?Cookie.u(m[2]).split("&"):[];for(i=0;i<C.length;i++){a=C[i].split("=");Cookie.db[Cookie.u(a[0])]=Cookie.u(a[1]);}Cookie.ready=1;},
upd:function(){var C=[],i;for(i in Cookie.db)C.push(Cookie.e(i)+"="+Cookie.e(Cookie.db[i]));document.cookie="C="+C.join("&")+";path="+ServerPath+";expires="+(new Date(+new Date+(C.length?31622400000:-1000))).toUTCString();},
set:function(k,v){Cookie.db[''+k]=''+v;Cookie.upd();},
get:function(k){if(Cookie.ready){return Cookie.db[''+k]||null;}return console.error("!Cookie.ready in Cookie.get("+k+") using document.cookie");}
};Cookie.ini&&Cookie.ini();
Welcome("Client Loaded");
errlog=window.console&&(console.error||console.log)||function(m){};
function ImgErr(){var u=this.src;this.src=DirItem+'/OZa.gif';errlog("Image error: "+u+" -> "+this.src);/*this.style.display="none"; happens prematurely*/}//could have a ghostly image option, as well, such as for items?
function ItemImgErr(){var u=this.src;/*if(this.src.search(/[\\\/]O[A-Z][0-9a-z]\.gif$/)<0){*/this.src=DirItem+"/OZa.gif";/*}*/errlog("Item image error: "+u+" -> "+this.src);}
function TileImgErr(){var u=this.src;this.src=DirItem+'/OZa.gif';errlog("Tile image error: "+u+" -> "+this.src);}
function CharImgErr(){var m,u=this.src;
if(m=u.match(/\/CHRH[MF][0-9a-z](L|R|)\.gif$/)){
this.src=DirChar+"/CHRHne"+m[1]+".gif";
}else if(m=u.match(/\/CHR[MF][0-9a-z](L|R|)\.gif$/)){
this.src=DirChar+"/CHRnw"+m[1]+".gif";
//}else if(m=this.src.match(/\/CHI[A-Z][0-9a-z](L|R)\.gif$/)){
}else{//unknown
this.src=DirItem+"/OZa.gif";
}
errlog("Character image error: "+u+" -> "+this.src);
}
function SetTiles(x,y,m){
var T,i,j,o=document.createElement("DIV"),z=0;
o.style.position="absolute";
o.style.left=x*Map2X+"px";
o.style.top=y*Map2Y+"px";
o.style.width=Map2X+"px";
o.style.height=Map2Y+"px";
for (i=0; i<MapSizeY1; i++) {
for (j=0; j<MapSizeX1; j++) {
T=document.createElement("IMG");
T.height=T.width=32;
T.src=DirTile+"/"+(m.substring(z*2,(z++)*2+2)||"G0")+".png";
T.onerror=TileImgErr;
T.className="tile";
T.onmousedown=new Function("ClickHere("+(i*MapSizeX1+j)+",this.parentNode)");
o.appendChild(T);
}
}
for(i=0;i<zdivs.length;i++){
T=document.createElement("DIV");
T.className=zdivs[i];
T.style.position="absolute";
T.style.left=T.style.top=0;
o.appendChild(T);
o[zdivs[i]]=T;
}
scroller.prepend(o);//prepend to keep in background
return o;
}
function ClickHere(z,T){//forget T if using client 4-screen view z-location, otherwise T is screen DOM object
if(document.onkeydown!=ProcessInput){return;}
var a,i,m=[],s,sX,sY,sZ,hZ,p,t;
if(T){//1-screen map z-location
sZ=z;
sY=Math.floor(z/MapSizeX1);
sX=z-sY*MapSizeX1;
//MoveX and MoveY could be made more accurate if called during a scroll if changed to use mapid instead of screen DOM object
MoveX=Math.min(ViewWide,Math.max(0,sX+(T==screenU||T==screenW?MapSizeX1:0)));
MoveY=Math.min(ViewHigh,Math.max(0,sY+(T==screenV||T==screenW?MapSizeY1:0)));
MoveZ=MoveY*ViewWide+MoveX;
s=T==screenW?3:T==screenV?2:T==screenU?1:0;
}else{//4-screen view z-location
MoveZ=z;
MoveY=Math.floor(MoveZ/ViewWide);
MoveX=MoveZ-MoveY*ViewWide;
s=MoveY<MapSizeY1?MoveX<MapSizeX1?0:1:MoveX<MapSizeX1?2:3;
sZ=sX+MapSizeX1*sY;
sX=MoveX%MapSizeX1;
sY=MoveY%MapSizeY1;
T=[screenT,screenU,screenV,screenW][s];
}
PopClick=MoveZ;
hZ="0"+sZ.toString(16);hZ=hZ.substring(hZ.length-2);
p=CharPObj.tz==sZ&&CharMapObj==T;
// is there a dynamic object at this location?
a=window["items"+s];
if(a.indexOf(hZ)>-1) {
for(i=2;i<a.length;i+=4) {
if(a.substring(i,i+2)==hZ){
m.push('<a href="javascript:var Que=\'get&j='+a.substring(i-2,i)+'\'; MoveThere();">Get '+ItemID(a.substring(i-2,i))+'</a>');
}
}
}
// is there a static object at this location?
a=staticitems[s];
if(a.indexOf(hZ)>-1) {
for(i=2;i<a.length;i+=4) {
if(a.substring(i,i+2)==hZ){
//m.push('<a href="javascript:var Que=\'static&j='+a.substring(i-2,i)+'\'; MoveThere();">'+ItemID(a.substring(i-2,i))+'</a>');
}
}
}
for (i in characters) {
if(characters[i].tz==sZ&&characters[i].tmap0==s&&i!=CharName) {
if(characters[i].NPC){
a=window[i];
m.push(a?'<a href=javascript:'+i+'(0);>'+(ItemID(i)||i)+'</a>':i);
}else{
m.push(i);//TODO: replace name with menu items for this player
}
}
}
// building menus
if (s==0) { sitems=static0; } else { if (s==1) { sitems=static1; } else { if (s==2) { sitems=static2; } else { sitems=static3; }}}
if(sitems){
items=sitems.split(" ");
for (i=0; i<items.length; i++) {
item=items[i].split("=");
if (item[1]==sZ) {
if (item[0].length==2) {
// make subroutine that includes data like bait
m.push('<a href="javascript:ClickStatic(\''+item[0]+'\');">'+ItemID(item[0])+'</a>');
} else {
if (item[0].substring(0,3)=="NPC") { // npc
// computer characters already processed, do nothing here
} else {
if (item[0].length>2) { //building
m.push('<a href="javascript:var Que=\'static&j='+item[0]+'\'; MoveThere();">'+ItemID(item[0])+'</a>');
} else {
if (item[0].length>0) {
m.push('one digit');
}
}
}
}
}
}
}
// if not, then move player
if(m.length){
POP((p?'<a href=javascript:Null(); onmousedown="RInven=1">Inventory</a><br />':'')+m.join("<br />")+'<br /><a href=javascript:Null(); onmousedown="MoveThere()">Walk Here</a>',"click");
}else{
if(p){
RInven=1;
}else{
MoveThere();
}
}
}
function ClickStatic(a) {
Que="static&j="+a;
if (a=="Zg") { Que=Que+"&k="+Bait; }
MoveThere();
}
function MoveThere(){
MovedZ=MoveZ;
var CharZ=CharToken[3].substring(2);
CharRY=Math.floor(CharZ/MapSizeX1);
CharRX=CharZ-(CharRY*MapSizeX1)+(CharToken[3].charAt(0)&1?0:MapSizeX1);
if(CharToken[3].charAt(0)>'2'){CharRY+=MapSizeY1;}
DistX=Math.abs(CharRX-MoveX);
DistY=Math.abs(CharRY-MoveY);
D1=CharRX>MoveX?"l":CharRX<MoveX?"r":'';
//if(D1){MoveChar(D1.toUpperCase());} //turn player in preparation of move
D2=CharRY>MoveY?"u":CharRY<MoveY?"d":D1;
if(D1==''){D1=D2;}
if (DistX>DistY) {
Step=Math.round(DistX/DistY);
} else {
var t=D1;D1=D2;D2=t;//swap
Step=Math.round(DistY/DistX);
}
if (Step==0) { Step++; }
HPOP(); PopForce="hidden";
$("#MH").css({left:MoveX*32+TopXPos,top:MoveY*32+TopYPos,visibility:"visible"});
HideObjs=setTimeout('document.getElementById("MH").style.visibility="hidden";',250);
if(D1){//if movement
Moves="";Move=1;MoveNum=100;
while (MoveZ&&Move) {
//MoveZ is destination, Move is last move, which shouldn't be blank
MovePlayer();
}
}
}
function MovePlayer() {
Move="";
if(!--MoveNum)return;
z=(CharRY*ViewWide)+CharRX;
if (z==MoveZ) {
MoveZ=0; MoveX=0; MoveY=0; ToDo="";
} else {
if (CharRY==MoveY) {
if (D1=="u" || D1=="d") { D1=D2; }
if (D2=="u" || D2=="d") { D2=D1; }
}
if (CharRX==MoveX) {
if (D1=="r" || D1=="l") { D1=D2; }
if (D2=="r" || D2=="l") { D2=D1; }
}
if (Step) {
Move=D1;
Step--;
} else {
if (D1) {
Move=D2;
Step=DistX>DistY?Math.round(DistX/DistY):Math.round(DistY/DistX);
if (Step==0) { Step++; }
}
}
Moves=Moves+Move;
if(Move=="l") { CharRX--; CharX--; /*MoveChar("L");*/ }
if(Move=="r") { CharRX++; CharX++; /*MoveChar("R");*/ }
if(Move=="u") { CharRY--; CharY--; /*MoveChar();*/ }
if(Move=="d") { CharRY++; CharY++; /*MoveChar();*/ }
}
//POP(Moves);
}
function Welcome(msg) {
document.onkeydown=document.onkeypress=document.onkeyup=Null;
parent.document.onkeydown=parent.document.onkeypress=parent.document.onkeyup=Null;
clearTimeout(MainLoop.timer);
Chatting=0;$('#CHAT',parent.document).css("visibility",'hidden');
PopForce="visible"; PopAlign="center";
Game="<p>Welcome to Queville "+CVer+"<br>Land of the Dragon Basher";
Game=Game+"<p>Can you imagine<br>a world without money?<p>Lets try!";
Game=Game+"<form name=login action=\"javascript:Login();\">";
if(msg){Game+='<p style="color:red;text-align:center">'+msg+'</p>';}
Game=Game+'<p align=right>Player Name: <input type=text name=n value="'+CharName+'">';
Game=Game+"<br>Password: <input type=password name=p>";
Game=Game+"<p><input type=submit name=c value=\"login\"><input type=hidden name=d value=\"\"><input type=hidden name=s value=\""+getServerName()+"\"></form>";
Game=Game+"<p><a href=\"javascript:NewChar();\">Create New Character</a>";
CharPswd=1;//allow popup
POP(Game);
CharPswd='';
}
function NewChar() {
PopForce="visible"; PopAlign="center";
Game="<p>Welcome to Queville v11<br>Land of the Dragon Basher";
Game=Game+"<form name=login action=\"javascript:Login();\">";
Game=Game+"<p align=right>Player Name: <input type=text name=n>";
Game=Game+"<p align=right>Password: <input type=password name=p>";
Game=Game+"<br>Verify Password: <input type=password name=d>";
Game=Game+"<p><input type=submit name=c value=\"create\"><input type=hidden name=s value=\""+getServerName()+"\"></form>";
Game=Game+"<p><a href=\"javascript:Welcome();\">Return to Login</a>";
CharPswd=1;//allow popup
POP(Game);
CharPswd='';
}
function Login() {
ToDo=document.forms.login.c.value+"&d="+document.forms.login.d.value;
ServerName=document.forms.login.s.value;
CharPswd=document.forms.login.p.value;
if(CharName!=document.forms.login.n.value){
CharName=document.forms.login.n.value;
for(var t in showtab.tabs){
if(showtab.tabs[t].log){
showtab.tabs[t].log.html((showtab.tabs[t].initHTML&&showtab.tabs[t].initHTML()||
'<p style="text-align:center"><br>Welcome, '+CharName+'<br>to Queville '+CVer+"<br>Land of the Dragon Basher<br><br>Can you imagine<br>a world without money?<br><br>Lets try<br></p>"
)+'<br>');
}
}
}
Sysop=CharName==ServerName;//||CharName=="qua";//remove the =qua part after testing (Server should block qua, though)
POP("Logging In...");
IStamp=(+new Date)+50000;
HitIt();
}
function getServerName(){ var s=location.search.match(/[?&]s=([^&]*)(&|$)/);s=s&&s[1]?s[1].replace(/[^A-Za-z0-9\-]/g,''):"";return s=="11-dragon"?"":s; }//same filter as server uses
function HitIt() {
var idle='',t,m=Moves,cmd=ToDo||m&&"refresh",chatlog=SendChatTo&&SendChatTo.log||Chatting&&Chatting.log;Moves=ToDo="";HittingIt=1;
if (IStamp+IdleLimit<CStamp){
if (true/*!isMod()*/) { //this check turns off idle logout for players with the sysop key
cmd="logout"; idle=" due to inactivity";
}
}
if (!cmd) { cmd=SendChat&&SendChatTo?"chat&j="+SendChatTo.metachannel+"&q="+(window.encodeURIComponent||window.escape)(SendChat).replace(/\+/g,"%2b"):Chatting&&Chatting.metachannel?"chat&j="+Chatting.metachannel:"refresh"; SendChat="";SendChatTo=0; }
servers=[];
$.ajax({
url: Server,
type: 'GET',
data: 's='+ServerName+'&n='+CharName+'&p='+CharPswd+'&c='+cmd+'&m='+m,
contentType: 'application/json; charset=utf-8', success: function (response) {
var i,i0="",i1="",i2="",i3="",s0="",s1="",s2="",s3="",p=0,t,h,M="";
SResults=response.match(/[^\r\n]+/g);
if (SResults) {
SPop="";
for (i in characters){characters[i].off=1;}
for (i=0; i<SResults.length; i++) {
SVar=SResults[i].substring(0,SResults[i].indexOf("="));
SValue=SResults[i].substring(SResults[i].indexOf("=")+1,SResults[i].length);
// uncomment next line to debug server results
// alert(SVar+"="+SValue);
// react to server results
// p=players, c=characters, b=buildings, i=items
if (SVar=="create"){ PopForce="hidden"; }
if (SVar=="login"){
CharName=SValue; POP(SValue+" logged in."); PopForce="hidden"; PopAlign="char"; cinput();
for(var t in showtab.tabs){
if(showtab.tabs[t].log){
clog(showtab.tabs[t].loginHTML&&showtab.tabs[t].loginHTML()||"Welcome to the "+ServerName+" server, "+CharName+"!",showtab.tabs[t].log);
}
}
document.onkeydown=ProcessInput; document.onkeypress=CancelKey; document.onkeyup=CancelKey;
parent.document.onkeydown=ProcessInput; parent.document.onkeypress=parent.document.onkeyup=CancelKey;
setTimeout('MainLoop();',subtick); // starts repeating loop
setTimeout(TeamChatInit,tick);
}
if (SVar=="logout"){
if(!idle){
for(var t in showtab.tabs){
if(showtab.tabs[t].log){
showtab.tabs[t].log.html("");
}
}
CharName="";
}
Welcome(clog("You have been logged out"+idle+".","POPLOG"));
ServerName="11-dragon";
}
if (SVar=="error") {
Welcome('ERROR: '+SValue);
ServerName="11-dragon";
}
if (SVar=="servers") { ShowServers(); }
if (SVar=="hpop") { PopForce="hidden"; HPOP(); }
if (SVar=="pop") { PopForce="hidden"; SPop=SPop+SValue+"<br>"; }
if (SVar=="chat") { clog(SValue,chatlog); }
if (SVar=="RMap") { RMap=SValue; }
if (SVar=="RChar"){ RChar=SValue; }
if (SVar=="RStatic"){ RStatic=SValue; }
if (SVar=="t0"){ (scrollmap?PendingTileset:Tileset)[0]=SValue; }
if (SVar=="t1"){ (scrollmap?PendingTileset:Tileset)[1]=SValue; }
if (SVar=="t2"){ (scrollmap?PendingTileset:Tileset)[2]=SValue; }
if (SVar=="t3"){ (scrollmap?PendingTileset:Tileset)[3]=SValue; }
if (SVar=="t4"){ Tileset[scrollmap?6:4]=SValue; }
if (SVar=="t5"){ Tileset[scrollmap?7:5]=SValue; }
if (SVar=="i0"){ i0=SValue; }
if (SVar=="i1"){ i1=SValue; }
if (SVar=="i2"){ i2=SValue; }
if (SVar=="i3"){ i3=SValue; }
if (SVar=="s0"){ s0=SValue; }
if (SVar=="s1"){ s1=SValue; }
if (SVar=="s2"){ s2=SValue; }
if (SVar=="s3"){ s3=SValue; }
if (SVar=="p") { AddCharacter(SValue.split(" ")); p=1; }
// token="[name] [level] [object] [z] ";
// token[0]=name;
// token[1]=level;
// token[2]=obj;
// token[3]=z;
//if (SVar=="c") { AddCharacter(SValue.split(" "),1);}
//if (SVar=="b") { buildings.push(SValue); }
if (SVar=="s") { servers.push(SValue); }
if (SVar=="scroll") { if(scrollmap){scrollmap2=SValue;}else{scrollmap=SValue;} }
if (SVar=="moves") { M=SValue; }
if (SVar=="inv"){ CharInven=SValue; }
if (SVar=="h"){ CharH=SValue; }
if (SVar=="dinv") { RInven=1; }
}
if (SPop) { SPop.length-=4;POP(clog(SPop,"POPLOG")); }
}
RefRPG=0;
if (Que) {
if (Moves=="") {
// @@@
ToDo=Que; Que="";
}
}
//console.log([scrollmap,M,Moves,MoveZ,MovedZ]);
if(scrollmap){
ScrollMap(scrollmap);
scrollmap=0;
if(M){
if(Moves){
Moves="";//TODO: fix this in ScrollMap() by adjusting MovedZ and moving below "if(Moves)" out of else clause
}else{
Moves=M;
}
}
}else{
if(Moves){/*This doesn't correct properly
MoveZ=MovedZ;//update since server moved player before new mouse click
MoveY=Math.floor(MoveZ/ViewWide);
MoveX=MoveZ-MoveY*ViewWide;
MoveThere();
*/
}else{
Moves=M;
}
}
if (RMap) { RefMap(); }
if (RChar) { SelectChar(RChar); }
//from here to RefItems(), the order is important
if (RStatic) { items0=i0;items1=i1;items2=i2;items3=i3;static0=s0;static1=s1;static2=s2;static3=s3;RefStatic();p|=2; }
for(i in characters){if(characters[i].off&&p&(characters[i].NPC?2:1)&&characters[i].tmapo==[screenT,screenU,screenV,screenW][characters[i].tmap0]&&i!=CharName){characters[i]=undefined;delete characters[i];}}//get rid of deleted NPCs and players who logged out
RefPlayers();
RefItems();
if(p&2&&!Chatting){$("#CHAT",parent.document).css("visibility","hidden");}//shown in MainLoop, below
if (RInven) { RefreshInven(); }
HittingIt=0;
CStamp=+new Date;
},
error: function (xhr,stat,emsg) {
if(typeof console!="undefined"){console.log("AJAX error: ",stat,emsg,xhr);}
Welcome("ERROR: Lost server connection"+(emsg?" ("+emsg+")":""));
}
});
}
function MainLoop() {
// if no character object, request object
// UpdateObjs();
RefPlayers();
// if (MoveZ) { MovePlayer(); }
//if (Chatting){showtab('default')}//hidden on RStatic, above
RefRPG=RefRPG+subtick;
if (RefRPG>=tick&&!HittingIt) { HitIt(); }
if (ServerName != "11-dragon") { clearTimeout(MainLoop.timer);MainLoop.timer=setTimeout(MainLoop,subtick); }
}
function RefStatic() {
RStatic=0;
staticitems=["","","",""];
if (static0) { RefStatic1(0,static0); }
if (static1) { RefStatic1(1,static1); }
if (static2) { RefStatic1(2,static2); }
if (static3) { RefStatic1(3,static3); }
}
function RefStatic1(n,sitems) {//adds items and NPCs to display lists, currently doesn't support buildings, example: s1=NPCKing-M23LL3=L0 L0=186
var i,sitem,s="TUVW".charAt(n),sx,sy,sz,statics=sitems.split(" "),b={},B,d;
for (i=0; i<statics.length; i++) {
sitem=statics[i].substring(0,statics[i].indexOf("="));
sz=parseInt(statics[i].substring(statics[i].indexOf("=")+1,statics[i].length));
sy=Math.floor(sz/MapSizeX1);
sx=sz-sy*MapSizeX1;
if (sitem.length==2) {
sz="0"+sz.toString(16);
if(window["items"+n].indexOf(sitem+=sz.substring(sz.length-2))<0){
staticitems[n]+=sitem;
}
} else {
if (sitem.substring(0,3)=="NPC") {
AddCharacter([sitem.substring(0,sitem.indexOf("-")),"",sitem.substring(sitem.indexOf("-")+1,sitem.length),(1+n)+"-"+sz],1);
} else {
if (sitem.length>2) {// render building
buildings[n]+=sitem; //@@@
b[d=sitem+"_"+s+sz]=1;
B=document.getElementById(d);
if(!B){
B=document.createElement("IMG");
B.setAttribute("id",d);
B.setAttribute("class","building");
B.setAttribute("src",DirBuild+"/"+sitem+".gif");
B.style.position="absolute";
B.onerror=ImgErr;
B.style.pointerEvents="none";
}
B.style.left=sx*32+"px";//was centered in Queville, though left align resolves IE problems...
B.style.bottom=(MapSizeY-sy)*32+"px";
B.onmousedown=new Function("ClickHere("+sz+",screen"+s+")");
window["screen"+s].builddiv.appendChild(B);
} else {
// reserved - one digit
//If the last character is a space, the empty static object ends up here as sitem[0]==""
}
}
}
}
B=window["screen"+s].builddiv.childNodes;
for(i=0;i<B.length;i++){if(!b[B[i].id]){B[i].parentNode.removeChild(B[i]);}}
}
function RefItems() {
// updates items on map
RefItems1(screenT,staticitems[0]+items0);
RefItems1(screenU,staticitems[1]+items1);
RefItems1(screenV,staticitems[2]+items2);
RefItems1(screenW,staticitems[3]+items3);
}
function RefItems1(m,inv){//example: i1=L0b8L0b9
var a=m.itemdiv,i=0,j=0,o,x,y,z;
while(i<inv.length){
o=a.childNodes[j++];
if(!o){a.appendChild(o=document.createElement("IMG"));}
o.setAttribute("src",DirItem+"/O"+inv.substring(i,i+=2)+".gif");
o.onerror=ItemImgErr;
z=parseInt(inv.substring(i,i+=2),16);
y=Math.floor(z/MapSizeX1);
x=z-(y*MapSizeX1);
o.style.position="absolute";
o.style.top=y*32+"px";
o.style.left=x*32+"px";
o.style.pointerEvents="none";
o.onmousedown=new Function("ClickHere("+z+",screen"+(m==screenT?"T":m==screenU?"U":m==screenV?"V":"W")+")");
}
while(j<a.childNodes.length)a.removeChild(a.lastChild);
}
function ClickInven(a){
//
// is player carrying item i ??
//
MenuSlot=a.split("-")[0];
MenuItem=a.split("-")[1];
Wearing=isWearing(MenuItem);
Game="<p> "+ItemID(MenuItem)+" <p>";
Game=Game+" <img src=\""+DirItem+"/O"+MenuItem+".gif\" height=32 width=32 onmousedown=\"DistplayInven();\" ";
bg="#ffffd0";
if (MenuItem==Bait) { bg="#80FF80"; }
if (Wearing) { bg="#80FF80"; }
Game=Game+" style=\"background-color: "+bg+";\" border=1> <p>";
if (MenuItem>="A0" && MenuItem<="Kz") {
Game=Game+'<a href="javascript:var ToDo=\'drop&j='+MenuSlot+'-'+MenuItem+'\'; HPOP();">Drop '+ItemID(MenuItem)+'</a><br>';
}
if (MenuItem==isMod.key) { // sysop key menu
var s=window["static"+CharPObj.tmap0].split(" "),i,o;
for(i=0;i<s.length;i++)if(s[i].split("=")[1]==CharPObj.tz){o=s[i].split("=")[0];break;}
Game+="<a href=\"javascript:LoadChat('/tele ','[map]-[z]')\">/teleport</a><br>";
if (TileMode) {
if (TileFill) {
Game+='<a href="javascript:SetFill();">Exit Tile Fill Mode</a><br>';
} else {
Game+='<a href="javascript:SetFill();">Enter Tile Fill Mode</a><br>';
}
Game+='<a href="javascript:SetMode();">Exit Tile Edit Mode</a><br>';
} else {
Game+='<a href="javascript:SetMode();;">Enter Tile Edit Mode</a><br>';
}
Game+='<a href="javascript:'+(i<s.length?'Null(ToDo=\'add&j='+o+'\');">Delete '+(o.length==2?ItemID(o):o):'AddStatic(0);">Add Static Item')+'</a><br>';
}
if (MenuItem>="Ga" && MenuItem<="Gz") {
Game=Game+'<a href="javascript:Cook(\''+MenuItem+'\');">Cook '+ItemID(MenuItem)+'</a><br>';
if (MenuItem==Bait) {
Game=Game+'<a href="javascript:ClickBait(0);">Using As Bait</a><br>';
} else {
Game=Game+'<a href="javascript:ClickBait(\''+MenuItem+'\');">Use As Bait</a><br>';
}
}
if (MenuItem>="Ja" && MenuItem<="Jz") {
Game=Game+'<a href="javascript:Eat(\''+MenuItem+'\');">Eat '+ItemID(MenuItem)+'</a><br>';
}
if (MenuItem>="La" && MenuItem<="Sz") {
if (Wearing) {
if (MenuItem=="Sa") {
Game=Game+'<a href="javascript:var ToDo=\'team&j='+MenuItem+'\';">Team Teleport</a><br>';
}
Game=Game+'<a href="javascript:var ToDo=\'remove&j='+MenuItem+'\';">Remove '+ItemID(MenuItem)+'</a><br>';
} else {
Game=Game+'<a href="javascript:var ToDo=\'wear&j='+MenuItem+'\';">Wear '+ItemID(MenuItem)+'</a><br>';
}
Game=Game+'<a href="javascript:var ToDo=\'drop&j='+MenuSlot+'-'+MenuItem+'\';">Drop '+ItemID(MenuItem)+'</a><br>';
}
if (MenuItem=="Za"&&isMod(1)){
Game+='<a href="javascript:CreateItem(\''+MenuSlot+'\')">Create Item</a>';
}
if (MenuItem=="Zj"){ Game=Game+'<a href="javascript:var ToDo=\'drop&j='+MenuSlot+'-'+MenuItem+'\'; HPOP();">Drop '+ItemID(MenuItem)+'</a><br>'; }
PopAlign="char"; POP(Game);
}
function ClickBait(a) { if (a) { Bait=a; } else { Bait=""; } RefreshInven(); }
function SetMode() {
if (TileMode) {
TileMode=0;
POP("Done editing tiles");
} else {
TileMode=1;
POP("You are now editing tiles");
}
}
function SetFill() {
if (TileFill) {
TileFill="";
POP("No longer in tile fill mode");
} else {
var screen=CharMapObj==screenW?3:CharMapObj==screenV?2:CharMapObj==screenU?1:0;
TileFill=Tileset[screen].charAt(CharZ*2)+Tileset[screen].charAt((CharZ*2)+1);
POP("Now in tile fill mode - "+TileFill);
}
}
function Cook(a) {
ToDo="cook&j="+a;
POP("Cooking "+ItemID(a)+"...");
}
function Eat(a) {
ToDo="eat&j="+a;
POP("Eating "+ItemID(a)+"...");
}
function Match(a) {
}
function CreateItem(a){
//list of items, sent to the server with ToDo=newitem&j=MenuSlot-MenuItem-Time
LoadChat("/inventory "+a+" ^","itemid minutes");
}
function RemoveArmr(i) {
HPOP();
ToDo="C=RA&J="+CharInven.substring(i*2,i*2+2);
}
function AddCharacter(token,NPC){var t2=token[2].split("-"),t3=token[3].split("-"),p={
token:token,
name:token[0],
level:token[1],
obj:t2[0],
ani:t2.length>1&&characters[token[0]]&&characters[token[0]].lastpZ_m==t2[1]+token[3]?"":t2[1],//movement bounce eliminator, so server doesn't need to sync animation for each client separately
lastpZ_m:t2[1]+token[3],
mapz:token[3],
tmap:+t3[0],
tmap0:t3[0]-1,
tmapo:[screenT,screenU,screenV,screenW][t3[0]-1],
tz:+t3[1],
NPC:NPC
};
characters[p.name]=p;
}
function RefPlayers() {
// loop through characters
var p,pt={},t,name;
for (name in characters) {
p=characters[name];
if(p.tmapo==[screenT,screenU,screenV,screenW][p.tmap0]||name==CharName){//check for scrollout
var i,C;
if (p.ani) {
i=Math.floor(RefRPG/subtick);
if(i<p.ani.length){
//
// move each player one tile as per [object-moves]
//
var m=+p.tmap,X=p.tz,Y=Math.floor(X/MapSizeX1);X-=Y*MapSizeX1;t=1;
for(;i<p.ani.length;i++){
C=p.ani.charAt(i);
if(C=="r") { X--;if(X<0){if(m&1){t=0;}else{m--;X+=MapSizeX1;}}}
if(C=="l") { X++;if(X>MapSizeX){if(m&1){m++;X-=MapSizeX1;}else{t=0;}}}
if(C=="d") { Y--;if(Y<0){if(m>2){m-=2;Y+=MapSizeY1;}else{t=0;}}}
if(C=="u") { Y++;if(Y>MapSizeY){if(m<3){m+=2;Y-=MapSizeY1;}else{t=0;}}}
}
t=t&&m+'-'+(X+(Y*(MapSizeX+1)));
}else{t=p.mapz;p.ani='';}
}else{t=p.mapz;}
// if player reaches an 'edge tile', delete object
if(t){//on visible screen? (otherwise will be deleted, below)
//RenderObj(p,t);
var D=([0,screenT,screenU,screenV,screenW][t.charAt(0)]||screenT).plyrdiv,
d,e,f=new Function("ClickHere("+p.tz+",screen"+" TUVW".charAt(t.charAt(0))+");"),
obj=p.obj.split("-")[0];
ObjZ=+t.substring(2);
ObjY=Math.floor(ObjZ/MapSizeX1);
ObjX=ObjZ-(ObjY*MapSizeX1);
//ObjZ=ObjX+(ObjY*MapSizeX1);
p.screenX=ObjX;//%MapSizeX1;
p.screenY=ObjY;//%MapSizeY1;
if (p.name==CharName) {
CharPObj=p;
CharMapObj=D.parentNode;
CharToken=p.token;
CharZ=ObjZ;
CharX=ObjX+(t.charAt(0)&1?0:MapSizeX1);
CharY=ObjY+(t.charAt(0)>'2'?MapSizeY1:0);
CharObj=obj;
}
C=['/CHR'+obj.charAt(0)+obj.charAt(2),'/CHRH'+obj.charAt(0)+obj.charAt(1)];for(i=4;i<obj.length;){C.push('/CHI'+obj.substring(i,i+=2));}
d=document.getElementById("obj_"+p.name);
if(!d){d=document.createElement("DIV");d.setAttribute("id","obj_"+p.name);d.setAttribute("class","object");d.style.position="absolute";}
p.div=d;
d.style.left=(ObjX*32)-16+"px";
d.style.top=(ObjY*32)-32+"px";
if(d.parentNode!=D){D.appendChild(d);}
while(d.childNodes.length>C.length){d.removeChild(d.lastChild);}
for(i=0;i<C.length;i++){
if(i<d.childNodes.length){e=d.childNodes[i];}else{e=document.createElement("IMG");e.style.position="absolute";e.style.top=e.style.left=0;e.style.pointerEvents="none";e.onerror=CharImgErr;d.appendChild(e);}
e.onmousedown=f;
D=DirChar+C[i]+obj.charAt(3)+".gif";
if (e.src != D) { e.setAttribute("src",D); }
}
pt[name]=1;
}}else{
if(p.tmapo.parentNode==scroller[0]){pt[name]=3;}//don't delete characters during scroll
}
}
var po=$(".object");
for (i=0;i<po.length;i++ ){name=po[i].id.substring(4);if(!pt[name]){po[i].parentNode.removeChild(po[i]);characters[name]=undefined;delete characters[name];}}
// ObjClass=1-ObjClass;
// $('.object'+ObjClass).remove();
}
function RenderObj(p, mapz) { //either merge with RefPlayers or add div name parameter to override "plyrdiv" if needed outside of RefPlayers
var object=p.obj,f1=null,/*f2=null,*/d=([0,screenT,screenU,screenV,screenW][mapz.charAt(0)]||screenT),D=d.plyrdiv,a0,a1,a2,i;
if (object.indexOf("-")>-1) { object=object.substr(0,object.indexOf("-")); }
ObjZ=mapz.substring(2,mapz.length);
if (p.name==CharName) { TokenZ=ObjZ; }
ObjY=Math.floor(ObjZ/MapSizeX1);
ObjX=ObjZ-(ObjY*MapSizeX1);
//if (mapz.charAt(0)=='2') { ObjX=ObjX+MapSizeX+1; }
//if (mapz.charAt(0)=='3') { ObjY=ObjY+MapSizeY+1; }
//if (mapz.charAt(0)=='4') { ObjX=ObjX+MapSizeX+1; ObjY=ObjY+MapSizeY+1; }
ObjZ=ObjX+(ObjY*MapSizeX1);
// ObjX, ObjrY, ObjZ should now be correct in relation to map #1
p.screenX=ObjX%MapSizeX1;
p.screenY=ObjY%MapSizeY1;
if (p.name==CharName) {
CharPObj=p;
CharMapObj=d;
CharToken=p.token;
CharX=ObjX+(mapz.charAt(0)&1?0:MapSizeX1);
CharY=ObjY+(mapz.charAt(0)>'2'?MapSizeY1:0);
CharZ=ObjZ;
CharObj=object;
}
f1=new Function("ClickHere("+p.tz+",screen"+" TUVW".charAt(mapz.charAt(0))+");");
x=(ObjX*32)-16+"px";
y=(ObjY*32)-32+"px";
a0=document.getElementById("obj0_"+p.name);
if (!a0) { a0=document.createElement("img"); a0.setAttribute("id","obj0_"+p.name); }
p.obj0=a0;
if(a0.parentNode!=D){D.appendChild(a0);}
a0.style.pointerEvents="none";
a0.onmousedown=f1;
//a0.onmouseover=f2;
a0.style.position="absolute";
a0.style.left=x;
a0.style.top=y;
a0.style.visibility="visible";
a0.style.zIndex=100;
a0.className = "obj0 object";
e=DirChar+'/CHR'+object.charAt(0)+object.charAt(2)+object.charAt(3)+'.gif';
if (a0.src != e) { a0.setAttribute("src",e); }
a1=document.getElementById("obj1_"+p.name);
if (!a1) { a1=document.createElement("img"); a1.setAttribute("id","obj1_"+p.name); }
p.obj1=a1;
if(a1.parentNode!=D){D.appendChild(a1);}
a1.style.pointerEvents="none";
a1.onmousedown=f1;
//a1.onmouseover=f2;
a1.style.position="absolute";
a1.style.left=x;
a1.style.top=y;
a1.style.visibility="visible";
a1.style.zIndex=100;
a1.className = "obj1 object";
e=DirChar+'/CHRH'+object.charAt(0)+object.charAt(1)+object.charAt(3)+'.gif';
if (a1.src != e) { a1.setAttribute("src",e); }
Wearing=object.substring(4,object.length);
if ((i=Wearing.indexOf("L"))>-1||(i=Wearing.indexOf("M"))>-1) {
a2=document.getElementById("obj2_"+p.name);
if (!a2) { a2=document.createElement("img"); a2.setAttribute("id","obj2_"+p.name); }
p.obj2=a2;
if(a2.parentNode!=D){D.appendChild(a2);}
a2.style.pointerEvents="none";
a2.onmousedown=f1;
//a2.onmouseover=f2;
a2.style.position="absolute";
a2.style.left=x;
a2.style.top=y;
a2.style.visibility="visible";
a2.style.zIndex=100;
a2.className = "obj2 object";
e=DirChar+'/CHI'+Wearing.substring(i,i+2)+object.charAt(3)+".gif";
if (a2.src != e) { a2.setAttribute("src",e); }
} else {
if (document.getElementById("obj2_"+p.name)) { D.removeChild(document.getElementById("obj2_"+p.name)); }
}