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       

Melee enemy attacking through walls
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: Sat Nov 05, 2016 7:33 pm
   Subject: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

I have added the melee mutant to Atomprojekt and everything works great, but for some reason it is able to attack through walls if the wall is only a single tile thick. Why is this happening and what can I change to prevent it?

Here is my T_Swing function that controls the enemy's attack.

::: CODE :::

void T_Swing (objtype *ob)
{
    int32_t    dx,dy;

 //   PlaySoundLocActor(SELECTITEMSND,ob);     // JAB

    dx = player->x - ob->x;
    if (dx<0)
        dx = -dx;
    dx -= TILEGLOBAL;
    if (dx <= MINACTORDIST)
    {
        dy = player->y - ob->y;
        if (dy<0)
            dy = -dy;
        dy -= TILEGLOBAL;
        if (dy <= MINACTORDIST)
        {
                TakeDamage ((30 + (US_RndT() % 31)),ob); // change this line to your needs
                SD_PlaySound(TAKEDAMAGESND);
                return;
        }
    }
}

_________________
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:00 ago.

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

PostPosted: Sat Nov 05, 2016 8:04 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The "dx -= TILEGLOBAL;" and "dy -= TILEGLOBAL;" lines are giving it an extra tile's worth of range; you probably don't want to remove those entirely, but it might be worth reducing them a bit. What sort of range do you want the attack to have?
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Sat Nov 05, 2016 8:40 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks. I like the range as is if I could somehow check for a wall. If I have to though, I would like to reduce to one tile.

_________________
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:00 ago.

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

PostPosted: Sat Nov 05, 2016 11:26 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Barry wrote:
Thanks. I like the range as is if I could somehow check for a wall. If I have to though, I would like to reduce to one tile.


Try replacing the section starting with "if (dy <= MINACTORDIST)" with this:

::: CODE :::
        if (dy <= MINACTORDIST)
        {
                if (CheckLine(ob))
                {
                        TakeDamage ((30 + (US_RndT() % 31)),ob); // change this line to your needs
                        SD_PlaySound(TAKEDAMAGESND);
                        return;
                }
        }
Barry
DieHard Officer
DieHard Officer


Joined: 27 Aug 2008
Last Visit: 28 Oct 2017

Topics: 64
Posts: 565

blank.gif

PostPosted: Sun Nov 06, 2016 6:46 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

^^^ Thanks a lot! So far, this has worked.

_________________
Atomprojekt Download: http://www.wolfenvault.com/files/barry/ATOM.3.zip
Passage to Hollenteufel Download: http://www.wolfenvault.com/files/barry/PTH.2.zip
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:33 ago.

Topics: 160
Posts: 8011
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sun Nov 06, 2016 7:58 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
Try replacing the section starting with "if (dy <= MINACTORDIST)" with this:

::: CODE :::
        if (dy <= MINACTORDIST)
        {
                if (CheckLine(ob))
                {
                        TakeDamage ((30 + (US_RndT() % 31)),ob); // change this line to your needs
                        SD_PlaySound(TAKEDAMAGESND);
                        return;
                }
        }

Couldn't it be simplified like this?
::: CODE :::
        if ((dy <= MINACTORDIST) && (CheckLine(ob)) )
        {
                {
                        TakeDamage ((30 + (US_RndT() % 31)),ob); // change this line to your needs
                        SD_PlaySound(TAKEDAMAGESND);
                        return;
                }
        }
AlumiuN
DieHard Wolfer
DieHard Wolfer


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

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

PostPosted: Sun Nov 06, 2016 10:01 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tricob wrote:
Couldn't it be simplified like this?
::: CODE :::
        if ((dy <= MINACTORDIST) && (CheckLine(ob)) )
        {
                {
                        TakeDamage ((30 + (US_RndT() % 31)),ob); // change this line to your needs
                        SD_PlaySound(TAKEDAMAGESND);
                        return;
                }
        }


Indeed it could, and normally that'd be the sort of thing I'd pick up on. The second set of curly brackets aren't necessary, though Razz
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:33 ago.

Topics: 160
Posts: 8011
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Mon Nov 07, 2016 1:38 pm
   Subject: Re: Melee enemy attacking through walls
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

AlumiuN wrote:
Indeed it could, and normally that'd be the sort of thing I'd pick up on. The second set of curly brackets aren't necessary, though Razz
Heh ... that's something *I* should've picked up on. Smile
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 [Help] BrotherTank's Enemy Damage Tutorial: LOWERING Damage?
Author: StoneFrog
8 807 Wed Dec 10, 2008 7:51 pm
StoneFrog View latest post
No new posts [Help, please] 90 Walls code in Wolf4SDL code
Author: Tricob
14 2055 Sun Sep 21, 2008 2:51 am
BrotherTank View latest post
No new posts [help] Changing enemy's attack strenght
Author: Mortimer
7 795 Tue Sep 16, 2008 7:34 am
Mortimer View latest post
No new posts [SDL-Help] Wall patches fix
Author: insurrectionman
0 915 Tue Jul 15, 2008 11:12 am
insurrectionman 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