]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'TimePath/effectinfo' into 'master'
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 3 Oct 2015 08:10:08 +0000 (08:10 +0000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 3 Oct 2015 08:10:08 +0000 (08:10 +0000)
QC generated effectinfo.txt

Has the major benefit of being able to template effects for teams

Is foundation for an in-game effects editor

See merge request !228

16 files changed:
gfx/hud/default/checkmark.tga [new file with mode: 0644]
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/itemstime.qc
qcsrc/menu/anim/animation.qc
qcsrc/menu/item/slider.qc
qcsrc/menu/item/textslider.qc
qcsrc/menu/xonotic/radiobutton.qc
qcsrc/menu/xonotic/slider.qc
qcsrc/menu/xonotic/slider_decibels.qc
qcsrc/menu/xonotic/slider_particles.qc
qcsrc/menu/xonotic/slider_resolution.qc
qcsrc/menu/xonotic/slider_sbfadetime.qc
qcsrc/menu/xonotic/textslider.qc
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/cl_client.qc
qcsrc/server/g_damage.qc

diff --git a/gfx/hud/default/checkmark.tga b/gfx/hud/default/checkmark.tga
new file mode 100644 (file)
index 0000000..71cbd68
Binary files /dev/null and b/gfx/hud/default/checkmark.tga differ
index 0734d54d56943b7e71809c383eaf68e722c2b90e..64c26447495a77b571322e40b68d169bec4ca47a 100644 (file)
@@ -1045,7 +1045,7 @@ void Monster_Dead(entity attacker, float gibbed)
 
 void Monster_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {SELFPARAM();
-       if((self.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL)
+       if((self.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL && !ITEM_DAMAGE_NEEDKILL(deathtype))
                return;
 
        if(self.frozen && deathtype != DEATH_KILL && deathtype != DEATH_NADE_ICE_FREEZE)
index d7ca5a3351585f82148d90d6457d184ff13f3b8c..4d859b1fcab1438db82826be497093395af67a11 100644 (file)
@@ -232,10 +232,15 @@ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, entity item, float
         HUD_Panel_DrawProgressBar(p_pos, p_size, autocvar_hud_panel_itemstime_progressbar_name, t/autocvar_hud_panel_itemstime_progressbar_maxtime, 0, autocvar_hud_panel_itemstime_iconalign, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
     }
 
-    if (t > 0 && autocvar_hud_panel_itemstime_text)
-        drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
-    else
-        picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2;
+    if(autocvar_hud_panel_itemstime_text)
+    {
+        if(t > 0)
+            drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+        else if(precache_pic("gfx/hud/default/checkmark")) // COMPAT: check if this image exists, as 0.8.1 clients lack it
+            drawpic_aspect_skin(numpos, "checkmark", eX * (ar - 1) * mySize_y + eY * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL);
+        else // legacy code, if the image is missing just center the icon
+            picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2;
+    }
     if (item_availableTime)
         drawpic_aspect_skin_expanding(picpos, item.m_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL, item_availableTime);
     drawpic_aspect_skin(picpos, item.m_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL);
index d52ae4f719e07b5017216e0251a01a6749b5d9dd..5563b969d98bfb4751e29e661b2c97a6c5248c45 100644 (file)
@@ -4,6 +4,7 @@
 void setterDummy(entity, float);
 CLASS(Animation, Object)
        METHOD(Animation, configureAnimation, void(entity, entity, void(entity, float), float, float, float, float));
+       METHOD(Animation, update, void(entity, float, float, float));
        METHOD(Animation, setTimeStartEnd, void(entity, float, float));
        METHOD(Animation, setTimeStartDuration, void(entity, float, float));
        METHOD(Animation, setValueStartEnd, void(entity, float, float));
@@ -36,6 +37,12 @@ void Animation_configureAnimation(entity me, entity obj, void(entity, float) obj
        me.setValueStartEnd(me, animStartValue, animEndValue);
 }
 
+void Animation_update(entity me, float animDuration, float animStartValue, float animEndValue)
+{
+       me.setTimeStartDuration(me, time, animDuration);
+       me.setValueStartEnd(me, animStartValue, animEndValue);
+}
+
 void Animation_setTimeStartEnd(entity me, float s, float e)
 {
        me.startTime = s;
index 03ad736b861fbbd49be229d9347eb73740f46c29..3340e335cb9aebe22d7b305022a52074cd84f123 100644 (file)
@@ -15,6 +15,8 @@ CLASS(Slider, Label)
        METHOD(Slider, mouseRelease, float(entity, vector));
        METHOD(Slider, valueToText, string(entity, float));
        METHOD(Slider, toString, string(entity));
+       METHOD(Slider, setValue_allowAnim, void(entity, float, bool));
+       METHOD(Slider, setValue_noAnim, void(entity, float));
        METHOD(Slider, setValue, void(entity, float));
        METHOD(Slider, setSliderValue, void(entity, float));
        METHOD(Slider, showNotify, void(entity));
@@ -24,6 +26,7 @@ CLASS(Slider, Label)
        ATTRIB(Slider, value, float, 0)
        ATTRIB(Slider, animated, float, 1)
        ATTRIB(Slider, sliderValue, float, 0)
+       ATTRIB(Slider, sliderAnim, entity, world)
        ATTRIB(Slider, valueMin, float, 0)
        ATTRIB(Slider, valueMax, float, 0)
        ATTRIB(Slider, valueStep, float, 0)
@@ -48,16 +51,27 @@ ENDCLASS(Slider)
 #endif
 
 #ifdef IMPLEMENTATION
-void Slider_setValue(entity me, float val)
+void Slider_setValue_allowAnim(entity me, float val, bool allowAnim)
 {
-       if (me.animated) {
-               anim.removeObjAnim(anim, me);
-               makeHostedEasing(me, Slider_setSliderValue, easingQuadInOut, 1, me.sliderValue, val);
+       if(allowAnim && me.animated) {
+               float t = 0.5;
+               if(!me.sliderAnim)
+                       me.sliderAnim = makeHostedEasing(me, Slider_setSliderValue, easingQuadOut, t, me.sliderValue, val);
+               else
+                       me.sliderAnim.update(me.sliderAnim, t, me.sliderValue, val);
        } else {
                me.setSliderValue(me, val);
        }
        me.value = val;
 }
+void Slider_setValue_noAnim(entity me, float val)
+{
+       Slider_setValue_allowAnim(me, val, false);
+}
+void Slider_setValue(entity me, float val)
+{
+       Slider_setValue_allowAnim(me, val, true);
+}
 void Slider_setSliderValue(entity me, float val)
 {
        me.sliderValue = val;
@@ -177,14 +191,10 @@ float Slider_keyUp(entity me, float key, float ascii, float shift)
 float Slider_mouseDrag(entity me, vector pos)
 {
        float hit;
-       float v, animed;
+       float v;
        if(me.disabled)
                return 0;
 
-       anim.removeObjAnim(anim, me);
-       animed = me.animated;
-       me.animated = false;
-
        if(me.pressed)
        {
                hit = 1;
@@ -194,17 +204,18 @@ float Slider_mouseDrag(entity me, vector pos)
                if(pos.y >= 1 + me.tolerance.y) hit = 0;
                if(hit)
                {
+                       // handle dragging
+                       me.pressed = 2;
+
                        v = median(0, (pos.x - me.pressOffset - 0.5 * me.controlWidth) / (1 - me.textSpace - me.controlWidth), 1) * (me.valueMax - me.valueMin) + me.valueMin;
                        if(me.valueStep)
                                v = floor(0.5 + v / me.valueStep) * me.valueStep;
-                       me.setValue(me, v);
+                       me.setValue_noAnim(me, v);
                }
                else
                        me.setValue(me, me.previousValue);
        }
 
-       me.animated = animed;
-
        return 1;
 }
 float Slider_mousePress(entity me, vector pos)
@@ -295,6 +306,14 @@ void Slider_draw(entity me)
                else
                        draw_Picture(eX * controlLeft, strcat(me.src, "_n"), eX * me.controlWidth + eY, me.color, 1);
        }
+
+       if(me.sliderAnim)
+       if(me.sliderAnim.isFinished(me.sliderAnim))
+       {
+               anim.removeObjAnim(anim, me);
+               me.sliderAnim = world;
+       }
+
        me.setText(me, me.valueToText(me, me.value));
        draw_alpha = save;
        SUPER(Slider).draw(me);
index 733b1d61255e155490021d7e12f6b53c61940acd..30b80c196d96884117def79c2c55496e65f34598 100644 (file)
@@ -6,6 +6,8 @@
 CLASS(TextSlider, Slider)
        METHOD(TextSlider, valueToText, string(entity, float));
        METHOD(TextSlider, valueToIdentifier, string(entity, float));
+       METHOD(TextSlider, setValueFromIdentifier_allowAnim, void(entity, string, bool));
+       METHOD(TextSlider, setValueFromIdentifier_noAnim, void(entity, string));
        METHOD(TextSlider, setValueFromIdentifier, void(entity, string));
        METHOD(TextSlider, getIdentifier, string(entity));
        METHOD(TextSlider, clearValues, void(entity));
@@ -35,16 +37,24 @@ string TextSlider_valueToText(entity me, int val)
                return _("Custom");
        return me.(valueStrings[val]);
 }
-void TextSlider_setValueFromIdentifier(entity me, string id)
+void TextSlider_setValueFromIdentifier_allowAnim(entity me, string id, bool allowAnim)
 {
        int i;
        for(i = 0; i < me.nValues; ++i)
                if(me.valueToIdentifier(me, i) == id)
                {
-                       SUPER(TextSlider).setValue( me, i );
+                       SUPER(TextSlider).setValue_allowAnim(me, i, allowAnim);
                        return;
                }
-       SUPER(TextSlider).setValue( me, -1 );
+       SUPER(TextSlider).setValue_allowAnim(me, -1, allowAnim);
+}
+void TextSlider_setValueFromIdentifier_noAnim(entity me, string id)
+{
+       TextSlider_setValueFromIdentifier_allowAnim(me, id, false);
+}
+void TextSlider_setValueFromIdentifier(entity me, string id)
+{
+       TextSlider_setValueFromIdentifier_allowAnim(me, id, true);
 }
 string TextSlider_getIdentifier(entity me)
 {
@@ -75,6 +85,6 @@ void TextSlider_insertValue(entity me, int pos, string theString, string theIden
 void TextSlider_configureTextSliderValues(entity me, string theDefault)
 {
        me.configureSliderValues(me, 0, 0, me.nValues - 1, 1, 1, 1);
-       me.setValueFromIdentifier(me, theDefault);
+       me.setValueFromIdentifier_noAnim(me, theDefault);
 }
 #endif
index 27282207795580b122182c1b38c5c47546594d7f..ceeae22ea060f06fd39b071852cfa2cd4263ff5c 100644 (file)
@@ -41,6 +41,7 @@ entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, s
 void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
 {
        me.cvarName = (theCvar) ? theCvar : string_null;
+       me.cvarValue = theValue;
        me.loadCvars(me);
        setZonedTooltip(me, theTooltip, theCvar);
        me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
index ca65c66218b12efe4561f37baa377e85e284edf4..7ecd7a9d0a4e6a03ead4ee4e262ddaea22136813 100644 (file)
@@ -71,7 +71,7 @@ void XonoticSlider_loadCvars(entity me)
        if (!me.cvarName)
                return;
 
-       me.setValue( me, cvar(me.cvarName) );
+       me.setValue_noAnim(me, cvar(me.cvarName));
 }
 void XonoticSlider_saveCvars(entity me)
 {
index c840fb07ef7b3e47a5bb65a20097351dbae5a71f..e577cba66407ce84db002f16a1d7c860e7a7a365 100644 (file)
@@ -62,9 +62,9 @@ void XonoticDecibelsSlider_loadCvars(entity me)
 
        // snapping
        if(v > fromDecibelOfSquare(me.valueMax - 0.5 * me.valueStep, me.valueMin))
-               Slider_setValue(me, me.valueMax);
+               Slider_setValue_noAnim(me, me.valueMax);
        else
-               Slider_setValue(me, me.valueStep * floor(0.5 + toDecibelOfSquare(v, me.valueMin) / me.valueStep) );
+               Slider_setValue_noAnim(me, me.valueStep * floor(0.5 + toDecibelOfSquare(v, me.valueMin) / me.valueStep));
 }
 void XonoticDecibelsSlider_saveCvars(entity me)
 {
index 0b2179d36eeede5497291f0afe6b8de486aed76e..1a7ee2c4a59101b65826e0ef2f1dce73485bc9d5 100644 (file)
@@ -32,7 +32,7 @@ void XonoticParticlesSlider_configureXonoticParticlesSlider(entity me)
 }
 void XonoticParticlesSlider_loadCvars(entity me)
 {
-       me.setValueFromIdentifier(me, sprintf("%s %s %s",
+       me.setValueFromIdentifier_noAnim(me, sprintf("%s %s %s",
                cvar_string("cl_particles_quality"),
                cvar_string("r_drawparticles_drawdistance"),
                cvar_string("cl_damageeffect")
index 8b91ecb1f3ad6180e7a2f84d9fede431a0e0d73c..c6d95b4304315381f3e3cbc973a572998079d244 100644 (file)
@@ -212,7 +212,7 @@ void XonoticResolutionSlider_loadResolutions(entity me, float fullscreen)
 }
 void XonoticResolutionSlider_loadCvars(entity me)
 {
-       me.setValueFromIdentifier(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight")));
+       me.setValueFromIdentifier_noAnim(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight")));
 }
 void XonoticResolutionSlider_saveCvars(entity me)
 {
index 5533a2361bf8bd2efc94cc42c4ad939f381b6ebe..ecf850f404f083b3548ed59138d7e34973c9ce80 100644 (file)
@@ -28,7 +28,7 @@ void XonoticScoreboardFadeTimeSlider_configureXonoticScoreboardFadeTimeSlider(en
 }
 void XonoticScoreboardFadeTimeSlider_loadCvars(entity me)
 {
-       me.setValueFromIdentifier(me, sprintf("%s %s",
+       me.setValueFromIdentifier_noAnim(me, sprintf("%s %s",
                cvar_string("scoreboard_fadeinspeed"),
                cvar_string("scoreboard_fadeoutspeed")
        ));
index 597772e340019f4d58077158dc710b619e3b5944..8c4682ee0ffbf9a25d5692bdd18ed1c267014777 100644 (file)
@@ -65,7 +65,7 @@ void XonoticTextSlider_loadCvars(entity me)
        float i;
        for(i = 1; i < n; ++i)
                s = strcat(s, " ", cvar_string(argv(i)));
-       me.setValueFromIdentifier(me, s);
+       me.setValueFromIdentifier_noAnim(me, s);
        if(me.value < 0 && n > 1)
        {
                // if it failed: check if all cvars have the same value
@@ -74,7 +74,7 @@ void XonoticTextSlider_loadCvars(entity me)
                        if(cvar_string(argv(i)) != cvar_string(argv(i-1)))
                                break;
                if(i >= n)
-                       me.setValueFromIdentifier(me, cvar_string(argv(0)));
+                       me.setValueFromIdentifier_noAnim(me, cvar_string(argv(0)));
        }
 }
 void XonoticTextSlider_saveCvars(entity me)
index 7a3ac0561af3c6ec66917479cad1b6a2ab1756de..629009761fbcece18ce7d57a4f2094d6ef842eef 100644 (file)
@@ -856,7 +856,7 @@ void havocbot_movetogoal()
 void havocbot_chooseenemy()
 {SELFPARAM();
        entity head, best, head2;
-       float rating, bestrating, i, hf;
+       float rating, bestrating, hf;
        vector eye, v;
        if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(self))
        {
@@ -908,10 +908,29 @@ void havocbot_chooseenemy()
 
        self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
 
-       for(i = 0; ; ++i)
+       bool scan_transparent = false;
+       bool scan_secondary_targets = false;
+       bool have_secondary_targets = false;
+       while(true)
        {
-               while (head)
+               scan_secondary_targets = false;
+               :scan_targets
+               for( ; head; head = head.chain)
                {
+                       if(!scan_secondary_targets)
+                       {
+                               if(head.classname == "misc_breakablemodel")
+                               {
+                                       have_secondary_targets = true;
+                                       continue;
+                               }
+                       }
+                       else
+                       {
+                               if(head.classname != "misc_breakablemodel")
+                                       continue;
+                       }
+
                        v = (head.absmin + head.absmax) * 0.5;
                        rating = vlen(v - eye);
                        if (rating<autocvar_bot_ai_enemydetectionradius)
@@ -925,20 +944,29 @@ void havocbot_chooseenemy()
                                        bestrating = rating;
                                }
                        }
-                       head = head.chain;
+               }
+
+               if(!best && have_secondary_targets && !scan_secondary_targets)
+               {
+                       scan_secondary_targets = true;
+                       // restart the loop
+                       head = head2;
+                       bestrating = 100000000;
+                       goto scan_targets;
                }
 
                // I want to do a second scan if no enemy was found or I don't have weapons
                // TODO: Perform the scan when using the rifle (requires changes on the rifle code)
                if(best || self.weapons) // || self.weapon == WEP_RIFLE.m_id
                        break;
-               if(i)
+               if(scan_transparent)
                        break;
 
                // Set flags to see through transparent objects
                self.dphitcontentsmask |= DPCONTENTS_OPAQUE;
 
                head = head2;
+               scan_transparent = true;
        }
 
        // Restore hit flags
@@ -946,6 +974,8 @@ void havocbot_chooseenemy()
 
        self.enemy = best;
        self.havocbot_stickenemy = true;
+       if(best && best.classname == "misc_breakablemodel")
+               self.havocbot_stickenemy = false;
 }
 
 float havocbot_chooseweapon_checkreload(int new_weapon)
index b31d4d55666dc747c5bd8f24126874ce1f872f0a..da1a180d4c38dad14c8d1678b6edd6e2731ab8fc 100644 (file)
@@ -205,6 +205,7 @@ void PutObserverInServer (void)
        }
 
        self.frags = FRAGS_SPECTATOR;
+       self.bot_attack = false;
 
        MUTATOR_CALLHOOK(MakePlayerObserver);
 
index b5d87eed172cb27eafd02cec6d4af64a6dfd440e..2cc773b73f526b53a46b927692be1ba1069d9970 100644 (file)
@@ -560,6 +560,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
        targ.revive_progress = ((frozen_type == 3) ? 1 : 0);
        targ.health = ((frozen_type == 3) ? targ_maxhealth : 1);
        targ.revive_speed = freeze_time;
+       self.bot_attack = false;
 
        entity ice, head;
        ice = spawn();
@@ -591,6 +592,9 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
 
 void Unfreeze (entity targ)
 {
+       if(!targ.frozen)
+               return;
+
        if(targ.frozen && targ.frozen != 3) // only reset health if target was frozen
                targ.health = ((IS_PLAYER(targ)) ? start_health : targ.max_health);
 
@@ -598,6 +602,7 @@ void Unfreeze (entity targ)
        targ.frozen = 0;
        targ.revive_progress = 0;
        targ.revival_time = time;
+       self.bot_attack = true;
 
        WaypointSprite_Kill(targ.waypointsprite_attached);