Free Hero Mesh

Check-in [20c6a757c5]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement warping in move_dir
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 20c6a757c526e2057d039e0e7fd0dbff255dcbb7
User & Date: user on 2021-03-24 22:17:25
Other Links: manifest | tags
Context
2021-03-25
06:31
Implement user flags (a way to give a name to bits of Misc4-Misc7 and CollisionLayers) check-in: 386d28a9fb user: user tags: trunk
2021-03-24
22:17
Implement warping in move_dir check-in: 20c6a757c5 user: user tags: trunk
22:17
Correct parsing instructions to write to global variables check-in: b93ef3c599 user: user tags: trunk
Changes

Modified class.doc from [6d089c8d88] to [80ade94c34].

1885
1886
1887
1888
1889
1890
1891
1892



1893
1894
1895
1896
1897
1898
1899
1900
1901





1902
1903
1904
1905
1906
1907
1908

bit27 *
  Allows hitting to the right regardless of Shape, Volume, etc. In order
  to actually move when sliding to the right, both bit25 and bit27 must
  be set, and bit7 must be clear.

bit28 *
  Reserved for future.




bit29 *
  Reserved for future.

bit30
  Available for your own use.

bit31
  Available for your own use.







=== Compatibility ===

Compatible objects have the following differences from the default:

* VisualOnly implies Stealthy.







|
>
>
>









>
>
>
>
>







1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916

bit27 *
  Allows hitting to the right regardless of Shape, Volume, etc. In order
  to actually move when sliding to the right, both bit25 and bit27 must
  be set, and bit7 must be clear.

bit28 *
  This bit is set by the game engine if a warp has occurred. See the below
  description of warping. You can also set this bit by yourself, and it
  persists across restarts. If this bit is set, the moving object's
  direction is updated after the movement if it is successful.

bit29 *
  Reserved for future.

bit30
  Available for your own use.

bit31
  Available for your own use.

The return value of HITBY can also be an object instead of a number. In
this case, a warp occurs. The movement is restarted, using the specified
object as the origin of the movement, and that object's direction as the
direction of movement.


=== Compatibility ===

Compatible objects have the following differences from the default:

* VisualOnly implies Stealthy.

Modified exec.c from [43426e4479] to [b39123f44e].

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
}

static int move_dir(Uint32 from,Uint32 obj,Uint32 dir) {
  // This function is complicated, and there may be mistakes.
  Object*o;
  Object*oE;
  Object*oF;

  Uint32 objE,objF,objLF,objRF;
  Uint32 hit=0;
  Uint32 vol;
  Value v;
  if(StackProtection()) Throw("Call stack overflow during movement");
  if(obj==VOIDLINK) return 0;
  o=objects[obj];
  o->dir=dir=resolve_dir(obj,dir);
  if(o->weight>o->inertia) goto fail;
  o->inertia-=o->weight;
  restart:
  if(hit&0x100000) dir=o->dir;
  objF=obj_dir(obj,dir);
  if(objF==VOIDLINK) goto fail;
  if(hit) hit=0x800;
  oF=objects[objF];
  objLF=obj_dir(obj,(dir+1)&7);
  objRF=obj_dir(obj,(dir-1)&7);
  if(height_at(oF->x,oF->y)<=o->climb) hit|=0x200000;
  if(dir&1) {
    // Diagonal movement
    hit|=0x80000;
    vol=o->volume;
    if(objLF!=VOIDLINK) vol+=volume_at(objects[objLF]->x,objects[objLF]->y);
    if(objRF!=VOIDLINK) vol+=volume_at(objects[objRF]->x,objects[objRF]->y);
    if(vol<=max_volume) {
      objE=objF;
      while(objE!=VOIDLINK) {
        if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
        oE=objects[objE];
        if(oE->height>0) {
          hit&=0xFC287000;
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          if(hit&8) goto fail;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(hit));

            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
            if(hit&8) goto fail;
          }
        }
        objE=obj_below(objE);
      }
      if((hit&0x200000) && !(hit&0x402008)) {
        if(hit&0x20000) goto success;







>
|





|





|

|



















|


|
>

|







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
}

static int move_dir(Uint32 from,Uint32 obj,Uint32 dir) {
  // This function is complicated, and there may be mistakes.
  Object*o;
  Object*oE;
  Object*oF;
  Object*oW;
  Uint32 objE,objF,objLF,objRF,objW;
  Uint32 hit=0;
  Uint32 vol;
  Value v;
  if(StackProtection()) Throw("Call stack overflow during movement");
  if(obj==VOIDLINK) return 0;
  oW=o=objects[objW=obj];
  o->dir=dir=resolve_dir(obj,dir);
  if(o->weight>o->inertia) goto fail;
  o->inertia-=o->weight;
  restart:
  if(hit&0x100000) dir=o->dir;
  objF=obj_dir(objW,dir);
  if(objF==VOIDLINK) goto fail;
  if(hit) hit=0x800|(hit&0x10000000);
  oF=objects[objF];
  objLF=obj_dir(obj,(dir+1)&7);
  objRF=obj_dir(obj,(dir-1)&7);
  if(height_at(oF->x,oF->y)<=o->climb) hit|=0x200000;
  if(dir&1) {
    // Diagonal movement
    hit|=0x80000;
    vol=o->volume;
    if(objLF!=VOIDLINK) vol+=volume_at(objects[objLF]->x,objects[objLF]->y);
    if(objRF!=VOIDLINK) vol+=volume_at(objects[objRF]->x,objects[objRF]->y);
    if(vol<=max_volume) {
      objE=objF;
      while(objE!=VOIDLINK) {
        if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
        oE=objects[objE];
        if(oE->height>0) {
          hit&=0xFC287000;
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1L);
          if(hit&8) goto fail;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(oW->x),NVALUE(oW->y),NVALUE(hit));
            if(v.t>TY_MAXTYPE) goto warp;
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1L);
            if(hit&8) goto fail;
          }
        }
        objE=obj_below(objE);
      }
      if((hit&0x200000) && !(hit&0x402008)) {
        if(hit&0x20000) goto success;
883
884
885
886
887
888
889
890
891
892
893







894
895
896
897
898
899
900
901
902
      if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
      oE=objects[objE];
      if(oE->height>0) {
        hit&=~7;
        // HIT/HITBY messages
        v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
        if(v.t) Throw("Type mismatch in HIT/HITBY");
        hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
        if(hit&8) goto fail;
        if(!(hit&0x11)) {
          v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(hit));







          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
        }
        if(hit&0x108) goto fail;
        // Hardness/sharpness
        if(!(hit&0x22)) {
          if(o->sharp[dir>>1]>oE->hard[(dir^4)>>1] && !v_bool(destroy(obj,objE,2))) hit|=0x8004;
          if(oE->sharp[(dir^4)>>1]>o->hard[dir>>1] && !v_bool(destroy(objE,obj,1))) hit|=0x4C;
        }







|


|
>
>
>
>
>
>
>

|







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
      if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
      oE=objects[objE];
      if(oE->height>0) {
        hit&=~7;
        // HIT/HITBY messages
        v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
        if(v.t) Throw("Type mismatch in HIT/HITBY");
        hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1L);
        if(hit&8) goto fail;
        if(!(hit&0x11)) {
          v=send_message(obj,objE,MSG_HITBY,NVALUE(oW->x),NVALUE(oW->y),NVALUE(hit));
          if(v.t>TY_MAXTYPE) {
            warp:
            oW=objects[objW=v_object(v)];
            dir=oW->dir;
            hit=0x10000000;
            goto restart;
          }
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1L);
        }
        if(hit&0x108) goto fail;
        // Hardness/sharpness
        if(!(hit&0x22)) {
          if(o->sharp[dir>>1]>oE->hard[(dir^4)>>1] && !v_bool(destroy(obj,objE,2))) hit|=0x8004;
          if(oE->sharp[(dir^4)>>1]>o->hard[dir>>1] && !v_bool(destroy(objE,obj,1))) hit|=0x4C;
        }
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
        if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
        oE=objects[objE];
        if(oE->height>0) {
          hit&=~7;
          // HIT/HITBY messages
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          if(hit&8) goto otherside;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(hit));
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          }
          if(hit&0x108) goto otherside;
          // Hardness/sharpness
          if(!(hit&0x22)) {
            if(o->sharp[dir>>1]>oE->hard[(dir^4)>>1] && !v_bool(destroy(obj,objE,2))) hit|=0x8004;
            if(oE->sharp[(dir^4)>>1]>o->hard[dir>>1] && !v_bool(destroy(objE,obj,1))) hit|=0x4C;
          }







|


|

|







939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
        if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
        oE=objects[objE];
        if(oE->height>0) {
          hit&=~7;
          // HIT/HITBY messages
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1L);
          if(hit&8) goto otherside;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(oW->x),NVALUE(oW->y),NVALUE(hit));
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1L);
          }
          if(hit&0x108) goto otherside;
          // Hardness/sharpness
          if(!(hit&0x22)) {
            if(o->sharp[dir>>1]>oE->hard[(dir^4)>>1] && !v_bool(destroy(obj,objE,2))) hit|=0x8004;
            if(oE->sharp[(dir^4)>>1]>o->hard[dir>>1] && !v_bool(destroy(objE,obj,1))) hit|=0x4C;
          }
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
          hit&=~7;
          // HIT/HITBY messages
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          if(hit&8) goto fail;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(hit));
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          }
          if(hit&0x108) goto fail;
          // Hardness/sharpness
          if(!(hit&0x22)) {
            if(o->sharp[dir>>1]>oE->hard[(dir^4)>>1] && !v_bool(destroy(obj,objE,2))) hit|=0x8004;







|







977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
          hit&=~7;
          // HIT/HITBY messages
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          if(hit&8) goto fail;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(oW->x),NVALUE(oW->y),NVALUE(hit));
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xC0098F7F:-1);
          }
          if(hit&0x108) goto fail;
          // Hardness/sharpness
          if(!(hit&0x22)) {
            if(o->sharp[dir>>1]>oE->hard[(dir^4)>>1] && !v_bool(destroy(obj,objE,2))) hit|=0x8004;
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
      if((hit&0x1000000) && !(hit&0x400080)) {
        if(hit&0x20000) goto success;
        if(move_to(from,obj,objects[objLF]->x,objects[objLF]->y)) goto success;
      }
    }
  }
  fail: if(hit&0x1000) goto success; o->inertia=0; return 0;
  success: if(!(hit&0x4000)) o->oflags|=OF_MOVED; return 1;
}

static int jump_to(Uint32 from,Uint32 n,Uint32 x,Uint32 y) {
  int xx,yy;
  if(n==VOIDLINK) return 0;
  xx=objects[n]->x;
  yy=objects[n]->y;







|







999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
      if((hit&0x1000000) && !(hit&0x400080)) {
        if(hit&0x20000) goto success;
        if(move_to(from,obj,objects[objLF]->x,objects[objLF]->y)) goto success;
      }
    }
  }
  fail: if(hit&0x1000) goto success; o->inertia=0; return 0;
  success: if(!(hit&0x4000)) o->oflags|=OF_MOVED; if(hit&0x10000000) o->dir=dir; return 1;
}

static int jump_to(Uint32 from,Uint32 n,Uint32 x,Uint32 y) {
  int xx,yy;
  if(n==VOIDLINK) return 0;
  xx=objects[n]->x;
  yy=objects[n]->y;