Raised This Month: $ Target: $400
 0% 

[bug] t-800 + darth maul


Post New Thread Reply   
 
Thread Tools Display Modes
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 03-09-2011 , 16:07   Re: [bug] t-800 + darth maul
Reply With Quote #11

Quote:
Originally Posted by Exploited View Post
Vittu, I was referring to the "and above" part.

Also, DG made this.

PHP Code:
//Darth Maul

#include <superheromod> 
#include <hamsandwich> 

//Global commands 
new gHeroID 
new gHeroName[] = "Darth Maul" 
new bool:gHasDarth[SH_MAXSLOTS+1
new 
gPcvarHealPoints 
new const gDarthWeapon[] = "models/shmod/darthmaul_knife.mdl" 
new const gDarthWeapon2[] = "models/shmod/darthmaul_p_knife.mdl" 

public plugin_init() 

    
//Plugin information 
    
register_plugin("SUPERHERO Darth Maul""2.0""Chivas2973"
     
    
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG 
    
new pcvarLevel register_cvar("darth_level""7"
    new 
pcvarKnifeSpeed register_cvar("darth_knifespeed""400"
    new 
pcvarKnifeMult register_cvar("darth_knifemult""400"
    
gPcvarHealPoints register_cvar("darth_healpoints""10"
     
    
// FIRE THE EVENT TO CREATE THIS SUPERHERO! 
    
gHeroID sh_create_hero(gHeroNamepcvarLevel
    
sh_set_hero_info(gHeroID"Sith Lightsaber & Regen""Get a Sith Double Bladed Lightsaber with more damage and speed. Also regenerate HP and a hook."
    
sh_set_hero_speed(gHeroIDpcvarKnifeSpeed, {CSW_KNIFE}) 
    
sh_set_hero_dmgmult(gHeroIDpcvarKnifeMultCSW_KNIFE)     
    
RegisterHam(Ham_Item_Deploy"weapon_knife""fwDeployedKnife"true

//--------------------------------------------------------------------------------------------------------------------------------------------------------- 
public sh_hero_init(idheroIDmode

    if (
gHeroID != heroID) return 
     
    if(
mode == SH_HERO_ADD
    { 
        
gHasDarth[id] = true 
        switch_model
(id//If client have the hero, switch the model  
        
set_task(1.0"taskHeal"id
    } 
    else 
    { 
        
gHasDarth[id] = false //If the client does not have the hero, don't do anything 
        
remove_task(id
    } 


public 
taskHeal(index

    if(!
sh_is_active() || !is_user_alive(index)    ) 
        return 
     
    
sh_add_hp(indexget_pcvar_num(gPcvarHealPoints)    ) 


public 
fwDeployedKnife(iEnt

    if(!
sh_is_active()    )  
        return 
     
    new 
index get_pdata_cbase(iEnt414
    
switch_model(index


switch_model(id

    if (!
is_user_alive(id)    )  
        return 
     
    if (
get_user_weapon(id) == CSW_KNIFE
    { 
        
set_pev(idpev_viewmodel2gDarthWeapon
        
set_pev(idpev_weaponmodel2gDarthWeapon2//Here we actually set the models 
    



//--------------------------------------------------------------------------------------------------------------------------------------------------------- 
public plugin_precache() 

    
precache_model(gDarthWeapon)  
    
precache_model(gDarthWeapon2//Here we precache the models. 

//--------------------------------------------------------------------------------------------------------------------------------------------------------- 

// Keeping this because I'm not sure if deployed is called when you spawn with it 
public sh_client_spawn(id

    if ( 
sh_is_active() && gHasDarth[id] ) 
    { 
        
switch_model(id//If the hero has the hero, lets give him the model when he spawns. 
    


Are you absolutely sure he made it? I dont think he would include ham when its already being included in superheromod..
__________________
The Art of War is offline
Exploited
Veteran Member
Join Date: Jul 2010
Location: Sweden
Old 03-09-2011 , 16:12   Re: [bug] t-800 + darth maul
Reply With Quote #12

Well he did.
__________________
Jelle (1): I LOVE YOU
Jelle (1): Yeah. omg you are so awesome!
--------------
Jelle (1): You know when a poo is about to exit but it is too big?
Jelle (1): God my ass still hurts
Exploited is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 03-09-2011 , 16:14   Re: [bug] t-800 + darth maul
Reply With Quote #13

This is my version, as efficient as I can get it:

PHP Code:
// Darth Maul!

/* CVARS - copy and paste to shconfig.cfg

//Darth Maul
darth_level 0
darth_healpoints 3            //The # of HP healed per second
darth_knifespeed 290            //Speed of wolveine when holding knife
darth_mult 1.35            //Multiplier for knife damage


*/



#include <superheromod>

// OFFSETS
const m_pPlayer 41
const XTRA_OFS_WEAPON 4

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Darth Maul"
new bool:gHasDarth[SH_MAXSLOTS+1]
new 
gPcvarHealPoints

new const gModelKnife[] = "models/shmod/darth_knife.mdl"
new const gModelKnife2[] = "models/shmod/darth_p_knife.mdl"
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// Plugin Info
    
register_plugin("SUPERHERO Darth Maul"SH_VERSION_STR"The Art of War")

    
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
    
new pcvarLevel register_cvar("darth_level""34")
    new 
pcvarSpeed register_cvar("darth_knifespeed""480")
    new 
pcvarMult register_cvar("darth_knifemult""3.75")
    
gPcvarHealPoints register_cvar("darth_healpoints""5")

    
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"Sith Lord""The dark side of the Sith channels it's mysterious energies through you! Get a lightsaber and heal your health.")
    
sh_set_hero_speed(gHeroIDpcvarSpeed, {CSW_KNIFE})
    
sh_set_hero_dmgmult(gHeroIDpcvarMultCSW_KNIFE)

    
RegisterHam(Ham_Item_Deploy"weapon_knife""Ham_KNIFE_Deploy_Post"true)

    
// HEAL LOOP
    
set_task(1.0"darth_loop"___"b")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
    
precache_model(gModelKnife)
    
precache_model(gModelKnife2)
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return

    switch(
mode) {
        case 
SH_HERO_ADD: {
            
gHasDarth[id] = true
            
if ( get_user_weapon(id) == CSW_KNIFE) {
            
switch_model(id)
            }
            
        }

        case 
SH_HERO_DROP: {
            
gHasDarth[id] = false
        
}
    }

    
sh_debug_message(id1"%s %s"gHeroNamemode "ADDED" "DROPPED")
}
//----------------------------------------------------------------------------------------------
public darth_loop()
{
    if ( !
sh_is_active() ) return

    static 
players[SH_MAXSLOTS], playerCountplayeri
    get_players
(playersplayerCount"ah")

    for ( 
0playerCounti++ ) {
        
player players[i]

        if ( 
gHasDarth[player] ) {
            
sh_add_hp(playerget_pcvar_num(gPcvarHealPoints))
        }
    }
}
//----------------------------------------------------------------------------------------------
switch_model(id)
{
    if ( !
sh_is_active() || !is_user_alive(id) || !gHasDarth[id] ) return

    
set_pev(idpev_viewmodel2gModelKnife)
    
set_pev(idpev_weaponmodel2gModelKnife2)
}
//----------------------------------------------------------------------------------------------
public Ham_KNIFE_Deploy_Post(const weapon_ent)
{
    new 
owner get_pdata_cbase(weapon_entm_pPlayerXTRA_OFS_WEAPON)
 
    
switch_model(owner)

__________________
The Art of War is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 03-09-2011 , 17:33   Re: [bug] t-800 + darth maul
Reply With Quote #14

I probably just changed a bit in it, I guess. It doesn't look like I made the model changing function other than one line in which I see my way of coding.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Exploited
Veteran Member
Join Date: Jul 2010
Location: Sweden
Old 03-09-2011 , 17:43   Re: [bug] t-800 + darth maul
Reply With Quote #15

I'm not sure as this was a while ago, but I believe you did. I remember this as the first time I saw someone change gSuperWeapon (as it is in Jelles tutorial) to something else, but again, I am not sure.
__________________
Jelle (1): I LOVE YOU
Jelle (1): Yeah. omg you are so awesome!
--------------
Jelle (1): You know when a poo is about to exit but it is too big?
Jelle (1): God my ass still hurts
Exploited is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 03-09-2011 , 17:47   Re: [bug] t-800 + darth maul
Reply With Quote #16

Quote:
Originally Posted by Exploited View Post
Vittu, I was referring to the "and above" part.
Well the svn has a couple of updates bring it up to version 1.2.0.16.


I wasn't aware of user updates to darth maul. I do trust DarkGod and his method works, but a "best practice" method would be more in tune to what the TAOW posted there. In SH some methods may not be done as efficiently as possible as it can be either a negligible difference, but in most cases it is to make it easier for users to understand what they copied to learn to code.

Last edited by vittu; 03-09-2011 at 17:50.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 03-09-2011 , 22:57   Re: [bug] t-800 + darth maul
Reply With Quote #17

Quote:
Originally Posted by vittu View Post
but in most cases it is to make it easier for users to understand what they copied to learn to code.
I'm pretty sure it makes more sense for a user to read that the model is changed whenever the weapon is deployed rather than on Current Weapon which probably doesn't mean anything to them. The only line which would be hard to understand would be the get_pdata_cbase() one. But I think that can be replaced with pev_owner to be more readable.

There's also an issue in the code Exploited posted as the regen loop is not infinite and thus you only get the heal once.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 03-10-2011 , 11:14   Re: [bug] t-800 + darth maul
Reply With Quote #18

Quote:
Originally Posted by DarkGod View Post
and thus you only get the heal once.
Lol.

Yes well, what can I say, the method was Fr33's originally, and he's pretty crazy about efficiency too

I used this in some random server I made some times ago, so everything should work (the healing loop). And no DG, Im sure you know that now but there's no need to call it on spawn, Ive never used it and I see the model all the time even on spawn. I dont see any logical reason why it wouldnt as either the weapon is deployed again on spawn which would make it set the model again or its not, meaning the model would still be there because it has been set before :p
__________________
The Art of War is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 03-10-2011 , 20:16   Re: [bug] t-800 + darth maul
Reply With Quote #19

Quote:
Originally Posted by DarkGod View Post
I'm pretty sure it makes more sense for a user to read that the model is changed whenever the weapon is deployed rather than on Current Weapon which probably doesn't mean anything to them.
Never argued that, in fact I was saying it should be used just didnt have time to create best practice method.

Quote:
Originally Posted by DarkGod View Post
The only line which would be hard to understand would be the get_pdata_cbase() one. But I think that can be replaced with pev_owner to be more readable.
True, but get_pdata_cbase() will still be needed anyway as as get_user_weapon does not update soon enough. But a function is needed to change the model in case it needs to be added outside of weapon deploy, such as user adding the hero.


Couple different ways to go about doing this, but I think this may be best. Thoughts?
Code:
// DARTH MAUL! evil Sith apprentice from Star Wars - Episode I: The Phantom Menace. Double Bladed Lightsaber is his trademark. /* CVARS - copy and paste to shconfig.cfg //Darth Maul darth_level 6 darth_healpoints 10     // the #of HP healed per second darth_knifespeed 400        // speed of Darth Maul in knife mode darth_knifemult 2.70        // multiplier for knife damage... */ /* * v1.4 - vittu - 3/10/11 *      - Changed model change method to use Ham_Item_Deploy instead of the CurWeapon event. * * v1.3 - vittu - 3/8/11 *      - Updated to SH 1.2.0.14 or above. *      - Added define to disable use of weapon models. * * v1.2 - vittu - 6/19/05 *      - Minor code clean up. *      - Added p_ knife model. * * v1.1 - vittu - 12/21/04 *      -SH mod 1.17.6 and up only *      -Model name and location changed (to follow new standard) *      -Also only needed one of the models not both (deleted useless second model) *      -Now heals past 100hp if you have more *      -Fixed extra speed to use knife * *   Darth Maul based on {HOJ}Batman's wolverine hero which is where most of the credit should go */ //---------- User Changeable Defines --------// // Comment out to force not using the model, will result in a very small reduction in code/checks // Note: If you change anything here from default setting you must recompile the plugin #define USE_WPN_MODEL //------- Do not edit below this point ------// #include <superheromod> // GLOBAL VARIABLES new gHeroID new bool:gHasDarthMaul[SH_MAXSLOTS+1] new gPcvarHealPoints #if defined USE_WPN_MODEL     #define XTRA_OFS_WEAPON 4     #define XTRA_OFS_PLAYER 5     #define m_pPlayer 41     #define m_iId 43     #define m_pActiveItem 373     new const gModelKnifeV[] = "models/shmod/darthmaul_knife.mdl"     new const gModelKnifeP[] = "models/shmod/darthmaul_p_knife.mdl"     new bool:gModelLoaded #endif //---------------------------------------------------------------------------------------------- public plugin_init() {     // Plugin Info     register_plugin("SUPERHERO Darth Maul", "1.4", "Chivas2973")     // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG     new pcvarLevel = register_cvar("darth_level", "6")     new pcvarKnifeSpeed = register_cvar("darth_knifespeed", "400")     new pcvarKnifeMult = register_cvar("darth_knifemult", "2.70")     gPcvarHealPoints = register_cvar("darth_healpoints", "10")     // FIRE THE EVENT TO CREATE THIS SUPERHERO!     gHeroID = sh_create_hero("Darth Maul", pcvarLevel)     sh_set_hero_info(gHeroID, "Sith Lightsaber & Regen", "Get a Sith Double Bladed Lightsaber with more Damage and Speed, also regenerate HP")     sh_set_hero_speed(gHeroID, pcvarKnifeSpeed, {CSW_KNIFE})     sh_set_hero_dmgmult(gHeroID, pcvarKnifeMult, CSW_KNIFE) #if defined USE_WPN_MODEL     // REGISTER EVENTS THIS HERO WILL RESPOND TO!     if ( gModelLoaded ) {         RegisterHam(Ham_Item_Deploy, "weapon_knife", "Ham_Knife_Deploy_Post", 1)     } #endif     // HEAL LOOP     set_task(1.0, "darth_loop", _, _, _, "b") } //---------------------------------------------------------------------------------------------- #if defined USE_WPN_MODEL public plugin_precache() {     // Method servers 2 purposes, moron check and optional way to not use the model     // Seperate checks so the model that is missing can be reported     gModelLoaded = true     if ( file_exists(gModelKnifeV) ) {         precache_model(gModelKnifeV)     }     else {         sh_debug_message(0, 0, "Aborted loading ^"%s^", file does not exist on server", gModelKnifeV)         gModelLoaded = false     }     if ( file_exists(gModelKnifeP) ) {         precache_model(gModelKnifeP)     }     else {         sh_debug_message(0, 0, "Aborted loading ^"%s^", file does not exist on server", gModelKnifeP)         gModelLoaded = false     } } #endif //---------------------------------------------------------------------------------------------- public sh_hero_init(id, heroID, mode) {     if ( gHeroID != heroID ) return     switch(mode) {         case SH_HERO_ADD: {             gHasDarthMaul[id] = true #if defined USE_WPN_MODEL             if ( gModelLoaded ) {                 switch_model(id)             } #endif         }         case SH_HERO_DROP: {             gHasDarthMaul[id] = false         }     } } //---------------------------------------------------------------------------------------------- public darth_loop() {     if ( !sh_is_active() ) return     static players[SH_MAXSLOTS], playerCount, player, i, healPoints     get_players(players, playerCount, "ah")     healPoints = get_pcvar_num(gPcvarHealPoints)     for ( i = 0; i < playerCount; i++ ) {         player = players[i]         if ( gHasDarthMaul[player] ) {             sh_add_hp(player, healPoints)         }     } } //---------------------------------------------------------------------------------------------- #if defined USE_WPN_MODEL public Ham_Knife_Deploy_Post(wpnEntId) {     // Who is the owner of this weapon entity?     new owner = get_pdata_cbase(wpnEntId, m_pPlayer, XTRA_OFS_WEAPON)     switch_model(owner)     return HAM_IGNORED } //---------------------------------------------------------------------------------------------- switch_model(id) {     if ( !sh_is_active() || !is_user_alive(id) || !gHasDarthMaul[id] ) return     // If user has a shield do not change model, since we don't have one with a shield     if ( cs_get_user_shield(id) ) return     // Gets the entity id of the active weapon     new wpnEntId = get_pdata_cbase(id, m_pActiveItem, XTRA_OFS_PLAYER)     // Is the entity the weapon we want?         if ( get_pdata_int(wpnEntId, m_iId, XTRA_OFS_WEAPON) == CSW_KNIFE ) {         set_pev(id, pev_viewmodel2, gModelKnifeV)         set_pev(id, pev_weaponmodel2, gModelKnifeP)     } } //---------------------------------------------------------------------------------------------- #endif

Last edited by vittu; 03-10-2011 at 21:44.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 03-11-2011 , 11:12   Re: [bug] t-800 + darth maul
Reply With Quote #20

Looks good to me, just that I dont understand why there's so many checks in switch model instead of just a get_user_weapon check if case SH_HERO_ADD: in sh_hero_init(), thats how I do it, works for me.

And how the hell did you get that entire code to be displayed without having to scroll in a very small "window"? :p
__________________
The Art of War is offline
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 23:39.


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