|
1 registered members (TipmyPip),
5,468
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Wait() problem
[Re: romin2011]
#355343
01/26/11 17:11
01/26/11 17:11
|
Joined: Jan 2011
Posts: 797 Da wo du nicht bist! Muhahaha!
xxxxxxx
User
|
User
Joined: Jan 2011
Posts: 797
Da wo du nicht bist! Muhahaha!
|
wait(-integer(random(9)) + 1); maby should fix that sorry for my english
mfg xxxxxxx
Last edited by xxxxxxx; 01/26/11 17:12.
Es ist immer wieder erstaunlich, dass Leute die riesen Scripte schreiben die einfachsten sachen nicht können zb. mich mit SIEBEN x zu schreiben!
|
|
|
Re: Wait() problem
[Re: romin2011]
#355348
01/26/11 17:28
01/26/11 17:28
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Hello, my enemy comes out of cover after random seconds wait(-integer(random(10))). But wait stops the whole function animation etc for that amount of time. Congratulations, you just discovered what wait does. How should it know that the only thing you want is to preserve the current state but nothing else? The solution: Wait only one frame but check every time if the 10 seconds have already passed, then trigger the state change of the ENTITY
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Wait() problem
[Re: WretchedSid]
#355349
01/26/11 17:35
01/26/11 17:35
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
The solution: Wait only one frame but check every time if the 10 seconds have already passed, then trigger the state change of the ENTITY To accomplish that increase an arbitrary skill, f.i. skill10 by time_step. my.skill10 += time_step; Every second my.skill10 will increase by 16 (because the engine time scale is "ticks"). That means if your skill is above 160, 10 seconds have passed: if(my.skill10 > 160) { get out of cover } Alternatively, you could increase by 1/16*time_step per frame and my.skill10 will equal to the seconds that have passed (it could be better to use time_frame instead).
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Wait() problem
[Re: WretchedSid]
#355354
01/26/11 17:38
01/26/11 17:38
|
Joined: Jan 2011
Posts: 120 United States
Logan
Member
|
Member
Joined: Jan 2011
Posts: 120
United States
|
Or, move the other behaviors you want to keep going to other functions. I.e.: You probably have:
function enemy() {
... your animation code here ...
... some other stuff here ...
wait(-integer(random(10))); // so this stops everything that this function is doing
}
Try moving your animation code and your other code to other functions, and the engine's multitasking should kick in.
function enemy_animate()
{
...your animation code here...
}
function enemy_otherstuff()
{
...other code here...
}
function enemy() {
enemy_animate();
enemy_otherstuff();
wait(-integer(random(10))); // now I'm pretty sure the other functions will continue to run
}
Give it a try?
|
|
|
Key ignore
[Re: Logan]
#355363
01/26/11 17:56
01/26/11 17:56
|
Joined: Dec 2010
Posts: 87
romin2011
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2010
Posts: 87
|
Thank you superku very much you have always better solutions and very helpful. But i got another problem. how to ignore a key once it is pressed. I mean once you pressed the key_space it should continue the function ignoring if u kept space key pressed? While(key_space)wait(1); will simply not run the func till u release it. Thanl you
Last edited by romin2011; 01/26/11 18:07.
|
|
|
Re: Key ignore
[Re: romin2011]
#355369
01/26/11 18:11
01/26/11 18:11
|
Joined: Dec 2010
Posts: 87
romin2011
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2010
Posts: 87
|
|
|
|
Re: Key ignore
[Re: Superku]
#355453
01/27/11 07:27
01/27/11 07:27
|
Joined: Oct 2002
Posts: 2,256 Oz
Locoweed
Expert
|
Expert
Joined: Oct 2002
Posts: 2,256
Oz
|
It's not as hard as you think, but takes too long to explain, create a variable/skill to handle it, use like wait(-time) in a function that changes the variable/skill.
Professional A8.30 Spoils of War - East Coast Games
|
|
|
Re: Key ignore
[Re: Locoweed]
#355454
01/27/11 07:29
01/27/11 07:29
|
Joined: Oct 2002
Posts: 2,256 Oz
Locoweed
Expert
|
Expert
Joined: Oct 2002
Posts: 2,256
Oz
|
Bad example, I know. Hard to explain.
Professional A8.30 Spoils of War - East Coast Games
|
|
|
|