From 4d0a7b861f9b384388d3178ae002982964078e32 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Sun, 18 Jun 2023 12:11:59 +0200 Subject: [PATCH] xonogotchi: add eat and sleep animation --- .../default/minigames/xonogotchi/pet_eat.png | Bin 0 -> 695 bytes .../default/minigames/xonogotchi/pet_eat2.png | Bin 0 -> 696 bytes .../minigames/xonogotchi/pet_eat2_r.png | Bin 0 -> 702 bytes .../minigames/xonogotchi/pet_eat_r.png | Bin 0 -> 701 bytes .../minigames/xonogotchi/pet_sleep.png | Bin 0 -> 859 bytes .../minigames/xonogotchi/pet_sleep2.png | Bin 0 -> 846 bytes .../minigames/xonogotchi/pet_sleep2_r.png | Bin 0 -> 846 bytes .../minigames/xonogotchi/pet_sleep_r.png | Bin 0 -> 859 bytes qcsrc/common/minigames/minigame/all.qh | 2 +- qcsrc/common/minigames/minigame/xonogotchi.qc | 75 +++++++++++++----- 10 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_eat.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_eat2.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_eat2_r.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_eat_r.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_sleep.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_sleep2.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_sleep2_r.png create mode 100644 gfx/hud/default/minigames/xonogotchi/pet_sleep_r.png diff --git a/gfx/hud/default/minigames/xonogotchi/pet_eat.png b/gfx/hud/default/minigames/xonogotchi/pet_eat.png new file mode 100644 index 0000000000000000000000000000000000000000..8f94bbca8b9c63aee85b362357d3ae07d2a2a450 GIT binary patch literal 695 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJEyI!_nJkcwMx?>OciG7xYG zWG^(>;lp<{^~Bjjvv`%CSjZiJ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It+WLkmsJI0cA-)-w&KbKrneA8zBo9ZfIG|Q}i?q_J(a_@066VOZn1_w~YfEWql z-x(&I{#X0|*6(8f11!kKDli;a`6fgE+VA4Oi|+^u8jZx>a#JryNt_L%w7HVtKHx1+~9Z!l(;-y L{an^LB{Ts5g(R_p literal 0 HcmV?d00001 diff --git a/gfx/hud/default/minigames/xonogotchi/pet_sleep.png b/gfx/hud/default/minigames/xonogotchi/pet_sleep.png new file mode 100644 index 0000000000000000000000000000000000000000..a22cc4b081f5b1c2cc1b959c0eb202ecf159ce62 GIT binary patch literal 859 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJD{B~KT}kcwMx?>go^HsEmx z-1_3+q|;9V_WINsr;4(?IFz-}LhR)CZ^37FoMUGXd2o*_Fn}2;$?e|d{WCxovoHuSI6xR4hx^R!tLuCqYB*rZOK&h9Pe0$!iBJgA z(ZFu~=0EP2oC|MY6cvj{qwuBWq-DKpa1iI_cq`&*Aq!C!+;sg67Ne zGxzxSzkgFKa&!HBBo~48n-}vjl)2phJR9LzaGage{C}qMIZM{*eaMmA07{Zm9^d`U ze2(+UGZ|RggeKCH7VH~#ym&6K>itdh$lG&Mw(y$Q=5OU|{(~aM)78&qol`;+0PlSD AX#fBK literal 0 HcmV?d00001 diff --git a/gfx/hud/default/minigames/xonogotchi/pet_sleep2.png b/gfx/hud/default/minigames/xonogotchi/pet_sleep2.png new file mode 100644 index 0000000000000000000000000000000000000000..0126f65c1431980cf6bc6e4cb7ae2cc57799f85b GIT binary patch literal 846 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJD{QBN1gkcwMx??(F_HV|+K zY~Hn@%s5tLc4k@HJ}niMMUs?b2wF*W_;3M1!}|wEKavO8^o0M8Jt?~%)rFJ z!JxpHK6PO2<00}=h*;i5b?avI5 zLJ%J+VR4GDa?dN7!Wti#u~75(biQUdq4)K(m=D8)c$jLCwuXWjc88LCs}o=rI55aC zfhBxm*blsV^V1j2q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Ie^>bP0l+XkK Dpz+go^HsEmx z-1_3+q|;9V_WINsr;4(?IFz-}LhR)CZ^37FoMUGXd2o*_Fn}2;$?e|d{WCxovoHuSI6xR4hx^R!tLuCqYB*rZOK&h9Pe0$!iBJgA z(ZFu~=0EP2oC|MY6cvj{qwuBWq-DKpa1iI_cq`&*Aq!C!+;sg67Ne zGxzxSzkgFKa&!HBBo~48n-}vjl)2phJR9LzaGage{C}qMIZM{*eaMmA07{Zm9^d`U ze2(+UGZ|RggeKCH7VH~#ym&6K>itdh$lG&Mw(y$Q=5OU|{(~aM)78&qol`;+0PlSD AX#fBK literal 0 HcmV?d00001 diff --git a/qcsrc/common/minigames/minigame/all.qh b/qcsrc/common/minigames/minigame/all.qh index 43fd10d0d..72c154ed6 100644 --- a/qcsrc/common/minigames/minigame/all.qh +++ b/qcsrc/common/minigames/minigame/all.qh @@ -103,7 +103,7 @@ that .owner is set to the minigame session entity and .minigame_autoclean is tru MSLE(pong_paddle,FIELD(MINIG_SF_CREATE,Byte,team) FIELD(MINIG_SF_CREATE,Float,pong_length) FIELD(MINIG_SF_UPDATE,Vector2D,origin)) \ MSLE(pong_ball,FIELD(MINIG_SF_CREATE,Float,pong_length) FIELD(PONG_SF_BALLTEAM,Byte,team) FIELD(MINIG_SF_UPDATE, Vector2D, velocity) FIELD(MINIG_SF_UPDATE, Vector2D, origin)) \ MSLE(pong_ai, FIELD(MINIG_SF_CREATE,Byte,team) FIELD(PONG_SF_PLAYERSCORE, Long, pong_score)) \ - MSLE(xonogotchi_pet,FIELD(MINIG_SF_UPDATE, Vector2D, origin) FIELD(MINIG_SF_UPDATE, Byte, xonogotchi_pet_movedir) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_level) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_health) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_hunger) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_energy)) \ + MSLE(xonogotchi_pet,FIELD(MINIG_SF_UPDATE, Vector2D, origin) FIELD(MINIG_SF_UPDATE, Byte, xonogotchi_pet_movedir) FIELD(MINIG_SF_UPDATE, Byte, xonogotchi_pet_action) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_level) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_health) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_hunger) FIELD(MINIG_SF_UPDATE, Float, xonogotchi_pet_energy)) \ MSLE(xonogotchi_nest,FIELD(MINIG_SF_UPDATE, Vector2D, origin)) \ MSLE(xonogotchi_bowl,FIELD(MINIG_SF_UPDATE, Vector2D, origin) FIELD(MINIG_SF_UPDATE, Float, count)) \ /*empty line*/ diff --git a/qcsrc/common/minigames/minigame/xonogotchi.qc b/qcsrc/common/minigames/minigame/xonogotchi.qc index 3e40c9845..70df3e663 100644 --- a/qcsrc/common/minigames/minigame/xonogotchi.qc +++ b/qcsrc/common/minigames/minigame/xonogotchi.qc @@ -10,6 +10,9 @@ const vector XONOGOTCHI_PET_MINS = -XONOGOTCHI_PET_MAXS; const int XONOGOTCHI_PET_MOVE_LEFT = 0x01; const int XONOGOTCHI_PET_MOVE_RIGHT = 0x02; +const int XONOGOTCHI_PET_ACTION_EAT = 1; +const int XONOGOTCHI_PET_ACTION_SLEEP = 2; + const float XONOGOTCHI_NEST_SIZE = 0.25; const vector XONOGOTCHI_NEST_MAXS = '1 1 0' * XONOGOTCHI_NEST_SIZE / 2; const vector XONOGOTCHI_NEST_MINS = -XONOGOTCHI_NEST_MAXS; @@ -37,6 +40,7 @@ const float XONOGOTCHI_ANIM_DURATION = XONOGOTCHI_STEP_DURATION * XONOGOTCHI_STE .entity xonogotchi_bowl; .int xonogotchi_pet_movedir; +.int xonogotchi_pet_action; .float xonogotchi_pet_goal; .float xonogotchi_pet_level; .float xonogotchi_pet_health; @@ -82,7 +86,8 @@ void xonogotchi_pet_think(entity this) entity minigame = this.owner; entity bowl = minigame.xonogotchi_bowl; float energy_goal = minigame.xonogotchi_nest.origin.x; - float hunger_goal = minigame.xonogotchi_bowl.origin.x; + float hunger_goal_min = minigame.xonogotchi_bowl.origin.x + XONOGOTCHI_BOWL_MINS.x; + float hunger_goal_max = minigame.xonogotchi_bowl.origin.x + XONOGOTCHI_BOWL_MAXS.x; bool want_sleep = (this.xonogotchi_pet_energy < 10); bool want_food = !want_sleep && (this.xonogotchi_pet_hunger < 10) && bowl.count; @@ -93,7 +98,14 @@ void xonogotchi_pet_think(entity this) else if(want_sleep) this.xonogotchi_pet_goal = energy_goal; else - this.xonogotchi_pet_goal = hunger_goal; + { + if((this.origin.x >= hunger_goal_min) && (this.origin.x <= hunger_goal_max)) + this.xonogotchi_pet_goal = this.origin.x; + else if(this.origin.x < hunger_goal_min) + this.xonogotchi_pet_goal = hunger_goal_min; + else + this.xonogotchi_pet_goal = hunger_goal_max; + } if(this.xonogotchi_pet_goal < this.origin.x) this.xonogotchi_pet_movedir = XONOGOTCHI_PET_MOVE_LEFT; @@ -110,7 +122,8 @@ void xonogotchi_pet_walkthink(entity this) entity minigame = this.owner; entity bowl = minigame.xonogotchi_bowl; float energy_goal = minigame.xonogotchi_nest.origin.x; - float hunger_goal = minigame.xonogotchi_bowl.origin.x; + float hunger_goal_min = minigame.xonogotchi_bowl.origin.x + XONOGOTCHI_BOWL_MINS.x; + float hunger_goal_max = minigame.xonogotchi_bowl.origin.x + XONOGOTCHI_BOWL_MAXS.x; bool want_sleep = (this.xonogotchi_pet_energy < 10); bool want_food = !want_sleep && (this.xonogotchi_pet_hunger < 10) && bowl.count; @@ -152,7 +165,7 @@ void xonogotchi_pet_walkthink(entity this) if(goal_reached) this.xonogotchi_pet_hunger = max(0, this.xonogotchi_pet_hunger - floor(random() * 5)); - if(want_food && (this.xonogotchi_pet_goal != hunger_goal)) + if(want_food && ((this.xonogotchi_pet_goal < hunger_goal_min) || (this.xonogotchi_pet_goal > hunger_goal_max))) { goal_reached = false; setthink(this, xonogotchi_pet_think); @@ -169,11 +182,13 @@ void xonogotchi_pet_walkthink(entity this) } else if(want_sleep) { + this.xonogotchi_pet_action = XONOGOTCHI_PET_ACTION_SLEEP; setthink(this, xonogotchi_pet_sleepthink); this.nextthink = time; } else { + this.xonogotchi_pet_action = XONOGOTCHI_PET_ACTION_EAT; setthink(this, xonogotchi_pet_eatthink); this.nextthink = time; } @@ -204,7 +219,10 @@ void xonogotchi_pet_sleepthink(entity this) this.xonogotchi_pet_health = min(100, this.xonogotchi_pet_health + random() * 5); if(this.xonogotchi_pet_energy == 100) + { + this.xonogotchi_pet_action = 0; setthink(this, xonogotchi_pet_think); + } this.nextthink = time + XONOGOTCHI_SLEEP_DURATION; this.SendFlags |= MINIG_SF_UPDATE; @@ -221,12 +239,16 @@ void xonogotchi_pet_eatthink(entity this) bowl.count -= 5; if(this.xonogotchi_pet_hunger == 100) + { + this.xonogotchi_pet_action = 0; setthink(this, xonogotchi_pet_think); + } bowl.SendFlags |= MINIG_SF_UPDATE; } else { + this.xonogotchi_pet_action = 0; setthink(this, xonogotchi_pet_think); } @@ -285,7 +307,7 @@ int xonogotchi_server_event(entity minigame, string event, ...) #elif defined(CSQC) -const int XONOGOTCHI_PET_ANIM_WALK = 0x01; +const int XONOGOTCHI_PET_ANIM_VARIANT = 0x01; const int XONOGOTCHI_PET_ANIM_LEFT = 0x02; const int XONOGOTCHI_PET_ANIM_RIGHT = 0x04; @@ -353,16 +375,23 @@ void xonogotchi_hud_board(vector pos, vector mySize) if(!e.anim_time || time > e.anim_time + XONOGOTCHI_ANIM_DURATION) { - switch(e.xonogotchi_pet_movedir) + bool use_anim = false; + + if(e.xonogotchi_pet_action) + use_anim = true; + + if((e.xonogotchi_pet_movedir == XONOGOTCHI_PET_MOVE_LEFT) || (e.xonogotchi_pet_movedir == XONOGOTCHI_PET_MOVE_RIGHT)) + use_anim = true; + + if(use_anim) + { + e.anim_time = time; + e.anim_state ^= XONOGOTCHI_PET_ANIM_VARIANT; + } + else { - case XONOGOTCHI_PET_MOVE_LEFT: - case XONOGOTCHI_PET_MOVE_RIGHT: - e.anim_time = time; - e.anim_state ^= XONOGOTCHI_PET_ANIM_WALK; - break; - default: - e.anim_time = 0; - e.anim_state &= ~XONOGOTCHI_PET_ANIM_WALK; + e.anim_time = 0; + e.anim_state &= ~XONOGOTCHI_PET_ANIM_VARIANT; } } @@ -378,11 +407,19 @@ void xonogotchi_hud_board(vector pos, vector mySize) break; } - string anim_texture; - if(!(e.anim_state & XONOGOTCHI_PET_ANIM_WALK)) - anim_texture = "xonogotchi/pet"; - else - anim_texture = "xonogotchi/pet2"; + string anim_texture = "xonogotchi/pet";; + switch(e.xonogotchi_pet_action) + { + case XONOGOTCHI_PET_ACTION_EAT: + anim_texture = strcat(anim_texture, "_eat"); + break; + case XONOGOTCHI_PET_ACTION_SLEEP: + anim_texture = strcat(anim_texture, "_sleep"); + break; + } + + if(e.anim_state & XONOGOTCHI_PET_ANIM_VARIANT) + anim_texture = strcat(anim_texture, "2"); org = e.origin; org.y -= XONOGOTCHI_PET_MINS.y; -- 2.39.2