V3: Problem with creating RT battle system
Displaying 1-19 of 19 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
CrazyAznGamer

I'm new here, so I haven't any experience in programming with Verge. The past few days had been smooth sailing til I got to the battle system. I decided to try and make a Real-Time Battle system like the ones in the Star Ocean and Mana Series, coupled with a combo system. I was able to create a status screen by using HookRetrace(), but since I'm new to Verge, I wasn't sure how to use HookRetrace() to update controls, so I used HookTimer() for the controls. I made it so that whenever you pressed Enter, the system would call a user-defined function called DoAttack.

But to my point. After the function is called, the entity performing the attack would freeze. Right now, the attack function is as follows:

void DoAttack()
{
int combofr = 29;
int miss = 0;
while(combofr-29 < mastercast[choice].curcombo && !miss)
{
entity.specframe[curbatplaya] = combofr;
//Here, I would calculate damage.
miss = 1;
Render();
timer = 0;
While(timer<20)
{
UpdateControls();
EntityStop(curbatplaya);
}
If(lastpressed = SCAN_ENTER)
{
lastpressed = 0-1;
miss = 0;
}
combofr++;
}
entity.specframe[curbatplaya] = 0;
SetPlayer(curbatplaya);
Render();
}

Of course, you probably didn't need to know ALL of the above, and you probably noticed how inefficient my coding is, but please try and help.(And I'm not sure how to keep the tabs there, so if you can tell me that, I would appreciate it. Wait, never mind.)

As a side note: This is my first post here.

Posted on 2004-12-29 14:21:13 (last edited on 2004-12-29 14:27:10)

RageCage

verge updates controls automatically every showpage() and before it calls anything you've hookretraced. If I were you, I'd stay away from hooktimer, it just seems to be good practice. Okay, here's how I'd set up a rt battle sys.


void autoexec(){
hookRetrace('RTloop');
}

void RTloop(){
processAI();
renderEffects();
renderHUD();

switch(lastpressed){
case SCAN_A: doAttack();
case SCAN_S: doDefence();
case SCAN_D: doJump();
}
lastpressed=0;
}


hopefully it's self explainatory... does that help?

Posted on 2004-12-29 14:51:30

CrazyAznGamer

Yes, and no.
It helped clear up my code quite a bit, but it really didn't do anything for the problem. Maybe I should have stated my problem a little clearer.
Anyhow, my problem is that the entity performing the attack function freezes after its attack animation is complete(my attack function is up there in my first post).
But thanks for clearing up my code, at least.

Posted on 2004-12-29 16:48:17

RageCage

take it out of a hooktimer. If you ever use hooktimer, do not try to do any graphics. Also, if you have that being called in a retrace it will perform an infinite loop because render() will call the retrace again. And just for the record, you have to call showpage to update the monitor, render only blits the graphics into 'int screen'.

sooo... it could be the infinite loop that's screwing you up.

also, instead of resetting timer to 0, you should create a timeStamp variable unique to the doAttack function and set it to timer any time you would want to set timer to 0. This way, when you're checking if(timer > 20) you'd check if(timer-timeStamp > 20). This will help a lot you when you start stacking functions that use timer so that timer never gets reset without you realizing it.

Posted on 2004-12-29 18:53:17 (last edited on 2004-12-29 18:57:58)

Omni

I do not like the double condition While() loop. I was not sure whether or not Verge has support for those (apparently it didn't cause any obvious problems for you), but I wouldn't trust it.

Try this.

Instead of

while(combofr-29 < mastercast[choice].curcombo && !miss)


Use something like this:

int done;


while (done == 0)
{
if ((combofr - 29) < mastercast[choice].curcombo || miss == 0)
{
done = 1;
}

//...do a bunch of stuff

}


Verge handles If statements quite well, so try a loop system based on that, rather than dual condition While()s.

Posted on 2004-12-29 19:46:40 (last edited on 2004-12-29 19:47:31)

Beni

I assure you, verge supports nested while loops perfectly well.


int fa,fb,fac,fbc;

void func()
{
fa=0;
while(fa<10)
{
fa++; fac++; fb=0;
while(fb<10)
{
fb++; fbc++;
}
}
}

void autoexec()
{
int a,b,c,d,e;
int ac,bc,cc,dc,ec;
while(a<10)
{
a++; ac++; b=0;
while(b<10)
{
b++; bc++; c=0;
while(c<10)
{
c++; cc++; d=0;
while(d<10)
{
d++; dc++; e=0;
while(e<10)
{
e++; ec++;
func();
}
}
}
}
}
log('ac = ' + str(ac));
log('bc = ' + str(bc));
log('cc = ' + str(cc));
log('dc = ' + str(dc));
log('ec = ' + str(ec));
log('fac = ' + str(fac));
log('fbc = ' + str(fbc));
}


VC System Compilation stats:
4 ints (4 expanded), 0 strings (0 expanded), 3 functions, 48 total lines

ac = 10
bc = 100
cc = 1000
dc = 10000
ec = 100000
fac = 1000000
fbc = 10000000

Posted on 2004-12-30 06:57:44

anonymous

I did not mean nested While() loops. I meant ones with multiple conditions.

While I haven't tested it, I feel almost sure there is a specific difference between

while(blah && blah2)  { }


and

while(blah)  {

while(blah2) {
}
}


--Omni, sorry about the anonymousnessiosity

Posted on 2004-12-30 09:50:14

anonymous

EDIT: Although, it seems that you can use nested to achieve similar results.

In which case, I recommend that CrazyAznGamer try nested loops. I'm just saying I don't know how well Verge supports dual-condition While()s.

But maybe it does and I'm just ignorant.

--Omni again.

Posted on 2004-12-30 09:52:42

CrazyAznGamer

Well, I seem to have solved the problem, so thanks to RageCage. I also like to point out that the problem wasn't in the dual condition loops, which, after a little testing, I found that it works perfectly fine, at least for my purpose. However, after I was successful in removing the HookTimer, I found that Verge would keep calling the HookRetraced function even after it called the function called in the HookRetraced function(I really should reword that). So I would just like to point out that in order to DoAttack() successfully, you would have to 'unset' lastpressed at the beginning of the DoAttack() function.

Posted on 2004-12-30 10:49:13

anonymous

Oh...

Since you did figure it out, I think it's right, but...putting a Render() in a function that is HookRetraced() would keep called the HookRetraced() function, since Render() calls all Retraced functions again. I'll conclude that was the problem and I think it's what you meant to reword, right?

--Omni. ...again

Posted on 2004-12-30 11:28:10

anonymous

I really wish I could read more before I post anonymously. Sorry for bothering everybody with that.

--Omni

Posted on 2004-12-30 11:29:03

Kildorf

Also, just to throw my two cents in about multiple-condition while loops.

As near as I've been able to find out, while loop conditions are treated as if statements internally anyway. I discovered this after searching for the if statement (it told me it was an if statement problem) that was making it crash for a while, only to eventually discover the problem was in a while condition.

That said, multiple conditions works fine in loops or if statements, if you only use one type of logic. You can, for instance, have either of:
if(flag[0] && flag[1] && !party[0].dead)

if(plot[0] == 1 || plot[0] == 2 || party[1].dead)

but you will run into trouble mixing ands and ors:
if((won_battle || ran_battle) && !party[0].dead)

will break with a bizaare and unhelpful error. Being an obsessive fan of obscure boolean logic constructs, this saddens me to an extent that flimsy textual communications cannot convey.

All this works with while loops as well, as near as I can remember, because, as I said, the while condition seems to be evaluated as an if statement internally anyway (if I'm wrong on that, vecna can correct me and I'll need to go over my drug-use history carefully).

Posted on 2004-12-30 11:33:26

Gayo

vecna said he'd change this one day. But then, vecna says a lot of things.

Posted on 2004-12-30 23:34:32

CrazyAznGamer

Ahh... all is well with my RT battle system...
Except...I don't know where to improve it next. So I thought some AI would be GREAT, ya know. But, uhhh, I'm not sure how to make this work. I know where to put the AI if I can make the AI. <==That's the problem.
soo, how would you go about in making AI for a RT battle system?

Posted on 2005-01-10 21:16:58

gannon

well I would start simply. ie. try making a enemy that goes toward the player or a certain distance from the player while avoiding obstacles.
that could be one of the actions that an enemy could take.

Posted on 2005-01-10 21:32:39

zonker6666

I'm going to assume that you're not making a tactical battle in which you would need obstacle avoidance - and that you are working on something more like final fantasy.

So you gotta decide how the battle happens (as in an rpg system) ....

-- roll initiative
-- run Current unit's decision making function
-- perform the action
-- next turn

the decision making process would require the unit to look at itself - its friends and its enemies to decide ....


for example -

void CombatActions(int UnitID)
{
if(myHitPoints<myMaxHitPoints/2)
{
if(HasHealingPotion(UnitID))
{
DrinkHealingPotion(UnitID);
}
else if(HasHealingSpell(UnitID))
{
CastSpell('Heal', UnitID);
}
else if(ShouldEscape(UnitID))
{
Escape(UnitID);
}
else
{
PerformAttack(UnitID, SelectTarget(UnitID));
}
}
else
{
if(ShouldEscape(UnitID))
{
Escape(UnitID);
}
else
{
PerformAttack(UnitID, SelectTarget(UnitID));
}

}

}


//// hope that gives you some ideas

Posted on 2005-01-11 15:23:58

zonker6666

There is a lot more decisions to make than the ones i put in there of course ----- things like
DoMyFriendsNeedHealing() ?
DoINeedAntidote() ?
ShouldICastDispellMagic() ?

-----

When determining which enemy to select as a target the units own capabilities should be taken into account so that he chooses a well matched opponent- We wouldnt want the Black Mage rushing the barbarian when he really should be casting mute on the white mage ;)

Posted on 2005-01-11 15:55:04 (last edited on 2005-01-11 15:59:20)

anonymous

It's me, CrazyAznGamer. Too lazy to login.

Anyways, I know multiple Rs in renderstring is suppose to be for multiple HookRetraces, but I'm not sure where exactly to put the HookRetraces. The manual says 'at the end of each function'...but its worded vaguely and I'm not sure which function it's talking about.

So yeah. That's it.

Posted on 2005-01-14 20:18:27

RageCage

You want to put the rensderstring right after or right before your entity layer on your map. Generally you'd want it right after but I can think of a few reasons you might find it handy to be before.

then! you can use this or just look at what it does. It shouldent be too hard to figure out so I'll leave it there.

Posted on 2005-01-15 09:44:17 (last edited on 2005-01-15 09:44:48)


Displaying 1-19 of 19 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.