]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/wyvern.qc
Remove commented out legacy keyframe information from monster codefiles and update...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / wyvern.qc
1 #include "wyvern.qh"
2
3 #ifdef SVQC
4
5 float autocvar_g_monster_wyvern_attack_fireball_damage;
6 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
7 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
8 float autocvar_g_monster_wyvern_attack_fireball_force;
9 float autocvar_g_monster_wyvern_attack_fireball_radius;
10 float autocvar_g_monster_wyvern_attack_fireball_speed;
11
12 void M_Wyvern_Attack_Fireball_Explode(entity this);
13 void M_Wyvern_Attack_Fireball_Touch(entity this, entity toucher);
14
15 SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
16 METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
17 {
18     TC(WyvernAttack, thiswep);
19     if (fire & 1)
20     if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) {
21         monster_makevectors(actor, actor.enemy);
22         if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_WYVERN.m_id);
23                 if (IS_MONSTER(actor)) {
24                         actor.attack_finished_single[0] = time + 1.2;
25                         actor.anim_finished = time + 1.2;
26                 }
27
28                 entity missile = new(WyvernAttack);
29                 missile.owner = missile.realowner = actor;
30                 missile.solid = SOLID_TRIGGER;
31                 set_movetype(missile, MOVETYPE_FLYMISSILE);
32                 missile.projectiledeathtype = DEATH_MONSTER_WYVERN.m_id;
33                 setsize(missile, '-6 -6 -6', '6 6 6');
34                 setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14);
35                 missile.flags = FL_PROJECTILE;
36         IL_PUSH(g_projectiles, missile);
37         IL_PUSH(g_bot_dodge, missile);
38                 missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
39                 missile.avelocity = '300 300 300';
40                 missile.nextthink = time + 5;
41                 setthink(missile, M_Wyvern_Attack_Fireball_Explode);
42                 settouch(missile, M_Wyvern_Attack_Fireball_Touch);
43                 CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
44
45         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
46     }
47 }
48
49 METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor, .entity weaponentity)) {
50     TC(WyvernAttack, this);
51         return true;
52 }
53
54 float autocvar_g_monster_wyvern_health;
55 float autocvar_g_monster_wyvern_damageforcescale = 0.6;
56 float autocvar_g_monster_wyvern_speed_stop;
57 float autocvar_g_monster_wyvern_speed_run;
58 float autocvar_g_monster_wyvern_speed_walk;
59
60 void M_Wyvern_Attack_Fireball_Explode(entity this)
61 {
62         Send_Effect(EFFECT_FIREBALL_EXPLODE, this.origin, '0 0 0', 1);
63
64         entity own = this.realowner;
65
66         RadiusDamage(this, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force,
67                                                 own, NULL, autocvar_g_monster_wyvern_attack_fireball_radius, this.projectiledeathtype, DMG_NOWEP, NULL);
68
69         FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_wyvern_attack_fireball_radius, it.takedamage == DAMAGE_AIM && it != own,
70         {
71                 Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, this.projectiledeathtype);
72         });
73
74         delete(this);
75 }
76
77 void M_Wyvern_Attack_Fireball_Touch(entity this, entity toucher)
78 {
79         PROJECTILE_TOUCH(this, toucher);
80
81         M_Wyvern_Attack_Fireball_Explode(this);
82 }
83
84 void M_Wyvern_Attack_Fireball(entity this)
85 {
86         w_shotdir = normalize((this.enemy.origin + '0 0 10') - this.origin);
87         Weapon wep = WEP_WYVERN_ATTACK;
88         // TODO
89         .entity weaponentity = weaponentities[0];
90         wep.wr_think(wep, this, weaponentity, 1);
91 }
92
93 bool M_Wyvern_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
94 {
95         switch(attack_type)
96         {
97                 case MONSTER_ATTACK_MELEE:
98                 case MONSTER_ATTACK_RANGED:
99                 {
100                         Monster_Delay(actor, 0, 1, M_Wyvern_Attack_Fireball);
101                         //actor.anim_finished = time + 1.2;
102                         setanim(actor, actor.anim_shoot, false, true, true);
103                         if(actor.animstate_endtime > time)
104                                 actor.anim_finished = actor.animstate_endtime;
105                         else
106                                 actor.anim_finished = time + 1.2;
107                         actor.attack_finished_single[0] = actor.anim_finished + 0.2;
108                         return true;
109                 }
110         }
111
112         return false;
113 }
114
115 spawnfunc(monster_wyvern) { Monster_Spawn(this, true, MON_WYVERN); }
116 #endif // SVQC
117
118 #ifdef SVQC
119 METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor))
120 {
121     TC(Wyvern, this);
122     return true;
123 }
124
125 METHOD(Wyvern, mr_deadthink, bool(Wyvern this, entity actor))
126 {
127     TC(Wyvern, this);
128     if(IS_ONGROUND(actor))
129         setanim(actor, actor.anim_die2, true, false, false);
130     return true;
131 }
132
133 METHOD(Wyvern, mr_pain, float(Wyvern this, entity actor, float damage_take, entity attacker, float deathtype))
134 {
135     TC(Wyvern, this);
136     actor.pain_finished = time + 0.5;
137     setanim(actor, actor.anim_pain1, true, true, false);
138     return damage_take;
139 }
140
141 METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor))
142 {
143     TC(Wyvern, this);
144     setanim(actor, actor.anim_die1, false, true, true);
145     actor.velocity_x = -200 + 400 * random();
146     actor.velocity_y = -200 + 400 * random();
147     actor.velocity_z = 100 + 100 * random();
148     return true;
149 }
150 #endif
151 #ifdef GAMEQC
152 METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
153 {
154     TC(Wyvern, this);
155     vector none = '0 0 0';
156     actor.anim_idle = animfixfps(actor, '0 1 1', none);
157     actor.anim_walk = animfixfps(actor, '1 1 1', none);
158     actor.anim_run = animfixfps(actor, '2 1 1', none);
159     actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
160     actor.anim_pain2 = animfixfps(actor, '4 1 2', none); // 0.5 seconds
161     actor.anim_melee = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
162     actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
163     actor.anim_die1 = animfixfps(actor, '7 1 0.5', none); // 2 seconds
164     actor.anim_die2 = animfixfps(actor, '8 1 0.5', none); // 2 seconds
165     return true;
166 }
167 #endif
168 #ifdef SVQC
169 METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
170 {
171     TC(Wyvern, this);
172     if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_wyvern_health);
173     if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); }
174     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); }
175     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
176     if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
177
178     actor.monster_loot = ITEM_Cells;
179     actor.monster_attackfunc = M_Wyvern_Attack;
180
181     return true;
182 }
183 #endif