Beispiel #1
0
 TRAVERSE_SPRITE_SECT(headspritesect[src_sp->sectnum], src_move, nextsrc_move)    
     {
     // don't move ST1 Copy Tags
     if (SPRITE_TAG1(src_move) != SECT_COPY_SOURCE)
         {
         int sx,sy,dx,dy,src_xoff,src_yoff,trash;
         
         // move sprites from source to dest - use center offset
         
         // get center of src and dest sect
         SectorMidPoint(src_sp->sectnum, &sx, &sy, &trash);
         SectorMidPoint(dest_sp->sectnum, &dx, &dy, &trash);
         
         // get offset
         src_xoff = sx - sprite[src_move].x;
         src_yoff = sy - sprite[src_move].y;
         
         // move sprite to dest sector
         sprite[src_move].x = dx - src_xoff;
         sprite[src_move].y = dy - src_yoff;
         
         // change sector
         changespritesect(src_move, dest_sp->sectnum);
         
         // check to see if it moved on to a sector object
         if (TEST(sector[dest_sp->sectnum].extra, SECTFX_SECTOR_OBJECT))
             {
             SECTOR_OBJECTp sop;
             extern short GlobSpeedSO;
             
             // find and add sprite to SO
             sop = DetectSectorObject(&sector[sprite[src_move].sectnum]);
             AddSpriteToSectorObject(src_move, sop);
             
             // update sprites postions so they aren't in the
             // wrong place for one frame
             GlobSpeedSO = 0;
             RefreshPoints(sop, 0, 0, TRUE);
             }
         }
     }
Beispiel #2
0
// how: bitfield: 1=set? 2=vars?
static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
{
    int32_t lValue;
    register int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;

    if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
        i = Gv_GetVarX(lVar1);

    if ((unsigned)i >= MAXSPRITES)
        goto badsprite;

    if (how&ACCESS_SET)
    {
        if (!m32_script_expertmode && (SpriteLabels[lLabelID].flags & 1))
            goto readonly;

        lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;

        asksave = 1;

        if (!m32_script_expertmode && (SpriteLabels[lLabelID].min != 0 || SpriteLabels[lLabelID].max != 0))
        {
            if (lValue < SpriteLabels[lLabelID].min)
                lValue = SpriteLabels[lLabelID].min;
            if (lValue > SpriteLabels[lLabelID].max)
                lValue = SpriteLabels[lLabelID].max;
        }

        switch (lLabelID)
        {
        case SPRITE_X: sprite[i].x=lValue; break;
        case SPRITE_Y: sprite[i].y=lValue; break;
        case SPRITE_Z: sprite[i].z=lValue; break;
        case SPRITE_CSTAT:
            sprite[i].cstat = lValue&0xe3ff;
            break;
        case SPRITE_PICNUM: sprite[i].picnum=lValue; break;
        case SPRITE_SHADE: sprite[i].shade=lValue; break;
        case SPRITE_PAL: sprite[i].pal=lValue; break;
        case SPRITE_CLIPDIST: sprite[i].clipdist=lValue; break;
        case SPRITE_BLEND: sprite[i].blend=lValue; break;
        case SPRITE_XREPEAT: sprite[i].xrepeat=lValue; break;
        case SPRITE_YREPEAT: sprite[i].yrepeat=lValue; break;
        case SPRITE_XOFFSET: sprite[i].xoffset=lValue; break;
        case SPRITE_YOFFSET: sprite[i].yoffset=lValue; break;
        case SPRITE_SECTNUM: changespritesect(i,lValue); break;
        case SPRITE_STATNUM: changespritestat(i,lValue); break;
        case SPRITE_ANG:
            sprite[i].ang = lValue&2047;
            break;
        case SPRITE_OWNER: sprite[i].owner=lValue; break;
        case SPRITE_XVEL: sprite[i].xvel=lValue; break;
        case SPRITE_YVEL: sprite[i].yvel=lValue; break;
        case SPRITE_ZVEL: sprite[i].zvel=lValue; break;
        case SPRITE_LOTAG: sprite[i].lotag=lValue; break;
        case SPRITE_HITAG: sprite[i].hitag=lValue; break;
        case SPRITE_EXTRA: sprite[i].extra=lValue; break;
        default:
            return -1;
        }

        return 0;
    }
    else
    {
        switch (lLabelID)
        {
        case SPRITE_X: lValue=sprite[i].x; break;
        case SPRITE_Y: lValue=sprite[i].y; break;
        case SPRITE_Z: lValue=sprite[i].z; break;
        case SPRITE_CSTAT: lValue=sprite[i].cstat; break;
        case SPRITE_PICNUM: lValue=sprite[i].picnum; break;
        case SPRITE_SHADE: lValue=sprite[i].shade; break;
        case SPRITE_PAL: lValue=sprite[i].pal; break;
        case SPRITE_CLIPDIST: lValue=sprite[i].clipdist; break;
        case SPRITE_BLEND: lValue=sprite[i].blend; break;
        case SPRITE_XREPEAT: lValue=sprite[i].xrepeat; break;
        case SPRITE_YREPEAT: lValue=sprite[i].yrepeat; break;
        case SPRITE_XOFFSET: lValue=sprite[i].xoffset; break;
        case SPRITE_YOFFSET: lValue=sprite[i].yoffset; break;
        case SPRITE_SECTNUM: lValue=sprite[i].sectnum; break;
        case SPRITE_STATNUM: lValue=sprite[i].statnum; break;
        case SPRITE_ANG: lValue=sprite[i].ang; break;
        case SPRITE_OWNER: lValue=sprite[i].owner; break;
        case SPRITE_XVEL: lValue=sprite[i].xvel; break;
        case SPRITE_YVEL: lValue=sprite[i].yvel; break;
        case SPRITE_ZVEL: lValue=sprite[i].zvel; break;
        case SPRITE_LOTAG: lValue=sprite[i].lotag; break;
        case SPRITE_HITAG: lValue=sprite[i].hitag; break;
        case SPRITE_EXTRA: lValue=sprite[i].extra; break;
        default:
            return -1;
        }

        if (how&ACCESS_USEVARS)
            Gv_SetVarX(lVar2, lValue);

        return lValue;
    }
badsprite:
    M32_ERROR("tried to set %s on invalid target sprite (%d)", SpriteLabels[lLabelID].name, i);
    return -1;
readonly:
    M32_ERROR("sprite structure member `%s' is read-only.", SpriteLabels[lLabelID].name);
    return -1;
}