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