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;
37 void trigger_gravity_use(entity this, entity actor, entity trigger)
39 this.setactive(this, ACTIVE_TOGGLE);
42 void trigger_gravity_touch(entity this, entity toucher)
46 if(this.active == ACTIVE_NOT)
49 EXACTTRIGGER_TOUCH(this, toucher);
53 if (!(this.spawnflags & GRAVITY_STICKY))
55 if(toucher.trigger_gravity_check)
57 if(this == toucher.trigger_gravity_check.enemy)
60 // NOTE: see explanation in trigger_gravity_check_think
61 toucher.trigger_gravity_check.count = 2; // gravity one more frame...
66 if(this.cnt > toucher.trigger_gravity_check.enemy.cnt)
67 trigger_gravity_remove(toucher);
71 toucher.trigger_gravity_check = spawn();
72 toucher.trigger_gravity_check.enemy = this;
73 toucher.trigger_gravity_check.owner = toucher;
74 toucher.trigger_gravity_check.gravity = toucher.gravity;
75 setthink(toucher.trigger_gravity_check, trigger_gravity_check_think);
76 toucher.trigger_gravity_check.nextthink = time;
77 toucher.trigger_gravity_check.count = 2;
82 if (toucher.gravity != g)
86 _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
87 UpdateCSQCProjectile(this.owner);
91 spawnfunc(trigger_gravity)
97 settouch(this, trigger_gravity_touch);
99 precache_sound(this.noise);
101 this.active = ACTIVE_ACTIVE;
102 this.setactive = generic_setactive;
106 this.use = trigger_gravity_use;
107 if(this.spawnflags & GRAVITY_START_DISABLED)
108 this.active = ACTIVE_NOT;