PDA

View Full Version : Log custom weapon damage...


=|[76AD]|= TatsuSaisei
08-08-2006, 10:32 PM
I figured out how to "log" kills with a custom weapon, but what I want to know now is how to "log" the damage done by the weapon...

=|[76AD]|= TatsuSaisei
08-10-2006, 11:33 PM
well, I found some natives that sound like it might be what I need, but heck if I can find any documentation on it...

/* Custom Weapon Support */
/* function will return index of new weapon */
native custom_weapon_add( wpnname[], melee = 0, logname[]="" );
/* Function will pass damage done by this custom weapon to stats module and other plugins */
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
/* Function will pass info about custom weapon shot to stats module */
native custom_weapon_shot( weapon, index ); // weapon id , player id
/* function will return 1 if true */
native xmod_is_melee_wpn(wpnindex);
/* Returns weapon name. */
native xmod_get_wpnname(wpnindex, name[], len);
/* Returns weapon logname. */
native xmod_get_wpnlogname(wpnindex, name[], len);
/* Returns weapons array size */
native xmod_get_maxweapons();
/* Returns stats array size ex. 8 in TS , 9 in DoD */
native xmod_get_stats_size();
/* Returns 1 if true */
native xmod_is_custom_wpn(wpnindex);

now mind you... everything I know about PAWN comes from reverse engineering everyone elses plugins, and the experience I have in other languages... and I am a "book" learned type of person, and the documentation on the AMXX stuff is not as good as I would like...

so... does anyone know anything about these natives, OR know where to look for more "help" ... I have looked through the amxx forum, and have actually talked to a few coders, but none are experienced in DOD, so you guys are the "kings" in this category...

diamond-optic
08-11-2006, 12:52 AM
well isnt that stuff done thru stats_logging plugin?

like:

log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^") (score ^"%d^")", szName,iUserid,szAuthid,szTeam,szWeapon,iStats[4],iStats[5],iStats[0], iStats[2],iStats[3],iStats[6],iStats[1],iStats[7])

isnt that logged for each weapon used on disconnect?

uses like:

get_user_wstats( id , i ,iStats , iHits )

so i dont know if theres anyway to write to that tho.. not even sure if that helps any
but maybe you could just create a similar log message for your weapon when clients disconnect.. only think is you'd have to collect all the individual parts of the message

=|[76AD]|= TatsuSaisei
08-11-2006, 02:51 PM
I have slowly been getting it... I am logging kills and certain damage now... BUT, what I need to do is stop the logging of the original weapon that has been replaced... I spent a good 2-3 hours skimming forums last night and did not find anything useful... what I did find is a bit disappointing... what I need to do is STOP a death before it happens... and then "kill" the player with code... but the more I read, the more people say its not possible to "stop" a death... or its not possible to reduce damage BEFORE its dealt to a player... and "adding health" to avoid a kill will not help those times that one hit kills...

btw, Diamond, I read a post of yours (amxmodx forums) about some rock throwing plugin you were try to make, which sounds like at one time you were trying to do the same thing as I am now.... how did that ever work out ??

Hell Phoenix
08-11-2006, 04:59 PM
Well you can block the death message, but i dont think there is anyway to block damage messages.

=|[76AD]|= TatsuSaisei
08-11-2006, 05:23 PM
Well you can block the death message, but i dont think there is anyway to block damage messages.
no, I do not want to block damage messages, those I want... and I don't care about the death messages, I have it showing a "world" kill, which is fine for now...

What I want to do is stop a death/kill from happening, so the "real" weapon used does not get the kill stat....

Here is what I have... I took the dod_ninja plugin, added the extra model bit so others see the sword... and I made it so the "ninja" gets a spade, regardless of the team (axis/allies) becuase the spade animation from the player is an overhead chop, where as the knives are stab animations... the stab animation looks so wrong when a sword is in a players hand... but the spade animation... WOW, does it look nice to see a player coming at you with sword swinging...

anyways... I have the "katana" logging kills now, BUT the spade is also getting the stat as well.. and THAT is what I want to stop... see the game doesnt care what "I" call the weapon, underneath the fancy coding trickery of replacing the spade model with a katana, it is still a spade... so what I want to do is have code that STOPS the spade from killing someone if they are a "ninja" use the user_kill/user_silentkill code and the code to +1 scoreboard stats... I can get the damage managed now with some code, but like I said, now all "katana" kills are also logging spade kills and damage... and I want to stop that...

I'm the kind of person who thrives on being told it is impossible... ALL things are possible, you just have to "figure" it out, or come up with a valid workaround...

Hell Phoenix
08-11-2006, 08:24 PM
I think in this case its impossible =p

diamond-optic
08-12-2006, 12:07 AM
well lol that rock plugin.. put it on my server last night.. and it would make it crash like every few hrs or less.. and for some reason it wouldnt reboot itself each time.. dont have any idea whats wrong with it.. but this is what im doing (but i dont have to block a kill to begin with..)


set_msg_block(get_user_msgid("DeathMsg"),BLOCK_ONCE)
log_block_state = true
user_kill(object, 1)
log_block_state = false

message_begin(MSG_ALL, get_user_msgid("DeathMsg"),{500, 500, 500}, 0)
write_byte(owner)
write_byte(object)
write_byte(0)
message_end()

new steam[32], teamname[32], name[32]
new steam2[32], teamname2[32], name2[32]
get_user_authid(owner, steam, 31)
get_user_authid(object, steam2, 31)
dod_get_pl_teamname(owner, teamname, 31)
dod_get_pl_teamname(object, teamname2, 31)
get_user_name(owner, name, 31)
get_user_name(object, name2, 31)

log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"rock^"", name, get_user_userid(owner), steam, teamname, name2, get_user_userid(object), steam2, teamname2)

dod_set_user_kills(owner, dod_get_user_kills(owner) + 1)


public log_block(type, msg[])
{
return(log_block_state?FMRES_SUPERCEDE:FMRES_IGNOR ED)
}

=|[76AD]|= TatsuSaisei
08-23-2006, 09:00 AM
I think in this case its impossible =p
In my effort to create my MG mustdeploy plugin, I found the answer to my problem... thanx to Wilson. I found that I could block the damage a weapon deals by using the following code:

public client_PreThink(id) {
new clip, ammo, myWeapon = dod_get_user_weapon(id,clip,ammo)
if((myWeapon == DODW_SPADE&&g_status[id])){
if(entity_get_int(id, EV_INT_button) & IN_ATTACK) {
if(dod_is_deployed(id) == 0){
client_print(id,print_chat,"Samurai - Katana") //testing text
entity_set_int(id, EV_INT_button, entity_get_int(id, EV_INT_button) & ~IN_ATTACK)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_HANDLED
}

It still allows the player to go through the normal attack animation, I just have to see about getting the players weapon model to recognize when it "touches" another player model, then code up damage sequences....

diamond-optic
08-23-2006, 09:09 AM
you could try like:


new ent,trash
get_user_aiming(id,ent,trash)
if(ent && pev_valid(ent) && ent>32)
{
new classname[32]
pev(ent,pev_classname, classname, 31)
if(equali(classname,"player"))
{
new Float:origin1[3], Float:origin2[3]
pev(id, pev_origin, origin1)
pev(ent, pev_origin, origin2)
new distance = floatround(get_distance_f(origin1, origin2))

if(distance <= 100)
.......................................

that way they have to be aiming at the other player and within a certain distance.. which you'd have to play around with that number..

basically the way ive got my animals so they can be killed by knives/bayos

=|[76AD]|= TatsuSaisei
08-23-2006, 06:35 PM
you could try like:


new ent,trash
get_user_aiming(id,ent,trash)
if(ent && pev_valid(ent) && ent>32)
{
new classname[32]
pev(ent,pev_classname, classname, 31)
if(equali(classname,"player"))
{
new Float:origin1[3], Float:origin2[3]
pev(id, pev_origin, origin1)
pev(ent, pev_origin, origin2)
new distance = floatround(get_distance_f(origin1, origin2))

if(distance <= 100)
.......................................

that way they have to be aiming at the other player and within a certain distance.. which you'd have to play around with that number..

basically the way ive got my animals so they can be killed by knives/bayos

using a method similar to this (aiming and distance) but using different conditions, it DOES in fact work. So the "impossible" is possible...

The next step is to get the players model to do a specific sequence during this time, as since the death/damage is now blocked, it also stops the sequence from displaying to others. This is the next hurdle...

=|[76AD]|= TatsuSaisei
08-23-2006, 06:37 PM
well isnt that stuff done thru stats_logging plugin?

like:

isnt that logged for each weapon used on disconnect?

uses like:

so i dont know if theres anyway to write to that tho.. not even sure if that helps any
but maybe you could just create a similar log message for your weapon when clients disconnect.. only think is you'd have to collect all the individual parts of the message
yes this is how it would be done, but not on disconnect, but after each "hit" or "kill", 1 log line for each action.... or constuct an array to collect the information as you play, THEN on disconnect use the values contained in the array to write only one log line, upon player disconnect.... either way works:D