3 .entity trigger_gravity_check;
4 void trigger_gravity_remove(entity own)
6 if(own.trigger_gravity_check.owner == own)
8 UpdateCSQCProjectile(own);
9 own.gravity = own.trigger_gravity_check.gravity;
10 delete(own.trigger_gravity_check);
13 backtrace("Removing a trigger_gravity_check with no valid owner");
14 own.trigger_gravity_check = NULL;
16 void trigger_gravity_check_think(entity this)
18 // This spawns when a player enters the gravity zone and checks if he left.
19 // Each frame, this.count is set to 2 by trigger_gravity_touch() and decreased by 1 here.
20 // It the player has left the gravity trigger, this will be allowed to reach 0 and indicate that.
23 if(this.owner.trigger_gravity_check == this)
24 trigger_gravity_remove(this.owner);
32 this.nextthink = time;
36 void trigger_gravity_use(entity this, entity actor, entity trigger)
38 this.state = !this.state;
41 void trigger_gravity_touch(entity this, entity toucher)
45 if(this.state != true)
48 EXACTTRIGGER_TOUCH(this, toucher);
52 if (!(this.spawnflags & 1))
54 if(toucher.trigger_gravity_check)
56 if(this == toucher.trigger_gravity_check.enemy)
59 toucher.trigger_gravity_check.count = 2; // gravity one more frame...
64 if(this.cnt > toucher.trigger_gravity_check.enemy.cnt)
65 trigger_gravity_remove(toucher);
69 toucher.trigger_gravity_check = spawn();
70 toucher.trigger_gravity_check.enemy = this;
71 toucher.trigger_gravity_check.owner = toucher;
72 toucher.trigger_gravity_check.gravity = toucher.gravity;
73 setthink(toucher.trigger_gravity_check, trigger_gravity_check_think);
74 toucher.trigger_gravity_check.nextthink = time;
75 toucher.trigger_gravity_check.count = 2;
80 if (toucher.gravity != g)
84 _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
85 UpdateCSQCProjectile(this.owner);
89 spawnfunc(trigger_gravity)
95 settouch(this, trigger_gravity_touch);
97 precache_sound(this.noise);
102 this.use = trigger_gravity_use;
103 if(this.spawnflags & 2)