AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=43)
-   -   Regeneration not stacking (How?) (https://forums.alliedmods.net/showthread.php?t=142129)

Exploited 11-01-2010 17:40

Regeneration not stacking (How?)
 
Hey,

So, I want to create a hero that heals 30hp and 30ap per second, but doesn't stack with other heroes, for example Wolverine or Iron Man. Jelle said he'd help me out with this one, but I wont be able to access Steam for another 9000 years so I might aswell ask here. I am also unable to access a compiler except for the online one, so I'm not sure if the errors are get are caused by the compiler or by the code, but when I try to compile it there it says every single line is too long, wich I have no idea how to fix, if it really is the code.

Like I said, what I wonder how to do is how to do so it doesn't stack with other heroes. The heroes I have that regens.. at the moment is:

Hp:
Wolverine
Darth Maul
Riddick

Ap:
Iron Man
Spy
Armor Pack

And heres the code I have so far wich hopefully compiles on a normal compiler.. As I said, the only errors I get are from too long lines.

PHP Code:

//Regeneration

#include <superheromod>
#include <hamsandwich>

//Global commands
new gHeroID
new gHeroName[] = "Regeneration"
new bool:gHasRegen[SH_MAXSLOTS+1]
new 
pcvarHpRegenpcvarApRegen
//-------------------------------------------------------
public plugin_init()
{
     
register_plugin("SUPERHERO Regeneration""1.0""Exploited")

     new 
pcvarLevel register_cvar("regen_level""10")
     
pcvarHpRegen register_cvar("regen_hpregen""30")
     
pcvarApRegen register_cvar("regen_apregen""30")

     
gHeroID sh_create_hero(gHeroNamepcvarLevel)
     
sh_set_hero_info(gHeroID"Regeneration""High-speed regeneration!")

}   
//-------------------------------------------------------
public sh_hero_init(idheroIDmode)
{
    if (
gHeroID != heroID) return
    
    if(
mode == SH_HERO_ADD)
    {
        
gHasRegen[id] = true
        set_task
(1.0"taskRegen"id)
    }
    else
    {
        
gHasRegen[id] = false
        remove_task
(id)
    }
}
//-------------------------------------------------------
public taskRegen(indexid)
{
    if(!
sh_is_active() || !is_user_alive(index) )
        return
    
    
sh_add_hp(indexget_pcvar_num(gPcvarHpRegen) )
    
set_user_armor(idmin(userarmor get_pcvar_num(pcvarApRegen), sh_get_max_ap(id)))


I was extremely tired when I made this, so I probably forgot something. I'm only human.

Any help is appreciated,
Exploited

DarkGod 11-01-2010 17:42

Re: Regeneration not stacking (How?)
 
set_task(1.0, "taskRegen", id)

public taskRegen(index, id)

wat

Exploited 11-01-2010 17:54

Re: Regeneration not stacking (How?)
 
wat, you're the one who taught me how to use tasks with the Darth Maul you sent me. Should I replace index with id in the hphealing thing and remove index from the parantheseline? Damn, I suck at explaining things, but I mean like this:

PHP Code:

public taskRegen(id)
{
    if(!
sh_is_active() || !is_user_alive(id) )
        return
    
    
sh_add_hp(idget_pcvar_num(gPcvarHpRegen) )
    
set_user_armor(idmin(userarmor get_pcvar_num(pcvarApRegen), sh_get_max_ap(id)))


Or are you on about something else?

DarkGod 11-01-2010 18:45

Re: Regeneration not stacking (How?)
 
Quote:

Originally Posted by Exploited (Post 1339570)
wat, you're the one who taught me how to use tasks with the Darth Maul you sent me. Should I replace index with id in the hphealing thing and remove index from the parantheseline? Damn, I suck at explaining things, but I mean like this:

PHP Code:

public taskRegen(id)
{
    if(!
sh_is_active() || !is_user_alive(id) )
        return
    
    
sh_add_hp(idget_pcvar_num(gPcvarHpRegen) )
    
set_user_armor(idmin(userarmor get_pcvar_num(pcvarApRegen), sh_get_max_ap(id)))


Or are you on about something else?

Yes, precisely that. One variable passed can't magically turn into two.

Exploited 11-01-2010 18:58

Re: Regeneration not stacking (How?)
 
Alright, I thought so. Anyways, do you know how to do so the regen doesn't stack?

Edit: I found this post by G-Dog, but I am not sure how to do it with multiple heroes, nor do I know how to do it if a forward is run in sh_hero_init, as it isn't in the example he gave. Any ideas?

Jelle 11-01-2010 20:56

Re: Regeneration not stacking (How?)
 
Look at the hero wolverine...

The Art of War 11-02-2010 04:19

Re: Regeneration not stacking (How?)
 
Quote:

Originally Posted by Jelle (Post 1339679)
Look at the hero wolverine...

Quote:

Originally Posted by Exploited (Post 1339612)
Anyways, do you know how to do so the regen doesn't stack?

But no.

Exploited 11-02-2010 06:15

Re: Regeneration not stacking (How?)
 
Wolverines regen stacks. I forgot to link G-DOgs post in my previous post, but here it is: http://forums.alliedmods.net/showpos...2&postcount=13

Fr33m@n 11-02-2010 06:42

Re: Regeneration not stacking (How?)
 
2 methods :
- use g-Dog method.
- combine 3 hero in one plugin.

Exploited 11-02-2010 07:08

Re: Regeneration not stacking (How?)
 
How would I use G-Dogs method in my code? I tried to insert it but it just looked weird and I had no idea where to put certain things as his sh_hero_init looks different to mine as he doesnt run any forwards in it.


All times are GMT -4. The time now is 17:41.

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