Home   Help Search Login Register  

Author Topic: Need help with: while{ (code) AND ((code) AND variable) AND (code) }do  (Read 1382 times)

0 Members and 1 Guest are viewing this topic.

Offline andersson

  • Members
  • *
  • I'm a llama!
Hi, need some help with a line of code.

I want to have 3 possible endings on a mission;
1 - 90% of the enemies are killed.
2 - 50% of all enemies are killed + a zone is empty of enemies.
3 - Out of time.

_enemy_count is a variable that counts the total enemies (random number of enemies spawned)
_10percent is 10% of _enemy_count
_50percent is 50% of _enemy_count
YES_enemies is default true until a trigger detects no enemies, then its YES_enemies = false
_curr_time is start time
_time_limit is set at 30

Code: [Select]
while{ ( _enemy_count > _10percent) AND ((_enemy_count > _50percent) AND YES_enemies) AND ((Time-_curr_time)<(_time_limit*60)) }do
The _Xpercent and time works just fine. Its the middle part I struggle with:
Code: [Select]
((_enemy_count > _50percent) AND YES_enemies)(_enemy_count > _50percent) for itself works just fine, when I have killed 50% the mission ends.
YES_enemies works just fine too. If I move away the trigger so no enemies are inside it the mission ends.

My problem is how to combine the two; (_enemy_count > _50percent) AND YES_enemies

I see no wrong with my line but right now its enough to kill 50% OR to have the YES_enemies as false. I need both at the same time.

Its probably something really easy, but I cant see it. Tried some variations but no...

Offline i0n0s

  • Moderator
  • *****
Interesting approach.
Normally a condition should get true if a victory condition is reached.

Code: [Select]
((_enemy_count > _50percent) OR YES_enemies)will do your job since it will get false when both conditions are false.

Offline andersson

  • Members
  • *
  • I'm a llama!
I see.. I will try that.

I was to "verbal" when reading the code :D

Thank you :)