1 /**********************************************************************************
2 * Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC
3 * Copyright (c) 2010, Moloch
4 * Copyright (c) 2018, Ketmar Dark
6 * This file is part of Spelunky.
8 * You can redistribute and/or modify Spelunky, including its source code, under
9 * the terms of the Spelunky User License.
11 * Spelunky is distributed in the hope that it will be entertaining and useful,
12 * but WITHOUT WARRANTY. Please see the Spelunky User License for more details.
14 * The Spelunky User License should be available in "Game Information", which
15 * can be found in the Resource Explorer, or as an external file called COPYING.
16 * If not, please obtain a new copy of Spelunky from <http://spelunkyworld.com/>
18 **********************************************************************************/
19 // ////////////////////////////////////////////////////////////////////////// //
20 // dunno, she is an item in the original code
21 class ObjCharacter : MapEnemy;
23 int holdXOfs, holdYOfs;
26 // turn them around if they are looking at a wall
27 final void initFixDirection () {
28 if (level.isSolidAtPoint(ix-4, iy+8)) dir = Dir.Right;
29 else if (level.isSolidAtPoint(ix+16+4, iy+8)) dir = Dir.Left;
33 // MapEnemy handler is ok
34 // override void onStunnedHitEnemy (MapEnemy enemy)
36 // MapEnemy handler is ok
37 //override bool onExplosionTouch (MapObject xplo)
40 // return `false` to do standard weapon processing
41 override bool onTouchedByPlayerWeapon (PlayerPawn plr, PlayerWeapon wpn) {
42 if (heldBy) return false;
45 spillBlood(); //k8: was iy-8, why?
50 override bool onTouchedByPlayer (PlayerPawn plr) {
55 override void onBulletHit (ObjBullet bullet) {
56 if (heldBy) heldBy.holdItem = none;
61 xVel = bullet.xVel*0.3;
65 override void fixHoldCoords () {
71 int dx = (heldBy.dir == Dir.Left ? -4 : 4);
72 int dy = (heldBy.status == DUCKING && fabs(heldBy.xVel) < 2 ? 4 : 0);
75 setXY(heldBy.fltx+dx, heldBy.flty+dy);
76 prevFltX = heldBy.prevFltX+dx;
77 prevFltY = heldBy.prevFltY+dy;
79 if (spriteRName) dir = heldBy.dir;
85 // return `true` if item hits the character
86 // this is called after item's event
87 override bool onHitByItem (MapItem proj) {
92 // return `true` if this entity can be sacrificed
93 override bool canBeSacrificed (MapTile altar) {
98 override bool onSacrificed (MapTile altar) {
99 level.performSacrifice(self, altar);
104 override void thinkFrame () {
106 if (status == DEAD && removeCorpse) {
107 if (deathTimer > 0) {
118 objName = 'BaseCharacter';
120 //setCollisionBounds(-4, -4, 4, 8);
132 removeCorpse = false; // only applies to enemies that have corpses (Caveman, Yeti, etc.)
133 deathTimer = 200; // how many steps after death until corpse is removed
135 canBeHitByBullet = true;
139 activeWhenHeld = true; // for animation
140 spectralWhenHeld = false;