Tremfusion.net

Game events

From TremFusion

Contents

Preliminary

  • There is a confusion with 'Think' events in tremulous sourcecode. Think = timer action, Think = each frame action, Think = ent->nextthink ? I assume (for the moment):
    • Frame = a simple frame
    • Think = managed by ent->nextthink
    • Timer1000 = every seconds
  • There is too many events, and some of there are useless. Following list will be cleared later

Tree

  • entity
    • player
    • buildable
    • missile
    • mover
  • weapon
  • game

Index

  • buildable
    • buildable.Decon
    • buildable.Die
    • buildable.Frame
    • buildable.Init
    • buildable.Pain
    • buildable.Spawn
    • buildable.Think
    • buildable.Use
  • entity
    • entity.Die
    • entity.Frame
    • entity.Init
    • entity.Pain
    • entity.Think
    • entity.Use
  • game
    • game.Exit
    • game.Frame
    • game.Init
    • game.PlayerBegin
    • game.PlayerConnect
    • game.PlayerDisconnect
    • game.Shutdown
    • game.StageUp
    • game.SuddenDeath (need tf.suddendeath script loaded)
  • missile
    • missile.Frame
  • mover
    • mover.Frame
  • player
    • player.Build
    • player.ChangeTeam
    • player.Die
    • player.Evolve
    • player.Frame
    • player.Init
    • player.Inventory
    • player.Pain
    • player.PrimaryAttack
    • player.SecondaryAttack
    • player.Spawn
    • player.Timer100
    • player.Timer1000
    • player.Think
    • player.ThirdAttack
    • player.Use
  • weapon
    • weapon.Frame

Events

buildable

buildable.Decon

TODO

buildable.Die

TODO

buildable.Frame

  • input argument: building=<thinking building entity>
  • no output argument

TODO

src/game/g_main.c:G_CalculateBuildPoints() stuff:

  • update level.reactorPresent/overmindPresent
  • decrease level.human(Powered)BuildPoints/level.alienBuildPoints

buildable.Init

TODO

buildable.Pain

TODO

buildable.Spawn

TODO

buildable.Think

  • input argument: building=<thinking building entity>
  • no output argument

TODO

buildable.Use

TODO

entity

entity.Die

TODO

entity.Frame

  • input argument: entity=<framing entity>
  • no output argument
  • check.system.InUse: skip unused entities
  • check.sytem.SkipTemporary: skip 'action' group for temporary entities (TODO: dirty, maybe scripted temporary entities have to run frames)
  • check.system.???: skip if( !ent->r.linked && ent->neverFree ) (TODO: what is it ?)
  • init.ClearEvents: clear events that are too old
  • action.EvaluateAcceleration: Set entity acceleration (not in init because don't use 'args') (/!\ WARNING /!\ : should overwrite check.system.???)
  • action.MissileFrame: run event.missile.Frame if entity is a missile
  • action.BuildableFrame: run event.buildable.Frame if entity is a buildable ( G_BuildableThink(), yek ! )
  • action.MoverFrame: run event.mover.Frame if entity is a mover
  • action.Physics: apply physics (G_Physics) for this entity
  • action.ClientSynchronousFrame: run event.player.Frame if entity is a synchronous client

entity.Init

TODO

entity.Pain

TODO

entity.Think

  • input argument: entity=<thinking entity>
  • no output argument
  • check.Time: check thinking time
  • action.BuildableThink: run event.buildable.Think if entity is a buildable
  • action.ClientThink: run event.client.Think if entity is a client
  • action.HookThink: run q3 think hook (TODO: howto make a scripting support for q3 hook stuff ?)
  • term.Next: initialize next think to a default value if there is not

entity.Use

TODO

game

game.Exit

TODO

game.Frame

calling function: src/game/g_main.c:G_RunFrame()

  • 'levelTime' (integer)
  • no output argument
  • check.IsLevelRestarting: do nothing if level is restarting
  • init.Msec: initialize 'msec' argument from 'levelTime' argument and level.time
  • action.init.UpdateCvars: update all cvars from server (TODO: UpdateCvars should call cvar updating event)
  • action.init.SeedRandom: seed the random generator
  • action.init.CountSpawns: count spawns and set result to level.num<Team>Spawns
  • action.UpdateTime: incrase frame number itself and update level.previousTime and level.time
  • action.CheckDemo: server side demo stuff ?
  • action.EntityFrame: run event.entity.Frame for each entity in game
  • action.PlayerFrame: run ClientEndFrame() for each client in game, then update CS_STAGES config string ( see G_CalculateBuildPoints() )
  • action.UnlaggedStore: run unlagged stuff for each frame
  • action.CalculateBuildPoints: finish buildpoints computation stuff did in event.buildable.Frame, then set config string
  • action.CalculateStages: call event game.StageUp for both team
  • action.SpawnClients: spawn awaiting clients
  • action.CalculateAvgPlayers: calculates the average number of players playing this game
  • action.CheckExitRules: check if it's time to end the level (TODO: should simply call a event.game.Exit event)
  • action.CheckTeamStatus: update all team status (about teamplay messages)
  • action.CheckVote: cancel vote if timed out (TODO: rewrite vote stuff for scripting engine)
  • action.CheckTeamVote: same thing for team votes (TODO: rewrite vote stuff for scripting engine)
  • action.CheckCvars: check cvars for tracking changes (TODO: useless with updating event hooks)
  • action.UpdateFrameMsec: update level.frameMsec with trap_Milliseconds()

remove this code (and add it as script if needed):

  if( g_listEntity.integer )
  {                                                                                                        
    for( i = 0; i < MAX_GENTITIES; i++ )
      G_Printf( "%4i: %s\n", i, g_entities[ i ].classname );                                               
  
    trap_Cvar_Set( "g_listEntity", "0" );                                                                  
  }

game.Init

calling function: src/game/g_main.c:G_InitGame()

  • 'levelTime' (integer), 'restart' (boolean)
  • no output argument
  • action.InitLevel:
  • action.InitLogs: (should be moved to scripts)
  • action.MapConfig: (should be moved to scripts)
  • action.ReadAdminConfig: (should be moved to scripts)
  • action.LocateGameData:
  • action.SetConfigstring: reset stuff in config string
  • action.Emoticons: init emoticons
  • action.Layout: init layouts and add layout entities to map
  • action.InitAllowedGameElements:
  • action.FindTeams:
  • action.initClassConfigs:
  • action.InitBuildableConfigs:
  • action.InitDamageLocations:
  • action.InitSpawnQueue:
  • action.InitVoices: init voip
  • action.Bots: init bots
  • action.ResetStages: reset stages cvar (g_*Stage, g_*Credits)
  • action.RemapTeamShaders: do nothing (???)
  • action.CountSpawns: count the spawns without a client attached
  • action.ResetPTRCConnections:

Removed (should add by script):

  if( g_debugMapRotation.integer )
    G_PrintRotations( );

game.PlayerBegin

TODO

game.PlayerConnect

TODO

game.PlayerDisconnect

TODO

game.Shutdown

TODO

game.StageUp

calling function: src/game/g_main.c:G_CalculateStages(). There is also stuff in G_CalculateBuildPoints()

  • input argument: team = "alien" or "human"
  • no output argument
  • check.IsStageUp: skip event if team don't stage up. Init "stage" argument with reached stage
  • check.IsStageAllreadyReached: Set a boolean args[reached] if stage allready reached
  • action.StageUp: do the stageup main action :
    • Set g_<team>Stage to args[stage]
    • Set level.<team>Stage<args[stage]>Time to level.time
  • action.RunTrigger: run stages triggers if args[reached] is false
  • action.log.Log: log stage up (lua script)

Need to rewrite all G_CalculateStages function

game.SuddenDeath

NOTE: lua side

TODO

missile

missile.Frame

TODO

mover

mover.Frame

TODO

player

player.Build

TODO

player.ChangeTeam

TODO

player.Die

TODO

player.Evolve

TODO

player.Frame

calling function: src/game/g_active.c:ClientEndFrame()

  • input argument: client=<client entity>
  • no output argument
  • check.IsGame: skip event during intermission
  • check.SelectState: selection an action group to run: action.ingame or action.spectator (skip other group)
  • action.spectator.UpdateFollowState: update client flags with following client flags
  • action.ingame.WorldEffect: apply world effect (burn from lava, etc...) to player
  • action.ingame.DamageFeedback: apply all the damage taken this frame
  • action.ingame.Respawn: respawn if dead
  • action.ingame.UpdateZaps: update zaps if player is zapping
  • action.ingame.UpdatePlayerState: update stuff in playerState
  • action.ingame.UpdateEFConnection: update EF_CONNECTION flag

Following Net Code should be hardcoded. All other code should be hardcoded too

  // set the latest infor
  if( g_smoothClients.integer )
    BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );
  else
    BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );

  SendPendingPredictableEvents( &ent->client->ps );

player.Init

TODO

player.Inventory

TODO

player.Pain

TODO

player.PrimaryAttack

TODO

player.SecondaryAttack

TODO

player.Spawn

calling function: src/game/g_client.c:ClientSpawn()

  • input argument: entity=<entity>, spawn=<entity> (can be undefinded), origin=<vec3> (can be undefinded), angles=<vec3> (can be undefinded)
  • no output argument
  • check.init.SetSpawnType: define spawn type in `type' arg. Can take value: "spectate", "evolve", "spawn"
  • init.SpectatorSpawnPoint: select a spawn point for spectator, if needed
  • init.BuildableSpawnTime: initialize `buildableSpawnTime' (used for action.BuildableSpawnEffects)
  • action.init.StopFollow: stop following teammates before spawning
  • action.clear.Reset: Reinitialize player, clear everything but the persistant data and set new datas
  • action.clear.ClearCredits: forget all rents
  • action.reinit.GameplayParameters: Set gameplay related parameters (stamina, health)
  • action.reinit.GiveEquipement: Give a blaster, medkit, the default weapon and ammo to spawning player
  • action.reinit.ScaleHealth: Scale health for evolving spawns
  • action.reinit.SelectBestWeapon: select the highest weapon number available, after any spawn given items have fired
  • action.spawn.ToggleTeleport: toggle the teleport bit so the client knows to not lerp
  • action.spawn.SetPosition: set player's origin and angle and give aliens some spawn velocity
  • action.spawn.BuildableSpawnEffects: if spawn in a buildable, run buildable animation and initialize spawn->clientSpawnTime with args["ClientSpawnTime"]
  • action.spawn.FireTarget: fire the targets of the spawn point
  • action.spawn.SpawnCount: Increase player spawn count
  • action.spawn.LinkEntity: Register spawned entity
  • action.finish.MoveToIntermission: move client to intermission if needed. Is it really usefull there ?
  • action.finish.UpdateRanks
  • action.finish.RunFrame: run a frame to drop exactly to the floor, and initialize animations and others things

player.Timer100

TODO

player.Timer1000

TODO

player.Think

calling function: src/game/g_active.c:ClientThink() called by G_RunFrame if client is a synchronousClient and by vm event if it isn't. ClientThink may be called with a random delay if it isn't a synchronousClient

  • input argument: player=<entity>
  • no output argument
  • check.IsConnected: skip event if client isn't connected (hardcoded ?)
  • check.IsDead: skip all action.alive hooks if client is dead
  • init.SanityTime: sanity check the command time to prevent speedup cheating
  • init.SetSpeed: set speed
  • init.CreepSlow: decrease speed because of creep
  • action.???: do unlagged, network, pmove stuff....
  • action.think.Intermission: start action.intermission.Think if it's intermission, then skip action
  • action.think.Spectator: start action.spectator.Think if client is a spectator, then skip action
  • action.???: stuff....
  • action.UpdateFlags: update client->ps.pm_type, client->ps.stats[ STAT_STATE ]
  • action.FireGrenade: fire a grenade and remove from inventory
  • action.DisableJetpackOnDamage: randomly disable the jetpack if damaged
  • action.DisableJetpackOnNoReac: switch jetpack off if no reactor
  • action.RunPMove: reinitialize PMove and run PMove (TODO: move PMove reset to 'init' if PMove is unused by upper values)
  • action.UnlaggedDetectCollisions: (TODO: may be moved in upper unlagged stuff ?)
  • action.WeaponThink: run event.weapon.Think on player's weapon
  • action.???: stuff...
  • (TODO: can player die between check.IsDead and action.alive ?)
  • action.alive.Evolve: FIXME !!! Evolve stuff is soooo dirty !!! rethink/rewrite it !
  • action.alive.GiveCredit: Give clients some credit periodically
  • action.alive.Suicide: check for suicides
  • action.CallTimer: call event.player.Timer100, event.player.Timer1000 events (maybe more than 1 time !)

NOTE: there is too many things to split all stuff. Must focus things to split.

player.ThirdAttack

TODO

player.Use

TODO

weapon

weapon.Frame

TODO