1 (edited by KillaBilla 2009-08-04 13:42:27)

Topic: [HELP] Some code questions for the Stay on the Flag mod

Hi everyone,

I'm making two mods called "Stay on the Flag" (short SotF) and "Get the Flag" (short GTF) and I don't know some code, so here my questions:

1. What is the code to wait a small time like 0.5,1,2,3 sec before going on in the code.

2.*  What is the Code to let a player selected by client id respawn, this one is not working:
                                                                                                        - game.players[client_id]->respawn();

3.* I want to make an instagib version of the mods, but what is the code to delete the entitys like
     health,  armor and weapons? My character is starting with only Laser and infinite ammo but
     if he picks up an laser he has only 10 shots left. And I need the the code for the laser that kills
     with one shot, without the damage-stars. 

* = DONE

I hope you can help me wink

2

Re: [HELP] Some code questions for the Stay on the Flag mod

@question1: get the current ticks-value (~time) and save them. in every tick you can now compare this saved tick-value + time_to_wait with the current tick-value. time_to_wait is the "tick-length" * seconds. I don't have the time to look it up in the code, but I guess you got the idea. Btw: This is heavily used in the teeworlds-code, too.

@question3: just have a look at the instagib-patch. first you need to prevent entities to appear, second you need to assign and allow only laser, third you need to make sure it's infinite ammo and last but not least you need to adjust the code for the damage (set to full-damage or die).

"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." - Terry Pratchett -

3

Re: [HELP] Some code questions for the Stay on the Flag mod

1. I understand what you mean, but I don't understandt how to write it in code. Please give me example code.

2. Noone is knowing this?

3. Thx I now know how to make it instagib.

4

Re: [HELP] Some code questions for the Stay on the Flag mod

#1
When the timer should start do:

XXX_tick = server_tick() + server_tickspeed() * seconds;

Then, in the tick() method of the class which should execute your code put

if(server_tick() > XXX_tick)
{
bla
}

I suggest to have XXX_tick = -1; as a default value and add XXX_tick != -1 to the if statement. wink

#2
use
try_respawn()
Though i don't know if the character needs to be dead for this to work.

Hope i helped you wink
-Tom

~{MonkeyStyle}~ - Instagib Teeworlds Clan
VISIT US: http://monkeystyle.xooit.com/
Check out our IRC channel: #monkeystyle on QuakeNet || Also check out the TeeWiki: http://teewiki.info

5 (edited by fazt-squirrel 2009-08-05 07:58:09)

Re: [HELP] Some code questions for the Stay on the Flag mod

#3 Go to src/game/server/gamecontroller.cpp and find:

    if(index == ENTITY_SPAWN)
        spawn_points[0][num_spawn_points[0]++] = pos;
    else if(index == ENTITY_SPAWN_RED)
        spawn_points[1][num_spawn_points[1]++] = pos;
    else if(index == ENTITY_SPAWN_BLUE)
        spawn_points[2][num_spawn_points[2]++] = pos;
    else if(index == ENTITY_ARMOR_1)
        type = POWERUP_ARMOR;
    else if(index == ENTITY_HEALTH_1)
        type = POWERUP_HEALTH;
    else if(index == ENTITY_WEAPON_SHOTGUN)
    {
        type = POWERUP_WEAPON;
        subtype = WEAPON_SHOTGUN;
    }
    else if(index == ENTITY_WEAPON_GRENADE)
    {
        type = POWERUP_WEAPON;
        subtype = WEAPON_GRENADE;
    }
    else if(index == ENTITY_WEAPON_RIFLE)
    {
        type = POWERUP_WEAPON;
        subtype = WEAPON_RIFLE;
    }
    else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
    {
        type = POWERUP_NINJA;
        subtype = WEAPON_NINJA;
    }

and delete what you dont want, Example only spawnpoints and health,armor:

    if(index == ENTITY_SPAWN)
        spawn_points[0][num_spawn_points[0]++] = pos;
    else if(index == ENTITY_SPAWN_RED)
        spawn_points[1][num_spawn_points[1]++] = pos;
    else if(index == ENTITY_SPAWN_BLUE)
        spawn_points[2][num_spawn_points[2]++] = pos;
    else if(index == ENTITY_ARMOR_1)
        type = POWERUP_ARMOR;
    else if(index == ENTITY_HEALTH_1)
        type = POWERUP_HEALTH;

6 (edited by LordSk 2009-08-05 08:17:48)

Re: [HELP] Some code questions for the Stay on the Flag mod

fazt-squirrel wrote:

#3 Go to src/game/server/gamecontroller.cpp and find:

    if(index == ENTITY_SPAWN)
        spawn_points[0][num_spawn_points[0]++] = pos;
    else if(index == ENTITY_SPAWN_RED)
        spawn_points[1][num_spawn_points[1]++] = pos;
    else if(index == ENTITY_SPAWN_BLUE)
        spawn_points[2][num_spawn_points[2]++] = pos;
    else if(index == ENTITY_ARMOR_1)
        type = POWERUP_ARMOR;
    else if(index == ENTITY_HEALTH_1)
        type = POWERUP_HEALTH;
    else if(index == ENTITY_WEAPON_SHOTGUN)
    {
        type = POWERUP_WEAPON;
        subtype = WEAPON_SHOTGUN;
    }
    else if(index == ENTITY_WEAPON_GRENADE)
    {
        type = POWERUP_WEAPON;
        subtype = WEAPON_GRENADE;
    }
    else if(index == ENTITY_WEAPON_RIFLE)
    {
        type = POWERUP_WEAPON;
        subtype = WEAPON_RIFLE;
    }
    else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
    {
        type = POWERUP_NINJA;
        subtype = WEAPON_NINJA;
    }

and delete what you dont want, Example only spawnpoints and health,armor:

    if(index == ENTITY_SPAWN)
        spawn_points[0][num_spawn_points[0]++] = pos;
    else if(index == ENTITY_SPAWN_RED)
        spawn_points[1][num_spawn_points[1]++] = pos;
    else if(index == ENTITY_SPAWN_BLUE)
        spawn_points[2][num_spawn_points[2]++] = pos;
    else if(index == ENTITY_ARMOR_1)
        type = POWERUP_ARMOR;
    else if(index == ENTITY_HEALTH_1)
        type = POWERUP_HEALTH;

That is like cut a paper with a chain saw.
As said Datag, have a look in the instagib patch, pickup.cpp file.

lordskelethom - want to reach me quickly? https://discord.gg/teeworlds

7

Re: [HELP] Some code questions for the Stay on the Flag mod

Thank you but to Question one:

Can you just give me the Hold the Flag source, In the topic of the Hold The flag Mod I download it, but the rar/zip file can't be anpacked, the archive is bad. sad You would help me very much if you give me the source auf the Hold the Flag Mod.