Page 3 of 5
Re: IF Hater Club: Replace The Code

Posted:
Sun Oct 04, 2009 12:50 pm
by Bee-Ant
Both line in a single code. Hehe,I think round() does it.
Ahh,its pretty embarasing...almost 3 years messing with GE yet know about round just now,
Re: IF Hater Club: Replace The Code

Posted:
Sun Oct 04, 2009 4:13 pm
by Bee-Ant
What if :
- Code: Select all
if(p1speed<p2speed)//CreateTimer(p2 move attack)
if(p1speed>p2speed)//CreateTimer(p1 move attack)
if(p1speed==p2speed)//decide who will attack first randomly
How do I replace those IFs?
Re: IF Hater Club: Replace The Code

Posted:
Sun Oct 04, 2009 6:20 pm
by Bee-Ant
viewtopic.php?f=5&t=7376&p=52354#p52354Mission IF disposal complete

Thanks to Fuzzy

Re: IF Hater Club: Replace The Code

Posted:
Mon Oct 05, 2009 11:41 am
by Fuzzy
I have a question.
do you do that once at the beginning of the battle, or every time before the hero attacks?
I mean,
decide, p1 attack, p2 attack, p1 attack....
or can it be p1, p1, p2, p1....
?
This will help me to optimise the code.
Re: IF Hater Club: Replace The Code

Posted:
Mon Oct 05, 2009 4:37 pm
by Bee-Ant
Both player (p1 and p2) can only do attack once each turn. So before the battle started, it always need to be checked who has the higher speed to attack first.
Heres the timer phase if p1 have higher speed:
-battle start
-p1 action text
-p1 action do
-p1 action end
-p2 action text
-p2 action do
-p2 action end
-battle end
-return to battle menu
*text: show what action he take by text
*do: do the action, attacking or blocking
*end: end the action and switch to the lower speed or end the battle. in this phase do the damage calculation also if the player take an attack action
*battle menu: where you choose what action you will take, open your pocket, party,run etc...
How long the switch time for each timer based on the length of the text shown...(I can do this myself)
Re: IF Hater Club: Replace The Code

Posted:
Tue Oct 06, 2009 10:22 am
by Fuzzy
So speed doesnt change during the battle. Or if it does, it doesnt change order of attack.
I would have a variable called first.
- Code: Select all
first = (p1.speed > p2.speed);
then i would say
- Code: Select all
if (first > 1) { set p1 timer}
set p2 timer
first = 1;
this way, first will set the p1 timer if p1 is faster. if not, he gets skipped. regardless, p2 timer is set and first is set to 1 so that next turn, p1 gets to attack.
Re: IF Hater Club: Replace The Code

Posted:
Tue Oct 06, 2009 1:21 pm
by Bee-Ant
The speed doesnt change during a battle. It will change after the battle is finished if some player used an attack that lower or higher the speed. This is done to avoid attack order changing during a battle.
Lets see...
If first is more than 1, p2 timer still occur right?afterall theres no condition to set it or not. Also, although you set first to 1 in the end line, it wont set p1 timer next turn...because its requirement is if first more than 1,not equal 1.
Well, thats how my logic say...but dunno with the reality. I'll give it a try

Re: IF Hater Club: Replace The Code

Posted:
Tue Oct 06, 2009 4:23 pm
by Bee-Ant
Hmm...just as I thought...
But have corrected
- Code: Select all
set p2 timer
if(first>0){set p1 timer; destroy p2 timer;}
first=1;
Thanks

Re: IF Hater Club: Replace The Code

Posted:
Wed Oct 07, 2009 7:00 am
by Fuzzy
Bee-Ant wrote:Hmm...just as I thought...
But have corrected
- Code: Select all
set p2 timer
if(first>0){set p1 timer; destroy p2 timer;}
first=1;
Thanks

That seems better. I think I misunderstood what you were doing.
Re: IF Hater Club: Replace The Code

Posted:
Wed Oct 07, 2009 8:48 am
by Bee-Ant
Have fixed the without IF version
- Code: Select all
char str[15];
first=(p2speed>p1speed)+1;
sprintf(str,"p%iattack",first);
CreateTimer(str);

Re: IF Hater Club: Replace The Code

Posted:
Wed Oct 07, 2009 9:17 am
by Fuzzy
Excellent work! That is very concise code.
How would you do it if you had 3 or more attackers?
Do you think you could do a whole game with no IF? Not WB, but some other game in the future?
Re: IF Hater Club: Replace The Code

Posted:
Wed Oct 07, 2009 3:01 pm
by Bee-Ant
Fuzzy wrote:Excellent work! That is very concise code.
You already know this way, but you let me find it myself then praise me...excellent work to trigger someone

Fuzzy wrote:How would you do it if you had 3 or more attackers?
Do you think you could do a whole game with no IF? Not WB, but some other game in the future?
Hmph hmph hmph...you bet?

Re: IF Hater Club: Replace The Code

Posted:
Wed Oct 07, 2009 4:21 pm
by Bee-Ant
Well, I come just to prove that I'M CAPABLE of doing it...
A little long...
There're 4 attackers.
I use array to declare each player speed
- Code: Select all
int speed[4];
speed[0] as p1speed
speed[1] as p2speed
etc...
Long before the battle started, check the attack order by timers
- Code: Select all
for(i=0;i<4;i++)
{
sprintf(str,"p%order",i+1);
CreateTimer(str,1000/spd[i] ms);
}
Timer->p1order:
- Code: Select all
order[current_order]=1;
current_order++;
Timer->p2order:
- Code: Select all
order[current_order]=2;
current_order++;
Timer->p3order:
- Code: Select all
order[current_order]=3;
current_order++;
Timer->p4order:
- Code: Select all
order[current_order]=4;
current_order++;
Then, when the battle is about to start:
- Code: Select all
sprintf(str,"p%iattack",order[current_attacker]);
CreateTimer(str);
current_attacker++;
Well done huh?

THERE MUST BE A WAY !!!
Although isn't concise yet...
But I will come up with a better code

Re: IF Hater Club: Replace The Code

Posted:
Thu Oct 08, 2009 11:09 pm
by DST
now its time for using Actor*.
You have a timer in each actor, but its better to access them directly, from a global script, rather than sending a timer to 4 different locations (if i read your script correctly).
Instead of sending timer and having the actors enable/disable, you should directly change their attributes from a remote function. Though i must admit, i don't really understand how to handle actor*, so i'm not sure what proper way is.
Re: IF Hater Club: Replace The Code

Posted:
Fri Oct 09, 2009 3:10 am
by Bee-Ant
DST wrote:rather than sending a timer to 4 different locations (if i read your script correctly)
Incorrect...
The operator is view actor. So I dont send any timer to any player, except their action timer. Beside, their action are limited in 3 secs before the view move to the next attack order.