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       

[tutorial] Changing Enemies' Attack Strength in SDL
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
Andy_Nonymous
Moderator
<B>Moderator</B>


Joined: 02 Apr 2003
Last Visit: 17 Feb 2015

Topics: 99
Posts: 589
Location: New Jersey, USA
usa.gif

PostPosted: Sat Jan 19, 2013 6:56 am
   Subject: [tutorial] Changing Enemies' Attack Strength in SDL
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Bottom of Posts

This is BrotherTank's tutorial adapted for Wolf4SDL. The original thread for DOS: Changing an Enemies Attack Strength - BrotherTank

One of the many benefits of going from DOS to SDL for Wolf3d modding is the upgrade in digitized sounds: where there was a single channel before, now there are 8. This is great for ambient sounds, and the need to prioritize sounds is pretty much gone.

Which is probably why Ripper changed the T_Shoot routine in WL_ACT2.CPP. Before, when CheckLine(ob) returned a 'false' (player is behind a wall, enemy has no shot at causing damage), T_Shoot was immediately exited, meaning that whatever sound might have come from that missed shot would not play. This made sense in a 1-channel digi-sound world.

In SDL with 8 sound channels, Ripper made sure all shots taken by enemies would be heard. So instead of exiting the T_Shoot rotuine when CheckLine(ob) is 'false', the damage-related code is executed only if CheckLine(ob) is 'true'.

In addition, the Borland compiler didn't say anything if you multiplied an integer by a number like 1.25 and assigned the result to an integer. The Dev-C++ compiler (and presumably other compilers used for Wolf4SDL) would give a warning: [Warning] converting to 'int' from 'double'. To get around this, I applied a simple arithmetic workaround pointed out by Chris Chokan in this thread.

BrotherTank's original changes:
::: CODE :::

 // see if the shot was a hit

   if (US_RndT()<hitchance)
   {
      if (dist<2)
         damage = US_RndT()>>2;
      else if (dist<4)
         damage = US_RndT()>>3;
      else
         damage = US_RndT()>>4;

//      TakeDamage (damage,ob);  Remmed out and replaced below

   }

   switch(ob->obclass)
   {
    case ssobj:
      PlaySoundLocActor(SSFIRESND,ob);
// is using a machine gun so we increase the damage      
      damage = damage * 1.25;
      break;
#ifndef SPEAR
    case giftobj:
    case fatobj:
      PlaySoundLocActor(MISSILEFIRESND,ob);
// is using a projectile weapon
      damage = damage * 1.8;      
      break;
    case mechahitlerobj:
    case realhitlerobj:
    case bossobj:
      PlaySoundLocActor(BOSSFIRESND,ob);
// is using a gatlin gun or better
      damage = damage * 1.6;      
      break;
    case schabbobj:
      PlaySoundLocActor(SCHABBSTHROWSND,ob);
// is using a syringe
      damage = damage * 1.5;    
      break;
    case fakeobj:
      PlaySoundLocActor(FLAMETHROWERSND,ob);
      break;
#endif
// Guards Default
    default:
      PlaySoundLocActor(NAZIFIRESND,ob);
// is using a pistol type weapon - strength no change      
   }

// New line for damage actor
   if (damage > 0) TakeDamage (damage,ob);


Become this for SDL:
::: CODE :::

 // see if the shot was a hit

   if (US_RndT()<hitchance)
   {
      if (dist<2)
         damage = US_RndT()>>2;
      else if (dist<4)
         damage = US_RndT()>>3;
      else
         damage = US_RndT()>>4;

     switch(ob->obclass)
     {
      case ssobj:
// is using a machine gun so we increase the damage      
        damage = (damage * 125) / 100;  // 1.25;
        break;
#ifndef SPEAR
      case giftobj:
      case fatobj:
// is using a projectile weapon
          damage = (damage * 180) / 100;  // 1.8;
        break;
      case mechahitlerobj:
      case realhitlerobj:
      case bossobj:
// is using a gatlin gun or better
        damage = (damage * 160) / 100;  // 1.6;      
        break;
      case schabbobj:
// is using a syringe
        damage = (damage * 150) / 100;  // 1.5;
        break;
      case fakeobj:
        break;
#endif
     }


      TakeDamage (damage,ob);
   }

 }            // note that this bracket is the end of the 'if CheckLine(ob)' test, and doesn't exist in the DOS version

   switch(ob->obclass)
   {
    case ssobj:
      PlaySoundLocActor(SSFIRESND,ob);
      break;
#ifndef SPEAR
    case giftobj:
    case fatobj:
      PlaySoundLocActor(MISSILEFIRESND,ob);
      break;
    case mechahitlerobj:
    case realhitlerobj:
    case bossobj:
      PlaySoundLocActor(BOSSFIRESND,ob);
      break;
    case schabbobj:
      PlaySoundLocActor(SCHABBSTHROWSND,ob);
      break;
    case fakeobj:
      PlaySoundLocActor(FLAMETHROWERSND,ob);
      break;
#endif
    default:
      PlaySoundLocActor(NAZIFIRESND,ob);
   }


In other words, keep all the damage code inside the CheckLine(ob) test, and leave the sound code where it was.

Andy
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 Announcement: Wolf4SDL released
Author: Ripper
522 178604 Mon May 22, 2017 2:04 pm
Tricob View latest post
No new posts [help] Adding teleporters in wolf4sdl
Author: Mortimer
35 8807 Fri May 26, 2017 8:19 am
Military View latest post
No new posts [WOLF4SDL Help] Blake Stone Style doors
Author: Haasboy
3 2578 Sun Jul 20, 2008 7:56 am
Haasboy View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 2738 Sat May 17, 2008 11:26 am
Mortimer View latest post
No new posts [SDL] Apply 2nd ScaleFactor to selected (hi-res) vga gfx
Author: Andy_Nonymous
9 3871 Sun Apr 27, 2008 2:30 am
AlumiuN 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