Achievement system fixes and stackable chanceboxes.

This commit is contained in:
Mari the Deer 2022-01-11 02:18:38 +01:00
commit 35b0ad1b2b
10 changed files with 126 additions and 37 deletions

View file

@ -798,10 +798,10 @@ Class CBoxLight : SpotLightAttenuated
Destroy();
return;
}
Vector2 ofs = ((special1<2)?8:-8,(special1%2)?12:-12);
Vector2 ofs = ((special1<2)?8:-8,(special1%2)?12:-12)*target.scale.x;
double ang = (special1<2)?0:180;
angle = target.angle+ang;
SetOrigin(target.Vec3Offset(ofs.x*cos(target.angle)-ofs.y*sin(target.angle),ofs.y*cos(target.angle)+ofs.x*sin(target.angle),10),true);
SetOrigin(target.Vec3Offset(ofs.x*cos(target.angle)-ofs.y*sin(target.angle),ofs.y*cos(target.angle)+ofs.x*sin(target.angle),10*target.scale.y),true);
}
}
@ -883,9 +883,9 @@ Class Chancebox : Actor
break;
}
if ( cz < bceil ) bceil = cz;
if ( cz-fz < 56 ) continue; // too short
if ( cz-fz < 60 ) continue; // too short
bool blockedff = false;
BlockThingsIterator bt = BlockThingsIterator.CreateFromPos(testpos.x,testpos.y,fz,56,256,false);
BlockThingsIterator bt = BlockThingsIterator.CreateFromPos(testpos.x,testpos.y,fz,60,256,false);
while ( bt.Next() )
{
if ( !bt.Thing ) continue;
@ -901,10 +901,10 @@ Class Chancebox : Actor
spots.Push(sp);
}
// spawn at the real floor
if ( bceil-testpos.z < 56 ) continue; // too short
if ( bceil-testpos.z < 60 ) continue; // too short
// don't spawn on sky or hurtfloors if there are 3D floors
if ( (nffloor > 0) && ((s.GetTexture(0) == skyflatnum) || (s.damageamount > 0)) ) continue;
BlockThingsIterator bt = BlockThingsIterator.CreateFromPos(testpos.x,testpos.y,testpos.z,56,256,false);
BlockThingsIterator bt = BlockThingsIterator.CreateFromPos(testpos.x,testpos.y,testpos.z,60,256,false);
while ( bt.Next() )
{
if ( !bt.Thing ) continue;
@ -954,7 +954,19 @@ Class Chancebox : Actor
if ( (candidates.Size() <= 0) || invoker.dud )
{
// no candidates? just burst into treats
if ( Random[Chancebox](0,1) )
if ( (scale.x > .5) && (Random[Chancebox](0,int(9*scale.x*scale.x)) < 3) )
{
// spawn another smaller chancebox
// (chance increases for the inner box, up until a scale factor of 50% is reached)
let a = Spawn("Chancebox",pos+(0,0,3*scale.y));
a.bDROPPED = false;
a.bNOGRAVITY = false;
a.vel.z = FRandom[Chancebox](2,4);
a.angle = angle;
a.scale *= scale.x-.125;
if ( target && (a.scale.x <= .5) ) SWWMUtility.MarkAchievement("matryoshka",target.player);
}
else if ( Random[Chancebox](0,1) )
{
Class<Inventory> vipammodrop = null;
if ( SWWMUtility.ItemExists("Ynykron") && Random[Chancebox](0,1) ) vipammodrop = "YnykronAmmo";
@ -1109,14 +1121,14 @@ Class Chancebox : Actor
}
action void A_Confetti()
{
A_StartSound("misc/tada",CHAN_ITEM);
A_StartSound("misc/tada",CHAN_ITEM,pitch:1./scale.x);
double ang, pt;
int numpt = Random[ExploS](100,120);
for ( int i=0; i<numpt; i++ )
{
ang = FRandom[ExploS](0,360);
pt = FRandom[ExploS](-90,30);
let c = Spawn("FancyConfetti",Vec3Offset(0,0,16));
let c = Spawn("FancyConfetti",Vec3Offset(0,0,16*scale.y));
c.vel = (cos(pt)*cos(ang),cos(pt)*sin(ang),-sin(pt))*FRandom[ExploS](2,8);
}
}
@ -1209,6 +1221,7 @@ Class Chancebox : Actor
SWWMLoreLibrary.Add(user.player,"Chancebox");
specialf2 = AngleTo(user);
SetStateLabel("PreActive");
target = user;
return true;
}
override void PostBeginPlay()
@ -1230,6 +1243,7 @@ Class Chancebox : Actor
dud = true;
break;
}
A_SetSize(default.radius*scale.x,default.height*scale.y);
}
Default
{
@ -1241,6 +1255,7 @@ Class Chancebox : Actor
+SOLID;
+INTERPOLATEANGLES;
+COUNTITEM;
+CANPASS;
Species "Chancebox";
}
States
@ -1263,7 +1278,7 @@ Class Chancebox : Actor
{
angle = specialf2;
specialf1 = angle;
A_StartSound("misc/drumroll",CHAN_WEAPON);
A_StartSound("misc/drumroll",CHAN_WEAPON,pitch:1./scale.x);
}
XZW1 A 1
{
@ -1272,23 +1287,26 @@ Class Chancebox : Actor
pitch = FRandom[Chancebox](-5,5);
roll = FRandom[Chancebox](-5,5);
special1++;
return A_JumpIf(special1>40,"BlowUp");
return A_JumpIf(special1>int(40*scale.x),"BlowUp");
}
Wait;
BlowUp:
XZW2 A 1
{
A_SetSize(12,3);
A_SetSize(default.radius*scale.x,2.5*scale.y);
A_QuakeEx(2,2,2,9,0,500,"",QF_RELATIVE|QF_SCALEDOWN,falloff:200,rollIntensity:.2);
A_StartSound("chancebox/explode",CHAN_VOICE);
A_StartSound("chancebox/explode",CHAN_VOICE,pitch:1./scale.x);
angle = specialf1;
pitch = roll = 0;
let t = Spawn("ChanceboxTop",Vec3Offset(0,0,20));
let t = Spawn("ChanceboxTop",Vec3Offset(0,0,20*scale.y));
t.angle = angle;
let s1 = Spawn("ChanceboxSide",level.Vec3Offset(pos,(RotateVector((12,0),angle+90),0)));
t.scale = scale;
let s1 = Spawn("ChanceboxSide",level.Vec3Offset(pos,(RotateVector((12*scale.x,0),angle+90),0)));
s1.angle = angle+90;
let s2 = Spawn("ChanceboxSide",level.Vec3Offset(pos,(RotateVector((12,0),angle-90),0)));
s1.scale = scale;
let s2 = Spawn("ChanceboxSide",level.Vec3Offset(pos,(RotateVector((12*scale.x,0),angle-90),0)));
s2.angle = angle-90;
s2.scale = scale;
A_DropSomething();
}
XZW2 BCDEFGHIJKLMNO 1;
@ -1312,6 +1330,7 @@ Class ChanceboxTop : Actor
{
Super.PostBeginPlay();
vel = (0,0,20);
A_SetSize(default.radius*scale.x,default.height*scale.y);
}
States
{
@ -1347,6 +1366,7 @@ Class ChanceboxSide : Actor
{
Super.PostBeginPlay();
vel = (cos(angle)*cos(pitch),sin(angle)*cos(pitch),-sin(pitch))*20;
A_SetSize(default.radius*scale.x,default.height*scale.y);
}
States
{