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       

statetypes
Page 1 of 1
DieHard Wolfers Forum Index -> 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
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Fri Oct 06, 2006 10:21 am
   Subject: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Hey folks,
Can someone explain the syntax of the statetype declarations?
::: CODE :::

statetype s_decoil1   = {false,SPR_ROCKET_1,3,NULL,T_MultiProjectile,&s_decoil1};

Just a little explaination about the possible attributes.
Another question, about statetypes in general. First, is there a tutorial on this?
And second, what are they actually. And most important, where does all the coding goes.
I mean, there is a declaration of "statetype" as above, but something like "extern statetype"
too. What is that all about? And how does it fit together with, for instance, SPR_xxx?

Another question: I do have 8 sprites, and I want to use them at random. Say 1 to 8, when it's 3, use sprite 3 out of 8.
I know US_RndT(), but how do I use this the best way. Create an int, put the random number in it and then use an if to
select the proper sprite? That sounds like the easiest way to me. Maybe someone has a better idea.

Thanks,
- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Fri Oct 06, 2006 10:41 am
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

To be a little more specific about the random thing:
::: CODE :::

if (gamestate.ammo<1)
   {
      return;
   }

   GetNewActor ();

   new->state = &s_decoil(US_RndT()%7);
   new->ticcount = 1;


   new->x = ob->x ;
   new->y = ob->y ;
   new->tilex = new->x >> TILESHIFT;
   new->tiley = new->y >> TILESHIFT;

   new->obclass = fireobj;
   new->dir = nodir;
   new->angle = ob->angle;
   new->speed = 0xFFFFl;
   new->flags = FL_NONMARK | FL_BONUS;
   new->active = true;


At the "(US_RndT()%7)" must be a number between 1 and 8. The code above is wrong, of course, but how do I make
the new->state right? Of course it has to be like new->state = &s_decoil1;, but the 1 has to be replaced by the random number. Like s_decoil1, or s_decoil5. I hope someone understands all this.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 02 Oct 2018

Topics: 46
Posts: 2314
Location: USA
usa.gif

PostPosted: Fri Oct 06, 2006 11:00 am
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You'd have to do something like:
::: CODE :::
switch (US_Rnd()%8)
{
    case 0:
        new->state = &s_decoil1;
        break;
    case 1:
        new->state = &s_decoil2;
        break;
... etc...
}

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Fri Oct 06, 2006 2:06 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ah, that'd come through my mind once. I didn't know how to do it, but thanks. Now I know.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Fri Oct 06, 2006 9:42 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

lwmxynedtodth wrote:
Hey folks,
Can someone explain the syntax of the statetype declarations?
::: CODE :::

statetype s_decoil1   = {false,SPR_ROCKET_1,3,NULL,T_MultiProjectile,&s_decoil1};

Here's how statetypes go... the first thing is a true/false value, and it's about whether or not the statetype is directional (8-sided). You'll notice that most guard statetypes have true here whereas boss statetypes will have false here.

Then there's SPR_ROCKET_1, which is just the name of the sprite for the statetype. This can be NULL if you don't want any sprite to be drawn for this state.

The 3 that comes next is the statetype's ticcount. That's how long the state lasts in tics (1/70th of a second). Pretty simple.

Next we have a NULL, which is the place in the statetype where you'd normally have a function that you want executed EVERY tic (called the "thinking" action). Stuff like projectile movement and guard movement traditionally goes here, functions like a damaging explosion do NOT go here unless you want it to inflict massive damage or something.

Then there's T_MultiProjectile, which is the function to be executed at the end of the statetype's life (when it's lasted the amount of tics indicated in the ticcount). This is only executed once, unlike the previous function.

Last we've got the next statetype to go to once this one's done. It's in the format of a statetype name with & in front of it unless it's NULL. If it's NULL, then your actor will get marked for removal from the objlist.

Hope that helps. Smile

_________________
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 12 Aug 2018

Topics: 22
Posts: 1283
Location: Rauma - Finland
finland.gif

PostPosted: Fri Oct 06, 2006 11:12 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Wrong! If you use NULL as the sprite number, it will display the SPR_DEMO sprite there, as NULL equals zero in this case.
Also, you forgot to mention if you set the sprite number to -1, then the sprite number will be taken from ob->temp1.
Wink

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Sat Oct 07, 2006 7:40 am
   Subject: don't do that again
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Wrong! I suggest you test the NULL thing out yourself, I just did and it made the sprite invisible.

And I guess that second bit is information, but I didn't "forget" to mention it, it would probably just be confusing and is something I've never used. Now that I'm thinking about it, it could have some interesting uses, but it's more of a nook of the code pulled at random.

AND SOMETHING NOBODY MENTIONED! If you set a projectile's directional attribute to "true" (if it wasn't already a directional projectile like the rocket), then its directions will look all wonky. You're going to have to change some things in CalcRotate to fix that, but it's easy, just tell that function to treat this projectile like a rocket. I can't believe you missed that one, Codetech! I mean come on now!

Wink

_________________
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 02 Oct 2018

Topics: 46
Posts: 2314
Location: USA
usa.gif

PostPosted: Sat Oct 07, 2006 8:48 am
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I've always wondered why they made rocket rotation different than sprite rotation.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Sat Oct 07, 2006 12:34 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Dugtrio17: thanks a lot! It's far more easier now! I just figured why my object was moving that fast, the ticcount was a bit too high. And I suppose that the last attribute, which you did explain, causes mostly an animation? Well, it does in my case. But won't I cause an infinite loop when this attribute is the same as the statetype itself?

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2018

Topics: 55
Posts: 2143
Location: Canada
blank.gif

PostPosted: Sat Oct 07, 2006 12:40 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Adam Biser wrote:
I've always wondered why they made rocket rotation different than sprite rotation.

It's probably just faster, since projectiles already have their angle calculated in T_Projectile (whereas ob->angle for guards is always 0).

So why do rockets have their angle calculated in advance? They use whole 360 radius to chase the player, whereas guards only move in 8 directions. Wink


Last edited by Chris on Sat Oct 07, 2006 12:48 pm; edited 69 times in total
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Sat Oct 07, 2006 12:40 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey Adam, you got a typo here:
switch (US_Rnd()%Cool

It is:
switch (US_RndT()%Cool

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Sat Oct 07, 2006 12:57 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yes! It works. All of you, thanks a lot, I made shot trails and decoils:D
I'm going to post a little mpg soon, if I did make the graphics any better.
And if someone thinks it is useful, I might write a tutorial on it. Woot woot, it finally works!???DVery Happy
Really, thanks.

- lwmxynedtodth

EDIT: to give proper credit: thanks to wolfie3dbreaker, dugtrio17, brothertank and adam biser

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 02 Oct 2018

Topics: 46
Posts: 2314
Location: USA
usa.gif

PostPosted: Sat Oct 07, 2006 2:28 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yeah, US_RndT().. I was air-coding. Smile

Also, setting the next state as the current state doesn't necessarily produce an infinite loop. Something can happen inside the state that makes it change states. Note that in Wofl3D, dead guards retain their state. (They don't in the last Catacomb trilogy game... the dead ants' legs twitch Smile )

True enough, Chris. No clue what I was thinking (or not) when I typed that.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Sat Oct 07, 2006 3:00 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

lwmxynedtodth wrote:
I just figured why my object was moving that fast, the ticcount was a bit too high.

Well really it's probably best to have your object's moving function (like T_Projectile) in the "thinking function" part of the state, so that it moves every tic. That way, the movement is nice and smooth instead of all jerky. It'll probably make it go faster, but just adjust the speed as necessary and I guarantee the extra smoothness will make you smile.
lwmxynedtodth wrote:
And I suppose that the last attribute, which you did explain, causes mostly an animation? Well, it does in my case. But won't I cause an infinite loop when this attribute is the same as the statetype itself?

If you set the attribute as the statetype itself, then yes, it will be an infinite loop, but as Adam said, other things can make something change state. Then again, Adam just said all that, so why am I repeating it?

_________________
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 23 Sep 2018

Topics: 55
Posts: 2143
Location: Canada
blank.gif

PostPosted: Sat Oct 07, 2006 3:24 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Adam Biser wrote:
True enough, Chris. No clue what I was thinking (or not) when I typed that.

Heh. I was going to correct my post before lwmxynedtodth sneaked in, but that last edited by message kinda irked me into cooking meatballs instead.

I see what you mean though now Adam. You're saying that the actual vswap images are in a different order, right? I just looked at this too, and it's true... the rocket uses the forward-right images before the backwards ones for the last 4 rotation frames (which is the opposite of the guards). The funny thing is, there is no special calculation to make this work! If you actually move to the left after a rocket is fired, and look closely, you'll see that it shows the incorrect backwards rocket picture instead of the correct frontward one, so each following frame gets displayed incorrectly on the screen:

- Frame 5 should be replaced with frame 8
- Frame 6 should be replaced with frame 7
- Frame 7 should be replaced with frame 6
- Frame 8 should be replaced with frame 5

Pretty funny eh? This bug is also part of the vswap for the top and center rocket frames for the Death Knight in Spear of Destiny.

Even more messed up, perhaps, is that the rocket doesn't have an actual front sprite (unlike the guards), it just has two "45-0 left" and "45-0 right" sprites, which seems to get calculated correctly, but the problem is that even when a rocket is coming right at you, it still looks like it's going kind of diagonally in the picture (since there is no direct-forward frame) - which looks rather silly. I think whoever set up those rocket frames was sniffing too many rocket candies at the time or something. Laughing

Dugtrio17 wrote:
This is your life, and it's ending one tic at a time.

Tell me about it! One time I tried to access the forum, and I guess I didn't type in the URL correctly because Firefox redirected me to DeathClock.com.

Apparently, according to the site, I only have 107,528,778,000 tics left to live, so I better use those each of them wisely! What's your ticcount down to Dan?
Dugtrio17
Code Master
Code Master


Joined: 11 Mar 2003
Last Visit: 03 Oct 2013

Topics: 49
Posts: 903
Location: Seattle
usa.gif

PostPosted: Sat Oct 07, 2006 4:01 pm
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

151,038,009,290 tics left to go, but that was a ton of tics ago, so it's probably off by a bit now.

Man, one of these days somebody should make a debugged version of the original code. Sad

_________________
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 12 Aug 2018

Topics: 22
Posts: 1283
Location: Rauma - Finland
finland.gif

PostPosted: Sun Oct 08, 2006 1:17 am
   Subject: Re: don't do that again
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Dugtrio17 wrote:
Wrong! I suggest you test the NULL thing out yourself, I just did and it made the sprite invisible.

And I guess that second bit is information, but I didn't "forget" to mention it, it would probably just be confusing and is something I've never used. Now that I'm thinking about it, it could have some interesting uses, but it's more of a nook of the code pulled at random.

AND SOMETHING NOBODY MENTIONED! If you set a projectile's directional attribute to "true" (if it wasn't already a directional projectile like the rocket), then its directions will look all wonky. You're going to have to change some things in CalcRotate to fix that, but it's easy, just tell that function to treat this projectile like a rocket. I can't believe you missed that one, Codetech! I mean come on now!

Wink


I actually went out to test the sprite number thing again, and you're right. But I remember doing this very long ago, and then the DEMO sprite replaced the enemy sprite. Could it be the noscalers, because it rewrites the original sprite drawing routine.

Edit: Oh wait, now I remember, I used 0 instead of null... Ok, my mistake.

To calculate true eight directional projectile rotation use this line in CalcRotate.
::: CODE :::
angle =  (viewangle-180)- ob->angle;


Oh and, by the way...

169,977,966,48 tics for me. Allthough I have no idea how much I weigh in pounds or how long I'm in feets.
So, it might be a bit off. I'm being optimistic...

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Sun Oct 08, 2006 5:24 am
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Dugtrio17 wrote:
It'll probably make it go faster, but just adjust the speed as necessary and I guarantee the extra smoothness will make you smile.


Thanks, I tried and it worked. Another problem was, that the shot decoils on the wall were only drawn if the trail really hit the wall. Sometimes
it just went through it because it was making too big steps at a time. Now that is a little reduced.
Did someone already coded this before? I've found it a big disadvantage: a shooting game without bullets.
The only issue now is to make correct sprites, and make all guards shoot:D

- lwmxynedtodth

EDIT: and I do not count my TTL in tics or seconds.

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Sun Oct 08, 2006 6:11 am
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yups, it is working. Just a thing of calling the decoil function in the T_Shoot function. There was only one problem, the shooting angle.
But I found an angle calculation in the FakeFire void, and used it to make all guards shoot particles.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
lemm
Registered User
Registered User


Joined: 04 Feb 2012
Last Visit: 13 Oct 2012

Topics: None
Posts: 2

blank.gif

PostPosted: Mon Feb 06, 2012 5:27 am
   Subject: Re: statetypes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

I've noticed that some of the pain statetypes are assigned a 2 for their (boolean) rotation field.

Does this have any significance, or is it just equivalent to 1 (true)?

EDIT: Never mind, I see that it alters the rotation based on hitpoint number.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> 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: [Info] Help for newbie coders! C++ Tutorial
Author: Dugtrio17
20 9605 Sun Jan 10, 2010 12:26 pm
Fragstein3D View latest post
No new posts [Info] Adding a Second Elevator or End Level
Author: Xarkon
13 2940 Tue Jul 05, 2005 7:31 pm
Tricob View latest post
No new posts [Info] Black & White Effect - Tutorial
Author: Guest
10 297 Thu Mar 17, 2005 6:24 pm
Dugtrio17 View latest post
No new posts Sounds not working!!
Author: ZuljinRaynor
9 1711 Mon Dec 06, 2004 1:24 pm
Hair Machine View latest post
No new posts General Midi
Author: ZuljinRaynor
7 1386 Mon May 10, 2004 12:46 pm
ZuljinRaynor 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