SpelunkyFan wiki

objects/oScarab/step.gml

From spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC, shown whole under the Spelunky User License v1.1b. Extracted by spelunky.ai's tools, an unofficial fan project, one file per script or event; the // ==== lines are the extractor's, naming each action of the event. Some scripts are others' work that Derek Yu credits in the source's readme.txt: Martin Piecyk's platform engine, ChevyRay's view scaling scripts and tsg1zzn's Super Sound System.

oScarab's step event, 64 lines of GML.

if ((x > view_xview[0]-20 and x < view_xview[0] + view_wview[0]+4 and        y > view_yview[0]-20 and y < view_yview[0] + view_hview[0]+4)){moveTo(xVel, yVel);if (collision_point(x+8, y+8, oSolid, 0, 0)) hp = -999;if (hp < 1){    repeat(3)    {        obj = instance_create(x+2+rand(0,14), y+2+rand(0,14), oFlareSpark);        obj.yVel = rand(1,3);    }    instance_destroy();}dir = 0dist = point_distance(x+8, y+8, oCharacter.x, oCharacter.y)if (status == IDLE){    if (xVel > 0) xVel -= 0.5;    if (yVel > 0) yVel -= 0.5;    if (xVel < 0) xVel += 0.5;    if (yVel < 0) yVel += 0.5;    if (abs(xVel) < 1) { xVel = 0; }    if (abs(yVel) < 1) { yVel = 0; }        if (xVel == 0 and yVel == 0 and counter > 0) counter -= 1;        if (counter == 0 and xVel < 1 and yVel < 1)    {        if (dist < 64)        {            dir = point_direction(x+8, y+8, oCharacter.x, oCharacter.y) + 180;        }        else        {            dir = rand(0,360);        }        xVel = 4 * cos(degtorad(dir));        yVel = -4 * sin(degtorad(dir));        counter = rand(10,30);    }        if (isCollisionRight(1) and xVel > 0)    {        xVel = -xVel;    }    if (isCollisionLeft(1) and xVel < 0)    {        xVel = -xVel;    }    if (isCollisionTop(1) and yVel < 0)    {        yVel = -yVel;    }    if (isCollisionBottom(1) and yVel > 0)    {        yVel = -yVel;    }}}