float TeamEqualiseDamage( gedict_t * targ, gedict_t * attacker, float damage ) { float adv = 0; float newdam; if ( strneq( targ->s.v.classname, "player" ) || strneq( attacker->s.v.classname, "player" ) ) return damage; if ( !targ->team_no || !attacker->team_no || attacker->team_no == targ->team_no ) return damage; if ( attacker->team_no > 0 && attacker->team_no < 4 ) adv = teamadvantage[attacker->team_no]; if ( !adv ) { G_conprintf( "There is a team with an advantage of 0\n" ); adv = 0.1; } newdam = damage * adv; if ( targ->team_no > 0 && targ->team_no < 4 ) adv = teamadvantage[targ->team_no]; if ( !adv ) { G_conprintf( "There is a team with an advantage of 0\n" ); adv = 0.1; } newdam = newdam * 1 / adv; return newdam; }
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { ClearGlobals(); switch ( command ) { case GAME_INIT: api_ver = trap_GetApiVersion(); if ( api_ver < MIN_API_VERSION ) { G_conprintf("Mod requried API_VERSION %d or higher, server have %d\n", MIN_API_VERSION, api_ver); return 0; } if( api_ver >= MIN_API_VERSION && api_ver <= GAME_API_VERSION ) { gamedata.APIversion = api_ver; } G_InitGame( arg0, arg1 ); return ( int ) ( &gamedata ); case GAME_LOADENTS: G_SpawnEntitiesFromString(); return 1; case GAME_START_FRAME: StartFrame( arg0 ); return 1; case GAME_CLIENT_CONNECT: self = PROG_TO_EDICT( g_globalvars.self ); self->auth_time = g_globalvars.time + 10.0; self->isSpectator = arg0?1:0; if ( arg0 ) SpectatorConnect(); else ClientConnect(); return 1; case GAME_PUT_CLIENT_IN_SERVER: self = PROG_TO_EDICT( g_globalvars.self ); if ( !arg0 ) PutClientInServer(); return 1; case GAME_CLIENT_DISCONNECT: self = PROG_TO_EDICT( g_globalvars.self ); if ( arg0 ) SpectatorDisconnect(); else ClientDisconnect(); return 1; case GAME_SETNEWPARMS: SetNewParms(); return 1; case GAME_CLIENT_PRETHINK: self = PROG_TO_EDICT( g_globalvars.self ); if ( !arg0 ) PlayerPreThink(); return 1; case GAME_CLIENT_POSTTHINK: self = PROG_TO_EDICT( g_globalvars.self ); if ( !arg0 ) PlayerPostThink(); else SpectatorThink(); return 1; case GAME_EDICT_TOUCH: G_EdictTouch(); return 1; case GAME_EDICT_THINK: G_EdictThink(); return 1; case GAME_EDICT_BLOCKED: G_EdictBlocked(); return 1; case GAME_SETCHANGEPARMS: //called before spawn new server for save client params self = PROG_TO_EDICT( g_globalvars.self ); SetChangeParms(); return 1; case GAME_CLIENT_COMMAND: self = PROG_TO_EDICT( g_globalvars.self ); return ClientCommand(); case GAME_CLIENT_USERINFO_CHANGED: // called on user /cmd setinfo if value changed // return not zero dont allow change // params like GAME_CLIENT_COMMAND, but argv(0) always "setinfo" and argc always 3 self = PROG_TO_EDICT( g_globalvars.self ); return ClientUserInfoChanged(); case GAME_SHUTDOWN: return 0; case GAME_CONSOLE_COMMAND: // called on server console command "mod" // params like GAME_CLIENT_COMMAND, but argv(0) always "mod" // self - rconner if can detect else world // other //SV_CMD_CONSOLE 0 //SV_CMD_RCON 1 //SV_CMD_MASTER 2 //SV_CMD_BOT 3 self = PROG_TO_EDICT( g_globalvars.self ); ModCommand(); return 0; } return 0; }
void TG_Eff_Remove( gedict_t * pl ) { gedict_t *te; float healam; if ( strneq( pl->s.v.classname, "player" ) ) return; if ( pl->s.v.health <= 0 ) return; for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "timer" ) ); ) { if ( te->s.v.owner != EDICT_TO_PROG( pl ) ) continue; if ( te->s.v.think != ( func_t ) ConcussionGrenadeTimer && te->s.v.think != ( func_t ) OldConcussionGrenadeTimer ) continue; if ( tf_data.old_grens == 1 ) stuffcmd( pl, "v_idlescale 0\nfov 90\n" ); dremove( te ); break; } if ( pl->tfstate & TFSTATE_HALLUCINATING ) { for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "timer" ) ); ) { if ( te->s.v.owner != EDICT_TO_PROG( pl ) ) continue; if ( te->s.v.think != ( func_t ) HallucinationTimer ) continue; pl->tfstate -= ( pl->tfstate & TFSTATE_HALLUCINATING ); ResetGasSkins( pl ); if ( tf_data.new_gas & GAS_MASK_PALETTE ) stuffcmd( pl, "v_cshift; wait; bf\n" ); dremove( te ); break; } if ( !te ) G_conprintf( "Warning: Error in Hallucination Timer logic.\n" ); } if ( pl->tfstate & TFSTATE_TRANQUILISED ) { for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "timer" ) ); ) { if ( te->s.v.owner != EDICT_TO_PROG( pl ) ) continue; if ( te->s.v.think != ( func_t ) TranquiliserTimer ) continue; pl->tfstate -= ( pl->tfstate & TFSTATE_TRANQUILISED ); TeamFortress_SetSpeed( pl ); dremove( te ); break; } if ( !te ) G_conprintf( "Warning: Error in Tranquilisation Timer logic.\n" ); } if ( pl->FlashTime > 0 ) { for ( te = world; ( te = trap_find( te, FOFS( s.v.netname ), "flashtimer" ) ); ) { if ( te->s.v.owner != EDICT_TO_PROG( pl ) ) continue; if ( strneq( te->s.v.classname, "timer" ) ) continue; pl->FlashTime = 0; if ( tf_data.new_flash ) disableupdates( pl, -1 ); /* server-side flash */ break; } if ( !te ) { G_conprintf( "Warning: Error in Flash Timer logic.\n" ); pl->FlashTime = 0; } } if ( pl->tfstate & TFSTATE_INFECTED ) { healam = rint( pl->s.v.health / 2 ); pl->tfstate -= ( pl->tfstate & TFSTATE_INFECTED ); tf_data.deathmsg = DMSG_MEDIKIT; T_Damage( pl, self, self, healam ); return; } if ( pl->numflames > 0 ) { sound( pl, 1, "items/r_item1.wav", 1, 1 ); pl->numflames = 0; return; } }