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

Hero: Protoman (useless)


Post New Thread Reply   
 
Thread Tools Display Modes
heliumdream
Senior Member
Join Date: Aug 2006
Old 10-29-2006 , 14:22   Re: Hero: Protoman (useless)
Reply With Quote #11

ahh ty for the tip with the set_task object. i really hadn't even written anything that used a set_task yet I was unfimiliar with how it worked, but it makes perfect sense.

I already rewrote this and got it working. I ended up sucking some code from juggernaut ii to get the health preservation property working right. But as you noted the timing is not perfect.

I will make more changes and post again. Personally I thought this was a great hero, there are far too many laser and explosion heroes not to have some sort of countermeasure.

As it stands now one my server, no laser and no explosion can kill someone standing still/hooking/blinking. It's kinda lame, so I'll add a variable for %chance shield failure.
heliumdream is offline
heliumdream
Senior Member
Join Date: Aug 2006
Old 10-30-2006 , 00:44   Re: Hero: Protoman (useless)
Reply With Quote #12

Code:
// Protoman - Proto Shield blocks all projectiles while not moving, shooting, or zooming for x seconds

 /*

 //Protoman
 protoman_level 60   - what level must they be for Protoman's powers?
 protoman_delay 8    - how long after shooting does the shield kick in?
 protoman_chance .25   - % chance the shield will work


 Version Changes:

 1.0 - useless

 * Initial Release

 1.2 - yang

 * Corrected for AMXX Compiler
 * Code CleanUp
 * Optimized Code

1.3 - heliumdream

* Made use of the proto_delay cvar
* Added a %chance cvar
* Switched health preservation code from old method to the method used in 'Juggernaut II'
* Added support so the 'Casper' hero won't cause interference with health preservation
* Also note about 8 lines below this is a defination 'HPNO 799'.  This should be treated as 'additional health'.

 */

 #include <amxmod>
 #include <superheromod>

 // VARIABLES
 #define HPNO 799
 new gHeroName[]="Protoman"
 new bool:gHasProtoPower[SH_MAXSLOTS+1]
 new bool:gProtoShield[SH_MAXSLOTS+1]
 new playerhealth[SH_MAXSLOTS+1]
 new casperHealth
 //----------------------------------------------------------------------------------------------
 public plugin_init()
 {
    // Plugin Info
    register_plugin("SUPERHERO Protoman","1.2","useless / yang")

    // FIRE THE EVENT TO CREATE THIS SUPERHERO!
    if ( isDebugOn() ) server_print("Attempting to create Protoman Hero")
    if ( !cvar_exists("protoman_level") ) register_cvar("protoman_level", "3")
    shCreateHero(gHeroName, "Proto Shield", "Autoblock all projectiles when not moving, shooting, or zooming for x seconds", false, "protoman_level" )

    // REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
    register_event("ResetHUD","newRound","b")
    register_event("Damage", "proto_damage", "b", "2!0")
    // INIT
    register_srvcmd("protoman_init", "protoman_init")
    shRegHeroInit(gHeroName, "protoman_init")

    // CHECK SOME BUTTONS
    set_task(0.01,"check_attack",0,"",0,"b")
    set_task(0.01,"check_two_buttons",0,"",0,"b")
    set_task(0.01,"check_move_buttons",0,"",0,"b")
    set_task(0.1,"protoman_loop",0,"",0,"b" )    

    // DEFAULT THE CVARS
    register_cvar("protoman_delay", "8.0")
    register_cvar("protoman_chance", "0.25")
    
    //CASPER SUPPORT
    if ( !cvar_exists("casper_health") ) register_cvar("casper_health", "300")
    casperHealth=get_cvar_num("casper_health")
 }
 //----------------------------------------------------------------------------------------------
 public protoman_init()
 {
    new temp[128]
    // First Argument is an id
    read_argv(1,temp,5)
    new id=str_to_num(temp)
    // 2nd Argument is 0 or 1 depending on whether the id has proto
    read_argv(2,temp,5)
    new hasPowers=str_to_num(temp)
    gHasProtoPower[id]=(hasPowers!=0)

    // Got to remove the powers if he is not Protoman
    if ( !hasPowers ){
        uninvis(id)
        //set_user_rendering(id)
    }
    //Give Powers to the Protoman
    if ( hasPowers )
    invis(id)
 }

 public newRound(id)
 {
    new parm[1]
    parm[0]=id  
    if ( is_user_alive(id) && gHasProtoPower[id] == true ) {
        invis(id)
        set_task(1.0,"sethealth",id,parm,1)
    }
 }

 public sethealth(parm[])
{
    new id=parm[0]
    playerhealth[id]=get_user_health(id)+HPNO    
    set_user_health(id, playerhealth[id])
}

 public invis(id) {
    if ( gProtoShield[id] != true )
    {
        //set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderNormal,16)
        client_print(id, print_chat, "[SH](Protoman): You have a chance to absorb projectiles.")
        gProtoShield[id] = true
    }
 }

 public uninvis(id) {
    if ( gProtoShield[id] != false )
    {
        //set_user_rendering(id,kRenderFxGlowShell,100,100,100,kRenderNormal,16)
        client_print(id, print_chat, "[SH](Protoman): No longer impervious to projectiles.")
        gProtoShield[id] = false
    }
 }

 public check_attack() {

    for(new i = 1; i <= get_maxplayers(); ++i) {
        if (is_user_alive(i)) {
            if ((get_user_button(i)&IN_ATTACK) && gHasProtoPower[i]) {
                uninvis(i)
            }
            else if (!(get_user_button(i)&IN_ATTACK) && gHasProtoPower[i]) {
                invis(i)
            }
        }
    }
    return PLUGIN_CONTINUE
 }

 public check_two_buttons() {

    for(new i = 1; i <= get_maxplayers(); ++i) {
        if (is_user_alive(i) || gHasProtoPower[i] ) {
            if (get_user_button(i)&IN_USE || get_user_button(i)&IN_ATTACK2) {
                uninvis(i)
            }
        }
    }
    return PLUGIN_CONTINUE
 }

 public check_move_buttons() {
    for(new i = 1; i <= get_maxplayers(); ++i)
    {
        if (is_user_alive(i) && gHasProtoPower[i] == true )
        {
            if (get_user_button(i)&IN_BACK || get_user_button(i)&IN_MOVELEFT || get_user_button(i)&IN_MOVERIGHT || get_user_button(i)&IN_FORWARD || get_user_button(i)&IN_RUN )
            {
                uninvis(i)
            }
        }
    }
    return PLUGIN_CONTINUE
 }
 
 public protoman_loop() {
     for (new id = 1; id <= SH_MAXSLOTS; id++) {
        if (gProtoShield[id] && (get_user_health(id) < playerhealth[id])) 
        {
             new randNum = random_num(0, 100)
            new protoChance = floatround(get_cvar_float("protoman_chance") * 100)
            client_print(id, print_chat,"[SH](Protoman): protoChance=%d, randNum=%d", protoChance, randNum)
            if (protoChance >= randNum)
            {
                set_user_health(id, playerhealth[id]) 
                new message[128]
                format(message, 127, "Protoman deflected the projectile!" )
                set_hudmessage(0,120,255,-1.0,1.0,0,0.25,1.0,0.0,0.0,4)
                show_hudmessage(id, message)
            }
            else 
            {
                if (get_user_health(id) > casperHealth + 10) playerhealth[id]=get_user_health(id)
            }    
        }
    }
 
 }
 
 public proto_damage(id) {
    if (gProtoShield[id]) {
        new damage = read_data(2)
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
        if (attacker!=id && weapon!=CSW_KNIFE) playerhealth[id] -= damage
    }
 }
I ended up re-writing it again, and this is what it came out looking like this time. I added in support for the casper hero, so that it doesn't cause a wierd collision when trying to preserve health.

This code makes the hero work next to flawlessly, only it is not using the protoman_delay cvar anymore, as I could not get it to work alongside the set_task function properly.

It is set up the way it was originally, where protoman is ALWAYS active unless you are moving or shooting. If I can set 'invis' to execute 8 seconds in the future instead of imediately (by using set_task), there will be no more errors or problems. If anyone would please give me a sample line code snippet for a proper set_task function that makes the called routine run x seconds in the future that would be appreicated.

And no I'm not a fucking idiot, it should be something like set_task(8.0,routine_name,id) but that doesn't work! that makes it execute imediately, not 8.0 seconds in the future. Perhaps my syntax is wrong, I think there are more vars to pass to set_task.
heliumdream is offline
yang
Veteran Member
Join Date: May 2005
Location: galoreservers.net
Old 11-01-2006 , 19:42   Re: Hero: Protoman (useless)
Reply With Quote #13

post your set_task code in scripting help o.O
yang is offline
Send a message via AIM to yang
heliumdream
Senior Member
Join Date: Aug 2006
Old 06-07-2015 , 02:51   Re: Hero: Protoman (useless)
Reply With Quote #14

this was all bad. i took another look at it.
i have made changes and fixed it, mostly a complete re-write based off invisible man.

ultimately a neat alternative to godmode heroes like captain america.

note: you cannot shield lethal damage. unfortunately the hero cannot prevent damage, so you must survive the attack in order for your health to be reset.

fix: set_user_info can make the sh_extra_damage function inside superheromodule aware of an active protoman shield and perform a check before you die...for expert scripters; or post for help.

i have done this on my server and tweaked superheromod to support anubis and protoman.
my anubis implementation is a bit wonky; after learning how pev and set_user_info work i should be able to clean it up. reference: Superhero Show Damage

note2: does not block bullets - only checks for superhero damage; lasers, projectiles, explosions, etc. this was a flavor choice...
fix: you can remove gWpnindex if you would like protoman to check for bullets.

note3: bug - occasionally protoman will shield a bullet.
i have a known issue with my tweaked superheromod; it has a check inside sh_extra_damage to prevent protoman from taking lethal damage. this check has no way to detect if that lethal damage was a bullet or not and will deflect it anyway. there are other cases, outside of this known lethal damage check issue, where protoman will block a bullet. not exactly sure why.

Code:
// Protoman - Proto Shield has a chance to block projectiles while not moving, shooting, or zooming for x seconds

/*
//Protoman
protoman_level 10
protoman_delay 4.0      //Seconds a player must be still to gain proto shield
protoman_checkmove 1        //0 = no movement check only shooting, 1 = check movement buttons, 2 or more = speed movement to check
protoman_checkonground 0    //Must player be on ground to be shielded (Default 0 = no, 1 = yes)
protoman_chance 0.25   - % chance the shield will work

*/
Attached Files
File Type: sma Get Plugin or Get Source (sh_protoman.sma - 819 views - 9.4 KB)
__________________

Last edited by heliumdream; 06-11-2015 at 01:40. Reason: yet another fix.
heliumdream is offline
Reply


Thread Tools
Display Modes

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 18:34.


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