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       

[Code] Adding an Object that causes Damage - Chris
Page 1 of 1
DieHard Wolfers Forum Index -> Code Tutorials 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
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 14 Jun 2019

Topics: 56
Posts: 2228
Location: Canada
blank.gif

PostPosted: Fri Jan 23, 2004 8:02 am
   Subject: Re: I need help
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Here's a rough little index of places you should look through as a starting point when trying to add objects.

WL_ACT1.C (top) - Where the objects themselves (picture, action) are defined.
WL_AGENT.C (GetBonus) - Where some of the code for the object's actions are written.
WL_DEF.H (various) - Where many objects / action ideas are declared so that they will be recognized.

Adding a regular solid object only requires editing the first file, unless you're also adding an entirely new picture with Floedit; which you should declare with a new name at the end of the "sprite constants" list (in WL_DEF.H). Like this:

::: CODE :::
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
SPR_CHAINATK4,SPR_NEWOBJECT,

To add an object to the map list, just open the first file (WL_ACT1.C) and type in a line roughly above the "{SPR_STAT_26,bo_clip2}," code like this:

::: CODE :::
{SPR_NEWOBJECT,block}

You'll now have to add a definition to Mapedit / Floedit (using the object number right after the vines) to be able to plug this new solid object into your maps. One example of how to do this is to open Mapedit's OBJDATA.WL6 file and add a new line of code like this:

::: CODE :::
0047 e00N New Solid Object

I just tested all this out with a fresh copy of the source code, and it works (displaying the new solid object with the correct picture when I plugged it into the floor map). Hope that helps! Smile
KyleRTCW
DieHard Officer
DieHard Officer


Joined: 30 Jul 2003
Last Visit: 06 Apr 2019

Topics: 45
Posts: 510
Location: Ohio
usa.gif

PostPosted: Fri Jan 23, 2004 8:12 am
   Subject: Re: I need help
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I don't how to do that, because having a block object that still hurts BJ when he's around it is beyond me, but it seems real possible.

@ Chris: Do you how to create a block object that hurts Bj when in close promitiy? I wanna know this also!!

_________________
Steam: http://steamcommunity.com/id/stormx312
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 14 Jun 2019

Topics: 56
Posts: 2228
Location: Canada
blank.gif

PostPosted: Fri Jan 23, 2004 11:23 am
   Subject: I need better reading glasses...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ahhh, ok. I tried reading MarioManiac's message over and over again, and it took awhile for me to understand what he was trying to say (guess I was wrong about what he was after, as your theory makes much more sense). I'm glad that you guys are on the same level of communication. Laughing

If you want to make the object actually hurt you; you'll have to do a little tweaking with the declarations. First you might want to add a new bo_object to the list in WL_DEF.H. Here's an example:

::: CODE :::
typedef enum {
   dressing,
   block,
   bo_gibs,
   bo_alpo,
   bo_hurt,      // added this object
   bo_firstaid,
   etc...

The actual code for the damage isn't hard to do, you just have to add something like this (probably above "bo_firstaid" in the top of GetBonus() in WL_AGENT.C):

::: CODE :::
case   bo_hurt:
      TakeDamage((gamestate.difficulty+1),NULL);
      break;

You can throw whatever formula you want into the first tag of TakeDamage (even just a number will work), as long as it hurts the player to some degree. Most objects will disappear after they've been touched, but to avoid this; you can create an if statement around the bottom of your GetBonus() function so it doesn't affect bo_hurt; like this:

::: CODE :::
   if (check->itemnumber != bo_hurt)
   {
      StartBonusFlash();
      check->shapenum = -1;      // remove from list
   }

You'll also have to declare a maptype for bo_hurt in SpawnStatic() of WL_ACT1.C. Here's an independant example of one (that I placed above "case bo_block"):

::: CODE :::
   case    bo_hurt:
      (unsigned)actorat[tilex][tiley] = 1;
      laststatobj->flags = FL_BONUS;
      laststatobj->itemnumber = statinfo[type].type;
      break;

This enforces it's solidness, but also keeps it's flags (like FL_BONUS) intact. One thing to note, though, the objects picture will disappear while you're getting injured - as part of the flash. To avoid this, open up WL_DRAW.C and add an if statement to this "continue" operation in DrawScaleds():

::: CODE :::
if (TransformTile (statptr->tilex,statptr->tiley
   ,&visptr->viewx,&visptr->viewheight) && statptr->flags & FL_BONUS)
{
   GetBonus (statptr);
   if (statptr->itemnumber != bo_hurt)   //added this line
      continue;                          //indented this line                     
}

Now there's just one more thing to do. You have to plug your new action into a Static Object of your choice. To do this, just change whatever action that object had (at the top of WL_ACT1.C) to bo_hurt; like this:

::: CODE :::
{SPR_NEWOBJECT,bo_hurt},

That's it! This "bo_hurt" object will only hurt BJ when he is emerging into the object on an angle (like the spikes in Halls of Stonehenge). To actually make it damage BJ when you're directly infront of it is a little different, as it has to detect beyond it's one block radius (or to a certain player->x/y point from the object). Maybe the code above is what you're looking for though; or atleast a good starting ground.

As always, I've just tested this out with a fresh copy of the source and it works. Have fun! Smile


Last edited by Chris on Fri Jan 23, 2004 1:30 pm; edited 1 time in total
Guest




Last Visit:





PostPosted: Fri Jan 23, 2004 12:01 pm
   Subject: Re: I need help
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Wow! I will try this, Chris! You know, I've tryied to something like this someday, but when I post my new object (who I've added much time before) it's just won't appeared. A few hours later, when I had already undone this tutorial, I've saw that I'm have do it to one game and post the new object to other. I will use your hints and try to do it again! Thank you!
Guest




Last Visit:





PostPosted: Sat Apr 24, 2004 7:53 pm
   Subject: Re: [Code] Adding an Object that causes Damage - Chris
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Hey Chris, could you specify the correct place of the new statement of WL_DRAW.C? I've got it works, but the image are still dissappear when I touch it.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials 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 [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 3270 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 2408 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 2707 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 3620 Sun Oct 26, 2003 1:21 am
Guest View latest post
No new posts [Help] Different Enemy Dying Frames/Views
Author: Guest
7 609 Tue Jul 29, 2003 3:00 pm
Codetech84 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