-
Notifications
You must be signed in to change notification settings - Fork 29
entity
Blub edited this page Nov 1, 2012
·
2 revisions
An entity represents an object in the game.
In QC the entity
type represents such an object. Usually implemented as an integer containing an entity ID. A variable of this type can be accessed similarly to struct
s in C: members can be accessed via the dot-operator.
Members are declared by prefixing a global variable declaration with a dot, thus writing
.float health;
in a QC source file at the global scope causes all entities to have a member of type float
named health
.
Snippet:
.float health;
.entity last_attacker;
.string name;
void(entity attacker, entity target, float dmg) damage = {
target.last_attacker = attacker;
target.health -= dmg;
if (target.health <= 0) {
print("Player ", target.name, " was killed by ", attacker.name);
die(target);
}
}