xmod_is_custom_wpn added

This commit is contained in:
Lukasz Wlasinksi 2004-08-05 12:45:25 +00:00
parent 3bedaa95e4
commit 5dd3fe742c
6 changed files with 157 additions and 131 deletions

View File

@ -213,6 +213,113 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
return 1;
}
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logname,melee=0
int i;
bool bFree = false;
for ( i=DODMAX_WEAPONS-DODMAX_CUSTOMWPNS;i<DODMAX_WEAPONS;i++){
if ( !weaponData[i].needcheck ){
bFree = true;
break;
}
}
if ( !bFree )
return 0;
int iLen;
char *szName = MF_GetAmxString(amx, params[1], 0, &iLen);
char *szLogName = MF_GetAmxString(amx, params[3], 0, &iLen);
strcpy(weaponData[i].name,szName);
strcpy(weaponData[i].logname,szLogName);
weaponData[i].needcheck = true;
weaponData[i].melee = params[2] ? true:false;
return i;
}
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){ // only for custom weapons
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int att = params[2];
if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int vic = params[3];
if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int dmg = params[4];
if ( dmg<1 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pAtt = GET_PLAYER_POINTER_I(att);
CPlayer* pVic = GET_PLAYER_POINTER_I(vic);
pVic->pEdict->v.dmg_inflictor = NULL;
pAtt->saveHit( pVic , weapon , dmg, aim );
if ( !pAtt ) pAtt = pVic;
int TA = 0;
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
TA = 1;
#ifdef FORWARD_OLD_SYSTEM
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA );
#else
MF_ExecuteForward( iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA );
#endif
if ( pVic->IsAlive() )
return 1;
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
#ifdef FORWARD_OLD_SYSTEM
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA );
#else
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
#endif
return 1;
}
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
pPlayer->saveShot(weapon);
return 1;
}
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
return DODMAX_WEAPONS;
}
@ -221,6 +328,14 @@ static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
return 9;
}
static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
return 0;
}
return 1;
}
AMX_NATIVE_INFO base_Natives[] = {
{ "dod_wpnlog_to_name", wpnlog_to_name },
@ -240,8 +355,14 @@ AMX_NATIVE_INFO base_Natives[] = {
{ "xmod_is_melee_wpn", is_melee },
{ "xmod_get_maxweapons", get_maxweapons },
{ "xmod_get_stats_size", get_stats_size },
{ "xmod_is_custom_wpn", is_custom },
{"register_statsfwd",register_forward },
{ "register_statsfwd",register_forward },
// Custom Weapon Support
{ "custom_weapon_add", register_cwpn }, // name,melee,logname
{ "custom_weapon_dmg", cwpn_dmg },
{ "custom_weapon_shot", cwpn_shot },
///*******************
{ NULL, NULL }

View File

@ -318,113 +318,6 @@ static cell AMX_NATIVE_CALL get_statsnum(AMX *amx, cell *params)
return g_rank.getRankNum();
}
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logname,melee=0
int i;
bool bFree = false;
for ( i=DODMAX_WEAPONS-DODMAX_CUSTOMWPNS;i<DODMAX_WEAPONS;i++){
if ( !weaponData[i].needcheck ){
bFree = true;
break;
}
}
if ( !bFree )
return 0;
int iLen;
char *szName = MF_GetAmxString(amx, params[1], 0, &iLen);
char *szLogName = MF_GetAmxString(amx, params[3], 0, &iLen);
strcpy(weaponData[i].name,szName);
strcpy(weaponData[i].logname,szLogName);
weaponData[i].needcheck = true;
weaponData[i].melee = params[2] ? true:false;
return i;
}
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){ // only for custom weapons
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int att = params[2];
if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int vic = params[3];
if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int dmg = params[4];
if ( dmg<1 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pAtt = GET_PLAYER_POINTER_I(att);
CPlayer* pVic = GET_PLAYER_POINTER_I(vic);
pVic->pEdict->v.dmg_inflictor = NULL;
pAtt->saveHit( pVic , weapon , dmg, aim );
if ( !pAtt ) pAtt = pVic;
int TA = 0;
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
TA = 1;
#ifdef FORWARD_OLD_SYSTEM
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA );
#else
MF_ExecuteForward( iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA );
#endif
if ( pVic->IsAlive() )
return 1;
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
#ifdef FORWARD_OLD_SYSTEM
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA );
#else
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
#endif
return 1;
}
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
pPlayer->saveShot(weapon);
return 1;
}
AMX_NATIVE_INFO stats_Natives[] = {
{ "get_stats", get_stats},
{ "get_statsnum", get_statsnum},
@ -438,11 +331,6 @@ AMX_NATIVE_INFO stats_Natives[] = {
{ "get_user_wstats", get_user_wstats},
{ "reset_user_wstats", reset_user_wstats },
// Custom Weapon Support
{ "custom_weapon_add", register_cwpn }, // name,melee,logname
{ "custom_weapon_dmg", cwpn_dmg },
{ "custom_weapon_shot", cwpn_shot },
{ NULL, NULL }
};

View File

@ -425,6 +425,14 @@ static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
return 8;
}
static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
int weapon = params[1];
if ( weapon < TFCMAX_WEAPONS-TFCMAX_CUSTOMWPNS ){
return 0;
}
return 1;
}
// Native list.
AMX_NATIVE_INFO base_Natives[] = {
{"tfc_setmodel", TFC_SetModel},
@ -439,6 +447,7 @@ AMX_NATIVE_INFO base_Natives[] = {
{"xmod_is_melee_wpn", TFC_IsMelee},
{"xmod_get_maxweapons", get_maxweapons},
{"xmod_get_stats_size", get_stats_size},
{"xmod_is_custom_wpn", is_custom},
{"tfc_userkill" , TFC_UserKill},

View File

@ -382,6 +382,13 @@ static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
return 8;
}
static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
int weapon = params[1];
if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){
return 0;
}
return 1;
}
AMX_NATIVE_INFO base_Natives[] = {
@ -390,6 +397,7 @@ AMX_NATIVE_INFO base_Natives[] = {
{ "xmod_is_melee_wpn", is_melee },
{ "xmod_get_maxweapons", get_maxweapons },
{ "xmod_get_stats_size", get_stats_size },
{ "xmod_is_custom_wpn", is_custom },
{ "ts_wpnlogtoname", wpnlog_to_name },
{ "ts_wpnlogtoid", wpnlog_to_id },

View File

@ -1,5 +1,5 @@
/*
* TSX
* TFCX
* Copyright (c) 2004 Lukasz Wlasinski
*
*

View File

@ -1,5 +1,5 @@
/*
* TSX
* TFCX
* Copyright (c) 2004 Lukasz Wlasinski
*
*