Jump to content

  • Log In with Google      Sign In   
  • Create Account

Attack Scripting?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Silverain Development   Members   -  Reputation: 166

Like
0Likes
Like

Posted 14 June 2012 - 08:54 AM

Hello, I am working on a Turn based Strategy rpg, and one of the issues that I'm having is that In the projects that I've worked on in the past, I have primarily hardcoded almost everything. Now I'm working on making an engine for this game that contains no game specific data, and I'm currently discussing with the other developer about how to implement special attacks and spells, so that we can be more flexible and allow players to modify the game if they wish.

Our first idea was to just read from one of our data files basic information, such as the energy cost of the attack, the AOE, the range,what animation the user should do, what attack animation should hit the target, the damage done (negative for healing), accuracy, and what buffs/debuffs to affect the target on hit.

However, we plan on having a good deal of our skills be a bit more complex than that would be able to handle. But we're at a loss at how to implement a scripting system that would be able to handle more interesting attacks (something like Chain Lightning, or summoning reinforcements for example)

I've heard that LUA might work for this, but we'd prefer to roll our own scripting system out. If someone has experience in this, or can link a relevant article/tutorial about this, I would be grateful. Thanks!

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2645

Like
4Likes
Like

Posted 14 June 2012 - 09:24 AM

I dont think you should make your own scripting language unless its purely for learning purposes, or if its a very simple one (where you call a few predefined functions in different orders or with different values). But if you need to do any logic or have more complex structures in the scripting language just use Lua or something.

o3o


#3 FLeBlanc   Crossbones+   -  Reputation: 3125

Like
4Likes
Like

Posted 14 June 2012 - 09:32 AM

Yeah, don't roll your own. If you're in this to make a game, why would you waste time writing a language instead? They're complex, and perfecting them is a lengthy process. Lua is lightweight, robust, well-tested and under very active support and development. Not to mention easy as balls to use.

#4 Explodinator   Members   -  Reputation: 119

Like
1Likes
Like

Posted 14 June 2012 - 12:44 PM

LUA does the job fine.

If you absolutely must define your own language, I suggest reading up on parsing: http://en.wikipedia.org/wiki/Parsing
Then, you can make your own pseudo-language that is simply used for your game and therefore easily usable:

Filename: ChainLightning.spell

"Chain Lightning"
required $caster $power $cost
decrease MANA of $caster by $cost
select $a in range(4,$caster)
select $b in range(1,$a)
select $c in range(1,$b)
damage $a by $power
damage $b by [$power/2]
damage $c by [$power/4]

This type of language is easily parsable and readable by the average non-programmer. The disadvantage is the strictness of the syntax and lack of power, obviously.

#5 Silverain Development   Members   -  Reputation: 166

Like
0Likes
Like

Posted 14 June 2012 - 01:07 PM

I suggest reading up on parsing: http://en.wikipedia.org/wiki/Parsing
Then, you can make your own pseudo-language that is simply used for your game and therefore easily usable:


This is exactly what we had originally planned, and still might do if we don't decide to work with Lua;

The only problem we're having is deciding how we'd handle more complex abilities, for example:

(Note that Targetting is already handled seperately, assume a legitimate target)
// Chain Lightning Pseudocode

ChainLightning.effect(Attacker,Target){

	 Attacker.state = ("Casting")
	 Draw lightning from the Attacker's sprite to the Target's sprite
	 Target.state = ("Hurt")
	 Target takes (Attacker.Intellect / Target.Lightning_Resist) damage
	 Target.Hit = True
	 show the damage done on the screen, over the target's head

	 while(Target is not null)
	 {
	 	 OldTarget = Target
	 	 Target = NULL
	 	 check tiles within 2 spaces of target
	 	 if(tile contains a unit that is hostile to the attacker and has not previously been hit){
	 	 	 Target = found unit
	 	 	 Target takes (Attacker.Intellect / Target.Lightning_Resist) damage
	 	 	 Target.Hit = True
	 	 	 Target.state = ("Hurt")
	 	 	 show the damage done on the screen, over the target's head
	 	 }
	 }

}

The problem is that doing very linear and simple spells will be incredibly easy, but anything that requires looping or other special effects will be hard.

#6 FLeBlanc   Crossbones+   -  Reputation: 3125

Like
1Likes
Like

Posted 14 June 2012 - 01:26 PM

Well, first off you wouldn't want your chain lightning effect script to actually handle drawing the lightning bolt. That responsibility belongs elsewhere (in the rendering system, however that is structured). The script would merely have access to functionality that would allow the spawning of effects.

Second, the chain lightning effect script shouldn't have the responsibility of displaying combat floating text. That also should be handled elsewhere.

Third, the chain lightning effect shouldn't be setting Target state, such as hurt. What if the Target is lightning immune? Why should the effect even care?

Here are the things the chain lightning effect should be responsible for: spawning a visual effect, generating the damage value, and handing some sort of ApplyDamage(DmgValue) message off to the target object. How the Target reacts to that message (is it immune? Does it take double damage? does it cause the target to put on a party hat and dance a little jig?) is all entirely up to the Target.

complex effects can simply be split up into various smaller and simpler effects.

#7 Explodinator   Members   -  Reputation: 119

Like
0Likes
Like

Posted 14 June 2012 - 01:32 PM

// Chain Lightning Pseudocode

ChainLightning.effect(Attacker,Target){

	 Attacker.state = ("Casting")
	 Draw lightning from the Attacker's sprite to the Target's sprite
	 Target.state = ("Hurt")
	 Target takes (Attacker.Intellect / Target.Lightning_Resist) damage
	 Target.Hit = True
	 show the damage done on the screen, over the target's head

	 while(Target is not null)
	 {
	 	 OldTarget = Target
	 	 Target = NULL
	 	 check tiles within 2 spaces of target
	 	 if(tile contains a unit that is hostile to the attacker and has not previously been hit){
	 	 	 Target = found unit
	 	 	 Target takes (Attacker.Intellect / Target.Lightning_Resist) damage
	 	 	 Target.Hit = True
	 	 	 Target.state = ("Hurt")
	 	 	 show the damage done on the screen, over the target's head
	 	 }
	 }

}


Ok, you seem to not understand what I was getting at. You need to generalize what you're doing as much as possible in the context if your game, not write a new language.

That means things like variables, loops, properties, etc. should be kept to a minimum. You define a set of rules in the context of your game and have your parser execute the programming logic.

#8 Silverain Development   Members   -  Reputation: 166

Like
0Likes
Like

Posted 14 June 2012 - 02:31 PM

Well, first off you wouldn't want your chain lightning effect script to actually handle drawing the lightning bolt. That responsibility belongs elsewhere (in the rendering system, however that is structured). The script would merely have access to functionality that would allow the spawning of effects.

Second, the chain lightning effect script shouldn't have the responsibility of displaying combat floating text. That also should be handled elsewhere.


Of course, the thing is though, that I will still need to know what information to send to the drawing/sound systems, and that's what I was trying to show in my example. I'm kind of regretting posting this Pseudocode as it was a pretty bad example of what I'm trying to do.

Ok, you seem to not understand what I was getting at. You need to generalize what you're doing as much as possible in the context if your game, not write a new language.

That means things like variables, loops, properties, etc. should be kept to a minimum. You define a set of rules in the context of your game and have your parser execute the programming logic.


The Pseudocode isn't anywhere near what I envisioned the actual parsing system should look like, it is more of what I need to do for this particular example. I know that my scripting system will need to be generalized regardless, but I will probably need loop functionality anyway for certain abilities.

Regardless, I think I've figured out how I'm going to approach this, and I'd like to thank everyone who helped me here.

#9 bobbias   Members   -  Reputation: 120

Like
0Likes
Like

Posted 15 June 2012 - 02:56 AM

You could create an XML based system. There are plenty of XML tools available (meaning you won't have to write your own parser) and it's pretty trivial to write something to extract your information from the XML.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS