- replaced the deletesprite calls inside the item interface, also using actors in callbacks.

This commit is contained in:
Christoph Oelckers 2021-11-13 23:34:57 +01:00
parent 99f0c89e4e
commit 799cddfb66
2 changed files with 145 additions and 143 deletions

View file

@ -2,7 +2,7 @@
struct Item {
using Callback = void (*)(PLAYER &plr, short i);
using Callback = void (*)(PLAYER &plr, DWHActor* i);
int sizx, sizy;
boolean treasures, cflag;

View file

@ -13,26 +13,26 @@ boolean isItemSprite(int i) {
void InitItems()
{
int a = 0;
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // SILVERBAG
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // SILVERBAG
{
showmessage("Silver!", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, krand() % 100 + 10);
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // GOLDBAG
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // GOLDBAG
{
showmessage("Gold!", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, krand() % 100 + 10);
});
items[a++].Init(27, 28, true, false, [](PLAYER& plr, short i) // HELMET
items[a++].Init(27, 28, true, false, [](PLAYER& plr, DWHActor* actor) // HELMET
{
showmessage("Hero Time", 360);
deletesprite(i);
DeleteActor(actor);
if (!isWh2())
addarmor(plr, 10);
plr.helmettime = 7200;
@ -42,11 +42,11 @@ void InitItems()
addscore(&plr, 10);
});
items[a++].Init(26, 26, true, false, [](PLAYER& plr, short i) // PLATEARMOR
items[a++].Init(26, 26, true, false, [](PLAYER& plr, DWHActor* actor) // PLATEARMOR
{
if (plr.armor <= 149) {
showmessage("Plate Armor", 360);
deletesprite(i);
DeleteActor(actor);
plr.armortype = 3;
plr.armor = 0;
addarmor(plr, 150);
@ -56,11 +56,11 @@ void InitItems()
}
});
items[a++].Init(26, 26, true, false, [](PLAYER& plr, short i) // CHAINMAIL
items[a++].Init(26, 26, true, false, [](PLAYER& plr, DWHActor* actor) // CHAINMAIL
{
if (plr.armor <= 99) {
showmessage("Chain Mail", 360);
deletesprite(i);
DeleteActor(actor);
plr.armortype = 2;
plr.armor = 0;
addarmor(plr, 100);
@ -69,11 +69,11 @@ void InitItems()
treasuresfound++;
}
});
items[a++].Init(47, 50, false, false, [](PLAYER& plr, short i) // LEATHERARMOR
items[a++].Init(47, 50, false, false, [](PLAYER& plr, DWHActor* actor) // LEATHERARMOR
{
if (plr.armor <= 49) {
showmessage("Leather Armor", 360);
deletesprite(i);
DeleteActor(actor);
plr.armortype = 1;
plr.armor = 0;
addarmor(plr, 50);
@ -82,11 +82,12 @@ void InitItems()
treasuresfound++;
}
});
items[a++].Init(56, 49, true, false, [](PLAYER &plr, short i) // GIFTBOX
items[a++].Init(56, 49, true, false, [](PLAYER &plr, DWHActor* actor) // GIFTBOX
{
sprite[i].detail = 0;
auto& spr = actor->s();
spr.detail = 0;
treasuresfound++;
spritesound(S_TREASURE1, &sprite[i]);
spritesound(S_TREASURE1, &spr);
int j = krand() % 8;
switch (j) {
case 0:
@ -137,7 +138,7 @@ void InitItems()
addscore(&plr, 30);
break;
}
sprite[i].picnum = OPENCHEST;
spr.picnum = OPENCHEST;
break;
case 1:
switch (krand() % 8) {
@ -206,10 +207,10 @@ void InitItems()
}
break;
}
sprite[i].picnum = OPENCHEST;
spr.picnum = OPENCHEST;
break;
case 2:
sprite[i].picnum = OPENCHEST;
spr.picnum = OPENCHEST;
addscore(&plr, (krand() % 400) + 100);
showmessage("Treasure Chest", 360);
SND_Sound(S_POTION1);
@ -266,7 +267,7 @@ void InitItems()
plr.weapon[7] = 2;
plr.ammo[7] = 1;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 30);
}
@ -274,7 +275,7 @@ void InitItems()
plr.weapon[7] = 2;
plr.ammo[7]++;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 30);
}
@ -283,7 +284,7 @@ void InitItems()
plr.weapon[7] = 1;
plr.ammo[7] = 30;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 7)
autoweaponchange(plr, 7);
@ -292,7 +293,7 @@ void InitItems()
}
break;
}
sprite[i].picnum = OPENCHEST;
spr.picnum = OPENCHEST;
break;
case 4:
// random armor
@ -334,18 +335,18 @@ void InitItems()
}
break;
}
sprite[i].picnum = OPENCHEST;
spr.picnum = OPENCHEST;
break;
case 5:
// poison chest
if ((krand() & 2) == 0) {
plr.poisoned = 1;
plr.poisontime = 7200;
sprite[i].detail = GIFTBOXTYPE;
spr.detail = GIFTBOXTYPE;
addhealth(plr, -10);
showmessage("Poisoned Chest", 360);
} else {
deletesprite(i);
DeleteActor(actor);
addscore(&plr, (krand() & 400) + 100);
showmessage("Treasure Chest", 360);
SND_Sound(S_POTION1);
@ -353,12 +354,12 @@ void InitItems()
break;
case 6:
for (j = 0; j < 8; j++)
explosion(i, sprite[i].x, sprite[i].y, sprite[i].z, sprite[i].owner);
spritesound(S_EXPLODE, &sprite[i]);
deletesprite(i);
explosion(actor->GetSpriteIndex(), spr.x, spr.y, spr.z, spr.owner);
spritesound(S_EXPLODE, &spr);
DeleteActor(actor);
break;
default:
sprite[i].picnum = OPENCHEST;
spr.picnum = OPENCHEST;
addscore(&plr, (krand() % 400) + 100);
showmessage("Experience Gained", 360);
SND_Sound(S_POTION1);
@ -366,31 +367,31 @@ void InitItems()
}
});
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, short i) // FLASKBLUE
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, DWHActor* actor) // FLASKBLUE
{
if (!potionspace(plr, 0))
return;
showmessage("Health Potion", 360);
updatepotion(plr, HEALTHPOTION);
plr.currentpotion = 0;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 10);
treasuresfound++;
});
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, short i) // FLASKGREEN
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, DWHActor* actor) // FLASKGREEN
{
if (!potionspace(plr, 1))
return;
showmessage("Strength Potion", 360);
updatepotion(plr, STRENGTHPOTION);
plr.currentpotion = 1;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 15);
treasuresfound++;
});
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, short i) // FLASKOCHRE
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, DWHActor* actor) // FLASKOCHRE
{
if (!potionspace(plr, 2))
@ -398,62 +399,62 @@ void InitItems()
showmessage("Cure Poison Potion", 360);
updatepotion(plr, ARMORPOTION);
plr.currentpotion = 2;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 15);
treasuresfound++;
});
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, short i) // FLASKRED
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, DWHActor* actor) // FLASKRED
{
if (!potionspace(plr, 3))
return;
showmessage("Resist Fire Potion", 360);
updatepotion(plr, FIREWALKPOTION);
plr.currentpotion = 3;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 20);
treasuresfound++;
});
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, short i) // FLASKTAN
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, DWHActor* actor) // FLASKTAN
{
if (!potionspace(plr, 4))
return;
showmessage("Invisibility Potion", 360);
updatepotion(plr, INVISIBLEPOTION);
plr.currentpotion = 4;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 30);
treasuresfound++;
});
items[a++].Init(14, 14, true, false, [](PLAYER& plr, short i) // DIAMONDRING
items[a++].Init(14, 14, true, false, [](PLAYER& plr, DWHActor* actor) // DIAMONDRING
{
plr.treasure[TDIAMONDRING] = 1;
showmessage("DIAMOND RING", 360);
plr.armor = 0;
addarmor(plr, 200);
plr.armortype = 3;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 25);
treasuresfound++;
});
items[a++].Init(30, 23, true, false, [](PLAYER& plr, short i) // SHADOWAMULET
items[a++].Init(30, 23, true, false, [](PLAYER& plr, DWHActor* actor) // SHADOWAMULET
{
plr.treasure[TSHADOWAMULET] = 1;
showmessage("SHADOW AMULET", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
plr.shadowtime = 7500;
addscore(&plr, 50);
treasuresfound++;
});
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, short i) // GLASSSKULL
items[a++].Init(-1, -1, true, false, [](PLAYER& plr, DWHActor* actor) // GLASSSKULL
{
plr.treasure[TGLASSSKULL] = 1;
showmessage("GLASS SKULL", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
switch (plr.lvl) {
@ -484,48 +485,48 @@ void InitItems()
}
addscore(&plr, 10);
});
items[a++].Init(51, 54, true, false, [](PLAYER& plr, short i) // AHNK
items[a++].Init(51, 54, true, false, [](PLAYER& plr, DWHActor* actor) // AHNK
{
plr.treasure[TAHNK] = 1;
showmessage("ANKH", 360);
plr.health = 0;
addhealth(plr, 250);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 100);
treasuresfound++;
});
items[a++].Init(32, 32, true, false, [](PLAYER& plr, short i) // BLUESCEPTER
items[a++].Init(32, 32, true, false, [](PLAYER& plr, DWHActor* actor) // BLUESCEPTER
{
plr.treasure[TBLUESCEPTER] = 1;
showmessage("Water walk scepter", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 10);
treasuresfound++;
});
items[a++].Init(32, 32, true, false, [](PLAYER& plr, short i) // YELLOWSCEPTER
items[a++].Init(32, 32, true, false, [](PLAYER& plr, DWHActor* actor) // YELLOWSCEPTER
{
plr.treasure[TYELLOWSCEPTER] = 1;
showmessage("Fire walk scepter", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 10);
treasuresfound++;
});
items[a++].Init(14, 14, true, false, [](PLAYER& plr, short i) // ADAMANTINERING
items[a++].Init(14, 14, true, false, [](PLAYER& plr, DWHActor* actor) // ADAMANTINERING
{
// ring or protection +5
plr.treasure[TADAMANTINERING] = 1;
showmessage("ADAMANTINE RING", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 30);
treasuresfound++;
});
items[a++].Init(42, 28, true, false, [](PLAYER& plr, short i) // ONYXRING
items[a++].Init(42, 28, true, false, [](PLAYER& plr, DWHActor* actor) // ONYXRING
{
// protection from missile
@ -533,12 +534,12 @@ void InitItems()
// dont forget to cleanup values
plr.treasure[TONYXRING] = 1;
showmessage("ONYX RING", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 35);
treasuresfound++;
});
items[a++].Init(-1, -1, true, true, [](PLAYER& plr, short i) // PENTAGRAM
items[a++].Init(-1, -1, true, true, [](PLAYER& plr, DWHActor* actor) // PENTAGRAM
{
if (sector[plr.sector].lotag == 4002)
@ -546,13 +547,13 @@ void InitItems()
else {
plr.treasure[TPENTAGRAM] = 1;
showmessage("PENTAGRAM", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
addscore(&plr, 100);
});
items[a++].Init(64, 64, true, false, [](PLAYER& plr, short i) // CRYSTALSTAFF
items[a++].Init(64, 64, true, false, [](PLAYER& plr, DWHActor* actor) // CRYSTALSTAFF
{
plr.treasure[TCRYSTALSTAFF] = 1;
@ -562,23 +563,23 @@ void InitItems()
plr.armortype = 2;
plr.armor = 0;
addarmor(plr, 300);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
addscore(&plr, 150);
});
items[a++].Init(26, 28, true, false, [](PLAYER& plr, short i) // AMULETOFTHEMIST
items[a++].Init(26, 28, true, false, [](PLAYER& plr, DWHActor* actor) // AMULETOFTHEMIST
{
plr.treasure[TAMULETOFTHEMIST] = 1;
showmessage("AMULET OF THE MIST", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
plr.invisibletime = 3200;
addscore(&plr, 75);
treasuresfound++;
});
items[a++].Init(64, 64, true, false, [](PLAYER& plr, short i) // HORNEDSKULL
items[a++].Init(64, 64, true, false, [](PLAYER& plr, DWHActor* actor) // HORNEDSKULL
{
if (isWh2()) {
@ -587,17 +588,17 @@ void InitItems()
}
plr.treasure[THORNEDSKULL] = 1;
showmessage("HORNED SKULL", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_STING2);
addscore(&plr, 750);
treasuresfound++;
});
items[a++].Init(32, 32, true, false, [](PLAYER& plr, short i) // THEHORN
items[a++].Init(32, 32, true, false, [](PLAYER& plr, DWHActor* actor) // THEHORN
{
plr.treasure[TTHEHORN] = 1;
showmessage("Ornate Horn", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
plr.vampiretime = 7200;
// gain 5-10 hp when you kill something
@ -605,57 +606,57 @@ void InitItems()
addscore(&plr, 350);
treasuresfound++;
});
items[a++].Init(30, 20, true, false, [](PLAYER& plr, short i) // SAPHIRERING
items[a++].Init(30, 20, true, false, [](PLAYER& plr, DWHActor* actor) // SAPHIRERING
{
plr.treasure[TSAPHIRERING] = 1;
showmessage("SAPPHIRE RING", 360);
plr.armortype = 3;
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 25);
treasuresfound++;
});
items[a++].Init(24, 24, true, false, [](PLAYER& plr, short i) // BRASSKEY
items[a++].Init(24, 24, true, false, [](PLAYER& plr, DWHActor* actor) // BRASSKEY
{
plr.treasure[TBRASSKEY] = 1;
showmessage("BRASS KEY", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 15);
treasuresfound++;
});
items[a++].Init(24, 24, true, false, [](PLAYER& plr, short i) // BLACKKEY
items[a++].Init(24, 24, true, false, [](PLAYER& plr, DWHActor* actor) // BLACKKEY
{
plr.treasure[TBLACKKEY] = 1;
showmessage("BLACK KEY", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 15);
});
items[a++].Init(24, 24, true, false, [](PLAYER& plr, short i) // GLASSKEY
items[a++].Init(24, 24, true, false, [](PLAYER& plr, DWHActor* actor) // GLASSKEY
{
plr.treasure[TGLASSKEY] = 1;
showmessage("GLASS KEY", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 15);
treasuresfound++;
});
items[a++].Init(24, 24, true, false, [](PLAYER& plr, short i) // IVORYKEY
items[a++].Init(24, 24, true, false, [](PLAYER& plr, DWHActor* actor) // IVORYKEY
{
plr.treasure[TIVORYKEY] = 1;
showmessage("IVORY KEY", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 15);
treasuresfound++;
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLSCARE
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLSCARE
{
if (plr.orbammo[0] < 10) {
@ -663,12 +664,12 @@ void InitItems()
plr.orbammo[0]++;
changebook(plr, 0);
showmessage("Scare Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLNIGHT
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLNIGHT
{
if (plr.orbammo[1] < 10) {
@ -676,12 +677,12 @@ void InitItems()
plr.orbammo[1]++;
changebook(plr, 1);
showmessage("Night Vision Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLFREEZE
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLFREEZE
{
if (plr.orbammo[2] < 10) {
@ -689,12 +690,12 @@ void InitItems()
plr.orbammo[2]++;
changebook(plr, 2);
showmessage("Freeze Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLMAGIC
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLMAGIC
{
if (plr.orbammo[3] < 10) {
@ -702,12 +703,12 @@ void InitItems()
plr.orbammo[3]++;
changebook(plr, 3);
showmessage("Magic Arrow Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLOPEN
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLOPEN
{
if (plr.orbammo[4] < 10) {
@ -715,12 +716,12 @@ void InitItems()
plr.orbammo[4]++;
changebook(plr, 4);
showmessage("Open Door Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLFLY
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLFLY
{
if (plr.orbammo[5] < 10) {
@ -728,12 +729,12 @@ void InitItems()
plr.orbammo[5]++;
changebook(plr, 5);
showmessage("Fly Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLFIREBALL
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLFIREBALL
{
if (plr.orbammo[6] < 10) {
@ -741,12 +742,12 @@ void InitItems()
plr.orbammo[6]++;
changebook(plr, 6);
showmessage("Fireball Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(35, 36, true, true, [](PLAYER& plr, short i) // SCROLLNUKE
items[a++].Init(35, 36, true, true, [](PLAYER& plr, DWHActor* actor) // SCROLLNUKE
{
if (plr.orbammo[7] < 10) {
@ -754,12 +755,12 @@ void InitItems()
plr.orbammo[7]++;
changebook(plr, 7);
showmessage("Nuke Scroll", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
treasuresfound++;
}
});
items[a++].Init(27, 27, false, false, [](PLAYER& plr, short i) // QUIVER
items[a++].Init(27, 27, false, false, [](PLAYER& plr, DWHActor* actor) // QUIVER
{
if (plr.ammo[6] < 100) {
@ -767,12 +768,12 @@ void InitItems()
if (plr.ammo[6] > 100)
plr.ammo[6] = 100;
showmessage("Quiver of magic arrows", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 10);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // WALLBOW BOW
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // WALLBOW BOW
{
plr.weapon[6] = 1;
@ -780,124 +781,125 @@ void InitItems()
if (plr.ammo[6] > 100)
plr.ammo[6] = 100;
showmessage("Magic bow", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 6)
autoweaponchange(plr, 6);
addscore(&plr, 10);
});
items[a++].Init(34, 21, false, false, [](PLAYER& plr, short i) // WEAPON1
items[a++].Init(34, 21, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON1
{
if (plr.ammo[1] < 12) {
plr.weapon[1] = 1;
plr.ammo[1] = 40;
showmessage("Dagger", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 1)
autoweaponchange(plr, 1);
addscore(&plr, 10);
}
});
items[a++].Init(34, 21, false, false, [](PLAYER& plr, short i) // WEAPON1A
items[a++].Init(34, 21, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON1A
{
if (plr.ammo[1] < 12) {
plr.weapon[1] = 3;
plr.ammo[1] = 80;
showmessage("Jeweled Dagger", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
autoweaponchange(plr, 1);
addscore(&plr, 30);
}
});
items[a++].Init(34, 21, false, false, [](PLAYER& plr, short i) // GOBWEAPON
items[a++].Init(34, 21, false, false, [](PLAYER& plr, DWHActor* actor) // GOBWEAPON
{
if (plr.ammo[2] < 12) {
plr.weapon[2] = 1;
plr.ammo[2] = 20;
showmessage("Short sword", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 2)
autoweaponchange(plr, 2);
addscore(&plr, 10);
}
});
items[a++].Init(26, 26, false, false, [](PLAYER& plr, short i) // WEAPON2
items[a++].Init(26, 26, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON2
{
if (plr.ammo[3] < 12) {
plr.weapon[3] = 1;
plr.ammo[3] = 55;
showmessage("Morning Star", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 3)
autoweaponchange(plr, 3);
addscore(&plr, 20);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // WALLSWORD WEAPON3A
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // WALLSWORD WEAPON3A
{
if (plr.ammo[4] < 12) {
plr.weapon[4] = 1;
plr.ammo[4] = 160;
showmessage("Broad Sword", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
autoweaponchange(plr, 4);
addscore(&plr, 60);
}
});
items[a++].Init(44, 39, false, false, [](PLAYER& plr, short i) // WEAPON3
items[a++].Init(44, 39, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON3
{
if (plr.ammo[4] < 12) {
plr.weapon[4] = 1;
plr.ammo[4] = 80;
showmessage("Broad Sword", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 4)
autoweaponchange(plr, 4);
addscore(&plr, 30);
}
});
items[a++].Init(25, 20, false, false, [](PLAYER& plr, short i) // WALLAXE WEAPON4
items[a++].Init(25, 20, false, false, [](PLAYER& plr, DWHActor* actor) // WALLAXE WEAPON4
{
if (plr.ammo[5] < 12) {
plr.weapon[5] = 1;
plr.ammo[5] = 100;
showmessage("Battle axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 5)
autoweaponchange(plr, 5);
addscore(&plr, 30);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // THROWHALBERD
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // THROWHALBERD
{
auto& spr = actor->s();
// EG fix: don't collect moving halberds, be hurt by them as you should be
// ...but only if you don't have the Onyx Ring
if (sprite[i].statnum != INACTIVE && plr.treasure[TONYXRING] == 0) {
if (spr.statnum != INACTIVE && plr.treasure[TONYXRING] == 0) {
addhealth(plr, -((krand() % 20) + 5)); // Inflict pain
// make it look and sound painful, too
if ((krand() % 9) == 0) {
spritesound(S_PLRPAIN1 + (rand() % 2), &sprite[i]);
spritesound(S_PLRPAIN1 + (rand() % 2), &spr);
}
startredflash(10);
deletesprite(i);
DeleteActor(actor);
return;
}
if (sprite[i].statnum != INACTIVE && plr.treasure[TONYXRING] != 0) {
if (spr.statnum != INACTIVE && plr.treasure[TONYXRING] != 0) {
// Can we grab?
if (plr.ammo[9] < 12 && plr.weapon[9] != 3) {
// You grabbed a halberd out of midair, so go ahead and be smug about it
@ -907,7 +909,7 @@ void InitItems()
}
else {
// Can't grab, so just block getting hit
deletesprite(i);
DeleteActor(actor);
return;
}
}
@ -916,68 +918,68 @@ void InitItems()
plr.weapon[9] = 1;
plr.ammo[9] = 30;
showmessage("Halberd", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 9)
autoweaponchange(plr, 9);
addscore(&plr, 30);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // WEAPON5
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON5
{
if (plr.ammo[9] < 12) {
plr.weapon[9] = 1;
plr.ammo[9] = 30;
showmessage("Halberd", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 9)
autoweaponchange(plr, 9);
addscore(&plr, 30);
}
});
items[a++].Init(12, 12, false, false, [](PLAYER& plr, short i) // GONZOBSHIELD
items[a++].Init(12, 12, false, false, [](PLAYER& plr, DWHActor* actor) // GONZOBSHIELD
{
if (plr.shieldpoints < 100) {
plr.shieldtype = 2;
plr.shieldpoints = 200;
droptheshield = false;
deletesprite(i);
DeleteActor(actor);
showmessage("Magic Shield", 360);
SND_Sound(S_POTION1);
addscore(&plr, 50);
}
});
items[a++].Init(26, 26, false, false, [](PLAYER& plr, short i) // SHIELD
items[a++].Init(26, 26, false, false, [](PLAYER& plr, DWHActor* actor) // SHIELD
{
if (plr.shieldpoints < 100) {
plr.shieldpoints = 100;
plr.shieldtype = 1;
deletesprite(i);
DeleteActor(actor);
showmessage("Shield", 360);
droptheshield = false; // EG 17 Oct 2017
SND_Sound(S_POTION1);
addscore(&plr, 10);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // WEAPON5B
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON5B
{
if (plr.ammo[9] < 12) { // XXX orly?
deletesprite(i);
DeleteActor(actor);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // WALLPIKE
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // WALLPIKE
{
if (plr.weapon[7] == 1) {
plr.weapon[7] = 2;
plr.ammo[7] = 2;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_PICKUPAXE);
addscore(&plr, 30);
}
@ -985,7 +987,7 @@ void InitItems()
plr.weapon[7] = 2;
plr.ammo[7]++;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_PICKUPAXE);
// score(plr, 30);
}
@ -994,7 +996,7 @@ void InitItems()
plr.weapon[7] = 1;
plr.ammo[7] = 30;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 7)
autoweaponchange(plr, 7);
@ -1002,14 +1004,14 @@ void InitItems()
}
}
});
items[a++].Init(20, 15, false, true, [](PLAYER& plr, short i) // WEAPON6
items[a++].Init(20, 15, false, true, [](PLAYER& plr, DWHActor* actor) // WEAPON6
{
if (plr.weapon[7] == 1) {
plr.weapon[7] = 2;
plr.ammo[7] = 10;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
addscore(&plr, 30);
}
@ -1017,7 +1019,7 @@ void InitItems()
plr.weapon[7] = 2;
plr.ammo[7] += 10;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
// score(plr, 30);
}
@ -1026,7 +1028,7 @@ void InitItems()
plr.weapon[7] = 2;
plr.ammo[7] = 10;
showmessage("Pike axe", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 7)
autoweaponchange(plr, 7);
@ -1034,30 +1036,30 @@ void InitItems()
}
}
});
items[a++].Init(41, 36, false, true, [](PLAYER& plr, short i) // WEAPON7
items[a++].Init(41, 36, false, true, [](PLAYER& plr, DWHActor* actor) // WEAPON7
{
if (plr.ammo[8] < 12) {
plr.weapon[8] = 1;
plr.ammo[8] = 250;
showmessage("Magic sword", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
if (plr.selectedgun < 8)
autoweaponchange(plr, 8);
addscore(&plr, 30);
}
});
items[a++].Init(32, 18, false, false, [](PLAYER& plr, short i) // GYSER
items[a++].Init(32, 18, false, false, [](PLAYER& plr, DWHActor* actor) // GYSER
{
if (plr.manatime < 1 && plr.invincibletime <= 0 && !plr.godMode) {
spritesound(S_FIREBALL, &sprite[i]);
spritesound(S_FIREBALL, &actor->s());
addhealth(plr, -1);
startredflash(30);
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // SPIKEBLADE
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // SPIKEBLADE
{
if (plr.invincibletime <= 0 && !plr.godMode && !justteleported) {
@ -1066,7 +1068,7 @@ void InitItems()
plr.spiked = 1;
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // SPIKE
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // SPIKE
{
if (plr.invincibletime <= 0 && !plr.godMode && !justteleported) {
@ -1075,7 +1077,7 @@ void InitItems()
plr.spiked = 1;
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // SPIKEPOLE
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // SPIKEPOLE
{
if (plr.invincibletime <= 0 && !plr.godMode && !justteleported) {
@ -1084,20 +1086,20 @@ void InitItems()
plr.spiked = 1;
}
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // MONSTERBALL
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // MONSTERBALL
{
if (plr.manatime < 1 && plr.invincibletime <= 0 && !plr.godMode)
addhealth(plr, -1);
});
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, short i) // WEAPON8
items[a++].Init(-1, -1, false, false, [](PLAYER& plr, DWHActor* actor) // WEAPON8
{
if (plr.ammo[8] < 12) {
plr.weapon[8] = 1;
plr.ammo[8] = 250;
showmessage("Two Handed Sword", 360);
deletesprite(i);
DeleteActor(actor);
SND_Sound(S_POTION1);
autoweaponchange(plr, 8);
addscore(&plr, 30);