fixed black market generator: if "generate lake" flag is also set, black market will...
[k8vacspelynky.git] / mapent / miscobj / webball.vc
blobba6b94c376e2a8f9412bcf5cb3c1d3db41907e61
1 /**********************************************************************************
2  * Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC
3  * Copyright (c) 2010, Moloch
4  * Copyright (c) 2018, Ketmar Dark
5  *
6  * This file is part of Spelunky.
7  *
8  * You can redistribute and/or modify Spelunky, including its source code, under
9  * the terms of the Spelunky User License.
10  *
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.
13  *
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/>
17  *
18  **********************************************************************************/
19 // web ball trail
20 class MapObjYellowTrail['oYellowTrail'] : MapObject;
23 override bool initialize () {
24   if (!::initialize()) return false;
25   setSprite('sYellowTrail');
26   return true;
30 override void onAnimationLooped () {
31   instanceRemove();
35 override void thinkFrame () {
39 defaultproperties {
40   depth = 1;
41   spectral = true;
42   imageSpeed = 1;
46 // ////////////////////////////////////////////////////////////////////////// //
47 // web ball
48 class ItemWebBall['oWebBall'] : MapObject;
50 int life;
51 int trailTime = -1; //4
54 override bool initialize () {
55   if (!::initialize()) return false;
56   setSprite('sWebBall');
57   yVel = -(global.randOtherFloat(3)+1);
58   xVel = global.randOther(1, 3);
59   if (global.randOther(1, 2) == 1) xVel *= -1;
60   life = global.randOther(20, 100);
61   return true;
65 override void onAnimationLooped () {
66   if (spriteLName == 'sWebCreate') {
67     auto obj = ItemWeb(level.MakeMapObject(ix-8, iy-8, 'oWeb'));
68     if (obj) obj.dying = true;
69     instanceRemove();
70   }
74 void createWeb () {
75   setSprite('sWebCreate');
76   xVel = 0;
77   yVel = 0;
81 override void thinkFrame () {
82   if (--trailTime == 0) {
83     level.MakeMapObject(ix, iy, 'oYellowTrail');
84     trailTime = default.trailTime;
85   }
87   shiftXY(xVel, yVel);
89   if (yVel < 6) yVel += 0.2;
90   // if (yVel &gt; 0) yVel = 0; // in the original
92   if (life > 0) life -= 1; else { createWeb(); return; }
94   level.checkTilesInRect(x0, y0, width, height, delegate bool (MapTile o) {
95     if (!o.collidesWith(self)) return false;
96     if (o.spectral || !o.visible || (!o.solid && !o.water)) return false;
97     createWeb();
98     return true;
99   });
101   if (spriteLName == 'sWebCreate') return;
103   level.isObjectInRect(x0, y0, width, height, delegate bool (MapObject o) {
104     if (!o.collidesWith(self)) return false;
106     // enemy
107     auto enemy = MapEnemy(o);
108     if (enemy) {
109       if (enemy.dead || enemy isa EnemyGiantSpiderHang) return false;
110       createWeb();
111       return true;
112     }
114     // item
115     if (o isa MapItem) { createWeb(); return true; }
118     return false;
119   }, precise:false);
123 defaultproperties {
124   objName = 'Web Ball';
126   invincible = true;
127   bounce = false; // true?
128   collectible = false;
130   spectral = false;
132   imageSpeed = 1; //???
134   setCollisionBounds(-8, -8, 7, 7);