Fri Jan 27, 2017 5:49 am
class SlopedThing : Candelabra
{
Default
{
+FLATSPRITE;
//+ROLLCENTER;
}
private void SetToSlope(double dang)
{
vector3 fnormal = CurSector.floorplane.normal;
if (!CurSector.floorplane.isSlope())
fnormal = (0, 0, 1);
vector2 fnormalp1 = (fnormal.x != 0 || fnormal.y != 0) ? (fnormal.x, fnormal.y).Unit() : (0, 0);
vector2 fnormalp2 = ((fnormal.x, fnormal.y).Length(), fnormal.z);
self.roll = 0;
self.angle = atan2(fnormalp1.y, fnormalp1.x);
self.pitch = -90+atan2(fnormalp2.x, fnormalp2.y);
//Console.Printf("angles = %.2f, %.2f, %.2f\n", angle, pitch, roll);
}
override void PostBeginPlay()
{
Super.PostBeginPlay();
}
override void Tick()
{
double dang = (level.time*3)%360;
//dang = 45;
SetToSlope(dang);
Super.Tick();
}
}
Fri Jan 27, 2017 9:02 am
Fri Jan 27, 2017 9:44 am
Fri Jan 27, 2017 9:56 am
Fri Jan 27, 2017 10:02 am
Fri Jan 27, 2017 11:41 am
Fri Jan 27, 2017 11:48 am
Fri Jan 27, 2017 12:59 pm
ZZYZX wrote:Ok so I got this horrible geometrical hack based on observing how it rotates :)
Has nothing to do with Caligari's solution though (in fact I didn't even understand what's going on there and why the /50).
http://pastebin.com/6qs9jviW (nevermind Sign, it's unused)
It's a little tiny bit off though (almost unnoticeable). I believe it needs to be upscaled/downscaled by 1.2 or smth.
Also, you probably can make it a shadow by giving it pitch of 90/-90. But it's a little tiny bit off too.
class Z_BloodSpot : Z_BloodBase
{
Default
{
Radius 8;
RenderStyle "Shaded";
}
private void SetToSlope(double dAng)
{
vector3 fNormal = CurSector.FloorPlane.Normal;
if (!CurSector.FloorPlane.isSlope())
fNormal = (0, 0, 1);
vector2 fNormalP1 = (fNormal.X != 0 || fNormal.Y != 0) ? (fNormal.X, fNormal.Y).Unit() : (0, 0);
vector2 fNormalP2 = ((fNormal.X, fNormal.Y).Length(), fNormal.Z);
vector2 angNormal1 = (cos(dAng - 90), sin(dAng - 90)).Unit();
vector2 angNormal2 = (cos(dAng), sin(dAng)).Unit();
double dDiff1 = (angNormal1.X * fNormalP1.X + angNormal1.Y * fNormalP1.Y); // dot product
double dDiff2 = (angNormal2.X * fNormalP1.X + angNormal2.Y * fNormalP1.Y); // dot product
Self.Pitch = -atan2(fNormalP2.X, fNormalP2.Y) * dDiff2;
Self.Roll = atan2(fNormalP2.X, fNormalP2.Y);
Self.Roll *= dDiff1;
Self.Angle = dAng;
}
override void PostBeginPlay()
{
Super.PostBeginPlay();
}
override void Tick()
{
SetToSlope(Angle);
Super.Tick();
}
States
{
Spawn:
TNT1 A 0 NoDelay A_SpawnItemEx("Z_BloodDrop", flags: BLOOD_FLAGS);
TNT1 A 1 A_Jump(256, "BloodSpot1", "BloodSpot2", "BloodSpot3", "BloodSpot4");
Stop;
BloodSpot1:
BSPT A 0 A_SetTics(BLOODSPOT_TICS);
Goto FadeOut;
BloodSpot2:
BSPT B 0 A_SetTics(BLOODSPOT_TICS);
Goto FadeOut;
BloodSpot3:
BSPT C 0 A_SetTics(BLOODSPOT_TICS);
Goto FadeOut;
BloodSpot4:
BSPT D 0 A_SetTics(BLOODSPOT_TICS);
Goto FadeOut;
FadeOut:
"####" "#" 2 A_FadeOut(BLOODSPOT_FADEOUTSPEED);
Loop;
}
}
Fri Jan 27, 2017 1:38 pm
Fri Jan 27, 2017 1:49 pm
Fri Jan 27, 2017 1:52 pm
Fri Jan 27, 2017 2:04 pm
Fri Jan 27, 2017 2:10 pm
Fri Jan 27, 2017 2:50 pm
override void Tick()
{
if (isVoodoo() || health <= 0)
{
Super.Tick();
return;
}
if (PentaNoiseWait > 0) PentaNoiseWait--;
if (level.maptime <= 1) InitPlayer();
ProcessCooldowns();
if (GetClass() == "Doom4Player") UpdateHAM();
Super.Tick();
}
void ProcessCooldowns()
{
// Use common denominator.
int timer = level.maptime % 30;
// No need to check for StaticChargeDrain since the upgrade alone
// shuts this off.
if (!(timer % 3))
{
if (!CountInv("StaticUpgrade4"))
{
if (CountInv("StaticUpgrade3"))
{ A_TakeInventory("StaticRifleChargingToken",1); }
else if (CountInv("StaticUpgrade2"))
{ A_TakeInventory("StaticRifleChargingToken",2); }
else
{ A_TakeInventory("StaticRifleChargingToken",4); }
}
A_TakeInventory("PlasmaStunBombCounter",1);
user_lasthp = health + CountInv("BasicArmor");
}
if (!(timer % 2))
{
A_TakeInventory("SGTripleShotTimer",1);
A_TakeInventory("SGGrenadeTimer",1);
}
if (!(timer % 10))
{
if (CountInv("GrenadeCooldown"))
{
A_TakeInventory("GrenadeCooldown",1);
if (!CountInv("GrenadeCooldown"))
{
A_PlaySound("Doom4/Weapon/Grenade/GrenadeRegen");
}
}
}
}
int CooldownTimer[3];
override void Tick()
{
if (isVoodoo() || health <= 0)
{
Super.Tick();
return;
}
if (PentaNoiseWait > 0) PentaNoiseWait--;
if (level.maptime <= 1) InitPlayer();
static const int CooldownCaps[] = { 3, 2, 10 };
for (int i = 0; i < 3; i++)
{
CooldownTimer[i] = (CooldownTimer[i] + 1) % CooldownCaps[i];
}
if (!CooldownTimer[0]) ProcessCooldown1();
if (!CooldownTimer[1]) ProcessCooldown2();
if (!CooldownTimer[2]) ProcessCooldown3();
if (GetClass() == "Doom4Player") UpdateHAM();
Super.Tick();
}
void ProcessCooldown1()
{
// No need to check for StaticChargeDrain since the upgrade alone
// shuts this off.
if (!CountInv("StaticUpgrade4"))
{
if (CountInv("StaticUpgrade3"))
{ A_TakeInventory("StaticRifleChargingToken",1); }
else if (CountInv("StaticUpgrade2"))
{ A_TakeInventory("StaticRifleChargingToken",2); }
else
{ A_TakeInventory("StaticRifleChargingToken",4); }
}
A_TakeInventory("PlasmaStunBombCounter",1);
user_lasthp = health + CountInv("BasicArmor");
}
void ProcessCooldown2()
{
A_TakeInventory("SGTripleShotTimer",1);
A_TakeInventory("SGGrenadeTimer",1);
}
void ProcessCooldown3()
{
if (CountInv("GrenadeCooldown"))
{
A_TakeInventory("GrenadeCooldown",1);
if (!CountInv("GrenadeCooldown"))
{
A_PlaySound("Doom4/Weapon/Grenade/GrenadeRegen");
}
}
}
Fri Jan 27, 2017 3:23 pm