mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-10 07:11:34 +00:00
Added reloadtorpedos-command and som fixes for weapon-fx
Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
parent
f3f7345ccd
commit
c2e135da16
3 changed files with 121 additions and 25 deletions
|
@ -920,6 +920,7 @@ void CG_InitConsoleCommands( void ) {
|
|||
trap_AddCommand("selfdestruct");
|
||||
trap_AddCommand("shipdamage");
|
||||
trap_AddCommand("shiphealth");
|
||||
trap_AddCommand("reloadtorpedos");
|
||||
|
||||
/* precacheFile */
|
||||
trap_AddCommand("generatePrecacheFile");
|
||||
|
|
|
@ -5997,6 +5997,79 @@ static void Cmd_shiphealth_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_reloadtorpedos_f
|
||||
Harry Young | 12/01/2013
|
||||
=================
|
||||
*/
|
||||
static void Cmd_reloadtorpedos_f(gentity_t *ent) {
|
||||
gentity_t *torpedo=NULL, *single;
|
||||
char arg[16];
|
||||
char target[512];
|
||||
|
||||
#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, SQLF_SMS ) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(trap_Argc() == 0){
|
||||
G_PrintfClient(ent, "Usage: reloadtorpedos [amount] [target] where amount is the number of torpedos the launcher will have after the command executed.\n");
|
||||
G_PrintfClient(ent, "Set 0 to depleet, set -1 to max out. You can not load more torpedos than the entity was designed for. If you do it will just Max out.\n");
|
||||
G_PrintfClient(ent, "target is the specific targetname of the fx_torpedo that shall be reloaded and needs to be entered if there is a map with multiple fx_torpedo's with limited stock.\n");
|
||||
G_PrintfClient(ent, "If set to all every limited launcher on the map will be set to amount or maxed out accordingly.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!G_Find(NULL, FOFS(classname), "fx_torpedo")){
|
||||
trap_SendServerCommand( ent-g_entities, "print \"^4This map does not support the fx_torpedo system.\n\"" );
|
||||
return;
|
||||
}
|
||||
|
||||
trap_Argv(1, arg, sizeof(arg));
|
||||
|
||||
if(trap_Argc() > 1){ //we have a specific targets or all entities shall be restocked, so let's go with that
|
||||
Q_strncpyz( target, ConcatArgs( 2 ), sizeof( target ) );
|
||||
while((torpedo = G_Find(torpedo, FOFS(classname), "fx_torpedo")) != NULL){
|
||||
if(!Q_stricmp(torpedo->targetname, target) || !Q_stricmp(target, "all")){ //this entity is generally affectable
|
||||
if(torpedo->damage > 0){ //we only need to consider this for restock if it is restockable
|
||||
if(atoi(arg) < 0 || atoi(arg) > torpedo->damage)
|
||||
torpedo->count = torpedo->damage;
|
||||
else
|
||||
torpedo->count = atoi(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
while((torpedo = G_Find(torpedo, FOFS(classname), "fx_torpedo")) != NULL){
|
||||
if(torpedo->damage < 0)//we can ignore unlimited supplies, we're just concerned with limits, which need to be specific
|
||||
continue;
|
||||
else { //something with stock
|
||||
single = torpedo; //if this is the only one we finish it right away
|
||||
while((torpedo = G_Find(torpedo, FOFS(classname), "fx_torpedo")) != NULL){
|
||||
if(torpedo->damage > 0){// we have 2 with stock so we can be wrong. Inform admin and abort
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"^1 ERROR: This map has more than one fx_torpedo with limited supply, therefore a target or all needs to be specified. Aborting call.\n\"" ) );
|
||||
return;
|
||||
}
|
||||
}//if we got here we only have one entity to restock, so let's do that
|
||||
if(atoi(arg) < 0 || atoi(arg) > single->damage)
|
||||
single->count = single->damage;
|
||||
else
|
||||
single->count = atoi(arg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_admin_centerprint_f
|
||||
|
@ -7629,6 +7702,8 @@ void G_Client_Command( int clientNum )
|
|||
Cmd_shipdamage_f(ent);
|
||||
else if (Q_stricmp(cmd, "shiphealth") == 0)
|
||||
Cmd_shiphealth_f(ent);
|
||||
else if (Q_stricmp(cmd, "Cmd_reloadtorpedos_f") == 0)
|
||||
Cmd_reloadtorpedos_f(ent);
|
||||
else if (Q_stricmp(cmd, "msg2") == 0)
|
||||
Cmd_admin_centerprint_f(ent);
|
||||
else if (Q_stricmp(cmd, "forcevote") == 0)
|
||||
|
|
|
@ -895,6 +895,7 @@ A phaser effect for use as a ship's weapon.
|
|||
|
||||
-----KEYS-----
|
||||
"target" - endpoint
|
||||
"swapname" - lock/unlock entity
|
||||
"wait" - how long the phaser fires
|
||||
"scale" - adjust the effects scale, default: 20
|
||||
"customSnd" - use a custom sound
|
||||
|
@ -905,15 +906,24 @@ A phaser effect for use as a ship's weapon.
|
|||
|
||||
void phaser_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
|
||||
if(ent->count == PHASER_FX_UNLINKED) return;
|
||||
if(ent->flags & FL_LOCKED) return;
|
||||
|
||||
if(ent->spawnflags & 2)
|
||||
{
|
||||
G_AddEvent(ent, EV_FX_DISRUPTOR, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
G_AddEvent(ent, EV_FX_PHASER, 0);
|
||||
if(!Q_stricmp(ent->swapname, activator->target)) {
|
||||
ent->flags ^= FL_LOCKED;
|
||||
} else {
|
||||
if(ent->flags & FL_LOCKED){
|
||||
trap_SendServerCommand(activator-g_entities, va("print \"^1Phasers are offline.\n\""));
|
||||
G_AddEvent(ent, EV_GENERAL_SOUND, ent->n00bCount);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ent->spawnflags & 2)
|
||||
{
|
||||
G_AddEvent(ent, EV_FX_DISRUPTOR, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
G_AddEvent(ent, EV_FX_PHASER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -978,6 +988,7 @@ void SP_fx_phaser(gentity_t *ent) {
|
|||
/*QUAKED fx_torpedo (0 0 1) (-8 -8 -8) (8 8 8) QUANTUM NO_SOUND LOCKED
|
||||
-----DESCRIPTION-----
|
||||
A torpedo effect for use as a ship's weapon.
|
||||
Torpedos can be limited and can be set to any value within their maximum range by admin-command "reloadtorpedos [amount] [targetname]"
|
||||
|
||||
-----SPAWNFLAGS-----
|
||||
1: QUANTUM - set this flag if you whant an quantum fx instead of an photon fx
|
||||
|
@ -986,6 +997,7 @@ A torpedo effect for use as a ship's weapon.
|
|||
|
||||
-----KEYS-----
|
||||
"target" - used for the calculation of the direction
|
||||
"swapname" - lock/unlock entity
|
||||
"wait" - time in seconds till fx can be used again
|
||||
"noise" - sound to play
|
||||
"soundNoAmmo" - sound to play if ammo is depleted
|
||||
|
@ -1000,22 +1012,30 @@ void fx_torpedo_think(gentity_t *ent) {
|
|||
}
|
||||
|
||||
void fx_torpedo_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
|
||||
if(ent->flags & FL_LOCKED) return;
|
||||
|
||||
if(ent->count > 0) {
|
||||
ent->count--;
|
||||
trap_SendServerCommand(activator-g_entities, va("print \"Torpedos: %i of %i left.\n\"", ent->count, ent->damage));
|
||||
G_AddEvent(ent, EV_GENERAL_SOUND, ent->s.time);
|
||||
if(!Q_stricmp(ent->swapname, activator->target)) {
|
||||
ent->flags ^= FL_LOCKED;
|
||||
} else {
|
||||
trap_SendServerCommand(activator-g_entities, "print \"^1Out of Torpedos.\n\"");
|
||||
G_AddEvent(ent, EV_GENERAL_SOUND, ent->n00bCount);
|
||||
return;
|
||||
if(ent->flags & FL_LOCKED){
|
||||
trap_SendServerCommand(activator-g_entities, va("print \"^1Torpedo launcher is offline.\n\""));
|
||||
G_AddEvent(ent, EV_GENERAL_SOUND, ent->n00bCount);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ent->count > 0) {
|
||||
ent->count--;
|
||||
trap_SendServerCommand(activator-g_entities, va("print \"Torpedos: %i of %i left.\n\"", ent->count, ent->damage));
|
||||
G_AddEvent(ent, EV_GENERAL_SOUND, ent->s.time);
|
||||
}
|
||||
if(ent->count == 0){
|
||||
trap_SendServerCommand(activator-g_entities, "print \"^1Out of Torpedos.\n\"");
|
||||
return;
|
||||
}
|
||||
|
||||
G_AddEvent(ent, EV_FX_TORPEDO, ent->spawnflags);
|
||||
ent->use = 0;
|
||||
ent->think = fx_torpedo_think;
|
||||
ent->nextthink = level.time + ent->wait;
|
||||
}
|
||||
|
||||
G_AddEvent(ent, EV_FX_TORPEDO, ent->spawnflags);
|
||||
ent->use = 0;
|
||||
ent->think = fx_torpedo_think;
|
||||
ent->nextthink = level.time + ent->wait;
|
||||
}
|
||||
|
||||
void fx_torpedo_link(gentity_t *ent) {
|
||||
|
@ -1039,9 +1059,9 @@ void fx_torpedo_link(gentity_t *ent) {
|
|||
|
||||
if(!ent->count) {
|
||||
ent->count = -1;
|
||||
} else {
|
||||
ent->damage = ent->count;
|
||||
}
|
||||
}
|
||||
|
||||
ent->damage = ent->count;
|
||||
|
||||
if(ent->spawnflags & 4) {
|
||||
ent->flags |= FL_LOCKED;
|
||||
|
|
Loading…
Reference in a new issue