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

API Scripting Help [ZP4.3] Giving powers to humans


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-03-2012 , 23:27   [ZP4.3] Giving powers to humans
Reply With Quote #1

I have been coding for 5.0 for some time, but I realized that 5.0 is very hard to get into. I don't like that everything little thing is a plugin of its own. It does give you an easier way to edit it, but I just find it a bit confusing.

So, for what I am trying to make, ZP 4.3 seemed to be the way to go.

Anyway, I am checking if the players are human (after the first infected was found) and if they are then give them the super powers from SuperHero Mod. This means that zombies does not get any SuperHero powers, but their zombie grow stronger in specific areas depending on their choice of heroes.

The zombie class works where you get powers if you have the hero and don't if you don't have it, but when it comes to coding the hero itself for SuperHero Mod it gets tricky.

Sometimes it happens that you do not get the hero power, in this case extra life/gravity/ap. I have experienced it happen randomly in normal game mode but in swarm mode it seems to never give the power. I was thinking that I may be overlooking a forward or a check or anything that could do this.

The superhero:

PHP Code:
#include <superheromod>
#include <zombieplague>

new gHeroID
new bool:gHasSuperman[SH_MAXSLOTS+1]

new 
pcvarHealth
new pcvarArmor
new pcvarGrav

public plugin_init()
{
    
register_plugin("SUPERHERO Superman""1337""Jelle")
    
    new 
pcvarLevel register_cvar("superman_level""0")
    
pcvarHealth register_cvar("superman_health""150")
    
pcvarArmor register_cvar("superman_armor""150")
    
pcvarGrav register_cvar("superman_gravity""0.35")
    
    
gHeroID sh_create_hero("Superman"pcvarLevel)
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return
    
    if ( 
mode == SH_HERO_ADD )
    {
        
gHasSuperman[id] = true
    
}
    
    else if ( 
mode == SH_HERO_DROP )
    {
        
gHasSuperman[id] = false
    
}
}

public 
zp_round_started(gamemodeid)
{
    
give_powers(id)
}

public 
zp_user_humanized_post(idsurvivor)
{
    
give_powers(id)
}

give_powers(id)
{
    new 
players[32], playerCountplayer
    get_players
(playersplayerCount"ah")
    
    for ( new 
0playerCounti++ )
    {
        
player players[i]
        
        if ( 
zp_get_user_zombie(id) ) continue
        
        if ( 
gHasSuperman[player] )
        {
            
sh_add_hp(playerget_pcvar_num(pcvarHealth), get_pcvar_num(pcvarHealth))
            
sh_add_ap(playerget_pcvar_num(pcvarArmor), get_pcvar_num(pcvarArmor))
            
set_user_gravity(playerget_pcvar_float(pcvarGrav))
        }
    }

And the zombie class, if it helps you understand:

PHP Code:
#include <amxmodx>
#include <superheromod>
#include <zombieplague>

// Zombie Attributes
new const zclass_name[] = "Zombie" // name
new const zclass_info[] = "Zombie" // description
new const zclass_model[] = "zombie_source" // model
new const zclass_clawmodel[] = "v_knife_zombie.mdl" // claw model
const zclass_health 3500 // health
const zclass_speed 200 // speed
const Float:zclass_gravity 1.0 // gravity
const Float:zclass_knockback 1.0 // knockback

// Class IDs
new g_zclassid1

//SH hero ID's
new gBatmanID
new gSupermanID

//SH booleans for chekc
new bool:gHasBatman[SH_MAXSLOTS+1]
new 
bool:gHasSuperman[SH_MAXSLOTS+1]

//cvars
new pcvarBatmanHealth
new pcvarSupermanHealth

public plugin_init()
{
    
register_plugin("[ZP] Zombie""1.0""Jelle")
    
    
pcvarBatmanHealth register_cvar("zp_batmanhealth""4000")
    
pcvarSupermanHealth register_cvar("zp_supermanhealth""5000")
    
    
//get hero ID's
    
gBatmanID sh_get_hero_id("Batman")
    
gSupermanID sh_get_hero_id("Superman")
}

// Zombie Classes MUST be registered on plugin_precache
public plugin_precache()
{
    
// Register the new class and store ID for reference
    
g_zclassid1 zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
heroID == gBatmanID )
    {
        if ( 
mode == SH_HERO_ADD )
        {
            
gHasBatman[id] = true
        
}
        
        else if ( 
mode == SH_HERO_DROP )
        {
            
gHasBatman[id] = false
        
}
    }
    
    if ( 
heroID == gSupermanID )
    {
        if ( 
mode == SH_HERO_ADD )
        {
            
gHasSuperman[id] = true
        
}
        
        else if ( 
mode == SH_HERO_DROP )
        {
            
gHasSuperman[id] = false
        
}
    }
}

// User Infected forward
public zp_user_infected_post(idinfector)
{
    
// Check if the infected player is using our custom zombie class
    
if (zp_get_user_zombie_class(id) == g_zclassid1)
    {
        if ( 
gHasBatman[id] )
        {
            
sh_add_hp(idget_pcvar_num(pcvarBatmanHealth), get_pcvar_num(pcvarBatmanHealth))
        }
        
        if ( 
gHasSuperman[id] )
        {
            
sh_add_hp(idget_pcvar_num(pcvarSupermanHealth), get_pcvar_num(pcvarSupermanHealth))
        }
    }

__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-04-2012 , 10:42   Re: [ZP4.3] Giving powers to humans
Reply With Quote #2

I think I found out why. For starters I used the id from zp_round_started and the other forwards to check if the user was a zombie, not the actual player it came to in the loop. I have not yet been able to test it, but the new version I made is here:

PHP Code:
#include <superheromod>
#include <zombieplague>

new gHeroID
new bool:gHasSuperman[SH_MAXSLOTS+1]

new 
pcvarHealth
new pcvarArmor
new pcvarGrav

public plugin_init()
{
    
register_plugin("SUPERHERO Superman""1337""Jelle")
    
    new 
pcvarLevel register_cvar("superman_level""0")
    
pcvarHealth register_cvar("superman_health""150")
    
pcvarArmor register_cvar("superman_armor""150")
    
pcvarGrav register_cvar("superman_gravity""0.35")
    
    
gHeroID sh_create_hero("Superman"pcvarLevel)
    
sh_set_hero_info(gHeroID"Health/Armor/Gravity""More health, free armor, and reduced gravity")
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return
    
    if ( 
mode == SH_HERO_ADD )
    {
        
gHasSuperman[id] = true
        give_powers
(id)
    }
    
    else if ( 
mode == SH_HERO_DROP )
    {
        
gHasSuperman[id] = false
    
}
}

public 
zp_round_started(gamemodeid)
{
    new 
players[32], playerCountplayer
    get_players
(playersplayerCount"ah")
    
    for ( new 
0playerCounti++ )
    {
        
player players[i]
        
        if ( 
zp_get_user_zombie(player) ) continue
        
        if ( 
zp_get_user_nemesis(player) ) continue
        
        if ( 
gHasSuperman[player] )
        {
            
sh_add_hp(playerget_pcvar_num(pcvarHealth), get_pcvar_num(pcvarHealth))
            
sh_add_ap(playerget_pcvar_num(pcvarArmor), get_pcvar_num(pcvarArmor))
            
set_user_gravity(playerget_pcvar_float(pcvarGrav))
        }
    }
}

public 
zp_user_humanized_post(idsurvivor)
{
    
give_powers(id)
}

give_powers(id)
{
    if ( !
zp_has_round_started() ) return
    
    if ( 
zp_get_user_zombie(id) ) return
    
    if ( 
zp_get_user_nemesis(id) ) return
    
    if ( 
gHasSuperman[id] ) 
    {
        
sh_add_hp(idget_pcvar_num(pcvarHealth), get_pcvar_num(pcvarHealth))
        
sh_add_ap(idget_pcvar_num(pcvarArmor), get_pcvar_num(pcvarArmor))
        
set_user_gravity(idget_pcvar_float(pcvarGrav))
    }

Any input is always nice.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
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 06:38.


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