Okay, all issues are resolved, the commands are in and the libs compile. All that's missing is the external file and a few failsaves. the latter I can do myself with some research, the first is outside my field of expertise.

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2012-08-03 00:17:15 +02:00
parent fdd83d724b
commit 3153b9a2d6
4 changed files with 109 additions and 16 deletions

View file

@ -968,5 +968,7 @@ void CG_InitConsoleCommands( void ) {
trap_AddCommand("camtestend");
trap_AddCommand("selfdestruct");
trap_AddCommand("shipdamage");
trap_AddCommand("shiphealth");
}

View file

@ -6412,6 +6412,84 @@ static void Cmd_selfdestruct_f(gentity_t *ent) {
}
}
/*
=================
Cmd_shipdamage_f
Harry Young | 02/08/2012
=================
*/
static void Cmd_shipdamage_f(gentity_t *ent) {
gentity_t *healthEnt;
char arg[16];
#ifndef SQL
if ( !IsAdmin( ent ) ) {
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as an admin.\n\" ") );
return;
}
#else
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, /*need to fill this*/-1 ) ) {
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
return;
}
#endif
trap_Argv(1, arg, sizeof(arg));
if(atoi(arg) == 0){
G_PrintfClient(ent, "Usage: shipdamage [damage] where damage is oviously the total amount dealt. It will be rendered to shields and hull respectively by the entity. Must be positive. You can not heal with this command.\n");
return;
}
healthEnt = G_Find(NULL, FOFS(classname), "target_shiphealth");
if(atoi(arg) > 0){
healthEnt->damage = atoi(arg);
} else {
G_PrintfClient(ent, "^1ERROR: Damage must be a positive value. You can not heal with this command.");
return;
}
healthEnt->use(healthEnt, NULL, NULL);
return;
}
/*
=================
Cmd_shiphealth_f
Harry Young | 02/08/2012
=================
*/
static void Cmd_shiphealth_f(gentity_t *ent) {
gentity_t *healthEnt;
int THS, CHS, TSS, CSS, SI, RHS, RSS;
healthEnt = G_Find(NULL, FOFS(classname), "target_shiphealth");
THS = healthEnt->health;
CHS = healthEnt->count;
TSS = healthEnt->splashRadius;
CSS = healthEnt->n00bCount;
SI = healthEnt->splashDamage;
RHS = floor((CHS / THS * 100));
RSS = floor((CSS / TSS * 100));
if(CHS == 0){
trap_SendServerCommand( ent-g_entities, va("print \"^4The Ship is destroyed, what do you want?\n\"", RHS, CHS, THS) );
} else {
if(SI == 1){
trap_SendServerCommand( ent-g_entities, va("print \"^4Shields are online\n\"", RHS, CHS, THS) );
trap_SendServerCommand( ent-g_entities, va("print \"^4Shield Capactiy at %i Percent (%i of %i Points)\n\"", RSS, CSS, TSS) );
trap_SendServerCommand( ent-g_entities, va("print \"^4Structual Integrity at %i Percent (%i of %i Points)\n\"", RHS, CHS, THS) );
} else if(SI == 0){
trap_SendServerCommand( ent-g_entities, va("print \"^4Shields are offline\n\"", RHS, CHS, THS) );
trap_SendServerCommand( ent-g_entities, va("print \"^4Shield Capactiy at %i Percent (%i of %i Points)\n\"", RSS, CSS, TSS) );
trap_SendServerCommand( ent-g_entities, va("print \"^4Structual Integrity at %i Percent (%i of %i Points)\n\"", RHS, CHS, THS) );
} else {
trap_SendServerCommand( ent-g_entities, va("print \"^4Shields are inoperable\n\"", RHS, CHS, THS) );
trap_SendServerCommand( ent-g_entities, va("print \"^4Structual Integrity at %i Percent (%i of %i Points)\n\"", RHS, CHS, THS) );
}
}
return;
}
/*
=================
Cmd_admin_centerprint_f
@ -7902,6 +7980,10 @@ void ClientCommand( int clientNum )
Cmd_alert_f(ent);
else if (Q_stricmp(cmd, "selfdestruct") == 0)
Cmd_selfdestruct_f(ent);
else if (Q_stricmp(cmd, "shipdamage") == 0)
Cmd_shipdamage_f(ent);
else if (Q_stricmp(cmd, "shiphealth") == 0)
Cmd_shiphealth_f(ent);
else if (Q_stricmp(cmd, "msg2") == 0)
Cmd_admin_centerprint_f(ent);
else if (Q_stricmp(cmd, "forcevote") == 0)

View file

@ -186,6 +186,7 @@ void SP_target_levelchange(gentity_t *ent);
void SP_target_shaderremap(gentity_t *ent);
void SP_target_selfdestruct(gentity_t *ent);
void SP_target_safezone(gentity_t *ent);
void SP_target_shiphealth(gentity_t *ent);
void SP_light (gentity_t *self);
void SP_info_null (gentity_t *self);
@ -391,6 +392,7 @@ spawn_t spawns[] = {
{"target_shaderremap", SP_target_shaderremap},
{"target_selfdestruct", SP_target_selfdestruct},
{"target_safezone", SP_target_safezone},
{"target_shiphealth", SP_target_shiphealth},
{"light", SP_light},
{"path_corner", SP_path_corner},

View file

@ -2928,7 +2928,7 @@ If hull health hit's 0 it will kill any client outside an active savezone.
Keys:
health: Total Hull strength
oldHealth: total shield strenght
splashRadius: total shield strenght
angle: Hull repair in % per minute
speed: Shield repair in % per minute (only active if shield's aren't fried)
@ -2986,7 +2986,7 @@ static int target_shiphealth_get_unsafe_players(gentity_t *ents[MAX_GENTITIES])
void target_shiphealth_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
int NSS, NHS, SD, HD, i, num;
float BT;
gentity_t* alertEnt, warpEnt, turboEnt, transEnt, client;
gentity_t *alertEnt, *warpEnt, *turboEnt, *transEnt, *client;
if(ent->splashDamage == 1){ //shields are active so we're just bleeding trough on the hull
BT = ((1 - (ent->count / ent->health)) / 10);
@ -3066,6 +3066,13 @@ void target_shiphealth_use(gentity_t *ent, gentity_t *other, gentity_t *activato
}
}
//disable shield-subsystem if need be.
if(((ent->count / ent->health) * crandom()) < 0.3){
ent->n00bCount = 0;
ent->splashDamage = -1;
}
//and of course...
if(ent->count <= 0){
gentity_t *ents[MAX_GENTITIES];
@ -3115,33 +3122,33 @@ void target_shiphealth_think(gentity_t *ent) {
}
// Shield Repair
if(ent->moverstate != -1){ //skip if shields are toast
if(ent->n00bCount < ent->oldHealth){
if(ent->splashDamage != -1){ //skip if shields are toast
if(ent->n00bCount < ent->splashRadius){
if(alertEnt->damage == 0) //condition green
NSS = (ent->n00bCount + (ent->oldHealth * ent->speed / 100);
NSS = (ent->n00bCount + (ent->splashRadius * ent->speed / 100));
else
NSS = (ent->n00bCount + (ent->oldHealth * ent->speed / 200);
NSS = (ent->n00bCount + (ent->splashRadius * ent->speed / 200));
if(NSS > ent->oldHealth)
ent->n00bCount = ent->oldHealth;
if(NSS > ent->splashRadius)
ent->n00bCount = ent->splashRadius;
else
ent->n00bCount = NSS;
}
}
//shield reenstatement
if(ent->moverstate == -1){ //else we don't need to run this
if(ent->splashDamage == -1){ //else we don't need to run this
if((ent->count / ent->health) > 0.5){
if(alertEnt->damage == 0) //what symbol is and AND? cause I'd like to failsave 1 if we don't have alerts...
ent->moverstate = 0;
ent->splashDamage = 0;
else
ent->moverstate = 1;
ent->splashDamage = 1;
} else {
if((ent->count / ent->health * crandom()) > 1){
if(alertEnt->damage == 0)
ent->moverstate = 0;
ent->splashDamage = 0;
else
ent->moverstate = 1;
ent->splashDamage = 1;
}
}
}
@ -3153,13 +3160,13 @@ void SP_target_shiphealth(gentity_t *ent) {
//we need to put the total health in for the current
ent->count = ent->health;
ent->n00bCount = ent->oldHealth;
ent->n00bCount = ent->splashRadius;
//now for the shieldindicator I need to know if we have an alertEnt available
if(G_Find(NULL, FOFS(classname), "target_alert"))
ent->moverstate = 0;
ent->splashDamage = 0;
else
ent->moverstate = 1;
ent->splashDamage = 1;
ent->think = target_shiphealth_think;
ent->use = target_shiphealth_use;