Raised This Month: $ Target: $400
 0% 

API Scripting Help [ZP4.3] [SOLVED] Block infection and call takedamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SergiCruz
Senior Member
Join Date: Mar 2012
Location: Andalucía, España
Old 05-23-2015 , 16:15   [ZP4.3] [SOLVED] Block infection and call takedamage
Reply With Quote #1

I'm making a plugin for a "more realistic infection" for zp4.3, so I need to avoid instant infection. I want zombies to kill humans, and then the humans will respawn as zombies. (I know it would be much easier with 5.0, in fact it's already done, but I prefer this older version)

I tried this

PHP Code:
public zp_user_infect_attempt(idinfectornemesis)
{
    
// g_is_infection : True when it's infection mode or multi infection mode
    // g_justDeath[id]: True when id has just been killed by a zombie. That allows to infect a human after his spawn
    
if(g_is_infection && !g_justDeath[id])
            return 
ZP_PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;

and that correctly blocks infection, but no damage it's taken. So, I decided to call TakeDamage manually:

PHP Code:
public zp_user_infect_attempt(idinfectornemesis)
{
    if(
g_is_infection && first_zombies && !g_justDeath[id]) {
        
        new 
button pev(infectorpev_button)
        if(
button == IN_ATTACK){
            
ExecuteHamB(Ham_TakeDamageidinfectorinfectorrandom_float(10.0,50.0), DMG_SLASH)
            return 
ZP_PLUGIN_HANDLED;
        }
        else if(
button == IN_ATTACK2){
            
ExecuteHamB(Ham_TakeDamageidinfectorinfectorrandom_float(50.0120.0), DMG_SLASH)
            return 
ZP_PLUGIN_HANDLED;
        }
        else    return 
ZP_PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;

but this is shitty, and it's making a mess with ammopacks rewards.

Can someone help me with this? I think I will need to modify the zombie_plague40.sma directly, but I still hope to be able to do it with a plugin.

Thanks in advance
__________________
PodBot waypointer. Feel free to ask for waypoints for zm_ maps.

Last edited by SergiCruz; 05-24-2015 at 06:41. Reason: Solved
SergiCruz is offline
Send a message via MSN to SergiCruz
SergiCruz
Senior Member
Join Date: Mar 2012
Location: Andalucía, España
Old 05-24-2015 , 06:41   Re: [ZP4.3] Block infection and call takedamage
Reply With Quote #2

Ok, it's solved. If anyone is interested in the solution I found, here it is (zombie_plague40.sma):
At the beginning
PHP Code:
new cvar_new_infection // For easily enabling/disabling infection block
new cNewInfection // For precaching the cvar value instead of calling get_pcvar_num in takeDamage 
At plugin_init
PHP Code:
cvar_new_infection register_cvar("zp_new_infection""1"
at event_round_start
PHP Code:
cNewInfection get_pcvar_num(cvar_new_infection// Precaching... 
at takeDamage, just after
PHP Code:
if (g_survround || g_nemround || g_swarmround || g_plagueround// I removed last human check here (see later)
        
return HAM_IGNORED// human is killed 
we write...
PHP Code:
if(cNewInfection || fnGetHumans() == 1// That should also work with last human
    
{
        
// Get victim armor
        
static Float:armor
        pev
(victimpev_armorvaluearmor)
            
        
// If he has some armor, we reduce it just before reducing health (otherwise, armor would be useless in the gameplay)
        
if (armor 0.0)
        {
            
emit_sound(victimCHAN_BODYsound_armorhit1.0ATTN_NORM0PITCH_NORM)
            if (
armor damage 0.0)
                
set_pev(victimpev_armorvaluearmor damage)
            else
                
cs_set_user_armor(victim0CS_ARMOR_NONE)
            return 
HAM_SUPERCEDE;
        }
        else 
// If there's no armor
            
return HAM_IGNORED// We avoid calling zombieme function
    

And then we set zp_deathmatch to the desired value to infect death people (or making a better respawn plugin). I also recomend to make 6-7 zombies at the beginning instead of one. The results are wonderful.

I did those plugins, so if anyone wanted them, I would share them here.
__________________
PodBot waypointer. Feel free to ask for waypoints for zm_ maps.
SergiCruz is offline
Send a message via MSN to SergiCruz
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 16:14.


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