Server Help

Bot Questions - Weapons

Jacen Solo - Wed Dec 29, 2004 6:49 pm
Post subject: Weapons
Does anyone know what the weapon values are?... I'm trying to write in some stuff for my bot to shoot different types of weapons but don't know what the values are... the only thing I know is -37000 which OverBurn told me was a level 3 mine with prox and shrap.

I'm writing it for TWCore but I don't think that really matters since it just sends a packet to the server to make it fire the weapon so the values should be the same for all cores.
Mr Ekted - Wed Dec 29, 2004 7:04 pm
Post subject:
Code: Show/Hide
#define WPN_NONE           0x00
#define WPN_BULLET         0x01
#define WPN_BOUNCINGBULLET 0x02
#define WPN_BOMB           0x03
#define WPN_PROXBOMB       0x04
#define WPN_REPEL          0x05
#define WPN_DECOY          0x06
#define WPN_BURST          0x07
#define WPN_THOR           0x08

typedef struct WPN_
   {
   WORD type        : 5;
   WORD level       : 2;
   WORD shrapbounce : 1;
   WORD shraplevel  : 2;
   WORD shrap       : 5;
   WORD multimine   : 1;
   } WPN;

Jacen Solo - Wed Dec 29, 2004 7:09 pm
Post subject:
mmm... that doesn't make much sense to me... I've never really looked at MERVBot... the Ship class for the bot in TWCore just has a method called fire and its parameter is a int value and the bot sends that int value in a fire weapon packet.
D1st0rt - Wed Dec 29, 2004 8:11 pm
Post subject:
the weapon number sent in the packet (wepinfo) is set up like this:

Code: Show/Hide
    public WeaponFired( ByteArray array ){
        super( array );
        short wepinfo = getWeaponInfo();
        m_weaponType = wepinfo & 0x001f;
        m_weaponLevel = ((wepinfo & 0x0060)>>5) + 1;
        m_weaponBouncyShrap = ((wepinfo & 0x0080)>>7)==1;
        m_weaponShrapLevel = ((wepinfo & 0x0300)>>8) + 1;
        m_weaponShrapCount = (wepinfo & 0x7c00)>>10;
        m_weaponAlternative = (wepinfo & 0x8000)>>15==1;
    }



I'll try to have something usable by tomorrow
Mr Ekted - Wed Dec 29, 2004 8:11 pm
Post subject:
The defines ARE the int values for the weapons. The structure shows how the weapon info is stored in the weapon packet.

d1stort, are you serious? Who wrote that ridiculous code? They should not be allowed to program ever again.
D1st0rt - Wed Dec 29, 2004 8:13 pm
Post subject:
it came with twcore...

not how I'd do it personally

EDIT: I was looking around, and I couldn't even find a way to extract certain bits from a number in java, so I had to write this function:

Code: Show/Hide
   public static int getBitFragment(byte b, int startIndex, int endIndex)
   {
      b &= (int)Math.pow(2,8 - startIndex);
      return (b >> (8 - endIndex));
   }

Solo Ace - Wed Dec 29, 2004 8:28 pm
Post subject:
Don't make fun of my code, it must be elite because Qndre was my teacher! icon_sad.gif
Mr Ekted - Wed Dec 29, 2004 8:50 pm
Post subject:
OMG! I'm staying out of this thread. I'm about to puke up what I had for Thanksgiving 1984. new_puppy_dog_eyes.gif
Solo Ace - Wed Dec 29, 2004 9:18 pm
Post subject:
Haha, yeah gtfo Ek! icon_smile.gif
50% Packetloss - Wed Dec 29, 2004 9:26 pm
Post subject:
Keep in mind that many of the weapons are controlled by server settings, such as emps.

This is how its written in mervbot (which is exactly what ekted has above)

Code: Show/Hide

union weaponInfo
{
   struct
   {
      Uint16 type         : 5;   // enum Projectile_Types
      Uint16 level      : 2;   // Only for bombs/bullets
      Uint16 shrapBounce   : 1;   // Bouncing shrapnel?
      Uint16 shrapLevel   : 2;   // Shrapnel level 0..3
      Uint16 shrapCount   : 5;   // 0-31
      Uint16 fireType      : 1;   // Bombs -> Mines, Bullets -> Multifire
   };

   Uint16 n;
};


// Weapon types for weaponInfo.type

enum Projectile_Types
{
   // Seen "in the wild"
   PROJ_None,
   PROJ_Bullet,
   PROJ_BBullet,
   PROJ_Bomb,
   PROJ_PBomb,
   PROJ_Repel,
   PROJ_Decoy,
   PROJ_Burst,
   PROJ_Thor,

   // Internal to the bot
   PROJ_InactiveBullet,
   PROJ_Shrapnel
};


// Weapon levels for weaponInfo.level

enum Weapon_Levels
{
   LVL_One,
   LVL_Two,
   LVL_Three,
   LVL_Four
};

Cyan~Fire - Wed Dec 29, 2004 11:43 pm
Post subject:
In case Ekted looks at this thread again, that's one of the cleaner ways of doing it in Java. icon_razz.gif
D1st0rt - Thu Dec 30, 2004 3:05 pm
Post subject:
If anyone can come up with a better solution, please tell me. I like to learn new techniques, and I've really only known how to program for a year. Heh, I wasn't even around in 1984.
Bak - Thu Dec 30, 2004 5:21 pm
Post subject:
Code: Show/Hide
/**
* get the bit fragment from startIndex to endIndex
* @param extractFrom the byte to extract from
* @param startIndex the inclusive leftbound index: 1234 5678
* @param endIndex the inclusive rightbound index 1234 5678 and > startIndex
* @return the int extracted from the requested bits
*/
public static int getBitFragment(byte extractFrom, int startIndex, int endIndex)
{
      int shift = 8 - endIndex;
      int numBits = endIndex - startIndex + 1;
      byte mask = (byte)((0x01 << numBits) - 1);

      return (extractFrom >> shift) & mask;
}

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group