AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Proper explosion dammage (https://forums.alliedmods.net/showthread.php?t=162665)

urban_ninja 07-21-2011 12:48

Proper explosion dammage
 
Hey, I need help making explosion damage. Not just some generic damage method found through out these forums. I'm trying to make a serious game play plugin for team fortress classic that adds new unique class weapons. Could someone give me an example of how to make explosion damage that wont count as a suicide death and wont hurt teammates?

[Edit]Need some help here. Why is everyone ignoring this post. I see everyone elses posts in this help forum today are getting answered as I type this so why is this one getting skipped?

Aykay 07-22-2011 04:03

Re: Proper explosion dammage
 
This is a fake bomb code, maybe you can see how it's done?

PHP Code:

#include <hamsandwich>
#include <engine>
#include <cstrike>


public PlantFakeC4(id)
{
    if (!
has_fakec4_player[id])
    {
        
client_print(idprint_center"You only get 1 Fake Bomb!");
        return 
PLUGIN_CONTINUE;
    }
    
has_fakec4_player[id]--;
    
    new 
Float:origin[3];
    
entity_get_vector(idEV_VEC_originorigin);
        
    new 
ent create_entity("info_target");
    
entity_set_string(ent ,EV_SZ_classname"FakeC4");
    
entity_set_edict(ent ,EV_ENT_ownerid);
    
entity_set_int(entEV_INT_movetypeMOVETYPE_TOSS);
    
entity_set_origin(entorigin);
    
entity_set_int(entEV_INT_solidSOLID_BBOX);
    
entity_set_model(ent"models/w_backpack.mdl");
    
entity_set_size(ent,Float:{-16.0,-16.0,0.0},Float:{16.0,16.0,2.0});
    
    
drop_to_floor(ent);

    
entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01) ;
    
    
set_rendering(ent,kRenderFxNone0,0,0kRenderTransTexture,255);
    
    return 
PLUGIN_CONTINUE;
}

public 
ExplodeFakeC4(entid)
{
    new 
attacker entity_get_edict(entEV_ENT_owner);
    if (
get_user_team(attacker) != get_user_team(id)) // this is the line you're looking for - it wont hurt himself or teammates.
    
{
        new 
Float:fOrigin[3], iOrigin[3];
        
entity_get_vectorentEV_VEC_originfOrigin);
        
iOrigin[0] = floatround(fOrigin[0]);
        
iOrigin[1] = floatround(fOrigin[1]);
        
iOrigin[2] = floatround(fOrigin[2]);
        
        
message_begin(MSG_BROADCAST,SVC_TEMPENTITYiOrigin);
        
write_byte(TE_EXPLOSION);
        
write_coord(iOrigin[0]);
        
write_coord(iOrigin[1]);
        
write_coord(iOrigin[2]);
        
write_short(sprite_blast);
        
write_byte(32); // scale
        
write_byte(20); // framerate
        
write_byte(0);// flags
        
message_end();
        new 
entlist[33];
        new 
numfound find_sphere_class(ent,"player"400.0 ,entlist32);
        
        for (new 
i=0numfoundi++)
        {        
            new 
pid entlist[i];
            
            if (!
is_user_alive(pid) || get_user_team(attacker) == get_user_team(pid))
                continue;
            
            
ExecuteHam(Ham_TakeDamagepidentattacker350.01);
        }
        
remove_entity(ent);
    }



drekes 07-22-2011 06:39

Re: Proper explosion dammage
 
Not sure if it's gonna count as suicide or team kill but you can easily test it.
http://forums.alliedmods.net/showthread.php?t=142412

urban_ninja 07-23-2011 20:44

Re: Proper explosion dammage
 
PHP Code:

#include <cstrike> 

I appreciate you guys trying to help but how is counter strike functions going to be valid in team fortress classic as they are 2 totally different game mods?

drekes 07-23-2011 22:14

Re: Proper explosion dammage
 
Cstrike isn't required in the code above.
You can safely remove it.

urban_ninja 07-23-2011 22:57

Re: Proper explosion dammage
 
Ok I'm getting compiler errors with that code.
Quote:

undefined symbol "has_fakec4_player"
So I added
PHP Code:

new has_fakec4_player 

Even more compiler errors follow:
Quote:

invalid subscript<not an array or too many subscripts>"has_fakec4_player"
expected token ";" but found "]"
fatal error too many errors on one line
invalid expression assumed as zero
All errors had to do with
PHP Code:

if (!has_fakec4_player[id]) 


Aykay 07-23-2011 23:52

Re: Proper explosion dammage
 
Quote:

Originally Posted by urban_ninja (Post 1517112)
Ok I'm getting compiler errors with that code.
So I added
PHP Code:

new has_fakec4_player 

Even more compiler errors follow:
All errors had to do with
PHP Code:

if (!has_fakec4_player[id]) 


It's definitely an array, but it might be a bool.

Try
PHP Code:

new bool:has_fakec4_player[32];

;OR

new 
has_fakec4_player[32]; 

I can't find the code, so can't confirm. :)

wrecked_ 07-24-2011 01:04

Re: Proper explosion dammage
 
The plugin above is not entirely what you're looking for. It provides an example for the explosion itself and the damage it deals, however it is also managing the concept of having a fake bomb. The code you're having problems with is not needed in your case because it is related to that concept.

The only thing you should be taking from that is code within ExplodeFakeC4(). The planting function has little to no involvement with your new weapons idea.

urban_ninja 07-24-2011 01:27

Re: Proper explosion dammage
 
Ok that fix that error and a few others but now theres yet an other compiler error saying this is an empty statement.
PHP Code:

if (!has_fakec4_player[id]); 

And its alos giving a "warning <unreachable code>" for this
PHP Code:

has_fakec4_player[id]--; 


wrecked_ 07-24-2011 01:28

Re: Proper explosion dammage
 
You don't need either of those lines.

Like I said, you only need the code snippets used within ExplodeFakeC4().


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

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