]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
Merge branch 'martin-t/angles' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_keyhunt.qc
index 5f3bd4b39597fff8371f165f8cfa2edecc77d92d..d32df0f59058cde75fa8e55f132914ecb210b539 100644 (file)
@@ -130,15 +130,15 @@ void kh_update_state()
                        f = key.team;
                else
                        f = 30;
-               s |= pow(32, key.count) * f;
+               s |= (32 ** key.count) * f;
        }
 
-       FOREACH_CLIENT(true, LAMBDA(it.kh_state = s));
+       FOREACH_CLIENT(true, { it.kh_state = s; });
 
        FOR_EACH_KH_KEY(key)
        {
                if(key.owner)
-                       key.owner.kh_state |= pow(32, key.count) * 31;
+                       key.owner.kh_state |= (32 ** key.count) * 31;
        }
        //print(ftos((nextent(NULL)).kh_state), "\n");
 }
@@ -248,7 +248,8 @@ void kh_Key_Attach(entity key)  // runs when a player picks up a key and several
        key.angles_y -= key.owner.angles.y;
 #endif
        key.flags = 0;
-       IL_REMOVE(g_items, key);
+       if(IL_CONTAINS(g_items, key))
+               IL_REMOVE(g_items, key);
        key.solid = SOLID_NOT;
        set_movetype(key, MOVETYPE_NONE);
        key.team = key.owner.team;
@@ -256,6 +257,7 @@ void kh_Key_Attach(entity key)  // runs when a player picks up a key and several
        key.damageforcescale = 0;
        key.takedamage = DAMAGE_NO;
        key.modelindex = kh_key_carried;
+       navigation_dynamicgoal_unset(key);
 }
 
 void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs several times times when all the keys are captured
@@ -287,7 +289,8 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs
        key.angles_y += key.owner.angles.y;
 #endif
        key.flags = FL_ITEM;
-       IL_PUSH(g_items, key);
+       if(!IL_CONTAINS(g_items, key))
+               IL_PUSH(g_items, key);
        key.solid = SOLID_TRIGGER;
        set_movetype(key, MOVETYPE_TOSS);
        key.pain_finished = time + autocvar_g_balance_keyhunt_delay_return;
@@ -295,6 +298,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs
        key.takedamage = DAMAGE_YES;
        // let key.team stay
        key.modelindex = kh_key_dropped;
+       navigation_dynamicgoal_set(key);
        key.kh_previous_owner = key.owner;
        key.kh_previous_owner_playerid = key.owner.playerid;
 }
@@ -390,9 +394,9 @@ void kh_Key_AssignTo(entity key, entity player)  // runs every time a key is pic
                        {
                                if (!k.owner) continue;
                                entity first = WP_Null;
-                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, { first = it; break; });
                                entity third = WP_Null;
-                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, { third = it; break; });
                                WaypointSprite_UpdateSprites(k.owner.waypointsprite_attachedforcarrier, first, WP_KeyCarrierFinish, third);
                        }
                }
@@ -405,9 +409,9 @@ void kh_Key_AssignTo(entity key, entity player)  // runs every time a key is pic
                        {
                                if (!k.owner) continue;
                                entity first = WP_Null;
-                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, LAMBDA(first = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model1, { first = it; break; });
                                entity third = WP_Null;
-                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, LAMBDA(third = it; break));
+                               FOREACH(Waypoints, it.netname == k.owner.waypointsprite_attachedforcarrier.model3, { third = it; break; });
                                WaypointSprite_UpdateSprites(k.owner.waypointsprite_attachedforcarrier, first, WP_KeyCarrierFriend, third);
                        }
                }
@@ -597,7 +601,7 @@ void kh_LoserTeam(int loser_team, entity lostkey)  // runs when a player pushes
                int players = 0;
                float of = autocvar_g_balance_keyhunt_score_destroyed_ownfactor;
 
-               FOREACH_CLIENT(IS_PLAYER(it) && it.team != loser_team, LAMBDA(++players));
+               FOREACH_CLIENT(IS_PLAYER(it) && it.team != loser_team, { ++players; });
 
                entity key;
                int keys = 0;
@@ -632,16 +636,16 @@ void kh_LoserTeam(int loser_team, entity lostkey)  // runs when a player pushes
                                continue;
 
                        players = 0;
-                       FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, LAMBDA(++players));
+                       FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, { ++players; });
 
                        DistributeEvenly_Init(fragsleft, j);
                        fragsleft = DistributeEvenly_Get(j - 1);
                        DistributeEvenly_Init(DistributeEvenly_Get(1), players);
 
-                       FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, LAMBDA(
+                       FOREACH_CLIENT(IS_PLAYER(it) && it.team == thisteam, {
                                f = DistributeEvenly_Get(1);
                                kh_Scores_Event(it, NULL, "destroyed", f, 0);
-                       ));
+                       });
 
                        --j;
                }
@@ -699,7 +703,7 @@ LABEL(not_winning)
        if(kh_interferemsg_time && time > kh_interferemsg_time)
        {
                kh_interferemsg_time = 0;
-               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it), {
                        if(it.team == kh_interferemsg_team)
                                if(it.kh_next)
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_KEYHUNT_MEET);
@@ -707,7 +711,7 @@ LABEL(not_winning)
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_KEYHUNT_HELP);
                        else
                                Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(kh_interferemsg_team, CENTER_KEYHUNT_INTERFERE));
-               ));
+               });
        }
 
        this.nextthink = time + 0.05;
@@ -742,6 +746,7 @@ void kh_Key_Spawn(entity initial_owner, float _angle, float i)  // runs every ti
        setsize(key, KH_KEY_MIN, KH_KEY_MAX);
        key.colormod = Team_ColorRGB(initial_owner.team) * KH_KEY_BRIGHTNESS;
        key.reset = key_reset;
+       navigation_dynamicgoal_init(key, false);
 
        switch(initial_owner.team)
        {
@@ -853,12 +858,12 @@ int kh_GetMissingTeams()
        {
                int teem = kh_Team_ByID(i);
                int players = 0;
-               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it), {
                        if(!IS_DEAD(it) && !PHYS_INPUT_BUTTON_CHAT(it) && it.team == teem)
                                ++players;
-               ));
+               });
                if (!players)
-                       missing_teams |= pow(2, i);
+                       missing_teams |= (2 ** i);
        }
        return missing_teams;
 }
@@ -934,14 +939,14 @@ void kh_StartRound()  // runs at the start of each round
                int teem = kh_Team_ByID(i);
                int players = 0;
                entity my_player = NULL;
-               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+               FOREACH_CLIENT(IS_PLAYER(it), {
                        if(!IS_DEAD(it) && !PHYS_INPUT_BUTTON_CHAT(it) && it.team == teem)
                        {
                                ++players;
                                if(random() * players <= 1)
                                        my_player = it;
                        }
-               ));
+               });
                kh_Key_Spawn(my_player, 360 * i / NumTeams(kh_teams), i);
        }