- cleaned up the generic destructible code and used it for several more things.

This commit is contained in:
Christoph Oelckers 2022-11-24 07:43:05 +01:00
parent f89ccec829
commit 4397e65443
17 changed files with 306 additions and 312 deletions

View file

@ -2235,6 +2235,7 @@ static void parseSpawnClasses(FScanner& sc, FScriptPosition& pos)
int res_id = -1;
int numframes = -1;
bool interpolate = false;
int clipdist = -1;
sc.SetCMode(true);
if (!sc.CheckString("{"))
@ -2251,6 +2252,7 @@ static void parseSpawnClasses(FScanner& sc, FScriptPosition& pos)
int basetex = -1;
int brokentex = -1;
int fullbright = 0;
int flags = 0;
FName sound = NAME_None;
FName cname;
sc.GetNumber(num, true);
@ -2287,6 +2289,28 @@ static void parseSpawnClasses(FScanner& sc, FScriptPosition& pos)
S_FindSound(sc.String).index();
if (sound <= 0) Printf(TEXTCOLOR_RED "Unknown sound %s in definition for spawn ID # %d\n", num);
#endif
if (sc.CheckString(","))
{
bool cont = true;
if (sc.CheckNumber())
{
clipdist = sc.Number;
cont = sc.CheckString(",");
}
if (cont) do
{
sc.MustGetString();
if (sc.Compare("damaging")) flags |= 1;
else if (sc.Compare("solid") || sc.Compare("blocking")) flags |= 2;
else if (sc.Compare("unblocking")) flags |= 4;
else if (sc.Compare("spawnglass")) flags |= 8;
else if (sc.Compare("spawnscrap")) flags |= 16;
else if (sc.Compare("spawnsmoke")) flags |= 32;
else if (sc.Compare("spawnglass2")) flags |= 64; // Duke has 2 ways of spawning glass debris...
else sc.ScriptMessage("'%s': Unknown actor class flag", sc.String);
} while (sc.CheckString(","));
}
}
}
@ -2294,7 +2318,7 @@ static void parseSpawnClasses(FScanner& sc, FScriptPosition& pos)
}
// todo: check for proper base class
spawnMap.Insert(num, { cname, nullptr, base, basetex, brokentex, sound, fullbright });
spawnMap.Insert(num, { cname, nullptr, base, basetex, brokentex, sound, int8_t(fullbright), int8_t(clipdist), int16_t(flags) });
}
sc.SetCMode(false);
}

View file

@ -278,7 +278,8 @@ struct SpawnRec
int param;
int basetex, brokentex;
FName breaksound;
int fullbright;
int8_t fullbright, clipdist;
int16_t flags;
PClass* Class(int pn)
{

View file

@ -1049,7 +1049,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
{
int j, k;
int j;
if (targ->GetClass() != RUNTIME_CLASS(DDukeActor))
{
@ -1060,38 +1060,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
switch (targ->spr.picnum)
{
case WTGLASS1:
case WTGLASS2:
if (!isWorldTour())
break;
S_PlayActorSound(GLASS_BREAKING, targ);
lotsofglass(targ, nullptr, 10);
targ->Destroy();
return;
case OCEANSPRITE1:
case OCEANSPRITE2:
case OCEANSPRITE3:
case OCEANSPRITE4:
case OCEANSPRITE5:
spawn(targ, SMALLSMOKE);
targ->Destroy();
break;
case HANGLIGHT:
case GENERICPOLE2:
for (k = 0; k < 6; k++)
{
auto a = randomAngle();
auto vel = krandf(4) + 4;
auto zvel = -krandf(16) - targ->vel.Z * 0.25;
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, STAT_MISC);
if (spawned) spawned->spriteextra = Scrap1 + (krand() & 15);
}
S_PlayActorSound(GLASS_HEAVYBREAK, targ);
targ->Destroy();
break;
case FANSPRITE:
targ->spr.picnum = FANSPRITEBROKE;
targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
@ -1122,48 +1090,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
targ->Destroy();
}
break;
case BOTTLE1:
case BOTTLE2:
case BOTTLE3:
case BOTTLE4:
case BOTTLE5:
case BOTTLE6:
case BOTTLE8:
case BOTTLE10:
case BOTTLE11:
case BOTTLE12:
case BOTTLE13:
case BOTTLE14:
case BOTTLE15:
case BOTTLE16:
case BOTTLE17:
case BOTTLE18:
case BOTTLE19:
case DOMELITE:
case SUSHIPLATE1:
case SUSHIPLATE2:
case SUSHIPLATE3:
case SUSHIPLATE4:
case SUSHIPLATE5:
case WAITTOBESEATED:
case VASE:
case STATUEFLASH:
case STATUE:
if (targ->spr.picnum == BOTTLE10)
fi.lotsofmoney(targ, 4 + (krand() & 3));
else if (targ->spr.picnum == STATUE || targ->spr.picnum == STATUEFLASH)
{
lotsofcolourglass(targ, nullptr, 40);
S_PlayActorSound(GLASS_HEAVYBREAK, targ);
}
else if (targ->spr.picnum == VASE)
lotsofglass(targ, nullptr, 40);
S_PlayActorSound(GLASS_BREAKING, targ);
targ->spr.Angles.Yaw = randomAngle();
lotsofglass(targ, nullptr, 8);
targ->Destroy();
break;
case FETUS:
targ->spr.picnum = FETUSBROKE;
S_PlayActorSound(GLASS_BREAKING, targ);
@ -1177,8 +1103,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
}
S_PlayActorSound(GLASS_HEAVYBREAK, targ);
S_PlayActorSound(SQUISHED, targ);
[[fallthrough]];
case BOTTLE7:
S_PlayActorSound(GLASS_BREAKING, targ);
lotsofglass(targ, nullptr, 10);
targ->Destroy();

View file

@ -1509,57 +1509,10 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
targ->Destroy();
}
break;
case YELLOWBOTTLE:
if (!isRRRA()) break;
[[fallthrough]];
case BOTTLE1:
case BOTTLE2:
case BOTTLE3:
case BOTTLE4:
case BOTTLE5:
case BOTTLE6:
case BOTTLE8:
case BOTTLE10:
case BOTTLE11:
case BOTTLE12:
case BOTTLE13:
case BOTTLE14:
case BOTTLE15:
case BOTTLE16:
case BOTTLE17:
case BOTTLE18:
case BOTTLE19:
case DOMELITE:
case SUSHIPLATE1:
case SUSHIPLATE2:
case SUSHIPLATE3:
case SUSHIPLATE4:
case SUSHIPLATE5:
case WAITTOBESEATED:
case VASE:
case STATUEFLASH:
case STATUE:
if (targ->spr.picnum == BOTTLE10)
fi.lotsofmoney(targ, 4 + (krand() & 3));
else if (targ->spr.picnum == STATUE || targ->spr.picnum == STATUEFLASH)
{
lotsofcolourglass(targ, nullptr, 40);
S_PlayActorSound(GLASS_HEAVYBREAK, targ);
}
else if (targ->spr.picnum == VASE)
lotsofglass(targ, nullptr, 40);
S_PlayActorSound(GLASS_BREAKING, targ);
targ->spr.Angles.Yaw = randomAngle();
lotsofglass(targ, nullptr, 8);
targ->Destroy();
break;
case RRTILE2654:
case RRTILE2656:
case RRTILE3172:
if (!isRRRA()) break;
[[fallthrough]];
case BOTTLE7:
S_PlayActorSound(GLASS_BREAKING, targ);
lotsofglass(targ, nullptr, 10);
targ->Destroy();

View file

@ -56,6 +56,8 @@ void setFromSpawnRec(DDukeActor* act, SpawnRec* info)
act->IntVar(NAME_brokenstate) = info->brokentex;
act->IntVar(NAME_breaksound) = S_FindSound(info->breaksound.GetChars()).index();
act->IntVar(NAME_fullbright) = info->fullbright;
act->spr.inittype = info->flags;
if (info->clipdist > 0) act->spr.clipdist = info->clipdist;
}
}
}

View file

@ -180,13 +180,10 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case NEON4:
case NEON5:
case NEON6:
case DOMELITE:
if (act->spr.picnum != WATERSPLASH2)
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
[[fallthrough]];
case NUKEBUTTON:
if (act->spr.picnum == DOMELITE)
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
ChangeActorStat(act, STAT_MISC);
break;
case NATURALLIGHTNING:
@ -262,43 +259,13 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case FUELPOD:
case SOLARPANNEL:
case ANTENNA:
case BOTTLE1:
case BOTTLE2:
case BOTTLE3:
case BOTTLE4:
case BOTTLE5:
case BOTTLE6:
case BOTTLE7:
case BOTTLE8:
case BOTTLE10:
case BOTTLE11:
case BOTTLE12:
case BOTTLE13:
case BOTTLE14:
case BOTTLE15:
case BOTTLE16:
case BOTTLE17:
case BOTTLE18:
case BOTTLE19:
case OCEANSPRITE1:
case OCEANSPRITE2:
case OCEANSPRITE3:
case OCEANSPRITE5:
case MONK:
case INDY:
case LUKE:
case JURYGUY:
case FANSPRITE:
case HANGLIGHT:
case FETUS:
case FETUSBROKE:
case SUSHIPLATE1:
case SUSHIPLATE2:
case SUSHIPLATE3:
case SUSHIPLATE4:
case SUSHIPLATE5:
case WAITTOBESEATED:
case VASE:
case PIPE1:
case PIPE2:
case PIPE3:
@ -307,8 +274,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case PIPE6:
act->clipdist = 8;
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
[[fallthrough]];
case OCEANSPRITE4:
ChangeActorStat(act, 0);
break;
case FEMMAG1:

View file

@ -149,7 +149,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case NEON4:
case NEON5:
case NEON6:
case DOMELITE:
if (act->spr.picnum != WATERSPLASH2)
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
ChangeActorStat(act, STAT_MISC);
@ -200,32 +199,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case SOLARPANNEL:
case ANTENNA:
case GRATE1:
case BOTTLE1:
case BOTTLE2:
case BOTTLE3:
case BOTTLE4:
case BOTTLE5:
case BOTTLE6:
case BOTTLE7:
case BOTTLE8:
case BOTTLE10:
case BOTTLE11:
case BOTTLE12:
case BOTTLE13:
case BOTTLE14:
case BOTTLE15:
case BOTTLE16:
case BOTTLE17:
case BOTTLE18:
case BOTTLE19:
case FANSPRITE:
case SUSHIPLATE1:
case SUSHIPLATE2:
case SUSHIPLATE3:
case SUSHIPLATE4:
case SUSHIPLATE5:
case WAITTOBESEATED:
case VASE:
case PIPE1:
case PIPE2:
case PIPE3:

View file

@ -32,6 +32,7 @@ int PicForName(int intname)
{"RedneckCircleStuck", "CIRCLESTUCK"},
{"DukePigCop", "PIGCOP"},
{"DukeSmallSmoke", "SMALLSMOKE"},
{"DukeMoney", "MONEY"},
};
for (auto& p : classes)
@ -464,6 +465,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofglass, DukeActor_Lotsofglass)
return 0;
}
void DukeActor_Lotsofcolourglass(DDukeActor* origin, int count)
{
lotsofcolourglass(origin, nullptr, count);
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofcolourglass, DukeActor_Lotsofcolourglass)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(count);
DukeActor_Lotsofcolourglass(self, count);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, makeitfall, makeitfall)
{
PARAM_SELF_PROLOGUE(DDukeActor);

View file

@ -2,5 +2,6 @@
spawnclasses
{
5163 = DukeFireball
5736 = DukeGenericDestructible, "WTGLASS1", "", "GLASS_BREAKING", spawnglass
5737 = DukeGenericDestructible, "WTGLASS2", "", "GLASS_BREAKING", spawnglass
}

View file

@ -65,7 +65,12 @@ spawnclasses
580 = DukeReactor2Spark
1088 = DukeReactor
1092 = DukeReactorSpark
4465 = DukeGenericPole2
979 = DukeHangLight
869 = DukeStatueFlash
753 = DukeStatue
1157 = DukeBottle10
765 = DukeVase
1272 = DukeTrash
634 = DukeBolt1
@ -101,25 +106,55 @@ spawnclasses
1528 = DukePlayerGun
1536 = DukePlayerLeg
595 = DukeGenericSolidUnblockingDestructible, "GRATE1", "BGRATE1", "VENT_BUST"
1113 = DukeGenericUnblockingDestructible, "CIRCLEPANNEL", "CIRCLEPANNELBROKE", "VENT_BUST"
342 = DukeGenericSolidUnblockingDestructible, "PANNEL1", "BPANNEL1", "VENT_BUST"
343 = DukeGenericSolidUnblockingDestructible, "PANNEL2", "BPANNEL3", "VENT_BUST"
4099 = DukeGenericUnblockingDestructible, "PANNEL3", "BPANNEL3", "VENT_BUST"
556 = DukeGenericSolidUnblockingDestructible, "CHAIR1", "BROKENCHAIR"
557 = DukeGenericSolidUnblockingDestructible, "CHAIR2", "BROKENCHAIR"
595 = DukeGenericDestructible, "GRATE1", "BGRATE1", "VENT_BUST", solid, unblocking
1113 = DukeGenericDestructible, "CIRCLEPANNEL", "CIRCLEPANNELBROKE", "VENT_BUST", unblocking
342 = DukeGenericDestructible, "PANNEL1", "BPANNEL1", "VENT_BUST", solid, unblocking
343 = DukeGenericDestructible, "PANNEL2", "BPANNEL3", "VENT_BUST", solid, unblocking
4099 = DukeGenericDestructible, "PANNEL3", "BPANNEL3", "VENT_BUST", unblocking
556 = DukeGenericDestructible, "CHAIR1", "BROKENCHAIR", solid, unblocking
557 = DukeGenericDestructible, "CHAIR2", "BROKENCHAIR", solid, unblocking
686 = DukeGenericSolidScrapSpawningDestructible, "MOVIECAMERA", "", "GLASS_HEAVYBREAK"
678 = DukeGenericSolidScrapSpawningDestructible, "SCALE", "", "GLASS_HEAVYBREAK"
685 = DukeGenericSolidScrapSpawningDestructible, "CAMERALIGHT", "", "GLASS_HEAVYBREAK"
689 = DukeGenericSolidScrapSpawningDestructible, "IVUNIT", "", "GLASS_HEAVYBREAK"
694 = DukeGenericSolidScrapSpawningDestructible, "POT1", "", "GLASS_HEAVYBREAK"
695 = DukeGenericSolidScrapSpawningDestructible, "POT2", "", "GLASS_HEAVYBREAK"
697 = DukeGenericSolidScrapSpawningDestructible, "POT3", "", "GLASS_HEAVYBREAK"
4444 = DukeGenericSolidScrapSpawningDestructible, "TRIPODCAMERA", "", "GLASS_HEAVYBREAK"
669 = DukeGenericSolidScrapSpawningDestructible, "*VACUUM", "", "GLASS_HEAVYBREAK"
686 = DukeGenericDestructible, "MOVIECAMERA", "", "GLASS_HEAVYBREAK", solid, spawnscrap
678 = DukeGenericDestructible, "SCALE", "", "GLASS_HEAVYBREAK", solid, spawnscrap
685 = DukeGenericDestructible, "CAMERALIGHT", "", "GLASS_HEAVYBREAK", solid, spawnscrap
689 = DukeGenericDestructible, "IVUNIT", "", "GLASS_HEAVYBREAK", solid, spawnscrap
694 = DukeGenericDestructible, "POT1", "", "GLASS_HEAVYBREAK", solid, spawnscrap
695 = DukeGenericDestructible, "POT2", "", "GLASS_HEAVYBREAK", solid, spawnscrap
697 = DukeGenericDestructible, "POT3", "", "GLASS_HEAVYBREAK", solid, spawnscrap
4444 = DukeGenericDestructible, "TRIPODCAMERA", "", "GLASS_HEAVYBREAK", solid, spawnscrap
669 = DukeGenericDestructible, "*VACUUM", "", "GLASS_HEAVYBREAK", solid, spawnscrap
971 = DukeGenericDestructible, "OCEANSPRITE1", "", "", 8, blocking, spawnsmoke
972 = DukeGenericDestructible, "OCEANSPRITE2", "", "", 8, blocking, spawnsmoke
973 = DukeGenericDestructible, "OCEANSPRITE3", "", "", 8, blocking, spawnsmoke
974 = DukeGenericDestructible, "OCEANSPRITE4", "", "", spawnsmoke
975 = DukeGenericDestructible, "OCEANSPRITE5", "", "", 8, blocking, spawnsmoke
1025 = DukeGenericDestructible, "BOTTLE7", "", "GLASS_BREAKING", solid, spawnglass
551 = DukeGenericDestructible, "DOMELITE", "", "GLASS_HEAVYBREAK", blocking, spawnglass2
954 = DukeGenericDestructible, "BOTTLE1", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
955 = DukeGenericDestructible, "BOTTLE2", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
956 = DukeGenericDestructible, "BOTTLE3", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
957 = DukeGenericDestructible, "BOTTLE4", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1012 = DukeGenericDestructible, "BOTTLE5", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1013 = DukeGenericDestructible, "BOTTLE6", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1014 = DukeGenericDestructible, "BOTTLE8", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1158 = DukeGenericDestructible, "BOTTLE11", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1159 = DukeGenericDestructible, "BOTTLE12", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1160 = DukeGenericDestructible, "BOTTLE13", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1161 = DukeGenericDestructible, "BOTTLE14", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1162 = DukeGenericDestructible, "BOTTLE15", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1163 = DukeGenericDestructible, "BOTTLE16", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1164 = DukeGenericDestructible, "BOTTLE17", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1165 = DukeGenericDestructible, "BOTTLE18", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1166 = DukeGenericDestructible, "BOTTLE19", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
716 = DukeGenericDestructible, "WAITTOBESEATED", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
768 = DukeGenericDestructible, "SUSHIPLATE1", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
769 = DukeGenericDestructible, "SUSHIPLATE2", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
774 = DukeGenericDestructible, "SUSHIPLATE3", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
779 = DukeGenericDestructible, "SUSHIPLATE4", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
792 = DukeGenericDestructible, "SUSHIPLATE5", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
}
tileflag TFLAG_WALLSWITCH {
HANDPRINTSWITCH
HANDPRINTSWITCHON

View file

@ -5,7 +5,7 @@ spawnclasses
5278 = "RedneckUfo3"
5282 = "RedneckUfo4"
5286 = "RedneckUfo5"
2654 = DukeGenericGlassSpawningDestructible, "*RRTILE2654", "", "GLASS_BREAKING"
2656 = DukeGenericGlassSpawningDestructible, "*RRTILE2656", "", "GLASS_BREAKING"
3172 = DukeGenericGlassSpawningDestructible, "*RRTILE3172", "", "GLASS_BREAKING"
2654 = DukeGenericDestructible, "*RRTILE2654", "", "GLASS_BREAKING", spawnglass
2656 = DukeGenericDestructible, "*RRTILE2656", "", "GLASS_BREAKING", spawnglass
3172 = DukeGenericDestructible, "*RRTILE3172", "", "GLASS_BREAKING", spawnglass
}

View file

@ -131,18 +131,19 @@ spawnclasses
8498 = DukeGenericDestructible, "RRTILE8498", "RRTILE5077", "GLASS_HEAVYBREAK"
8499 = DukeGenericDestructible, "RRTILE8499", "RRTILE5078", "GLASS_HEAVYBREAK"
2445 = DukeGenericDestructible, "RRTILE2445", "RRTILE2450", "GLASS_HEAVYBREAK"
7885 = DukeGenericDamagingDestructible, "RRTILE7885", "RRTILE5045", "SIGNHIT"
7890 = DukeGenericDamagingDestructible, "RRTILE7890", "RRTILE5045", "SIGNHIT"
7886 = DukeGenericDamagingDestructible, "RRTILE7886", "RRTILE5046", "SIGNHIT"
7887 = DukeGenericDamagingDestructible, "RRTILE7887", "RRTILE5044", "GLASS_HEAVYBREAK"
2123 = DukeGenericDamagingDestructible, "RRTILE2123", "RRTILE2124", "GLASS_BREAKING"
3773 = DukeGenericDamagingDestructible, "RRTILE3773", "RRTILE8651", "GLASS_BREAKING"
7533 = DukeGenericDamagingDestructible, "*RRTILE7533", "*RRTILE5035", "SIGNHIT"
3584 = DukeGenericDamagingDestructible, "RRTILE3584", "RRTILE8681", "SIGNHIT"
7885 = DukeGenericDestructible, "RRTILE7885", "RRTILE5045", "SIGNHIT", damaging
7890 = DukeGenericDestructible, "RRTILE7890", "RRTILE5045", "SIGNHIT", damaging
7886 = DukeGenericDestructible, "RRTILE7886", "RRTILE5046", "SIGNHIT", damaging
7887 = DukeGenericDestructible, "RRTILE7887", "RRTILE5044", "GLASS_HEAVYBREAK", damaging
2123 = DukeGenericDestructible, "RRTILE2123", "RRTILE2124", "GLASS_BREAKING", damaging
3773 = DukeGenericDestructible, "RRTILE3773", "RRTILE8651", "GLASS_BREAKING", damaging
7533 = DukeGenericDestructible, "*RRTILE7533", "*RRTILE5035", "SIGNHIT", damaging
3584 = DukeGenericDestructible, "RRTILE3584", "RRTILE8681", "SIGNHIT", damaging
8394 = DukeGenericDestructible, "RRTILE8394", "RRTILE5072", "SIGNHIT"
8461 = DukeGenericDestructible, "RRTILE8461", "RRTILE5074", "GLASS_HEAVYBREAK"
8462 = DukeGenericDestructible, "RRTILE8462", "RRTILE5074", "GLASS_HEAVYBREAK"
8682 = DukeGenericDestructible, "RRTILE8682", "RRTILE8683", "GLASS_HEAVYBREAK"
1824 = DukeGenericDestructible, "YELLOWBOTTLE", "", "GLASS_HEAVYBREAK", spawnglass2
}
tileflag TFLAG_WALLSWITCH {

View file

@ -67,7 +67,13 @@ spawnclasses
1109 = DukeReactor2Spark
2239 = DukeReactor
2243 = DukeReactorSpark
2754 = DukeGenericPole2
3063 = DukeHangLight
2231 = DukeStatueFlash
1168 = DukeStatue
1280 = DukeBottle10
1172 = DukeVase
285 = RedneckChickenSpawner1
286 = RedneckChickenSpawner2
287 = RedneckFeatherSpawner
@ -109,34 +115,58 @@ spawnclasses
5607 = RedneckCootJibB
5616 = RedneckCootJibB
3114 = DukeGenericGlassSpawningDestructible, "RRTILE3114", "RRTILE3117", "GLASS_BREAKING"
2876 = DukeGenericGlassSpawningDestructible, "RRTILE2876", "RRTILE2990", "GLASS_BREAKING"
3152 = DukeGenericGlassSpawningDestructible, "RRTILE3152", "RRTILE3218", "GLASS_BREAKING"
3153 = DukeGenericGlassSpawningDestructible, "RRTILE3153", "RRTILE3219", "GLASS_BREAKING"
2030 = DukeGenericGlassSpawningDestructible, "RRTILE2030", "RRTILE2034", "GLASS_BREAKING"
2915 = DukeGenericGlassSpawningDestructible, "RRTILE2915", "RRTILE2977", "GLASS_BREAKING"
2893 = DukeGenericGlassSpawningDestructible, "RRTILE2893", "RRTILE2978", "GLASS_BREAKING"
3115 = DukeGenericGlassSpawningDestructible, "RRTILE3115", "RRTILE3116", "GLASS_BREAKING"
3171 = DukeGenericGlassSpawningDestructible, "RRTILE3171", "RRTILE3216", "GLASS_BREAKING"
2156 = DukeGenericGlassSpawningDestructible, "*RRTILE2156", "*RRTILE2157", "GLASS_BREAKING"
2158 = DukeGenericGlassSpawningDestructible, "*RRTILE2158", "*RRTILE2159", "GLASS_BREAKING"
2160 = DukeGenericGlassSpawningDestructible, "*RRTILE2160", "*RRTILE2161", "GLASS_BREAKING"
2175 = DukeGenericGlassSpawningDestructible, "*RRTILE2175", "*RRTILE2176", "GLASS_BREAKING"
3114 = DukeGenericDestructible, "RRTILE3114", "RRTILE3117", "GLASS_BREAKING", spawnglass
2876 = DukeGenericDestructible, "RRTILE2876", "RRTILE2990", "GLASS_BREAKING", spawnglass
3152 = DukeGenericDestructible, "RRTILE3152", "RRTILE3218", "GLASS_BREAKING", spawnglass
3153 = DukeGenericDestructible, "RRTILE3153", "RRTILE3219", "GLASS_BREAKING", spawnglass
2030 = DukeGenericDestructible, "RRTILE2030", "RRTILE2034", "GLASS_BREAKING", spawnglass
2915 = DukeGenericDestructible, "RRTILE2915", "RRTILE2977", "GLASS_BREAKING", spawnglass
2893 = DukeGenericDestructible, "RRTILE2893", "RRTILE2978", "GLASS_BREAKING", spawnglass
3115 = DukeGenericDestructible, "RRTILE3115", "RRTILE3116", "GLASS_BREAKING", spawnglass
3171 = DukeGenericDestructible, "RRTILE3171", "RRTILE3216", "GLASS_BREAKING", spawnglass
2156 = DukeGenericDestructible, "*RRTILE2156", "*RRTILE2157", "GLASS_BREAKING", spawnglass
2158 = DukeGenericDestructible, "*RRTILE2158", "*RRTILE2159", "GLASS_BREAKING", spawnglass
2160 = DukeGenericDestructible, "*RRTILE2160", "*RRTILE2161", "GLASS_BREAKING", spawnglass
2175 = DukeGenericDestructible, "*RRTILE2175", "*RRTILE2176", "GLASS_BREAKING", spawnglass
234 = DukeGenericSolidUnblockingDestructible, "GRATE1", "BGRATE1", "VENT_BUST"
2251 = DukeGenericUnblockingDestructible, "CIRCLEPANNEL", "CIRCLEPANNELBROKE", "VENT_BUST"
343 = DukeGenericSolidUnblockingDestructible, "PANNEL2", "BPANNEL3", "VENT_BUST"
1085 = DukeGenericSolidUnblockingDestructible, "CHAIR1", "BROKENCHAIR"
1086 = DukeGenericSolidUnblockingDestructible, "CHAIR2", "BROKENCHAIR"
1158 = DukeGenericSolidScrapSpawningDestructible, "MOVIECAMERA", "", "GLASS_HEAVYBREAK"
1150 = DukeGenericSolidScrapSpawningDestructible, "SCALE", "", "GLASS_HEAVYBREAK"
1157 = DukeGenericScrapSpawningDestructible, "CAMERALIGHT", "", "GLASS_HEAVYBREAK"
1163 = DukeGenericSolidScrapSpawningDestructible, "IVUNIT", "", "GLASS_HEAVYBREAK"
1164 = DukeGenericSolidScrapSpawningDestructible, "POT1", "", "GLASS_HEAVYBREAK"
1165 = DukeGenericSolidScrapSpawningDestructible, "POT2", "", "GLASS_HEAVYBREAK"
1166 = DukeGenericSolidScrapSpawningDestructible, "POT3", "", "GLASS_HEAVYBREAK"
1141 = DukeGenericSolidScrapSpawningDestructible, "VACUUM", "", "GLASS_HEAVYBREAK"
234 = DukeGenericDestructible, "GRATE1", "BGRATE1", "VENT_BUST", solid, unblocking
2251 = DukeGenericDestructible, "CIRCLEPANNEL", "CIRCLEPANNELBROKE", "VENT_BUST", unblocking
343 = DukeGenericDestructible, "PANNEL2", "BPANNEL3", "VENT_BUST", solid, unblocking
1085 = DukeGenericDestructible, "CHAIR1", "BROKENCHAIR", solid, unblocking
1086 = DukeGenericDestructible, "CHAIR2", "BROKENCHAIR", solid, unblocking
1157 = DukeGenericDestructible, "CAMERALIGHT", "", "GLASS_HEAVYBREAK", spawnscrap
1158 = DukeGenericDestructible, "MOVIECAMERA", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1150 = DukeGenericDestructible, "SCALE", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1163 = DukeGenericDestructible, "IVUNIT", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1164 = DukeGenericDestructible, "POT1", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1165 = DukeGenericDestructible, "POT2", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1166 = DukeGenericDestructible, "POT3", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1141 = DukeGenericDestructible, "VACUUM", "", "GLASS_HEAVYBREAK", solid, spawnscrap
1080 = DukeGenericDestructible, "DOMELITE", "", "GLASS_HEAVYBREAK", blocking, spawnglass2
1215 = DukeGenericDestructible, "BOTTLE1", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1216 = DukeGenericDestructible, "BOTTLE2", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1217 = DukeGenericDestructible, "BOTTLE3", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1218 = DukeGenericDestructible, "BOTTLE4", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1219 = DukeGenericDestructible, "BOTTLE5", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1220 = DukeGenericDestructible, "BOTTLE6", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1221 = DukeGenericDestructible, "BOTTLE7", "", "GLASS_BREAKING", solid, spawnglass
1222 = DukeGenericDestructible, "BOTTLE8", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1281 = DukeGenericDestructible, "BOTTLE11", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1282 = DukeGenericDestructible, "BOTTLE12", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1283 = DukeGenericDestructible, "BOTTLE13", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1284 = DukeGenericDestructible, "BOTTLE14", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1285 = DukeGenericDestructible, "BOTTLE15", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1286 = DukeGenericDestructible, "BOTTLE16", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1287 = DukeGenericDestructible, "BOTTLE17", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1288 = DukeGenericDestructible, "BOTTLE18", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1289 = DukeGenericDestructible, "BOTTLE19", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
2215 = DukeGenericDestructible, "WAITTOBESEATED", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1174 = DukeGenericDestructible, "SUSHIPLATE1", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1175 = DukeGenericDestructible, "SUSHIPLATE2", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1176 = DukeGenericDestructible, "SUSHIPLATE3", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1178 = DukeGenericDestructible, "SUSHIPLATE4", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
1180 = DukeGenericDestructible, "SUSHIPLATE5", "", "GLASS_HEAVYBREAK", 8, blocking, spawnglass2
}

View file

@ -57,6 +57,7 @@ version "4.10"
#include "zscript/games/duke/actors/soundcontroller.zs"
#include "zscript/games/duke/actors/respawncontroller.zs"
#include "zscript/games/duke/actors/respawnmarker.zs"
#include "zscript/games/duke/actors/genericdestructible.zs"
#include "zscript/games/duke/actors/projectiles.zs"
#include "zscript/games/duke/actors/rat.zs"
@ -83,8 +84,8 @@ version "4.10"
#include "zscript/games/duke/actors/ooz.zs"
#include "zscript/games/duke/actors/bloodsplats.zs"
#include "zscript/games/duke/actors/reactor.zs"
#include "zscript/games/duke/actors/destructibles.zs"
#include "zscript/games/duke/actors/genericdestructible.zs"
#include "zscript/games/duke/actors/redneckmisc.zs"
#include "zscript/games/duke/actors/rabbitspawner.zs"
#include "zscript/games/duke/actors/chickenplant.zs"

View file

@ -0,0 +1,110 @@
class DukeGenericPole2 : DukeActor
{
default
{
pic "GENERICPOLE2";
}
override void OnHit(DukeActor proj)
{
for (int k = 0; k < 6; k++)
{
let a = frandom(0, 360);
let vel = frandom(4, 8);
let zvel = -frandom(0, 16) - self.vel.Z * 0.25;
let spawned = dlevel.SpawnActor(self.sector, self.pos.plusZ(-8), 'DukeScrap', -8, (0.75, 0.75), a, vel, zvel, self, STAT_MISC);
if (spawned) spawned.spriteextra = DukeScrap.Scrap1 + random(0, 15);
}
self.PlayActorSound("GLASS_HEAVYBREAK");
self.Destroy();
}
}
class DukeHangLight : DukeGenericPole2
{
default
{
statnum STAT_ACTOR;
clipdist 8;
pic "HANGLIGHT";
}
override void Initialize()
{
self.cstat |= CSTAT_SPRITE_BLOCK_ALL;
}
}
class DukeStatueFlash : DukeActor
{
default
{
pic "STATUEFLASH";
}
override void OnHit(DukeActor proj)
{
self.lotsofcolourglass(40);
self.PlayActorSound("GLASS_HEAVYBREAK");
self.angle = frandom(0, 360);
self.lotsofglass(8);
self.Destroy();
}
}
class DukeStatue : DukeStatueFlash
{
default
{
pic "STATUE";
}
}
class DukeBottle10 : DukeActor
{
Default
{
pic "BOTTLE10";
clipdist 8;
}
override void Initialize()
{
self.cstat |= CSTAT_SPRITE_BLOCK_ALL;
}
override void OnHit(DukeActor proj)
{
self.lotsofstuff("DukeMoney", random(4, 7));
self.PlayActorSound("GLASS_HEAVYBREAK");
self.angle = frandom(0, 360);
self.lotsofglass(8);
self.Destroy();
}
}
class DukeVase : DukeActor
{
Default
{
pic "VASE";
clipdist 8;
}
override void Initialize()
{
self.cstat |= CSTAT_SPRITE_BLOCK_ALL;
}
override void OnHit(DukeActor proj)
{
self.lotsofglass(49);
self.PlayActorSound("GLASS_HEAVYBREAK");
self.angle = frandom(0, 360);
self.lotsofglass(8);
self.Destroy();
}
}

View file

@ -1,5 +1,5 @@
// Generic class that can handle most simple destructible items without writing any new code at all. All actions are defined in .def files in the spawnclasses block.
class DukeGenericDestructible : DukeActor
{
TextureID spawnstate, brokenstate;
@ -7,12 +7,24 @@ class DukeGenericDestructible : DukeActor
int fullbright;
int broken;
enum EFlags
{
f_damaging = 1,
f_solid = 2,
f_unblocking = 4,
f_spawnglass = 8,
f_spawnscrap = 16,
f_spawnsmoke = 32,
f_spawnglass2 = 64
}
native bool SetBroken(bool bust); // sets broken texture. Must be done natively as long as we do not have proper texture support.
virtual bool DestroyAction() { return false; } // for customized subclasses
override void Initialize()
{
if (self.inittype & f_solid) self.cstat |= CSTAT_SPRITE_BLOCK_ALL;
self.SetBroken(false);
}
@ -21,8 +33,21 @@ class DukeGenericDestructible : DukeActor
if (broken) return;
broken = true;
if (breaksound >= 0) self.PlayActorSound(breaksound);
bool res1 = self.SetBroken(true);
bool res2 = DestroyAction();
let flags = self.inittype;
if (flags & f_unblocking) self.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
if (flags & f_damaging) self.hitradius(10, 0, 0, 1, 1);
if (flags & f_spawnglass) self.lotsofglass(10);
if (flags & f_spawnscrap) for(int i = 0; i < 16; i++) self.RandomScrap();
if (flags & f_spawnsmoke) self.spawn('DukeSmallSmoke');
if (flags & f_spawnglass2)
{
self.angle = frandom(0, 360);
self.lotsofglass(8);
}
if (res1 || res2)
self.Destroy();
}
@ -34,70 +59,3 @@ class DukeGenericDestructible : DukeActor
}
}
class DukeGenericDamagingDestructible : DukeGenericDestructible
{
override bool DestroyAction()
{
self.hitradius(10, 0, 0, 1, 1);
return false;
}
}
class DukeGenericGlassSpawningDestructible : DukeGenericDestructible
{
override bool DestroyAction()
{
self.lotsofglass(10);
return false;
}
}
class DukeGenericScrapSpawningDestructible : DukeGenericDestructible
{
override bool DestroyAction()
{
for(int i = 0; i < 16; i++) self.RandomScrap();
self.Destroy();
return false;
}
}
class DukeGenericUnblockingDestructible : DukeGenericDestructible
{
override bool DestroyAction()
{
self.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
return false;
}
}
class DukeGenericSolidScrapSpawningDestructible : DukeGenericDestructible
{
override void Initialize()
{
self.SetBroken(false);
self.cstat |= CSTAT_SPRITE_BLOCK_ALL;
}
override bool DestroyAction()
{
for(int i = 0; i < 16; i++) self.RandomScrap();
self.Destroy();
return false;
}
}
class DukeGenericSolidUnblockingDestructible : DukeGenericDestructible
{
override void Initialize()
{
self.SetBroken(false);
self.cstat |= CSTAT_SPRITE_BLOCK_ALL;
}
override bool DestroyAction()
{
self.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
return false;
}
}

View file

@ -167,6 +167,7 @@ class DukeActor : CoreActor native
native DukeActor spawnsprite(int type); // for cases where the map has a picnum stored. Avoid when possible.
native DukeActor spawnweaponorammo(int type);
native void lotsofglass(int count);
native void lotsofcolourglass(int count);
native void makeitfall();
native void detonate(name type);
native void checkhitdefault(DukeActor proj);