move plataform

alemasper

Member
Hello friends.
I am making my game and would ask a question if they were so friendly.
In stage two I want to make the conveyor machine, and my problem is that players do not slide or are transported by the machine.
I tell them what I did. moveplataform.c put the animation in the script folder, I have all the relevant animation and also put the values ​​of the wall in txt.
Players stand up to the machine but are not transported, would like to know is what is missing me.
thank you very much and I hope your reply. a hug

Hola amigos .
Yo estoy realizando mi juego y quisiera hacerles una pregunta si fueran tan amables.
En la etapa dos quiero hacer la maquina transportadora , y mi problema es que los jugadores no se deslizan o son transportados por la maquina.
les comento lo que hice yo . puse la animacion moveplataform.c en la carpeta script , tengo toda la animacion correspondiente y tambien puse los valores del muro en txt .
los jugadores se paran arriba de la maquina pero no son transportados , quisiera saber que es lo que me esta faltando.
muchas gracias y espero su contestacion . un abrazo

[attachment deleted by admin]
 
if I am not wrong, you will need to make a script (a didhitscrpit in fact) to check if there is any valid target (damagetaker) and if they are on valid animations (it can't be in jumping animation), then you get this target velocity and add the desired velocity.

Plus, I think its more safe if you check the target A position, to check if they are on top of the conveyor belt.
 
For conveyer belt, you can just make an entity like this:

name GBelter
type none
offscreenkill 3000


anim idle
@script
    void vSelf    = getlocalvar("self");            //Caller.
    void vEntity;                                    //Target entity placeholder.
    int iEntity;                                    //Entity enumeration holder.
    int iType;                                      //Entity type.
    int iMax      = openborvariant("ent_max");      //Entity count.
    int Ex;
    int Ey;
    int Ez;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){   
        vEntity = getentity(iEntity);                //Get target entity from current loop.
        iType  = getentityproperty(vEntity, "type"); //Get target type.

        //Enemy & player type?
        if(iType == openborconstant("TYPE_ENEMY") || iType == openborconstant("TYPE_PLAYER")){
          Ex = getentityproperty(vEntity, "x");
          Ey = getentityproperty(vEntity, "a");
          Ez = getentityproperty(vEntity, "z");

          if(Ex >= 607 + Ez && Ex <= 724 + Ez && Ez >= 439 && Ez <= 456 && Ey == 203){
            changeentityproperty(vEntity, "position", Ex+2);
          }
        }
    }
@end_script
loop 1
delay 2
offset 10 10
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

What this entity does is check all active entities and if any is standing on defined area it will move it 2 pixels right. The check rate is once per 2 centiseconds
This script only does the conveyer belt effect not the animation though

BTW for those who have read blower script I posted, there are many similarities and it's true cause blower script was actually made from conveyer belt script.
 
Hello friend.
To solve the problem of mobile platform so look in the mod double dragon genesis .
You have to put in the folder SCRIPT text file moveplataform.c
This script takes this:

int isInRange(void self,int dir,void target,int Rx, int Rz,int Ra,float x,float z,float a,float angle)
{
  if (getentityproperty(target,"animationid")==openborconstant("ANI_GRABBED")){
      return 0;
  }else{
  }

  float Tx = getentityproperty(target, "x");
  float Sx = Tx - openborvariant("xpos");
  int type=getentityproperty(target,"type");
  if (type==openborconstant("TYPE_PLAYER")){

//To prevent player from moving off the screen.
      if(Sx<=10){
        return 0;
      }else{
        if (Sx>=910){//The case is base on 320x240,you need to modify sth here.

            return 0;
        }else{}
      }
  }else{}


  float Tz = getentityproperty(target, "z");
  float Ta = getentityproperty(target, "a");
  float Disx = Tx - x;
  float Disz = z - Tz;
  float Disa = Ta - a;
 
  if (Disz<0){
      return 0;
  }

  /*if (dir){
      Disx = Tx - x;
  }else{
      Disx = x - Tx;
  }*/


  if (dir){
      Disx+=(Disz*angle);
  }else{
      Disx-=(Disz*angle);
  }

  if(Disa < 0){
      Disa = -Disa;
  }
 

  if( Disx <= Rx && Disx>0 && Disz <= Rz && Disz>0 && Disa<=Ra)
  {
      return 1;
  }else{
      return 0;
  }
}

void movePlatform(int Rx, int Rz,int Ra,int speed,float angle)
{
  return movePlatform2(Rx, Rz,Ra,speed,angle,0);
}

void movePlatform2(int Rx, int Rz,int Ra,int speed,float angle,float a)
{
  int iECnt = openborvariant("ent_max");
  float xx;
  int iEnt;
  void vEnt;
  void self = getlocalvar("self");
  float x = getentityproperty(self, "x");
  float z = getentityproperty(self, "z");
  int dir=getentityproperty(self,"direction");
  for(iEnt=0; iEnt<iECnt; iEnt++)
  {
      vEnt = getentity(iEnt);
      if (
      getentityproperty(vEnt,"exists")
      && vEnt
      ){
        if (isInRange(self,dir,vEnt,Rx,Rz,Ra,x,z,a,angle)){
            xx = getentityproperty(vEnt, "x");
            if (getentityproperty(vEnt,"animationid")==openborconstant("ANI_GRAB")){
              void grabbing=getentityproperty(vEnt,"grabbing");
              if (dir){
                  changeentityproperty(grabbing,"position",getentityproperty(grabbing, "x")+speed);
              }else{
                  changeentityproperty(grabbing,"position",getentityproperty(grabbing, "x")-speed);
              }
            }

            if (dir){
              changeentityproperty(vEnt,"position",xx+speed);
            }else{
              changeentityproperty(vEnt,"position",xx-speed);
            }
        }
      }
  }
  return NULL();
}


Then build a platform where the animation of the conveyor belt slides

wall 270 255 -12 0 500 500 15 16


Then do the animation to end of the conveyor belt .

name conv
type none
icon data/chars/misc/conv2/icon.gif
animationscript data / scripts / movePlatform.c
setLayer 1


anim idle
loop 1
delay 5
Offset 14 92
@ cmd movePlatform2 100 16 3 0.7 1 15
        sound data / sounds / conveyor.wav
        frame data/chars/misc/conv/conv1.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv2.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv3.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv4.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv5.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv6.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv7.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv8.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv9.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv10.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv11.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv12.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv13.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        sound data / sounds / conveyor.wav
        frame data/chars/misc/conv/conv14.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv15.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv16.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv17.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv18.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv19.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv20.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv21.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv22.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv23.gif
@ cmd movePlatform2 100 16 3 0.7 1 15
        frame data/chars/misc/conv/conv24.gif


Well friend I hope I've been useful with the information, I hope your answer. Hug and thank you very much ;)

 
Okay, here's a conveyer belt entity with rectangular shaped belt area:

name      GBelter
type      none
offscreenkill  3000

anim idle
@script
    void vSelf    = getlocalvar("self");            //Caller.
    void vEntity;                                    //Target entity placeholder.
    int iEntity;                                    //Entity enumeration holder.
    int iType;                                      //Entity type.
    int iMax      = openborvariant("ent_max");      //Entity count.
    int Ex;
    int Ey;
    int Ez;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){ 
        vEntity = getentity(iEntity);                //Get target entity from current loop.
        iType  = getentityproperty(vEntity, "type"); //Get target type.

        //Enemy & player type?
        if(iType == openborconstant("TYPE_ENEMY") || iType == openborconstant("TYPE_PLAYER")){
          Ex = getentityproperty(vEntity, "x");
          Ey = getentityproperty(vEntity, "a");
          Ez = getentityproperty(vEntity, "z");

          if(Ex >= 500 && Ex <= 700 && Ez >= 400 && Ez <= 500 && Ey == 200){
            changeentityproperty(vEntity, "position", Ex+2);
          }
        }
    }
@end_script
  loop  1
  delay  2
  offset  10 10
  frame  data/chars/misc/empty.gif
  frame  data/chars/misc/empty.gif

This entity checks if there any enemy or player (defined clearly in the code) within this area:

X = 500 to X = 700
Z = 400 to Z = 500
Y = 200

Any enemy or player in that area will be moved 2 pixels to the right per 2 centiseconds

For your wall, change this line:

Code:
 if(Ex >= 500 && Ex <= 700 && Ez >= 400 && Ez <= 500 && Ey == 200){

to this:

Code:
 if(Ex >= 2007 && Ex <= 2257 && Ez >= 778 && Ez <= 810 && Ey == 367){

I set these based on wall setting. TBH the code should be using trapezoid shaped belt area but it require calculation to set properly AND it's not worth the time since any enemy or player standing off wall will fall off and thus not affected by this script

Do you understand how this entity works and where I got those values? :)

Offtopic: I have hunch where this is going to be used and it's a coincidence that the entity posted above also is used for that similar level i.e Double Dragon stage 2 :)
 
Back
Top Bottom