SpelunkyFan wiki

objects/oDeadFish/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.

oDeadFish's step event, 75 lines of GML.

if ((x > view_xview[0]-16 and x < view_xview[0] + view_wview[0] and        y > view_yview[0]-16 and y < view_yview[0] + view_hview[0])){if (hp < 1){    repeat(3)    {        instance_create(x+4, y+4, oBone);    }    if (countsAsKill)    {        if (isRealLevel()) global.enemyKills[11] += 1;        global.deadfish += 1;        global.kills += 1;    }    instance_destroy()}dist = point_distance(x, y, oCharacter.x, oCharacter.y)if (status == IDLE){    if (dir == 0)    {        if (collision_point(x+8+2, y, oWater, 0, 0) and not (collision_point(x+10, y, oSolid, 0, 0)))            moveTo(1,0);        else dir = 180;    }    else    {        if (collision_point(x-2, y, oWater, 0, 0) and not (collision_point(x-2, y, oSolid, 0, 0)))            moveTo(-1,0);        else dir = 0;    }    if (dist < 90 and oCharacter.swimming)    {        status = ATTACK;    }}else if (status == PAUSE){    if (counter > 0) counter -= 1;    else    {        status = IDLE;        dir = rand(0,1)*180;    }}else if (instance_exists(oCharacter)){    if (dist < 90 and oCharacter.swimming and not oCharacter.dead)    {        dir = point_direction(x, y, oCharacter.x, oCharacter.y)+rand(0,1)-rand(0,1);        if (collision_point(x + cos(degtorad(dir)), y - sin(degtorad(dir)), oWater, 0, 0))            moveTo(1 * cos(degtorad(dir)), -1 * sin(degtorad(dir)))    }    else    {        status = PAUSE;        counter = rand(20,40);    }}if (dir > 90 and dir < 270)    sprite_index = sDeadFishLeft;else    sprite_index = sDeadFishRight;    if (not collision_point(x+4, y+4, oWater, 0, 0)){    instance_create(x, y, oFishBone);    instance_destroy();}}