Well, relatively simple. (mostly kludgy and inefficient)
A few years ago, I did an arena-combat game for renpy. It was inspired by RPGMaker’s system, which allows the creation of JRPG-style game. On the user side, it is made up little more than of several different editable lists - globals (such as names, identifiers, etc), characters (and their stats and growth curves), enemies (and their stats, usable skills, etc), a single block of skills and attacks (which both players and enemies can use) and an inventory list.
I tried porting the renpy game into choicescript, but ran into the problem that the python-based script allowed me to just $new_variable = value pretty much anywhere while now I must remember and predefine every variable. The inventory list alone is pretty tiring to re-encode, not to mention the special abilities/spells/etc. Each of them checks if active_player = “hero” or “enemy” and with two all-but-identical code to check for success, damage, etc. Better than having separate label enemy_firebolt and hero_firebolt?
Still, the ideal is that once it’s done, it would be plug-and-play. All that’s need to customize it is to change the lists - the ‘meat’ of the script, the combat system, is actually quite short and does not need any further editing.
The process looks something like:
Bpen’s simple 1 vs 1 combat script
Step 1:
Select the player character
– > *set hero_class “knight”
– > gosub to “knight”
– > etc.
Step 2:
Define the player’s stats and abilities
– > *set DEF, ATK, SPD, END, LCK etc
– > *set hero_hp and hero_hp
– > *set max_hero_hp and max_hero_mp as hero_hp and hero_mp
– > *set equipped items (hero_wpn_dmg, hero_wpn_ac, hero_wpn_dsc, etc.)
– > *set all status (poisoned, bleeding, stunned , etc.) to 0
– > *set inventory items
– > return
Step 2:
Do the same, but for the chosen enemy
– > as above
Step 3:
Offer the player a choice of what to do
– > Simple attack
----- > set act_id 101 (simple attack)
– > Special Action
----- > goto special menu
-----------> Action 1
-------------- > set act_id for this action
-----------> Action 2
– > Use item
----- > goto item menu
---------- > drink health potion
---------- > drink mana potion
– > etc
Step 4:
Begin the combat script
Display Combat Report
Step 4a. Roll initiative to see who goes first
– > set active player = “hero” or “enemy”
– > goto (active player) turn
Step 5: (Assuming hero wins init)
Execute player_turn
– > check status
----- > Poisoned? Stunned? Regenerating?
----- > Add or subtract to hp/mp
Goto the actions list
– > perform chosen action
– > if act_id = 101
– > goto simple_attack
– > etc.
Goto the label to execute the action
(assuming simple attack)
– > if active_player = “hero”
----- > roll to hit
----- > if hit succeeds
---------- > check for critical hit
-------------- > double damage
---------- > do normal damage
---------- > check if enemy_hp < 1
-------------- > goto you_lose
----- > if hit fails
----- > say ‘you missed’
– > goto continue_player_turn
Back to hero_turn
– > check who won initiative
– > if enemy, then go back to player action choice
– > else, go to enemy_turn
Step 6:
Initiate enemy combat
– > check status
----- > Poisoned? Stunned? Regenerating?
----- > Add or subtract to hp/mp
Get enemy_ai
– > gotoref (enemy class)_ai
Get action from the pattern list
– > roll dice
– > if enemy_hp < max_hp/2, drink potion
----- > if enemy_mp < max_mp/2, 50/50 chance of drink another potion
– > if roll_dice = 1: evade
----- > set act_id 201
– > if roll_dice = 3: heavy attack
----- > set act_id 301
– > if roll_dice = 6: special/magic attack
----- > set act_id 301
– > etc.
– > else do a simple attack
– > go back to enemy_turn
Goto the actions list
– > perform chosen action
– > if act_id = 101
– > goto simple_attack
– > etc.
Goto the label to execute the action
(assuming simple attack)
– > if active_player = “enemy”
----- > roll to hit
----- > if hit succeeds
---------- > check for critical hit
-------------- > double damage
---------- > do normal damage
---------- > check if hero_hp < 1
-------------- > goto you_lose
----- > if hit fails
----- > say ‘you missed’
– > goto continue_enemy_turn
Back to enemy_turn
– > check who won initiative
– > if enemy, then goto hero_turn
– > else, go go back to player action choice
Step 8:
Check if won or lost
Step 9:
Check hero xp
– > *set xp_adj hero_xp+100
– > *set level_inc hero_level*hero_level
– > *set next_level 100*level_inc
This creates an xp curve that goes
100, 300, 600, 1500, 2500, etc.
– > if hero_xp >= next_level
– > you gained a level
– > add max_hp/mp bonus
– > every two levels, allow a stat increase
Step 10:
Give the player a choice
– > fight again
– > rest
– > select different enemy
– > select different player class
– > quit
https://dl.dropbox.com/u/644231/choicescript/web/mygame2/index.html
It’s still all sorts of borked right now, with only the Knight, Goblin, Orc, and simple attacks functioning correctly. I have no idea how the hay to even BEGIN turning this into a team or multiple-enemy system.
Help? Any ideas?