Jump to content

Photo

Help With RPG-Style Scripts


  • Please log in to reply
22 replies to this topic

#1 ywkls

ywkls

    Master

  • Members

Posted 07 November 2015 - 12:50 AM

I'm working in 2.5.1, creating my own tileset using Dance of Remembrance (Hybrid) as a base. My overall objective, is to create a form of action-RPG. (Like say, Secret of Mana.) To do this, requires a larger amount of scripting.
 
I've developed a system which works for switching character appearances and stats, though I haven't bothered to set up individual items and abilities yet. And I've created a script which sets up the HP and MP of each character to be randomly selected upon start and increase by a random amount when they level up.
 
My current trouble is translating damage between Link and the character. Perhaps some code would shed more light on this. I'm having to store it elsewhere, since the code is so long. This is a test quest, with the code in the buffer.
 
RPG Code Test Quest
 
I know that it is rather long and complex, but for the most part it works. The only thing which doesn't seem to function is the changes to the character's HP and MP. I can tell they're getting hurt (the sound is made) but the current HP doesn't alter.
 
Strange as it may sound, right now it appears that Link is never being hurt, even when he has four hearts and is being struck by a Death Knight. Since I don't manipulate Link->HP at any point this puzzles me.
 
This is obviously only the beginning of what will likely be a long and complex project, for which I will likely have many requests; so I'll probably place them all here. Right now, I'd be satisfied with making the character's actually take damage correctly.


Edited by ywkls, 07 November 2015 - 09:11 AM.


#2 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 07 November 2015 - 04:59 AM

I've just tried compiling your script into a test quest and it doesn't even compile. Function Start_HP_MP_Setup is undeclared. In your global init script you named it as Start_HP_MP_SetUp() but the actual function's name is Start_HP_SetUp(). Sorry I couldn't be more of a help right now.


  • ywkls likes this

#3 ywkls

ywkls

    Master

  • Members

Posted 07 November 2015 - 09:12 AM

@Avataro- Thanks for catching that bug. I'm changing the link to a test quest where it is running rather than the code so people can see what is happening, with the code in the buffer. To change party members, press Ex3 or Ex4.



#4 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 07 November 2015 - 11:17 AM

The problem isn't in your script file at all. You use Ring class items for the character costumes, and have the damage divisor on all of them set to 0, making Link completely invincible. You should set it to 1 instead.


  • ywkls likes this

#5 ywkls

ywkls

    Master

  • Members

Posted 07 November 2015 - 05:43 PM

@Lejes- Wow... that's a fact about rings I never knew... thanks!

 

I'll be continuing to work on this. Hopefully, I'll get somewhere without running into more problems that I completely didn't anticipate, like this one.



#6 ywkls

ywkls

    Master

  • Members

Posted 07 November 2015 - 10:31 PM

I've updated the test quest for anyone who wants to try it out and see how it works. Current set up is for a minimum of three party members, although I plan to have a total of six possible characters in the final version. (Just three at a time, to keep things from being too complicated.)

 

A little more tweaking was needed to get the damage transference working properly, but now it is. I haven't created animations for the characters when they're dead yet, or for one of the six possible characters at all. I also have yet to implement weapons or abilities. But progress is progress and this is a rather smoothly done piece of work, which I believe could be easily transferred to someone else's quest if they were interested in doing something similar.

 

I think that this may mean I am finally getting the hang of arrays...

 

My next objective will be to start coding some basic weapons and items scripts, using stdWeapons.zh as a starting point and tying them in to my existing code where you can't use an item or ability that uses MP if the character you're currently playing as doesn't have any MP. If anyone has ideas about what kinds to include, I'm open to suggestions.


Edited by ywkls, 07 November 2015 - 10:31 PM.


#7 ywkls

ywkls

    Master

  • Members

Posted 08 November 2015 - 04:24 PM

So, current problem can be basically explained as killing the party, then reviving them upon reloading the game.

 

I've updated the test quest to reflect the current code setup and even ran some Traces to try and discover what is causing this. As near as I can tell, while the array that determines if the character is dead seems to be set to the right value when their HP drops low enough, when enough characters die to trigger a game over; you aren't being really revived upon restarting. Though the HP is restored (I can see that in the frame after it loads) the sequence that triggers the Death code is still being run.

 

I can tell from the Traces that the second part of the code, where the HP is restored and the Character State is being set back to Alive is running. But for some reason, even though the first test seems to be invalid (Character State having been set to Is Alive rather than Is Dead) the whole thing is running anyways.

 

I know that code which handles manipulation of LInk's HP needs to go before Waitdraw() from previous experimentation, which is where this code resides. What I'm not sure of is why even though the value of Current HP is greater than zero when the code finishes running, it is even being triggered in the first place.

 

I've added some comments to explain how I think that it should be working.



#8 ywkls

ywkls

    Master

  • Members

Posted 09 November 2015 - 03:35 PM

For the moment I've decided to dispense with the idea of having to kill the whole party to get a game over, since nothing I do seems to be working. Instead, I'm making it where if any character in the party dies; you get a game over.

 

This means there will be no revival items or abilities (although I might have something like auto-life later on). Instead, if you want to heal you either have to use an item or ability. Some items/abilities will affect one character and others, the whole party. All party members will have access to consumable items, but it is my intent that the abilities you can use will depend on which party member you are playing as.

 

Thus, one character may not be low on HP but can still use items. (But not have a healing ability.) Another may be able to heal, when you run out of items. Since these abilities will require MP, we have MP-healing items too. And if you're out of them, you'll either have to buy/find more or locate a place to rest and heal. (Which will probably end up being a scripted inn.)

 

With that done (however haphazardly) I'm ready to move on to actually making items/abilities and switching them out depending on which character you're playing as.



#9 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 10 November 2015 - 12:57 AM

if you can wait until the end of the week, when I get back, I will ship over some code segments from RPG.zh that do this stuff.

Have you considered just joining that project as a contributor, instead of starting from scratch?
  • ywkls likes this

#10 ywkls

ywkls

    Master

  • Members

Posted 10 November 2015 - 10:04 AM

if you can wait until the end of the week, when I get back, I will ship over some code segments from RPG.zh that do this stuff.

Have you considered just joining that project as a contributor, instead of starting from scratch?

 

I can wait as long as you like. This is intended to be a long-term kind of thing.

 

As for joining a project, which one are you referring to? Legacy of Emperors, RPG.zh or something else?

 

Or are you offering to join my project? Either way, any help I can get to iron out difficulties that I encounter would be useful.

 

I have ideas for an 'enemy damage' and 'player damage' system which would allow a player to take more damage in a hit than Link would be able to absorb even with 24 Hearts and the Level 3-Ring. This would also allow enemies to have much higher levels of HP than is normally possible with the enemy editor.

 

Basically, I'd used one of the attributes in the enemy editor to define enemy HP and one to define enemy MP. When certain abilities were used, enemy MP would drop. When attacked, enemy HP would drop. If enemy HP reached zero, the script would then kill the enemy.

 

I'll probably get around to doing things like players stats with arrays and maybe even an elemental-type damage and resistance function, though if I do that I'll probably limit it to about four elements.

 

Thanks for the offer and I look forward to examining any contribution that you want to make.



#11 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 10 November 2015 - 12:16 PM

Link can have a lot more than 384 HP, even without scripting a new HP system. You just need to set a script counter to Link's HP every frame and put a counter element on the subscreen and/or draw whatever other representation of remaining health you want. Enemies can also have a lot more HP than you'd generally need: 32767. You could push that up to 214748 by using a virtual HP stat, or even further if you want to mess around with the logic of rolling it over across multiple ints. Unless you really need to break these number limits, though, you can safely use the default HP. It's possible to make modifications to it in real time. Just as one example, a hit that would normally kill an enemy or Link can be nulled with a defense stat. Scripts can hijack the damage process before ZC initiates enemy/player death, no problem.

 

For your enemy MP idea, would you be scripting every enemy for this? It's not actually possible to read when a default enemy is attacking. The best you can do is an approximation. Likewise for telling what attack Link/an enemy is hit by. The simplest solution for this that I know of is to simply turn off collision detection on all enemies and weapons. Then you can replace it with your own collisions and call whatever functions you want when they happen. The approach I went with was to handle all collisions with my own script. For special attack properties, I set a list of binary flags in one element of the weapon's Misc array, and if it hit anything, those flags would be copied directly to the target. The damage function would then read those flags and take appropriate action. The code I have for this is way too specialized for my own purposes to copy wholesale, but you can look through it if you want.


  • ywkls likes this

#12 ywkls

ywkls

    Master

  • Members

Posted 10 November 2015 - 01:34 PM

@Lejes- My current method of HP tracking is very similar to what you mention. Basically, any damage taken by Link is transferred to the counter, then Link's HP is restored to max. I already have the corresponding counter element set up and tested and it works great. (Except for the part that is supposed to wait until everyone in the party dies to kill you, then revive you all afterward.)

 

The method I envisioned for the Enemy HP system is a bit hard to explain, but I'll see if I can break iit down into fairly simple steps.

 

Step 1- All enemies are probably going to have to ghosted. That means no regular enemies and no regular enemy attacks. Since everything is handled by script, we don't even necessarily have to damage Link. (Just call for Link->Action to be LA_GOTHURTLAND and reduce the counter that tracks HP accordingly.)

Step 2- Nearly all weapons would probably be scripted too. Since Level and various other stats are being stored in global arrays, the enemy can detect what character is on screen, read the stats of that character from the array and calculate how much damage is done to the variable that is the actual HP. A simple way to do this is to use the command GhostGotHit. Then restore GhostHP to max afterward.

Step 3- Nearly every enemy attack uses up a set amount of the variable that tracks enemy MP. These would be semi-random and include some that don't use any. If enemy MP is zero, they can't use those attacks.

Step 4- When your attacks drop the variable tracking enemy HP to zero, they die.

 

For the character HP system, I imagine doing something similar; but in reverse. The trouble comes if there are multiple enemies onscreen. I'd probably have to assign unique Misc values to their eweapons, then have the character's code set up to detect collision with an eweapon and to read its Misc value and then determine how much damage to take.

 

This portion of the code is still in its infancy, really. At the moment, I've started on item and ability code. Here's a sample.

 

MP Ability Example

 

The ability itself doesn't do anything other than make a sound at this point, but I think that I can use stdWeapons.zh to handle this to a certain extent. When the enemy collides with the ffc generated, it would then run the code for being damaged.

 

But as I said, this is still just getting started.


Edited by ywkls, 10 November 2015 - 01:37 PM.


#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 12 November 2015 - 02:01 AM

Clarification:
RPG.zh is a header, that includes a ful RPG engine for ZC 2.5x+.

'Legacy of Emperors' is one game, that will use that engine.

I'm inviting you to contribute to RPG.zh, although if you want to work on any games that use it, that's also brilliant. I honestly don't want to work on multiple RPG script projects, nor do I think it is either prudent, or beneficial to have two massive, essentially competing packages in the works. That's both wasteful, in terms of resources, and it's potentially confusing, given the present community size.

It's better for anyone who wants to make such an engine to collaborate, which will make one, better product in the end, particularly given the present state of the project. (It's nearly ready for a 1.0 alpha.)

#14 ywkls

ywkls

    Master

  • Members

Posted 12 November 2015 - 11:42 AM

At present, my script for my project comes to about 31K of text. This is what it does so far...

 

1, Create HP/MP stats for all characters when the game is initiated. Uses semi-random function, so the characters won't have the same HP or MP if you start a new game. Sets value of four arrays  to track Current HP and MP and  Max HP and MP.

2. Track damage to the actual Link object. (Rather than using virtual damage. That's something which would have to come much later on.) Trace MP use. Reduce HP/MP of character onscreen accordingly.

3. If HP or MP lost would drop below zero, keep it from doing so. If Character's HP is zero, declare that character to be dead in an array. (Needs work.)

4. Draws Character combos on screen, changing them depending on the direction you're facing; whether you've moved and what action you.re performing.

5. Switch character who appears onscreen by pressing Ex3 or Ex4.

6. Uses items to track which characters are in the party.

7. Has Item scripts for items that heal HP or MP for one character and HP for the party. Makes sure HP or MP doesn't exceed previously determined Max.

 

I haven't really looked at Rpg.zh recently to see what it does and what might be redundant features that I've been creating. Mostly it has been a matter of thinking about what I want to do, then trying to figure out a way to do it.

 

I agree that creating two Rpg engines doesn't make much sense, but to be honest... half the time I don't have a clue what you're talking about. I often find your code (even when well commented) to be somewhat obscure in its intended purpose. And sometimes it seems as though you take the most complicated method possible to do simple things.

 

I have no problem contributing ideas to Rpg.zh or using some of them myself. That's one of the reason that I created this topic in the first place and placed a notice about it where I was fairly certain that you would see it. I just tend to go for the method that I feel would be the easiest rather than the most precise.

 

An example is what I envision for the script to handle damage to an enemy.

 

Virtual Enemy Damage

 

Any thoughts would be appreciated.



#15 grayswandir

grayswandir

    semi-genius

  • Members

Posted 12 November 2015 - 01:56 PM

For the character HP system, I imagine doing something similar; but in reverse. The trouble comes if there are multiple enemies onscreen. I'd probably have to assign unique Misc values to their eweapons, then have the character's code set up to detect collision with an eweapon and to read its Misc value and then determine how much damage to take.

I just wanted to pop in and mention I've gotten this working using the default collision detection by giving each weapon on screen a unique damage value as its id, and then looking up its actual damage in a table.


  • ywkls likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users