View previous topic :: View next topic |
Author |
Message |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Tue Aug 23, 2005 2:06 pm Post subject: a small question |
|
|
A trigger's self.touch calls this:
Quote: |
void() wsy_counter_on =
{
wsy_check = 1;
other.nextthink = time + 10;
other.think = tellme;
};
|
tellme being:
Quote: |
void() tellme =
{
sound (other, CHAN_VOICE, "boss1/pain.wav", 1, ATTN_NONE);
};
|
Which does what I want it to; plays that sound 10 seconds after the player passes through the trigger. However, the weapon animation is all messed up, worse still if I set it to self.nextthink, self.think etc., rather than other...
Why does this happen, is it because the next.think is affecting the player, whether I set it to self, or other? _________________ my site |
|
Back to top |
|
 |
RenegadeC

Joined: 15 Oct 2004 Posts: 370 Location: The freezing hell; Canada
|
Posted: Tue Aug 23, 2005 5:23 pm Post subject: |
|
|
because you're messing with the players self.think by using "other".
You could simply spawn another entity once those 10 seconds are up to play the sound OR spawn the entity immediately, have it count to 10, then have it play the sound, then remove itself once the sound is finished playing.
Pros:
Simple, gets the job done
Cons:
Extra temporary entity in the game world, can be deadly for older quake engines if you're near the MAX entity limit.
Or,
define 2 variables.. "sound_on", and "sound_count".
If the player touches the trigger, sound_on becomes TRUE on the player, which then activates self.sound_count, which will count upwards. If sound_count > #, then play the sound, reset sound_count to 0, and self.sound_on to 0 also as to stop it from repeating.
Pros:
No messing with think times, no spawning additional entities (if you're really worried about that).
Cons:
You're increasing the # of variables on every entity. |
|
Back to top |
|
 |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Tue Aug 23, 2005 7:09 pm Post subject: |
|
|
Quote: | // ===================================================
// WSY . QC
// ===================================================
// =====================================
// wsy define stuff
// =====================================
float wsy_check = 0; //checks whether or not the counter is on or off
entity wsy_ent; //for timer
// =====================================
// temp stuff; for testing and the like
// =====================================
void() tellme =
{
sound (other, CHAN_VOICE, "boss1/pain.wav", 1, ATTN_NONE);
};
// ======================================================================
// wsy_counter_on and _off
// these turn the wsy counter on and off sent by trigger_wsy
// ======================================================================
void(vector org) wsy_counter_on =
{
wsy_check = 1;
wsy_ent = spawn ();
wsy_ent.origin = org;
wsy_ent.nextthink = time + 10;
wsy_ent.think = tellme;
};
void() wsy_counter_off =
{
wsy_check = 0;
};
// ======================================================================
// trigger_wsy
// ======================================================================
void() touch_wsy =
{
if (other.classname != "player")
return;
if (wsy_check == 0)
wsy_counter_on();
else if (wsy_check == 1)
wsy_counter_off();
};
void() trigger_wsy =
{
InitTrigger();
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_TRIGGER;
self.touch = touch_wsy;
}; |
Thanks Ren, I tried the above, but still the same. I'm missing something obvious aren't I?  _________________ my site |
|
Back to top |
|
 |
FrikaC Site Admin

Joined: 08 Oct 2004 Posts: 947
|
Posted: Tue Aug 23, 2005 7:12 pm Post subject: |
|
|
Or you could simply use the trigger's own think (make sure it's self.think and self.nextthink, If either of those are other, it will affect the entity touching the trigger).
There's also something Renegade forgot to mention, you're using "other" as the entity emitting the sound in the tellme function. In a think function, other is undefined (it could be anything, most probably world). That should probably be self. |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Tue Aug 23, 2005 7:47 pm Post subject: |
|
|
In wsy_counter_on, add 'wsy_ent.enemy = other;'
Then in tellme, change other to self.enemy
I'm not really sure why you want the sound the play from the player, but oh well  _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
RenegadeC

Joined: 15 Oct 2004 Posts: 370 Location: The freezing hell; Canada
|
Posted: Wed Aug 24, 2005 6:17 pm Post subject: |
|
|
FrikaC wrote: | Or you could simply use the trigger's own think (make sure it's self.think and self.nextthink, If either of those are other, it will affect the entity touching the trigger).
There's also something Renegade forgot to mention, you're using "other" as the entity emitting the sound in the tellme function. In a think function, other is undefined (it could be anything, most probably world). That should probably be self. |
D'oh, I so should of thought of that. *slaps forehead*
Also ajay, always define entity = spawn(); FIRST before changing any variables on it. You cannot change floats/strings on an entity before it exists. |
|
Back to top |
|
 |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Wed Aug 24, 2005 9:12 pm Post subject: |
|
|
Thanks for the tips, but I'm struggling, so I'm dragging myself back to the beginning.
So I want to have this trigger:
Quote: |
void() trigger_wsy =
{
InitTrigger();
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_TRIGGER;
self.touch = touch_wsy;
};
|
Which when triggered, does this:
Quote: |
void() touch_wsy =
{
if (other.classname != "player")
return;
if (wsy_check == 0)
wsy_counter_on();
else if (wsy_check == 1)
wsy_counter_off();
};
|
Checks that it's the player doing the triggering, then checks if it's been triggered already, the wsy_check variable. If it == 0, it goes to the turning it on function:
Quote: |
void(vector org) wsy_counter_on =
{
wsy_check = 1;
wsy_ent = spawn ();
wsy_ent.origin = org;
wsy_ent.nextthink = time + 10;
wsy_ent.think = tellme;
};
void() wsy_counter_off =
{
wsy_check = 0;
};
|
This sets the variable to 1, so that next time the player goes throught the trigger, it's set to "on", and will therefore go to the "off" function
Quote: |
void() wsy_counter_off =
{
wsy_check = 0;
};
|
It (the wsy_counter_on function) then does the waiting for 10 seconds, before setting off the sound bit. Now when I finally get all this business working, it will play a sound, but it'll also do some other stuff, at the moment the sound is just a test for me that it's working. But I'm ahed of myself, the problem that I mentioned is that the weapon animation gets all screwy, either as soon as the trigger is activated (my first attempt at the top of the thread), or when the timer bit reaches 10 seconds (the last example).
I've since tried setting the self.nextthink etc in the trigger's touch function:
Quote: |
void() touch_wsy =
{
if (other.classname != "player")
return;
self.nextthink = time + wsy_wait; // defined as 10 btw
self.think = wsy_counter;
};
|
wsy_counter being the function thats does an on/off check:
Quote: |
void() wsy_counter =
{
if (wsy_check == 0)
{
wsy_counter_on();//play the sound
}
else if (wsy_check == 1)
{
wsy_counter_off();//turn it off type stuff
}
};
|
But, although after 10 seconds the sound is triggered, and will be prevented if the player goes back through the trigger, the same animation problem exists.
Now the reason I write all this out again, is to just get myself organised and clear in what I'm trying to do, 'cos I'm confused, and realise I'm not getting exactly what I'm meant to be doing. I also think the solution is, like what I'm actually trying to acheive, pretty simple. I have hoped I'd just luck out getting it working, but I guess doing it because I understand it properly is probably better in the long run
Sorry for all this, but it's kinda fundemental to my whole mod type thing, and I do appreciate all the help.
ajay _________________ my site |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Fri Aug 26, 2005 7:06 am Post subject: |
|
|
Well, first of all. If the player were to simply stand inside the trigger, would it alternate wsy_check between 0 and 1 rapidly? It doesn't look like there's anything stopping it from waiting a little while between triggers.
It would help greatly if you told us what this entity was doing, because I see things that may be wrong, or may be completely right, depending on what you are actually trying to do. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
RenegadeC

Joined: 15 Oct 2004 Posts: 370 Location: The freezing hell; Canada
|
Posted: Fri Aug 26, 2005 11:06 pm Post subject: |
|
|
What Sajt said is correct, best way to correct that error is to either do one of the following:
A) Remove the trigger entity, remove(self);, SUB_Remove();
B) Set a boolean to 1 if it's touched then can no longer be touched if the boolean is 1
C) use a "time", like if (self.attack_finished > time) return;
good luck. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|