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

Help with touch teammates


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 01-21-2022 , 15:58   Help with touch teammates
Reply With Quote #1

Hello, my problem is that this power also freezes your team, I would like this not to happen

PHP Code:
//Sub-Zero From Mortal Kombat

//Credits go to SRGety for forge

/*
//Subzero
subzero_level 0 //At what level is this hero available
subzero_cooldown  2.0 //cooldown for his ice balst
subzero_blastspeed 600 //Speed of SubZero's ice blast
subzero_freezetime 5 //for How long is the player Freezed
subzero_freezeradius 50 //radius for the ice blast
subzero_freezedamage 35 //how much damage the ice blast does

*/
/*
* Version 1.0 Posted
* Version 1.1 Better Freeze Effect + a Freeze Sound
* Version 1.1 Fully converted to amxmodx
*/

#include <amxmodx>
#include <superheromod>
#include <engine>

new gHeroName[]="Sub Zero"
new bool:g_HasSubZeroPower[SH_MAXSLOTS+1]
new 
gLastWeapon[SH_MAXSLOTS+1]
new 
blastring
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// Plugin Info
    
register_plugin("SUPERHERO Sub-Zero","1.2","Om3gA/Yang")

    
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
    
register_cvar("subzero_level""7" )
    
register_cvar("subzero_cooldown""2.0")
    
register_cvar("subzero_blastspeed""600")
    
register_cvar("subzero_freezetime""5" )
    
register_cvar("subzero_freezeradius""50")
    
register_cvar("subzero_freezedamage""35")

    
shCreateHero(gHeroName"Ice Blast!""Dispara una Bola de Hielo para Congelar a tus Enemigos."true"subzero_level" )

    
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
    
register_event("ResetHUD","new_spawn","b")
    
register_touch("ice_blast","*","frozen")
    
// KEY DOWN
    
register_srvcmd("subzero_kd""subzero_kd")
    
shRegKeyDown(gHeroName"subzero_kd")

    
// INIT
    
register_srvcmd("subzero_init""subzero_init")
    
shRegHeroInit(gHeroName"subzero_init")

}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
    
precache_model("sprites/shmod/iceball.spr")
    
precache_sound("shmod/freezed.wav")
    
precache_model("models/shmod/freezed.mdl")
    
blastring precache_model("sprites/white.spr")
}
//----------------------------------------------------------------------------------------------
public subzero_init()
{
    new 
temp[6]
    
read_argv(1,temp,5)
    new 
id=str_to_num(temp)
    
read_argv(2,temp,5)
    new 
hasPowers=str_to_num(temp)

    
g_HasSubZeroPower[id]=(hasPowers!=0)
}
//----------------------------------------------------------------------------------------------
public subzero_kd()
{
    new 
temp[6]

    if ( !
hasRoundStarted() ) return PLUGIN_HANDLED

    
// First Argument is an id with SubZero Powers!
    
read_argv(1,temp,5)
    new 
id=str_to_num(temp)
    if ( !
is_user_alive(id) || !g_HasSubZeroPower[id] || !shModActive() ) return PLUGIN_HANDLED
    
if ( gPlayerUltimateUsed[id] ) {
        
playSoundDenySelect(id)
        return 
PLUGIN_HANDLED
    
}

    new 
clip,ammo,weaponID get_user_weapon(id,clip,ammo)
    
gLastWeapon[id] = weaponID


    engclient_cmd
(id,"weapon_knife")

    
make_iceblast(id)

    if(
get_cvar_float("subzero_cooldown") > 0.0)
    
ultimateTimer(idget_cvar_float("subzero_cooldown"))

    
// Switch back to previous weapon...
    
if ( gLastWeapon[id] != CSW_KNIFE shSwitchWeaponIDidgLastWeapon[id] )

    return 
PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public frozen(pToucherpTouched)
{

    new 
szClassName[32]
    new 
victim pTouched
    entity_get_string
(pToucherEV_SZ_classnameszClassName31)

    if(
equal(szClassName"ice_blast") )
    {
        new 
freezeradius get_cvar_num("subzero_freezeradius")
        new 
freezedamage get_cvar_num("subzero_freezedamage")

        new 
Float:fl_vExplodeAt[3]
        
entity_get_vector(pToucherEV_VEC_originfl_vExplodeAt)
        new 
vExplodeAt[3]
        
vExplodeAt[0] = floatround(fl_vExplodeAt[0])
        
vExplodeAt[1] = floatround(fl_vExplodeAt[1])
        
vExplodeAt[2] = floatround(fl_vExplodeAt[2])
        new 
id entity_get_edict(pToucherEV_ENT_owner)
        new 
origin[3],dist,i,Float:dRatio,damage

        
for ( 1<= SH_MAXSLOTSi++)
        {

            if( !
is_user_alive(i) ) continue
            
get_user_origin(i,origin)
            
dist get_distance(origin,vExplodeAt)
            if (
dist <= freezeradius) {

                
dRatio floatdiv(float(dist),float(freezeradius))
                
damage freezedamage floatroundfreezedamage dRatio)

                
shExtraDamage(iiddamage"Ice Blast" )
                
shStun(iget_cvar_num("subzero_freezetime"))
                
set_user_maxspeed(i0.1)
                
set_hudmessage(50100255, -1.00.4020.024.00.010.17)
                
show_hudmessage(i"You Got Frozen")
                
emit_sound(iCHAN_WEAPON"shmod/freezed.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                
freezed(victim)
            }
        }

        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte21 )
        
write_coord(vExplodeAt[0])
        
write_coord(vExplodeAt[1])
        
write_coord(vExplodeAt[2])
        
write_coord(vExplodeAt[0])
        
write_coord(vExplodeAt[1])
        
write_coord(vExplodeAt[2] + freezeradius )
        
write_shortblastring )
        
write_byte// startframe
        
write_byte// framerate
        
write_byte// 3 life 2
        
write_byte// width 16
        
write_byte// noise
        
write_byte50 // r
        
write_byte50 // g
        
write_byte255 // b
        
write_byte200 //brightness
        
write_byte// speed
        
message_end()

        
remove_entity(pToucher)
    }
}
//----------------------------------------------------------------------------------------------
public freezed(victim)
{
    new 
Float:vOrigin[3]
    
entity_get_vector(victimEV_VEC_originvOrigin)
    
vOrigin[2] -= 25
    
    
new frozenground create_entity("info_target")
    
entity_set_string(frozengroundEV_SZ_classname"freezed")
    
entity_set_model(frozenground"models/shmod/freezed.mdl")
    
entity_set_size(frozengroundFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5})
    
entity_set_int(frozengroundEV_INT_solid0)
    
entity_set_int(frozenground,EV_INT_movetypeMOVETYPE_NOCLIP)
    
entity_set_vector(frozengroundEV_VEC_originvOrigin)
}
//----------------------------------------------------------------------------------------------
public make_iceblast(id)
{
    new 
Float:Origin[3]
    new 
Float:Velocity[3]
    new 
Float:vAngle[3]

    new 
BlastSpeed get_cvar_num("subzero_blastspeed")

    
entity_get_vector(idEV_VEC_origin Origin)
    
entity_get_vector(idEV_VEC_v_anglevAngle)

    new 
NewEnt create_entity("info_target")

    
entity_set_string(NewEntEV_SZ_classname"ice_blast")

    
entity_set_model(NewEnt"sprites/shmod/iceball.spr")

    
entity_set_size(NewEntFloat:{-1.5, -1.5, -1.5}, Float:{1.51.51.5})

    
entity_set_origin(NewEntOrigin)
    
entity_set_vector(NewEntEV_VEC_anglesvAngle)
    
entity_set_int(NewEntEV_INT_solid2)

    
//thanx to vittu for this part.
    
entity_set_int(NewEntEV_INT_rendermode5)
    
entity_set_float(NewEntEV_FL_renderamt200.0)
    
entity_set_float(NewEntEV_FL_scale1.00)

    
entity_set_int(NewEntEV_INT_movetype5)
    
entity_set_edict(NewEntEV_ENT_ownerid)

    
velocity_by_aim(idBlastSpeed Velocity)
    
entity_set_vector(NewEntEV_VEC_velocity ,Velocity)

    return 
PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public new_spawn(id)
{
    
gPlayerUltimateUsed[id]=false
    RemoveByClass
(id)

    return 
PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public RemoveByClass(id)
{
    new 
frozenground 0
    
do {
        
frozenground find_ent_by_class(frozenground"freezed")
        if (
frozenground 0)
            
remove_entity(frozenground)
    }
    while (
frozenground)
}
//---------------------------------------------------------------------------------------------- 
Arje is offline
heliumdream
Senior Member
Join Date: Aug 2006
Old 02-17-2022 , 07:34   Re: Help with touch teammates
Reply With Quote #2

you should be able to achieve this fairly easily.

inside the public frozen routine, inside the for loop that checks each player...
after you check if a given player is hit (if (dist <= freezeradius)...)

you would check if the owner of the entity (id) and the current user being checked by the for loop (i) are on the same team; and if they are just use continue, the code will stop there and the teammate will be unaffected by subzero.

im not sure off the top of my head what the statement looks like to check if players are on the same team...but certainly this is addressed many times over in code solutions in other heroes, just look up another hero and reference how to do it. i could grab it for you, but itd be better for you to learn yourself!
__________________
heliumdream is offline
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 02-24-2022 , 12:38   Re: Help with touch teammates
Reply With Quote #3

If at the time I managed to fix it, I forgot to update this, but if many conditions and/or effects are already there, other heroes are just a matter of knowing them

This was the solution at the time, although I should review it, I think there are better ways to do it:
PHP Code:
public frozen(pToucherpTouched)
{
    new 
szClassName[32]
    new 
victim pTouched
    entity_get_string
(pToucherEV_SZ_classnameszClassName31)

    if(
equal(szClassName"ice_blast") )
    {
        new 
freezeradius get_pcvar_num(gPcvarRadius)
        new 
freezedamage get_pcvar_num(gPcvarDamage)

        new 
Float:fl_vExplodeAt[3]
        
entity_get_vector(pToucherEV_VEC_originfl_vExplodeAt)
        new 
vExplodeAt[3]
        
vExplodeAt[0] = floatround(fl_vExplodeAt[0])
        
vExplodeAt[1] = floatround(fl_vExplodeAt[1])
        
vExplodeAt[2] = floatround(fl_vExplodeAt[2])
        new 
id entity_get_edict(pToucherEV_ENT_owner)
        
        new 
origin[3], Float:dRatiodistdamage
        
new players[SH_MAXSLOTS], pnumvic
        get_players
(playerspnum"a")
        for (new 
0pnumi++) {
            
vic players[i]
            if (!
is_user_alive(vic)) continue
            if (
get_user_team(id) == get_user_team(vic) && !get_cvar_num("mp_friendlyfire") && id != vic ) continue
            
            
get_user_origin(vic,origin)
            
dist get_distance(origin,vExplodeAt)
            if (
dist <= freezeradius)
                {     
                
dRatio floatdiv(float(dist),float(freezeradius))
                
damage freezedamage floatroundfreezedamage dRatio)
                
// aca iba una i en lugar del vic (i=vic
                
shExtraDamage(viciddamage"Ice Blast" )
                
shStun(vicget_pcvar_num(gPcvarFreezeTime))
                
set_user_maxspeed(vic0.1)
                
set_hudmessage(50100255, -1.00.4020.024.00.010.12)
                
show_hudmessage(vic"Te congelo Sub-Zero.")
                
emit_sound(vicCHAN_WEAPON"shmod/freezed.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                
freezed(victim)
                }
            }
            
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte21 )
        
write_coord(vExplodeAt[0])
        
write_coord(vExplodeAt[1])
        
write_coord(vExplodeAt[2])
        
write_coord(vExplodeAt[0])
        
write_coord(vExplodeAt[1])
        
write_coord(vExplodeAt[2] + freezeradius )
        
write_shortblastring )
        
write_byte// startframe
        
write_byte// framerate
        
write_byte// 3 life 2
        
write_byte// width 16
        
write_byte// noise
        
write_byte50 // r
        
write_byte50 // g
        
write_byte255 // b
        
write_byte200 //brightness
        
write_byte// speed
        
message_end()

        
remove_entity(pToucher)
    }

Arje is offline
heliumdream
Senior Member
Join Date: Aug 2006
Old 02-26-2022 , 11:09   Re: Help with touch teammates
Reply With Quote #4

Glad to see you making progress! Good stuff!
__________________
heliumdream 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 03:14.


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