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