Duke4.net Forums: How do we UN-cstat a sprite like undoing cstat /cstator? - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How do we UN-cstat a sprite like undoing cstat /cstator?

User is offline   Zaxtor 

#1

Like if you do cstat 1 it makes the sprite block you.
But is there such thing as contrary of it.
Like cstat xx to make it unblock?

Tried searching cstat/cstator and can't find.

I tried cstat 0 and I don't think it works.

The sprite is blockable but I want to make it unblock (without killing sprite) when it execute the code.
0

User is offline   Mblackwell 

  • Evil Overlord

#2

Cstat 0 would undo blocking, yes (as well as every other cstat/any other cstat). I'm not sure that's true if there was a clipshape for the actor though. My usage of clipshapes is fairly limited.
0

User is offline   Zaxtor 

#3

I can try the cstat 0.
Never tried for blocking sprites.

Was other things I have tried and didn't work.
0

User is offline   Zaxtor 

#4

Cstat 0 worked thx.

PS
Is funny when not mentioned in Eduke32 wiki site.

This post has been edited by Zaxtor: 13 January 2012 - 08:15 PM

0

User is online   Hendricks266 

  • Weaponized Autism

  #5

View PostZaxtor, on 13 January 2012 - 08:14 PM, said:

Is funny when not mentioned in Eduke32 wiki site.

I added a note explicitly saying this, but in general the possibility of using zero for a value comes along with basic understanding of bitfields.
1

#6

Don't forget that cstat 0 also disables all of the other flags. So you need to check if the cstat includes bit 1 which is block. If it does, then just substitute the cstat 1. Are you able to put the cstat into a gamevar?
0

User is offline   Helixhorned 

  • EDuke32 Developer

#7

Yeah, the idiom to use here would be something like

get(...) SOMEGAMEVAR
ifand SOMEGAMEVAR THEBIT
    subvar SOMEGAMEVAR THEBIT
set(...) SOMEGAMEVAR


edit: ifvarand, of course...
0

#8

Oh yea it's ifand. I always forget those bit commands :S
0

User is online   Hendricks266 

  • Weaponized Autism

  #9

Does anyone know of the proper way to set and un-set bits in CON using andvar, orvar, xorvar, etc., rather than addvar or subvar?

This post has been edited by Hendricks266: 14 January 2012 - 01:54 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#10

View PostHendricks266, on 14 January 2012 - 01:41 PM, said:

Does anyone know of the proper way to set and un-set bits in CON using andvar, orvar, xorvar, etc., rather than addvar or subvar?


Examples:

orvar TEMP 8

will set the bit for 8 in the var TEMP. It's no more complicated than using the cstator command, and you want to use it when there is no point in checking whether the bit is already set.

ifvarand TEMP 8 xorvar TEMP 8

will check to see if the bit for 8 is set in the var TEMP, and if it is will eliminate only that bit from TEMP. I use this myself, but I don't see any advantage over using subvar, unless it is slightly faster due to being a bitwise operation.

ifvarand and ifvarvarand are the most useful bitwise operators in my experience
0

#11

View PostHendricks266, on 14 January 2012 - 01:41 PM, said:

Does anyone know of the proper way to set and un-set bits in CON using andvar, orvar, xorvar, etc., rather than addvar or subvar?


Setting bits via CON is quite obvious; as DeeperThought already stated, it should be done like this (sets the bit 8, for example):
orvar TEMP 8


Also, in order to reset a bit, you aren't ought to use an "if" statement; instead, you may perform a bitwise AND operation using the negated bit mask (that is, all bits are on except one that needs to be reset). Note that the hexadecimal number format suits better for this:
andvar TEMP 0xFFF7

Since 0xFFFF minus 8 gives 0xFFF7, this operation would reset the bit 8 which was set in the previous line.

Here's a short table of conversions between decimal and hexadecimal number representations and their inverses for 16-bit tags (such as the cstat parameters). It can be continued until 32768, but I think you've got the idea.
Decimal   Hex   Inv. Hex
     1    0x0001  0xFFFE
     2    0x0002  0xFFFD
     4    0x0004  0xFFFB
     8    0x0008  0xFFF7
    16    0x0010  0xFFEF


This post has been edited by CraigFatman: 10 February 2012 - 11:10 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options