P_BlackOw is a liar

Status
Not open for further replies.

Sapheros

Member
This part of lua is lying, as its description doesn't prove what is supposed to happen:
void P_BlackOw(player_t player)

This is used by the Armageddon Shield to blow up enemies, flash the palettes of all players within the explosion radius (1536*FRACUNITs) and destroy the shield currently being held by player. Also plays the Armageddon explosion sound.
Think i did something wrong in the script? I don't think so:
Code:
        addHook("ThinkFrame", do
            for player in players.iterate
                if not (player.shieldtimer)
                    player.shieldtimer = 0
                end
                if player.powers[pw_shield] == SH_ATTRACT
                and player.shieldtimer == 0
                    player.shieldtimer = 10*TICRATE
                end
                if player.shieldtimer > 0
                    player.shieldtimer = $1 - 1
                end
                if player.shieldtimer == 1
                    player.powers[pw_shield] = SH_NONE
                end
                if player.powers[pw_shield] == SH_BOMB
                and player.shieldtimer == 0
                    player.shieldtimer = 10*TICRATE
                end
                if player.shieldtimer == 1
                and player.powers[pw_shield] == SH_BOMB
                        P_NukeEnemies(player.mo, player.mo, 2048*FRACUNIT)
                        P_BlackOw(player)
                end
            end
        end)
What this script was originally supposed to do for the Nuke Shield was that by the end of the 10 seconds the shield was activated, it was supposed to execute the explosion, the flash, and the sound of the blast (although I didn't test the blast to hurt enemies/players yet)

No proof? Pffft: https://gfycat.com/HalfCarefulDowitcher
 
Code:
                if player.shieldtimer == 1
                    player.powers[pw_shield] = SH_NONE
                end

                -- code never executes because of above if condition
                if player.shieldtimer == 1
                and player.powers[pw_shield] == SH_BOMB
                        P_NukeEnemies(player.mo, player.mo, 2048*FRACUNIT)
                        P_BlackOw(player)
                end
 
I feel really silly making this entire thread... Thanks for noticing the error...
Edit: HOLD ON THERE PARTNER, turns out that if i remove that line, the attraction shield now blows up when the timer is up
 
Last edited:
Just a heads up, P_BlackOw itself already calls P_NukeEnemies internally...

(code from p_user.c)

Code:
void P_BlackOw(player_t *player)
{
	INT32 i;
	S_StartSound (player->mo, sfx_bkpoof); // Sound the BANG!

	for (i = 0; i < MAXPLAYERS; i++)
		if (playeringame[i] && P_AproxDistance(player->mo->x - players[i].mo->x,
			player->mo->y - players[i].mo->y) < 1536*FRACUNIT)
			P_FlashPal(&players[i], PAL_NUKE, 10);

	P_NukeEnemies(player->mo, player->mo, 1536*FRACUNIT); // Search for all nearby enemies and nuke their pants off!
	player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK;
}

Unless you don't really care about blasting all enemies 1536*FRACUNIT and closer around you twice in one go, You may prefer to just recreate P_BlackOw as it is in from C to Lua (with of course a tweak to make it 2048*FRACUNIT instead of 1536*FRACUNIT), it's no extraordinary feat if you know what you're doing.

....


...on second thought, chances are you probably don't. Open the spoiler box if you're reeeeally stuck.

Code:
local function P_BlackOwEdit(player)
	S_StartSound(player.mo, sfx_bkpoof)

	// searches through all players to have them see the armageddon shield "flash" palette for their screens
	// (only applies to players actually within the explosion range)

	for player2 in players.iterate
		if P_AproxDistance(player.mo.x-player2.mo.x,player.mo.y-player2.mo.y) < 2048*FRACUNIT
			P_FlashPal(player2,PAL_NUKE,10)
		end
	end
	P_NukeEnemies(player.mo,player.mo,2048*FRACUNIT)

	// for those who have no clue what the below does, this basically cuts off all types of non-combinable shields from the player, including of course SH_BOMB (Armageddon);
	// if the player had the fireflower "shield", this will be the only thing left over!
	// i.e the player keeps only stackable/combinable shields if any were already present (of which fire flower is currently the only one)

	player.powers[pw_shield] = $1 & SH_STACK 
end

Just paste this somewhere above the relevant ThinkFrame hook function in your script, and hopefully you should realise you should replace P_BlackOw(player) with P_BlackOwEdit(player).

(Of course it DOESN'T have to be called P_BlackOwEdit, but chances are nobody's going to listen to me regarding that anyway =V)
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top