DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

Possible last minute critical issue
Page 1 of 1
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Tue Jan 17, 2017 9:17 pm
   Subject: Possible last minute critical issue
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

On one of my levels, I have a capture sequence. The way I do it is I use the VictoryTile object to trigger it. The enemies go invincible and when the player is killed, instead of dying, the level ends. 9 out of 10 times it works properly. However, every now and then I have an issue where the enemies will go invincible as they should, but I will die instead of the level ending the way it should. I have not discovered what is different about times where it doesn't work properly. Here is my code that deals with this sequence.

Here is my TakeDamage function in wl_agent.cpp

::: CODE :::

/*
===============
=
= TakeDamage
=
===============
*/

void TakeDamage (int points,objtype *attacker)
{
    LastAttacker = attacker;

    if (gamestate.victoryflag)
        return;
    if (gamestate.difficulty==gd_baby)
        points>>=2;

    if (!godmode)
        gamestate.health -= points;


    if (gamestate.health<=0)
    {
        if (!gamestate.captured)
        {
            gamestate.health = 0;
            playstate = ex_died;
            killerobj = attacker;
        }
        else
        {
            gamestate.health = 10;
            gamestate.bestweapon = wp_pistol;
            gamestate.weapon = wp_knife;
            gamestate.chosenweapon = wp_pistol;
            gamestate.ammo = 0;
            gamestate.attackframe = gamestate.weaponframe = 0;
            DrawAmmo();
            DrawWeapon();
            playstate = ex_completed;
            gamestate.captured = false;

        }
    }

    if (!godmode)
        StartDamageFlash (points);

    DrawHealth ();
    DrawFace ();


Here is the VictoryTile function that triggers the capture.

::: CODE :::

/*
===================
=
= VictoryTile
=
===================
*/

void VictoryTile (void)
{
        if(gamestate.mapon == 18)
        {
            gamestate.keys = 0;
            gamestate.captured = true;
        }
        else
        playstate = ex_completed;
}


Whenever starting a new level, I always set gamestate.captured to 0 or false. It is a boolean variable. Does it make a difference whether I use false/true or 0/1?

Does anybody have any idea why this would happen? Thanks for any replies.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:01 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Tue Jan 17, 2017 9:49 pm
   Subject: Re: Possible last minute critical issue
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

This looks like it should be working fine to me; if you send me your code I can probably take a look through it some time tonight.
fraggeur
DieHard Guard
DieHard Guard


Joined: 31 Dec 2012
Last Visit: 8:24 ago.

Topics: 11
Posts: 259

blank.gif

PostPosted: Fri Jan 20, 2017 12:21 pm
   Subject: Re: Possible last minute critical issue
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I would think it is because the first time your health goes below 0, you go in the else and ex_completed.
But before GameLoop interprets it, you keep getting damage, and this time the captured flag is not there anymore so you die.

I am not sure at all
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Fri Jan 20, 2017 12:50 pm
   Subject: Re: Possible last minute critical issue
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

fraggeur wrote:
I would think it is because the first time your health goes below 0, you go in the else and ex_completed.
But before GameLoop interprets it, you keep getting damage, and this time the captured flag is not there anymore so you die.

I am not sure at all


I believe this is what is happening. Removing the captured flag from that else statement seems to prevent the player from dying. However, It appears the player still continues to take damage and doesn't always start the next level with the correct amount of health.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 17503 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [HELP] Different ammo types.
Author: Raziel
15 1629 Thu Jan 01, 2009 4:45 am
Raziel View latest post
No new posts [help] Weapon shooting rockets
Author: RichterBelmont12
13 1382 Wed Aug 06, 2008 3:22 am
Zombie_Plan View latest post
No new posts [Help] Adding a weapon problem
Author: Zombie_Plan
10 1454 Thu Jul 24, 2008 4:26 pm
RichterBelmont12 View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 2335 Sat May 17, 2008 11:26 am
Mortimer View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group