Raised This Month: $51 Target: $400
 12% 

Realistic Defuse v1.4


Post New Thread Reply   
 
Thread Tools Display Modes
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-25-2009 , 03:11   Re: Realistic Defuse v1.4
Reply With Quote #11

I have not tested it, because I wrote it here fast. Please post if you have problems.

PHP Code:
#include <fakemeta>
#include <hamsandwich>

// We need this for owner save
#define OFFSET_OWNER        41
#define OFFSET_LINUX        4

new g_flash_ent
new g_flasher

public plugin_init()
{
    
// We need the first forward for clearing the data
    
register_forward(FM_EmitSound"fw_emitsound",1)
    
// We use this forward for owner set
    
register_forward(FM_SetModel"fw_setmodel"1)
    
// We use this to prepare the preflash data
    
RegisterHam(Ham_Think"grenade""fw_think")
    
    
set_task(1.0"delayed_register")
}

public 
delayed_register()
{
    
// We register this delayed so that we let other plugins mess with it
    
register_message(get_user_msgid("ScreenFade"), "message_screenfade")
}

public 
message_screenfade(msg_idmsg_destent)
{
    
// No flasher? No interest!
    
if (!g_flash_ent || !g_flasher)
        return 
PLUGIN_CONTINUE

    
// This is sent after the player is flashed!
    // Use get_msg_arg_int() to get all the argument data
    
new alpha get_msg_arg_int(7)
    
// Rest are colors so we aren't interested
    
    // Here we convert the holdtime and the duration in 0.1 seconds
    // Ex: If flashdur is 1 that means that the duration is 0.1 seconds!
    
new flashdur floatround(float(get_msg_arg_int(1)) / 409.6)
    new 
flashhold floatround(float(get_msg_arg_int(2)) / 409.6)
    new 
name[32]
    
get_user_name(g_flashernamecharsmax(name))
    
    
client_print(entprint_console"Flashed by:%s, dur:%d, hold:%d, Alpha:%d",nameflashdurflashholdalpha)
    
    return 
PLUGIN_CONTINUE
}


public 
fw_think(ent)
{
    
// The entity isn't a flash
    // Or this entity is the exploding flashbang?
    // If yes ignore!
    
if (!is_flash(ent) || g_flash_ent == ent)
        return 
FMRES_IGNORED
    
    
// The flash has not kaboomed 
    
if (pev_float(ent,pev_dmgtime) > get_gametime())
        return 
FMRES_IGNORED
    
    
// If we reached here means that we have an exploding flashbang
    // We now get the owner and the flashbang entity
    
g_flasher get_pdata_int(entOFFSET_OWNEROFFSET_LINUX)
    
g_flash_ent ent
    
    
return FMRES_IGNORED
}

public 
fw_setmodel(ent,const model[])
{
    
// Valid entity?
    
if (!pev_valid(ent))
        return 
FMRES_IGNORED
    
    
// Not yet thrown
    
if (pev_float(ent,pev_gravity) == 0.0)
        return 
FMRES_IGNORED
    
    
// Is flash? Not? Ignore!
    
if (containi(model,"w_flashbang.mdl") == -1)
        return 
FMRES_IGNORED
    
    
// Set the owner, in the offset because when the nade explodes for some reason the 
    // engine clears the owner this is what we need to do to aviod the problem.    
    
set_pdata_int(entOFFSET_OWNERpev(ent,pev_owner), OFFSET_LINUX)
    
    
// Ignore
    
return FMRES_IGNORED
}


public 
fw_emitsound(ent,chan,const sound[])
{
    
// Check if it is flash if yes then clear all the data that we have used!
    
if (!pev_valid(ent))
        return 
FMRES_IGNORED
    
    
if (contain(sound"flash") == -1)
        return 
FMRES_IGNORED
    
    
static classname[32]
    
pev(entpev_classnameclassname31)
    if (!
equal(classname"grenade"))
        return 
FMRES_IGNORED
    
    
// Good time to reset the flasher and the ent id
    
g_flash_ent 0
    g_flasher 
0
    
    
return FMRES_IGNORED
}


// Is flash? Useful stock
stock bool:is_flash(ent)
{
    if (!
pev_valid(ent)) return false
    
static classname[32]
    static 
model[32]
    
pev(entpev_classnameclassname31)
    
pev(ent,pev_model,model,31)
    return (
equal(classname"grenade") && containi(model,"w_flashbang.mdl") != -1) ? true false
}

stock Float:pev_float(index,type)
{
    static 
Float:nr
    pev
(index,type,nr)
    return 
nr

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 09-25-2009 at 03:14.
ot_207 is offline
aln'
New Member
Join Date: Oct 2009
Old 10-04-2009 , 18:05   Re: Realistic Defuse v1.4
Reply With Quote #12

congratulations!

it`s nice
aln' is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 11-06-2009 , 05:30   Re: Realistic Defuse v1.4
Reply With Quote #13

Quote:
Originally Posted by ot_207 View Post
I have not tested it, because I wrote it here fast. Please post if you have problems.
Don't you think that code is a bit... TOO MUCH for what's needed to be done ? All you need to do is hook screenfade for flash, set a bool that player is flashed and set a task or set gametime to a var and while that bool var is true, hook ham use and block usage of C4... I don't see why you should complicate yourself with THAT much code... also calls alot of functions... I don't know why shouldn't you check right away for screenfade because you need to be blind, doesn't really matter if it's a real flashbang or a emessage fake-flash

So, alucard, are you going to add this feature ? If not, I'll make the plugin separately :}
__________________
Hunter-Digital is offline
xD_1991
Senior Member
Join Date: Jul 2008
Location: Turkey/Istanbul
Old 01-05-2010 , 03:50   Re: Realistic Defuse v1.4
Reply With Quote #14

nice
xD_1991 is offline
chudy_cwaniak
Junior Member
Join Date: Apr 2010
Old 05-28-2010 , 21:35   Re: Realistic Defuse v1.4
Reply With Quote #15

I have founded two things in this plugin, that, IMHO, are glitches.

The first glitch concerns buying a new defuse kit. For example, if I set new defuse kit’s price to 2500 and I will use say /defuse command to buy it, then everything is fine. However, if I will die (or drop my new defuse kit, more below) and I would like to buy a normal defuse kit again, then instead of buying a normal defuse kit I am not only buying a new defuse kit, but it also costs me 200 (prize for a normal defuse kit) instead of 2500. And this thing is happening until next map is loaded, or a current map is reloaded (sv_restart command doesn’t help).

I have discovered a second glitch while I was testing this plugin with the Drop Defuser Kit plugin (http://forums.alliedmods.net/showthread.php?p=57960). This is what happens. First, I have bought a normal defuse kit and dropped it, then I have bought a new defuse kit and dropped it too. And now, when I have picked up a normal defuse kit, I have picked up a new defuse kit instead of the normal one?

Also, I have a few suggestions, that, IMO, might improve this plugin .

How about an ability to upgrade your normal defuse kit to the new one, for a price of course? This is how it could work: you have bought a normal defuse kit for a 200 and now you want to have the new kit which costs, for example, 1000, but you can’t buy it because you already have that normal kit. At this point you can upgrade your kit via the menu (witch is, for example, accessible by using say_team /kitupgrade command) to the new one by paying 800 (or any other value witch could be configured by a cvar) and there you go . No need to risk your life (and a gun on witch you have collected so much cash ) just to deplete your defuse kit on that C4. You can just simply perform an upgrade in a buy zone (or everywhere. This could depend by setting an other cvar).

How about an adding a say_team /defuse command, so only CTs would know that I have bought a better version of a defuse kit?

And I suggest to add a little improvement to bot support. I mean, everything is fine , but if a bot will deplete his defuse kit on a bomb, he won’t buy another defuser, because he thinks, that he still has one. You can imagine what may happen if a defuse_block is set to 1 . And he will only attempt to buy it again, if he gets killed. I think that a setting that would force a bots to attempt to buy a defuse kits at the beginning of each round (even if they already have one) would solve this.

Last edited by chudy_cwaniak; 05-28-2010 at 21:49. Reason: Just a little minor improvement, that’s all ;).
chudy_cwaniak is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode