X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret.qh;h=8e5239702866c4c6fe4519a7c34d67f2aa00b7fd;hp=a2c934277c280a5d6db959f945b09faa837f0220;hb=79eebf87e68861e205a8754d6551bd0aa2229c44;hpb=6ddac53e429edfca2f00c0966dcee6a825b10826 diff --git a/qcsrc/common/turrets/turret.qh b/qcsrc/common/turrets/turret.qh index a2c934277..8e5239702 100644 --- a/qcsrc/common/turrets/turret.qh +++ b/qcsrc/common/turrets/turret.qh @@ -1,8 +1,60 @@ -#ifndef TURRET_H -#define TURRET_H +#pragma once -// functions: -entity get_turretinfo(int id); +#include + +CLASS(Turret, Object) + ATTRIB(Turret, m_id, int, 0); + + /** short name */ + ATTRIB(Turret, netname, string); + /** human readable name */ + ATTRIB(Turret, turret_name, string, _("Turret")); + /** currently a copy of the model */ + ATTRIB(Turret, mdl, string); + /** full name of model */ + ATTRIB(Turret, model, string); + /** full name of tur_head model */ + ATTRIB(Turret, head_model, string); + + ATTRIB(Turret, spawnflags, int, 0); + /** turret hitbox size */ + ATTRIB(Turret, mins, vector, '-0 -0 -0'); + /** turret hitbox size */ + ATTRIB(Turret, maxs, vector, '0 0 0'); + + METHOD(Turret, display, void(Turret this, void(string name, string icon) returns)) { + returns(this.turret_name, string_null); + } + /** (BOTH) setup turret data */ + METHOD(Turret, tr_setup, void(Turret this, entity it)) { + + } + /** (SERVER) logic to run every frame */ + METHOD(Turret, tr_think, void(Turret this, entity it)) { + + } + /** (SERVER) called when turret dies */ + METHOD(Turret, tr_death, void(Turret this, entity it)) { + + } + /** (BOTH) precaches models/sounds used by this turret */ + METHOD(Turret, tr_precache, void(Turret this)) { + + } + ATTRIB(Turret, m_weapon, Weapon); +#ifdef SVQC + /** (SERVER) called when turret attacks */ + METHOD(Turret, tr_attack, void(Turret this, entity it)) { + Weapon w = this.m_weapon; + .entity weaponentity = weaponentities[0]; + w.wr_think(w, it, weaponentity, 1); + } +#endif + /** (ALL) */ + METHOD(Turret, tr_config, void(Turret this)) { + // TODO + } +ENDCLASS(Turret) // fields: .entity tur_head; @@ -123,65 +175,3 @@ const int TNSF_MOVE = 64; const int TNSF_ANIM = 128; const int TNSF_FULL_UPDATE = 16777215; - - -// other useful macros -#define _TUR_ACTION(tur, mrequest) tur.turret_func(tur, mrequest) -#define TUR_ACTION(tur, mrequest) _TUR_ACTION(get_turretinfo(tur), mrequest) -#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name - -bool t_new(entity this, int req); - -CLASS(Turret, Object) - ATTRIB(Turret, m_id, int, 0) - - /** short name */ - ATTRIB(Turret, netname, string, string_null) - /** human readable name */ - ATTRIB(Turret, turret_name, string, string_null) - /** t_... */ - ATTRIB(Turret, turret_func, float(Turret, int), t_new) - /** currently a copy of the model */ - ATTRIB(Turret, mdl, string, string_null) - /** full name of model */ - ATTRIB(Turret, model, string, string_null) - /** full name of tur_head model */ - ATTRIB(Turret, head_model, string, string_null) - - ATTRIB(Turret, spawnflags, int, 0) - /** turret hitbox size */ - ATTRIB(Turret, mins, vector, '-0 -0 -0') - /** turret hitbox size */ - ATTRIB(Turret, maxs, vector, '0 0 0') - - METHOD(Turret, display, void(entity this, void(string name, string icon) returns)) { - returns(this.turret_name, string_null); - } - -ENDCLASS(Turret) - -// turret requests -const int TR_SETUP = 1; // (BOTH) setup turret data -.bool(Turret) tr_setup; -const int TR_THINK = 2; // (SERVER) logic to run every frame -.bool(Turret) tr_think; -const int TR_DEATH = 3; // (SERVER) called when turret dies -.bool(Turret) tr_death; -const int TR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this turret -.bool(Turret) tr_precache; -/** (SERVER) called when turret attacks */ -.void(Turret) tr_attack; -const int TR_CONFIG = 6; // (ALL) -.bool(Turret) tr_config; - -bool t_new(Turret this, int req) -{ - if (req == TR_SETUP) return this.tr_setup ? this.tr_setup(this) : false; - if (req == TR_THINK) return this.tr_think ? this.tr_think(this) : false; - if (req == TR_DEATH) return this.tr_death ? this.tr_death(this) : false; - if (req == TR_PRECACHE) return this.tr_precache ? this.tr_precache(this) : false; - if (req == TR_CONFIG) return this.tr_config ? this.tr_config(this) : false; - return false; -} - -#endif