IF Hater Club: Replace The Code

Non-platform specific questions.

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Sun Oct 04, 2009 12:50 pm

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,
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Sun Oct 04, 2009 4:13 pm

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?
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Sun Oct 04, 2009 6:20 pm

viewtopic.php?f=5&t=7376&p=52354#p52354
Mission IF disposal complete :D
Thanks to Fuzzy ;)
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Fuzzy » Mon Oct 05, 2009 11:41 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Mon Oct 05, 2009 4:37 pm

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)
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Fuzzy » Tue Oct 06, 2009 10:22 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Tue Oct 06, 2009 1:21 pm

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 :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Tue Oct 06, 2009 4:23 pm

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 :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Fuzzy » Wed Oct 07, 2009 7:00 am

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 :D



That seems better. I think I misunderstood what you were doing.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Wed Oct 07, 2009 8:48 am

Have fixed the without IF version
Code: Select all
char str[15];
first=(p2speed>p1speed)+1;
sprintf(str,"p%iattack",first);
CreateTimer(str);

:D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Fuzzy » Wed Oct 07, 2009 9:17 am

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?
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Wed Oct 07, 2009 3:01 pm

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 :D

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? :wink:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Wed Oct 07, 2009 4:21 pm

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? :D
THERE MUST BE A WAY !!!
Although isn't concise yet...
But I will come up with a better code ;)
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: IF Hater Club: Replace The Code

Postby DST » Thu Oct 08, 2009 11:09 pm

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: IF Hater Club: Replace The Code

Postby Bee-Ant » Fri Oct 09, 2009 3:10 am

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.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron