I'm working on a fireworks mod for doom and I'm adding fuse that you can place on the ground. I have a transparent red hologram that displays on the ground to show you where you're placing the fuse.
The problem is that I'm making a script so that the fuse and the hologram adjust to slopes and steps and look more smooth. I have made a similar script before for grass decorations where they auto aligned themselves to the ground when they were spawned. That worked for the grass decorations, but this isn't working at all for some reason.
Code: Select all
Script "Slope_Adjust" (void)
{
int angle = GetActorAngle(0);
int x = GetActorX(0);
int y = GetActorY(0);
log(f:x);
log(f:y);
int z1 = GetSectorFloorZ(0, (x + cos(angle + 0.25) * 40) >> 16, (y + sin(angle + 0.25) * 40) >> 16);
int z2 = GetSectorFloorZ(0, (x + cos(angle + 0.75) * 40) >> 16, (y + sin(angle + 0.75) * 40) >> 16);
log(f:z1);
log(f:z2);
log(s:"");
int z3 = GetSectorFloorZ(0, (x + cos(angle) * 40) >> 16, (y + sin(angle) * 40) >> 16);
int z4 = GetSectorFloorZ(0, (x + cos(angle + 0.5) * 40) >> 16, (y + sin(angle + 0.5) * 40) >> 16);
SetActorRoll(0,-(z2 - z1) / 64);
SetActorPitch(0,-(z4 - z3) / 64);
}
If it helps, here are the actor definitons.
Code: Select all
ACTOR FireworkFuse
{
+SHOOTABLE
+NODAMAGE
+NOBLOOD
Radius 12
Height 3
States
{
Spawn:
TNT1 A 0 NoDelay
TNT1 A 0 ACS_NamedExecuteAlways("Slope_Adjust")
FFUS A 1 A_JumpIfInventory("RadiusExplode",1,"RadiusDetonate")
Loop
RadiusDetonate:
TNT1 A 0 A_PlaySound("FUSE",7,1.0,true)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-16,16),random(-16,16),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-32,32),random(-32,32),5,0,0,0.7)
FFUS A 5 Bright A_SpawnItemEx("FireworkSmoke1",random(-24,24),random(-24,24),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-16,16),random(-16,16),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-32,32),random(-32,32),5,0,0,0.7)
FFUS A 5 Bright A_SpawnItemEx("FireworkSmoke1",random(-24,24),random(-24,24),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-16,16),random(-16,16),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-32,32),random(-32,32),5,0,0,0.7)
FFUS A 5 Bright A_SpawnItemEx("FireworkSmoke1",random(-24,24),random(-24,24),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-16,16),random(-16,16),5,0,0,0.7)
TNT1 A 0 A_SpawnItemEx("FuseFXSpawner",random(-32,32),random(-32,32),5,0,0,0.7)
FFUS A 5 Bright A_SpawnItemEx("FireworkSmoke1",random(-24,24),random(-24,24),5,0,0,0.7)
TNT1 A 0 A_RadiusGive("RadiusExplode",112,RGF_ITEMS|RGF_MISSILES|RGF_OBJECTS|RGF_NOSIGHT)
TNT1 A 0 A_StopSound(7)
Stop
}
}
ACTOR FireworkFuseFake
{
Radius 32
Height 4
Renderstyle Add
Alpha 0.8
+NOINTERACTION
States
{
Spawn:
TNT1 A 0 NoDelay
TNT1 A 0 ACS_NamedExecuteAlways("Slope_Adjust")
FFUS A 1 Bright
Stop
}
}