Finally, here is the tutorial for it...
This might be a bit memorywasting, but it works...
Okay, lets start... First open WL_Agent.C and go to the
Cmd_Use function...
Now under "boolean elevatorok" add this line:
Code:
statobj_t *statptr;
Then scroll few lines down and you should see
this:
Code:
doornum = tilemap[checkx][checky];
if (*(mapsegs[1]+farmapylookup[checky]+checkx) == PUSHABLETILE)
{
//
// pushable wall
//
PushWall (checkx,checky,dir);
return;
}
Now just under it add this block:
Code:
for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
{
if(statptr->tilex == checkx && statptr->tiley == checky &&
statptr->shapenum == SPR_STAT_1 && !buttonheld[bt_use])
{
buttonheld[bt_use] = true;
//Check direction of movement (corrected directions)
switch(dir)
{
case di_north:
if((unsigned)actorat[checkx][checky-1] == 1) // Check if new tile is free
return;
check = actorat[checkx][checky-1]; // Check for walls
if (check && check<objlist)
return;
statptr->tiley = checky-1; //Move object north
statptr->visspot = &spotvis[checkx][checky-1];
(unsigned)actorat[checkx][checky] = 0; //Make old tile unblocking...
(unsigned)actorat[checkx][checky-1] = 1; //...And new one blocking
break;
case di_east:
if((unsigned)actorat[checkx+1][checky] == 1)
return;
check = actorat[checkx+1][checky];
if (check && check<objlist)
return;
statptr->tilex = checkx+1; //Move object east
statptr->visspot = &spotvis[checkx+1][checky];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx+1][checky] = 1;
break;
case di_south:
if((unsigned)actorat[checkx][checky+1] == 1)
return;
check = actorat[checkx][checky+1];
if (check && check<objlist)
return;
statptr->tiley = checky+1; //Move object south
statptr->visspot = &spotvis[checkx][checky+1];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx][checky+1] = 1;
break;
case di_west:
if((unsigned)actorat[checkx-1][checky] == 1)
return;
check = actorat[checkx-1][checky];
if (check && check<objlist)
return;
statptr->tilex = checkx-1; //Move object west
statptr->visspot = &spotvis[checkx-1][checky];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx-1][checky] = 1;
break;
case nodir:
return;
}
// This is optional:
// gamestate.secretcount++;
// SD_PlaySound (PUSHWALLSND);
}
}
And now you have a movable object...
Oh, change the SPR_STAT_1 to match the objects sprite
define, that you want to move...
And to avoid strange reactions, please select SPR_STAT
that is defined as blocking in WL_Act1.C
This might be a bit memorywasting, but it works...
Okay, lets start... First open WL_Agent.C and go to the
Cmd_Use function...
Now under "boolean elevatorok" add this line:
Code:
statobj_t *statptr;
Then scroll few lines down and you should see
this:
Code:
doornum = tilemap[checkx][checky];
if (*(mapsegs[1]+farmapylookup[checky]+checkx) == PUSHABLETILE)
{
//
// pushable wall
//
PushWall (checkx,checky,dir);
return;
}
Now just under it add this block:
Code:
for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
{
if(statptr->tilex == checkx && statptr->tiley == checky &&
statptr->shapenum == SPR_STAT_1 && !buttonheld[bt_use])
{
buttonheld[bt_use] = true;
//Check direction of movement (corrected directions)
switch(dir)
{
case di_north:
if((unsigned)actorat[checkx][checky-1] == 1) // Check if new tile is free
return;
check = actorat[checkx][checky-1]; // Check for walls
if (check && check<objlist)
return;
statptr->tiley = checky-1; //Move object north
statptr->visspot = &spotvis[checkx][checky-1];
(unsigned)actorat[checkx][checky] = 0; //Make old tile unblocking...
(unsigned)actorat[checkx][checky-1] = 1; //...And new one blocking
break;
case di_east:
if((unsigned)actorat[checkx+1][checky] == 1)
return;
check = actorat[checkx+1][checky];
if (check && check<objlist)
return;
statptr->tilex = checkx+1; //Move object east
statptr->visspot = &spotvis[checkx+1][checky];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx+1][checky] = 1;
break;
case di_south:
if((unsigned)actorat[checkx][checky+1] == 1)
return;
check = actorat[checkx][checky+1];
if (check && check<objlist)
return;
statptr->tiley = checky+1; //Move object south
statptr->visspot = &spotvis[checkx][checky+1];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx][checky+1] = 1;
break;
case di_west:
if((unsigned)actorat[checkx-1][checky] == 1)
return;
check = actorat[checkx-1][checky];
if (check && check<objlist)
return;
statptr->tilex = checkx-1; //Move object west
statptr->visspot = &spotvis[checkx-1][checky];
(unsigned)actorat[checkx][checky] = 0;
(unsigned)actorat[checkx-1][checky] = 1;
break;
case nodir:
return;
}
// This is optional:
// gamestate.secretcount++;
// SD_PlaySound (PUSHWALLSND);
}
}
And now you have a movable object...
Oh, change the SPR_STAT_1 to match the objects sprite
define, that you want to move...
And to avoid strange reactions, please select SPR_STAT
that is defined as blocking in WL_Act1.C