from datatypes import * Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"] PlayerStates = ["UNKNOWN", "PLAYING", "IN_MENU", "CHATTING"] GameFlags = ["TEAMS", "FLAGS"] Emoticons = [str(x) for x in xrange(1,16)] Powerups = ["HEALTH", "ARMOR", "WEAPON", "NINJA"] RawHeader = ''' #include enum { INPUT_STATE_MASK=0x3f, }; ''' RawSource = ''' #include #include "protocol.h" ''' Enums = [ Enum("PLAYERSTATE", PlayerStates), Enum("EMOTE", Emotes), Enum("POWERUP", Powerups), Enum("EMOTICON", Emoticons) ] Flags = [ Flags("GAMEFLAG", GameFlags) ] Objects = [ NetObject("PlayerInput", [ NetIntAny("m_Direction"), NetIntAny("m_TargetX"), NetIntAny("m_TargetY"), NetIntAny("m_Jump"), NetIntAny("m_Fire"), NetIntAny("m_Hook"), NetIntRange("m_PlayerState", 0, len(PlayerStates)), NetIntAny("m_WantedWeapon"), NetIntAny("m_NextWeapon"), NetIntAny("m_PrevWeapon"), ]), NetObject("Projectile", [ NetIntAny("m_X"), NetIntAny("m_Y"), NetIntAny("m_VelX"), NetIntAny("m_VelY"), NetIntRange("m_Type", 0, 'NUM_WEAPONS-1'), NetTick("m_StartTick"), ]), NetObject("Laser", [ NetIntAny("m_X"), NetIntAny("m_Y"), NetIntAny("m_FromX"), NetIntAny("m_FromY"), NetTick("m_StartTick"), ]), NetObject("Pickup", [ NetIntAny("m_X"), NetIntAny("m_Y"), NetIntRange("m_Type", 0, 'max_int'), NetIntRange("m_Subtype", 0, 'max_int'), ]), NetObject("Flag", [ NetIntAny("m_X"), NetIntAny("m_Y"), NetIntRange("m_Team", 0, 1), NetIntRange("m_CarriedBy", -2, 'MAX_CLIENTS-1') ]), NetObject("Game", [ NetIntRange("m_Flags", 0, 256), NetTick("m_RoundStartTick"), NetIntRange("m_GameOver", 0, 1), NetIntRange("m_SuddenDeath", 0, 1), NetIntRange("m_Paused", 0, 1), NetIntRange("m_ScoreLimit", 0, 'max_int'), NetIntRange("m_TimeLimit", 0, 'max_int'), NetIntRange("m_Warmup", 0, 'max_int'), NetIntRange("m_RoundNum", 0, 'max_int'), NetIntRange("m_RoundCurrent", 0, 'max_int'), NetIntAny("m_TeamscoreRed"), NetIntAny("m_TeamscoreBlue"), ]), NetObject("CharacterCore", [ NetIntAny("m_Tick"), NetIntAny("m_X"), NetIntAny("m_Y"), NetIntAny("m_VelX"), NetIntAny("m_VelY"), NetIntAny("m_Angle"), NetIntRange("m_Direction", -1, 1), NetIntRange("m_Jumped", 0, 3), NetIntRange("m_HookedPlayer", 0, 'MAX_CLIENTS-1'), NetIntRange("m_HookState", -1, 5), NetTick("m_HookTick"), NetIntAny("m_HookX"), NetIntAny("m_HookY"), NetIntAny("m_HookDx"), NetIntAny("m_HookDy"), ]), NetObject("Character:CharacterCore", [ NetIntRange("m_PlayerState", 0, 'NUM_PLAYERSTATES-1'), NetIntRange("m_Health", 0, 10), NetIntRange("m_Armor", 0, 10), NetIntRange("m_AmmoCount", 0, 10), NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'), NetIntRange("m_Emote", 0, len(Emotes)), NetIntRange("m_AttackTick", 0, 'max_int'), ]), NetObject("PlayerInfo", [ NetIntRange("m_Local", 0, 1), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'), NetIntRange("m_Team", -1, 1), NetIntAny("m_Score"), NetIntAny("m_Latency"), NetIntAny("m_LatencyFlux"), ]), NetObject("ClientInfo", [ # 4*6 = 24 charachters NetIntAny("m_Name0"), NetIntAny("m_Name1"), NetIntAny("m_Name2"), NetIntAny("m_Name3"), NetIntAny("m_Name4"), NetIntAny("m_Name5"), # 4*6 = 24 charachters NetIntAny("m_Skin0"), NetIntAny("m_Skin1"), NetIntAny("m_Skin2"), NetIntAny("m_Skin3"), NetIntAny("m_Skin4"), NetIntAny("m_Skin5"), NetIntRange("m_UseCustomColor", 0, 1), NetIntAny("m_ColorBody"), NetIntAny("m_ColorFeet"), ]), ## Events NetEvent("Common", [ NetIntAny("m_X"), NetIntAny("m_Y"), ]), NetEvent("Explosion:Common", []), NetEvent("Spawn:Common", []), NetEvent("HammerHit:Common", []), NetEvent("Death:Common", [ NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'), ]), NetEvent("SoundGlobal:Common", [ NetIntRange("m_SoundId", 0, 'NUM_SOUNDS-1'), ]), NetEvent("SoundWorld:Common", [ NetIntRange("m_SoundId", 0, 'NUM_SOUNDS-1'), ]), NetEvent("DamageInd:Common", [ NetIntAny("m_Angle"), ]), ] Messages = [ ### Server messages NetMessage("Sv_Motd", [ NetString("m_pMessage"), ]), NetMessage("Sv_Broadcast", [ NetString("m_pMessage"), ]), NetMessage("Sv_Chat", [ NetIntRange("m_Team", -1, 1), NetIntRange("m_Cid", -1, 'MAX_CLIENTS-1'), NetString("m_pMessage"), ]), NetMessage("Sv_KillMsg", [ NetIntRange("m_Killer", 0, 'MAX_CLIENTS-1'), NetIntRange("m_Victim", 0, 'MAX_CLIENTS-1'), NetIntRange("m_Weapon", -3, 'NUM_WEAPONS-1'), NetIntAny("m_ModeSpecial"), ]), NetMessage("Sv_SoundGlobal", [ NetIntRange("m_Soundid", 0, 'NUM_SOUNDS-1'), ]), NetMessage("Sv_TuneParams", []), NetMessage("Sv_ExtraProjectile", []), NetMessage("Sv_ReadyToEnter", []), NetMessage("Sv_WeaponPickup", [ NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'), ]), NetMessage("Sv_Emoticon", [ NetIntRange("m_Cid", 0, 'MAX_CLIENTS-1'), NetIntRange("m_Emoticon", 0, 'NUM_EMOTICONS-1'), ]), NetMessage("Sv_VoteClearOptions", [ ]), NetMessage("Sv_VoteOption", [ NetStringStrict("m_pCommand"), ]), NetMessage("Sv_VoteSet", [ NetIntRange("m_Timeout", 0, 60), NetStringStrict("m_pDescription"), NetStringStrict("m_pCommand"), ]), NetMessage("Sv_VoteStatus", [ NetIntRange("m_Yes", 0, 'MAX_CLIENTS'), NetIntRange("m_No", 0, 'MAX_CLIENTS'), NetIntRange("m_Pass", 0, 'MAX_CLIENTS'), NetIntRange("m_Total", 0, 'MAX_CLIENTS'), ]), ### Client messages NetMessage("Cl_Say", [ NetBool("m_Team"), NetString("m_pMessage"), ]), NetMessage("Cl_SetTeam", [ NetIntRange("m_Team", -1, 1), ]), NetMessage("Cl_StartInfo", [ NetStringStrict("m_pName"), NetStringStrict("m_pSkin"), NetBool("m_UseCustomColor"), NetIntAny("m_ColorBody"), NetIntAny("m_ColorFeet"), ]), NetMessage("Cl_ChangeInfo", [ NetStringStrict("m_pName"), NetStringStrict("m_pSkin"), NetBool("m_UseCustomColor"), NetIntAny("m_ColorBody"), NetIntAny("m_ColorFeet"), ]), NetMessage("Cl_Kill", []), NetMessage("Cl_Emoticon", [ NetIntRange("m_Emoticon", 0, 'NUM_EMOTICONS-1'), ]), NetMessage("Cl_Vote", [ NetIntRange("m_Vote", -1, 1), ]), NetMessage("Cl_CallVote", [ NetStringStrict("m_Type"), NetStringStrict("m_Value"), ]), NetMessage("Cl_IsRace", []), NetMessage("Cl_TeamsState", [ NetIntAny("m_Tee0"), NetIntAny("m_Tee1"), NetIntAny("m_Tee2"), NetIntAny("m_Tee3"), NetIntAny("m_Tee4"), NetIntAny("m_Tee5"), NetIntAny("m_Tee6"), NetIntAny("m_Tee7"), NetIntAny("m_Tee8"), NetIntAny("m_Tee9"), NetIntAny("m_Tee10"), NetIntAny("m_Tee11"), NetIntAny("m_Tee12"), NetIntAny("m_Tee13"), NetIntAny("m_Tee14"), NetIntAny("m_Tee15"), ]), ]