1 (edited by Mario74 2009-11-18 18:34:47)

Topic: [SOLVED] I need help at the shotspread for doublegun...

Hi, i need some help ;D
Here is my actual Gun spread:

{
                int shotspread = config.sv_gun_num;

                        float spreading;

                        msg_pack_start(NETMSGTYPE_SV_EXTRAPROJECTILE, 0);
                        //msg_pack_int(shotspread*2+1);
                        msg_pack_int(shotspread);
            
                        for(float i = -shotspread; i <= shotspread; i++)
                        {
                        spreading = (float)i * 0.1;
                        float a = get_angle(direction);
                        a += spreading;
                        float v = 1-(abs(i)/(float)shotspread);
                        float speed = mix((float)tuning.gun_speeddiff, 1.0f, v);
                        PROJECTILE *proj = new PROJECTILE(WEAPON_GUN,
                            player->client_id,
                            projectile_startpos,
                            vec2(cosf(a), sinf(a))*speed,
                            (int)(server_tickspeed()*tuning.shotgun_lifetime),
                            1, PROJECTILE::PROJECTILE_FLAGS_EXPLODE, 0, -1, WEAPON_GUN);
                        // pack the projectile and send it to the client directly
                        NETOBJ_PROJECTILE p;
                        proj->fill_info(&p);
                
                        for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
                        msg_pack_int(((int *)&p)[i]);
                        game.create_sound(pos, SOUND_GUN_FIRE);
                        }
            }
            
        } break;

but with this is have 3 bullets not just double gun.... plz help me

Thanks for reading big_smile
I just want double gun... the gun speediff is unles and the num of projektiles also....
and do u have a idea how i can make more damage for it? because a admin has got this gun and a normal player a normal gun... the normal player deals 1 dmg.... i want that the admin deals 6 dmg = 3 dmg * 2 (double gun)

thanks big_smile

2

Re: [SOLVED] I need help at the shotspread for doublegun...

looks like shotgun?! ö.Ö

        case WEAPON_GUN:
        {

                                int    gun_split = config.sv_gun_projectiles;
                                int    gun_damage = config.sv_gun_damage;

                if(gun_split == 1)
                {
                        PROJECTILE *proj = new PROJECTILE(WEAPON_GUN,
                            player->client_id,
                            projectile_startpos + direction,
                            direction,
                            (int)(server_tickspeed()*tuning.gun_lifetime),
                                gun_damage, 0, 0, -1, WEAPON_GUN);    
    
                        // pack the projectile and send it to the client directly
                        NETOBJ_PROJECTILE p;
                        proj->fill_info(&p);
                        
                        msg_pack_start(NETMSGTYPE_SV_EXTRAPROJECTILE, 0);
                        msg_pack_int(1);
                        for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
                            msg_pack_int(((int *)&p)[i]);
                        msg_pack_end();
                        server_send_msg(player->client_id);
                }
                else
                {
                    for(float i = -0.5f * gun_split; i < 0.5f * gun_split; i++)
                    {
                        float a = get_angle(direction);
                        a += i * 0.1f*config.sv_gun_angle*0.001;

                        vec2 ndir(direction.x + 0.5f * i, direction.y + 0.5f * i);

                        

                            PROJECTILE *proj = new PROJECTILE(WEAPON_GUN,
                                player->client_id,
                                projectile_startpos + direction,
                                vec2(cosf(a), sinf(a)),
                                (int)(server_tickspeed()*tuning.gun_lifetime),
                                gun_damage, 0, 0, -1, WEAPON_GUN);
                        
                            // pack the projectile and send it to the client directly
                            NETOBJ_PROJECTILE p;
                            proj->fill_info(&p);
                    
                            msg_pack_start(NETMSGTYPE_SV_EXTRAPROJECTILE, 0);
                            msg_pack_int(1);
                            for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
                                msg_pack_int(((int *)&p)[i]);
                            msg_pack_end();
                            server_send_msg(player->client_id);

                        game.create_sound(pos, SOUND_GUN_FIRE);
                    }
                }
        }
                break;

now you can change the damage for special reasons like:
if(player->is_authed())
gun_damage = ....
etc

3

Re: [SOLVED] I need help at the shotspread for doublegun...

oh i thank u sow much ;D

4

Re: [SOLVED] I need help at the shotspread for doublegun...

Sorry for double post;D
at least there are 2 things what i dont no and where i need your help...
i want to have invisibility and colors (like the coloring effect in tcatch if u are alone in the server) both are if the player is authed as 2 (admin)and says /color//invisibility for these effects...  if he/she says it again it is now no more...
i hope u now what i am meaning...
here something code like you say something in the chat for it:

else if(str_comp_nocase(msg->message, "/invisible")==0 && (game.players[client_id]->authed=2))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        for(int i=1;i<5;i++)
                        {
                            chr->INVISIBILITY.got = 1;
                        }
                        chr->race_state = RACE_NONE;
                    }
                }
                else if (str_comp_nocase(msg->message, "/invisible")==0 && (game.players[client_id]->authed=2) && (game.players[client_id]->INVISIBILITY.got))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        for(int i=1;i<5;i++)
                        {
                            chr->INVISIBILITY.got = 0;
                        }
                        chr->race_state = RACE_NONE;
                    }
                }

the problem is, that my code wont work, but i had named it in the character header and i had written it under characte cpp so:
if (player->INVISIBILITY.got)
return;


hope u can help me

5

Re: [SOLVED] I need help at the shotspread for doublegun...

add to the first one case that it isnt used if he has invisibility.
and i think it would look better if you write it like this
if (msg->"invisibility")
{
   if(has_invisibilty)
   ...
   else if(!has_invisibility)
   ...
}


also i cant understand why this one?!:

                        for(int i=1;i<5;i++)
                        {
                            chr->INVISIBILITY.got = 1;
                        }

maybe you should give us a snippet with the invisibilty-effect, as their can be a misstake either.
i had the problem at first with the "is_authed(x)", maybe you should check if your one is working,too^^

6 (edited by Mario74 2009-11-21 07:34:38)

Re: [SOLVED] I need help at the shotspread for doublegun...

sorry i dont understand u O.o

your problem with outhed is about the mod ;D if its ddrace there is no problem with authed, but i u have an other mod it wont be work, because the file "es_server" hasn´t got the lvls  of admins, moderator, helper big_smile

no i don´t know what u are meaning ;D ok....

for(int i=1;i<5;i++)
                        {
                            chr->INVISIBILITY.got = 1;
                        }

hm i don´t know y it wont work... i have taken this one as character which u can get and my thirst idea where that i take a code like this in the charakter cpp under snapping.....
but i is exactly wrong ;D
it is not importend which code for invisibility....
i only want if the player writes /invisibility that he has got it if he is authed as admin (lvl2) if not theres only a messag from de server:
*** No command!
i think my code for "invisibility" is bad ;D
i took this from teemo, if u kill 6 peoples there u get the invi scharcter and snapping is false....
if you have an other code for invisibility, plz write it, u help me alot big_smile
and if he writes it against it is gone.....
hm i know i am a noob proggrammer but i thank you for help big_smile


if it can help you, here are the say (/command) commands:

void mods_message(int msgtype, int client_id)
{
    void *rawmsg = netmsg_secure_unpack(msgtype);
    PLAYER *p = game.players[client_id];
    
    if(!rawmsg)
    {
        dbg_msg("server", "dropped weird message '%s' (%d), failed on '%s'", netmsg_get_name(msgtype), msgtype, netmsg_failed_on());
        return;
    }
    
    if(msgtype == NETMSGTYPE_CL_SAY)
    {
        NETMSG_CL_SAY *msg = (NETMSG_CL_SAY *)rawmsg;
        int team = msg->team;
        if(team)
            team = p->team;
        else
            team = GAMECONTEXT::CHAT_ALL;
        
        if(config.sv_spamprotection && p->last_chat+time_freq() > time_get())
            game.players[client_id]->last_chat = time_get();
        else if(p->muted>0)
            game.send_chat_target(client_id, "You are muted yet...");
        else
         {
            if(msg->message[0] == '/')
            {
                if(!str_comp_nocase(msg->message, "/info"))
                {
                    game.send_chat_target(client_id, "Round-Race mod 0.1.4 by Hardbass247[!]");
                    game.send_chat_target(client_id, "Great thanks to Blackside, he has done important things for this mod...");
                    if (strcmp(config.sv_ticket_file,""))
                        game.send_chat_target(client_id, "Write /ticket <your message> to post a message for  Hardbass247[!]");
                        game.send_chat_target(client_id, "what is missing in the mod or could be make better and why...");
                }
                else if(!strncmp(msg->message, "/top5", 5) && game.controller->is_race())
                {
                    const char *pt=msg->message;
                    int number=0;
                    pt+=6;
                    while(*pt && *pt >= '0' && *pt <= '9')
                    {
                        number=number*10+(*pt-'0');
                        pt++;
                    }
                    if(number)
                        top5_draw(client_id,number);
                    else
                        top5_draw(client_id,0);
                }
                else if(!str_comp_nocase(msg->message, "/rank"))
                {
                    rank_draw(client_id);
                    game.players[client_id]->last_chat = time_get()+time_freq()*10;
                }
                else if(!strncmp(msg->message, "/ticket", 7))
                {
                    if (!str_comp_nocase(config.sv_ticket_file,""))
                        game.send_chat_target(client_id, "No command!");
                    else
                    {
                        char buf[512];
                        str_format(buf, sizeof(buf), "%s %s",server_clientname(client_id),msg->message);
                        write_ticket(buf);

                        game.send_chat_target(client_id, "Your ticket posted");
                        game.players[client_id]->last_chat = time_get()+time_freq()*10;
                    }
                }
                else if(str_comp_nocase(msg->message, "/weapons")==0 && (game.players[client_id]->authed>0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        for(int i=1;i<5;i++)
                        {
                            chr->weapons[i].got = 1;
                            chr->weapons[i].ammo = -1;
                        }
                        chr->race_state = RACE_CHEAT;
                    }
                    
                }
            /*    else if(str_comp_nocase(msg->message, "/invisible")==0 && (game.players[client_id]->authed=2))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        for(int i=1;i<5;i++)
                        {
                            chr->INVISIBILITY.got = 1;
                        }
                        chr->race_state = RACE_NONE;
                    }
                }
                else if (str_comp_nocase(msg->message, "/invisible")==0 && (game.players[client_id]->authed=2) && (game.players[client_id]->INVISIBILITY.got))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        for(int i=1;i<5;i++)
                        {
                            chr->INVISIBILITY.got = 0;
                        }
                        chr->race_state = RACE_NONE;
                    }
                } invisible wont work.... btw compiler crashs */
                else if(str_comp_nocase(msg->message, "/status")==0)
                {
                    char buf[512];
                    str_format(buf, sizeof(buf), "%s (%d), lvl=%d", server_clientname(client_id),client_id,game.players[client_id]->authed);
                    game.send_chat_target(client_id, buf);
                }
                else if(str_comp_nocase(msg->message, "/ninja")==0 && (game.players[client_id]->authed>0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        give_ninja(chr);
                        chr->race_state = RACE_CHEAT;
                    }
                    
                }
                else if(str_comp_nocase(msg->message, "/freeze")==0 && (game.players[client_id]->authed>0 || game.players[client_id]->authed<0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        chr->freeze(700);
                        //char buf[512];
                        //str_format(buf, sizeof(buf), "%s Froze himself", server_clientname(cid));
                        //game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
                    }
                }
                else if(str_comp_nocase(msg->message, "/unfreeze")==0 && (game.players[client_id]->authed>0 || game.players[client_id]->authed<0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        chr->unfreeze(false);
                        chr->race_state = RACE_NONE;
                        //char buf[512];
                        //str_format(buf, sizeof(buf), "%s Froze himself", server_clientname(cid));
                        //game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
                    }
                }
                else if(str_comp_nocase(msg->message, "/left")==0 && (game.players[client_id]->authed>0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        chr->core.pos.x-=32;
                        chr->race_state = RACE_NONE;
                    }
                }
                else if(str_comp_nocase(msg->message, "/right")==0 && (game.players[client_id]->authed>0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        chr->core.pos.x+=32;
                        chr->race_state = RACE_NONE;
                    }
                }
                else if(str_comp_nocase(msg->message, "/up")==0 && (game.players[client_id]->authed>0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        chr->core.pos.y-=32;
                        chr->race_state = RACE_NONE;
                    }
                }
                else if(str_comp_nocase(msg->message, "/down")==0 && (game.players[client_id]->authed>0))
                {
                    CHARACTER* chr = game.players[client_id]->get_character();
                    if(chr)
                    {
                        chr->core.pos.y+=32;
                        chr->race_state = RACE_NONE;
                    }
                }
                else
                    game.send_chat_target(client_id, "No command!");
            }
            else
            {
                game.players[client_id]->last_chat = time_get();
                game.send_chat(client_id, team, msg->message);
            }
        }
    } ......................................


hm i dont know why it wont work, i am looking in the german teeworlds forum, maybe i could find it...

7

Re: [SOLVED] I need help at the shotspread for doublegun...

LOL I'm just working with you at this, and I already finished it, and you know this. ^^
Invisiblity is working, Rainbow is working. ^^
And anotherthing, why should you be a cheater if you use one of this things, I read chr->race_state = RACE_NONE in your code.
And anothernother thing, I also finished This Ninja-Round with Infinite Ninja and Ninjaweaponchange.

8

Re: [SOLVED] I need help at the shotspread for doublegun...

lol ;D
yes your code works, but u didn´t give me the src and then you where offline  a few days... first i thougt you want do somethign on the mod anymore, but then, you where online again ;D
i don´t knew why you where offline ^^ if you look at the date of this topics, u can see, that it was in this time, where you are be offline ;D
now:
topic can be closed


ps. i thougt u won´t come online and so i have taken questions here, lol, but the important thing is that u are online again ;D

9

Re: [SOLVED] I need help at the shotspread for doublegun...

ok u can close this topic
~closed~

You can use the Report function whenever you are in need of someone of the moderator staff. // ~{MS}~ Azon