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(id, heroID, mode)
{
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(gamemode, id)
{
give_powers(id)
}
public zp_user_humanized_post(id, survivor)
{
give_powers(id)
}
give_powers(id)
{
new players[32], playerCount, player
get_players(players, playerCount, "ah")
for ( new i = 0; i < playerCount; i++ )
{
player = players[i]
if ( zp_get_user_zombie(id) ) continue
if ( gHasSuperman[player] )
{
sh_add_hp(player, get_pcvar_num(pcvarHealth), get_pcvar_num(pcvarHealth))
sh_add_ap(player, get_pcvar_num(pcvarArmor), get_pcvar_num(pcvarArmor))
set_user_gravity(player, get_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_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
public sh_hero_init(id, heroID, mode)
{
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(id, infector)
{
// 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(id, get_pcvar_num(pcvarBatmanHealth), get_pcvar_num(pcvarBatmanHealth))
}
if ( gHasSuperman[id] )
{
sh_add_hp(id, get_pcvar_num(pcvarSupermanHealth), get_pcvar_num(pcvarSupermanHealth))
}
}
}
__________________