View Full Version : how to STOP a timer??
bloodymax
03-15-2004, 11:50 AM
hi...
i have a subanimation (hands up) which i have to start every time it stops so i set up a timer but i want that after a special event he takes his hands down! how do i program that? or better said how to stop a timer
p.s. i programed the timer following: on end timer its starts new ^^
on end timer:
this->AI_EnablePerceiving(false);
this->ai_pushcommand(stand, nothing, "");
this->ai_pushcommand(subanimate, nothing, sub_hands_up);
this->fsm_starttimer(timer_0);
thanks for answers
bloodymax
Joonas
03-15-2004, 12:17 PM
When you are typing in the FSM et cetera -command... MaxED2 opens a DROP-DOWN LIST! http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif
... wow. That's so fascinating. http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif
Then you are supposed to use the muscles next to your eye balls to rotate the two eyes in your head so that your sight is aimed lower. Keep doing that. and soon you will notice a line that says "FSM_PauseTimer".
Now, guess what is the right command.
http://forums.3drealms.com/ubbthreads/images/graemlins/rolleyes.gif
... or shall I just answer your question?
Kozak
03-15-2004, 12:19 PM
Don't forget you can use your neck muscles for that aswell.
bloodymax
03-15-2004, 03:03 PM
When you are typing in the FSM et cetera -command... MaxED2 opens a DROP-DOWN LIST! http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif
... wow. That's so fascinating. http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif
Then you are supposed to use the muscles next to your eye balls to rotate the two eyes in your head so that your sight is aimed lower. Keep doing that. and soon you will notice a line that says "FSM_PauseTimer".
Now, guess what is the right command.
http://forums.3drealms.com/ubbthreads/images/graemlins/rolleyes.gif
... or shall I just answer your question?
hey was busy and just thought: hey who could help me in short time.... but of coz master joonas is so helpful and arrogantly at the same time... thats the reaon why i never sent you apm and will never do.. you may a good mapper and so on but on your human side i could talk to a wall as well...
i didnt study the remedian fsm msg and you know why? they dont tell you the truth for example add command is useless if the perceiving is on! so may pause timer isnt the right cmd..
but ok the next time i will study the tuts at first master joonas... why dont you just stopping replying on my threads? i would save me some nervs...
thank you
MrUniq
03-15-2004, 05:16 PM
the name of the fsm may confuse people....pause means to temporarily stop. but remedy does state to turn pierceving off when u want to exectute script stacks http://forums.3drealms.com/ubbthreads/images/graemlins/wink.gif
I look in messages.txt to see them all. But i looked at some of remedy's prefabs and it looks like they "may" have more functions/directives than initially stated. Like there was "disable" listed in an fsm_send i think....but didn't see any states or aniimations named disable.
and using ## to comment fsm's.
Ghast
03-15-2004, 09:16 PM
I believe disable is to prevent a trigger repeating, but yes there is quite a learning curve, and sometimes overly complex or quirky workarounds have been posted, when many modders would really appreciate some simple suggestions to explore?
I am looking forward to reading more about the uses of character meshes? and (boo1) instead of (true or false)???
Oh and subanimations!
MrUniq
03-15-2004, 10:27 PM
If I could learn that disable and how it works it'd simplify my fsms in my level. I'm gonna try to study some of remedys' prefabs.
Ghast
03-15-2004, 10:44 PM
this->T_Enable(false);
Disables this trigger once it's been activated, so that we don't get a loop once the animation is finished!
from kipsta
I used disable to keep a fsm from being triggered later in a level in case it had been missed being triggered earlier and it wasn't appropraite to be triggered later?
Which prefabs are you working with? the water cooler in the prefab level isn't the same as the game version, I suspect others may be a little iffy too?
theHunted
03-16-2004, 12:45 AM
are you talking about the 'disable' as a seperate part in the Custom Events area of the FSM dialog? all those are customly defined 'triggers' in a way. you add them (right click custom events -> add custom event handler) and then you can add custom FSM code into it. like ::enemyXYZ->C_Hide(true); or whatever. now you can trigger this whole thing as follows:
::DO->FSM_Send(disable);
note that DO is the DO where you have add the custom event, and disable is the name of the event you gave.
whats the use for it? well, in combination with states you can do something similar do 'if' statements, or dependancies if you wanna call em like that. how? try to add 2 states to the same DO, say '1' and '2'. if you look back at the 'disable' custom event you can now see 2 new areas where you can write your code. 1 below '%%1' and another one below '%%2'. so let's move the piece of code we have written before
[::enemyXYZ->C_Hide(true);] right below the '%%2' section (just cut an paste the text). now whenever you do send the ::DO->FSM_Send(disable); message it'll perform the C_Hide thing only if the DO is actually in state 2. and switching states can be done with the command
::DO->FSM_Switch(state_it_has);
for example you could do that fsm_switch from the on_death tab of some enemy, and the fsm_send from the on_death tab of another enemy.
guess pointing you to a deathcounter tutorial would've been smarter, but i hope this was of a little help.
whats important are the 2 messages
FSM_Send();
FSM_Switch();
and btw, random quotage from the official remedy tutorials:
AI_EnablePerceiving( true/false );
This is a very important message. The character scripting works so that the enemies will stop their scripting as soon as they perceive their target. So in the cases where you want a character to perform a script without interruptions, you must disable the sensory systems of the character. You can do this by using the before mentioned AI_EnableHearing / Seeing / Feeling -messages, but in most cases it is far easier to use the special command AI_EnablePerceiving( false );, which blocks all the sensory systems regardless of their state, for the period of the scripting. When the AI returns to the tactic behavior, AI_EnablePerceiving automatically returns to true, and the sensory systems behave like they did before.
pushcommand seems to be what most beginners use these days. it's kinda sloppy for my personal taste. while it's needed for certain things (interrupting currently running animations), ai_addcommand should be what you want to use mainly. otherwise you'll always have to manually push from all kinds of triggers and timers to get more complex scripts done, where instead you could've just stacked a punch of commands using the AI_Addcommand code.
MrUniq
03-16-2004, 01:21 AM
I used push and the enemy never stoped the script. But yea those states within states is tricky. OK...question. I want an event to happen ONLY when a specific number of enemies die...like max has to clear out the room before he can move on. But I have no idea how to do this because it seems like there is no way to count or keep track of that. My solution was just to make an enemy lag far behind. But if the player catches on all they have to do is kill that one guy to move on.
Uisor
03-16-2004, 07:17 AM
I don't think if it's right way to do, but this is what I did:
1st. Make few states for FSM or DO, if you have 2 enemies then make 3 states.
2nd. Make 3 states for each enemy.
3. Now in enemies OnDeath tab you can see all these states. Add line "::roomXYZ::FSMZYX->FSM_Switch(stateXYZ); to 2 states. So it looks like this:
State_0
"::roomXYZ::FSMZYX->FSM_Switch(state_1);
State_1
"::roomXYZ::FSMZYX->FSM_Switch(state_2);
4. Then you'll have to add following messages to FSM's state tab:
::roomXYZ::enemy_XYZ->FSM_Switch(state_XYZ);
So it looks like this:
State_1
::roomXYZ::enemy_1->FSM_Switch(state_1);
::roomXYZ::enemy_2->FSM_Switch(state_1);
5. Now that all enemies are killed and FSM's state is changed to state_2 then you add your event to that state tab.
That was kind of a mess, but hopefully it helps.
Kozak
03-16-2004, 09:22 AM
Yup it should be done like that ( after looking on it quickly)
Joonas
03-16-2004, 10:45 AM
When you are typing in the FSM et cetera -command... MaxED2 opens a DROP-DOWN LIST! http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif
... wow. That's so fascinating. http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif
Then you are supposed to use the muscles next to your eye balls to rotate the two eyes in your head so that your sight is aimed lower. Keep doing that. and soon you will notice a line that says "FSM_PauseTimer".
Now, guess what is the right command.
http://forums.3drealms.com/ubbthreads/images/graemlins/rolleyes.gif
... or shall I just answer your question?
hey was busy and just thought: hey who could help me in short time.... but of coz master joonas is so helpful and arrogantly at the same time... thats the reaon why i never sent you apm and will never do.. you may a good mapper and so on but on your human side i could talk to a wall as well...
i didnt study the remedian fsm msg and you know why? they dont tell you the truth for example add command is useless if the perceiving is on! so may pause timer isnt the right cmd..
but ok the next time i will study the tuts at first master joonas... why dont you just stopping replying on my threads? i would save me some nervs...
thank you
I suck at mapping and you were supposed to laugh at that form of tutoring.
theHunted
03-16-2004, 02:00 PM
I don't think if it's right way to do, but this is what I did:
1st. Make few states for FSM or DO, if you have 2 enemies then make 3 states
....
That was kind of a mess, but hopefully it helps.
it does look really messy indeed :P. i unfortunately don't have links to kipstas tutorials but i recall that he did a death-counter/death-cam tutorial. if anybody got the link to kipstas tutorials please feel free to post it. until then i'm gonna try to explain what uisor did, with his lines of code, in words and as clean as possible. and btw death-counters like that are just the perfect example for the use of fsm code. anyway lets get started.
say we have 3 enemies in a room, and you want to open a door once all 3 enemies are dead.
so you start out placing a 'fsm' from the entity drop down list. that's gonna be your death counter. so now you're gonna add as many states to this fsm as there are enemies. 3 in this case. i usually call those states '1', '2' and '3'. additionally you'll want to add a custom event handler and call it something like 'kill'.
now let's interrupt it at that point. for every enemie's on_death tab you now simply add the single line '::roomXYZ::death_counter->FSM_Send(kill);'. just add that line to each enemie's on_death tab.
now let'S continue at the fsm. what do we got? we know that we should receive the custom event handler message 'kill' 3 times, and that's exactly where we're gonna do the complete coding part. at the event handler's fsm code category. what do we want? for the first states we just want to switch the states to a higher one. at the '%%1' section we want to switch to state 2 as soon as the 'kill' message gets called. so we add 'this->FSM_Switch(2);' right there. almost identically we do for area '%%2', only this time we switch to state 3. now this is where the fun starts. if we are in state 3 we know that 2 enemies have died already (the custom handler 'kill' got sent 2 times from 2 on_death tabs, switching the fsm states from 1 to 2, and from 2 to 3). so the next time we receive the 'kill' message we know that all enemies are dead. so what to do? simeple, just add the lines of code you wanna perform after the last enemy died (open a door for example), to the '%%3' section of the custom event handler 'kill'. and that's it.
i think it's crutial to understand how the system works. custom event handlers are a little bit similar to function in software development (like c++). you can call them and they can perform stuff. in combination with states you can squeeze out even more functionality.
this example should work for you uniq. it wouldn't suffice for death-cams that circle around the last killed enemy. for that you'll additionally need not only one custom event handler but as many as there are enemies. but i'm nt gonna go into detail how to do that. somebody please browse through kipsta's tutorials first. i think there should be a death-cam tutorial.
Uisor
03-16-2004, 02:35 PM
Well that was same as I told, but you said it better http://forums.3drealms.com/ubbthreads/images/graemlins/grin.gif
MrUniq
03-16-2004, 04:32 PM
thanks i'll practice this since it's essential to what i have planned for future levels. I'm an experienced programmer(5 yrs) and I still had trouble grasping those fsm's.
theHunted
03-17-2004, 01:05 AM
think of custom event handlers as functions then. you can call them from outside (as well as inside) using ...->FSM_Send(); and they can perform your code if they are called. and states could be seen as (very restricted) helper variables. once you figured that out it's easy to understand and create new and more powerful scripts.
oh, and Uisor, somehow your example reminded me of this:
http://www.rockstargames.com/maxpayne/tutorials/MaxED/images/fsm_structure_incorrect.jpg
http://forums.3drealms.com/ubbthreads/images/graemlins/tongue.gif
and i hope my description has been somewhat like that:
http://www.rockstargames.com/maxpayne/tutorials/MaxED/images/fsm_structure_correct.jpg
http://forums.3drealms.com/ubbthreads/images/graemlins/hhg.gif
Uisor
03-17-2004, 08:44 AM
http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif. Could look like that, I was pretty tired when writing it, but when I made mine it was like correct structure AFAIK.
But lets not arque with this, both ways work, but your is more clearly explayned and done.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.