Home
Start a new game
Explore games
Help
Log in or sign up
Log in
Username
Password (
Forgot it?
)
×
New to Playfic?
Full Name
Email
Username
Password
Password (confirm)
Are you sure about this?
Combat Demo
by
Psuedonym
Played 2,381 times
View game source
(spoilers!)
Download the
.z8 file
Source Code
"Combat Demo" by "AuthorAnonymous" After printing the banner text, say "[line break][italic type]A demonstration of a simple combat system. Version 2.0.2.[roman type][line break] ". The release number is 2. Include Plurality by Emily Short. [ Hey there! If you're looking at the source code, you probably want to know how to implement it in a work of your own. That can be frustrating if there's a bunch of code and you didn't write any of it. To help streamline the process, here's a quick rundown of what code is where and how things work. Section one covers the concept of dangerous items, and provides text for referring to the weapons wielded by different characters. It establishes 'damage potential', i.e. how much a given item adds to a person's attack statistic when equipped. Notably, the 'dangerous' adjective can be applied regardless of damage potential, allowing for non-damaging weapons. This section also establishes the concept of clothing as a kind of thing. Section two covers the 'wielding' relation, and provides rules for equipping and unequipping weapons. Section three covers the basic statistics for people in-game -- HP (current health points), MaxHP (maximum health points), ATK (Attack), defense, and accuracy. It also gives an alternate way of describing the player, indicating those statistics as well as inventory. Section four removes the usual block attacking rule, and provides an alternate set of rules for how attacking works. Section five introduces death, and establishes a 'killing' action which occurs when an attack reduces a target to 0 HP (which may be useful for tracking who kills whom, if needed.) Section six provides redirects for alternate ways of attacking, such as attempting to attack with specific items, including items the player neither wields nor carries. Section seven goes into depth about clothing and its usage as armor, altering a person's defense statistic, using a 'defense potential' (like the 'damage potential' for dangerous things.) Section eight creates a variable for people's attitude toward the player (friendly, hostile, or indifferent) and persuasion rules and automatic responses to violence based on this (hostile characters attacking, indifferent characters attacking if attacked, characters unprepared for combat needing an extra round before fighting back, etc.) Section nine is the demonstration of the these mechanics in the form of the game you're playing. It doesn't showcase all mechanics, but it does display several of them. Section ten provides a quick rundown of in-game commands and mechanics for confused players in response to a 'help' command. Best of luck, IF writer! And please remember to credit me if you use this! --AuthorAnonymous ] Section 1 - Weapons and Other Things A thing can be harmless or dangerous. A thing is usually harmless. A person has a text called a chosen-weapon-name. The chosen-weapon-name of a person is usually "pair of bare fists". The player-weapon is a text that varies. The player-weapon is "bare fists". After the player unequipping something: now the player-weapon is "bare fists". A thing has a number called a damage potential. The damage potential of the thing is usually 0. Clothing is a kind of thing. Clothing is always wearable. Section 2 - Wielding, Equipping, Unequipping Wielding relates one person (called the wielder) to one thing. The verb to wield (he wields, they wield, she wielded, it was wielded, she is wielding) implies the wielding relation. Equipping is an action applying to one carried thing. Understand "equip [something]" and "wield [something]" and "brandish [something]" and "use [something] as a weapon" and "use [something] as weapon" and "weaponize [something]" as equipping. Unequipping is an action applying to one thing. Understand "unequip [something]" and "stop wielding [something]" and "quit wielding [something]" and "stop brandishing [something]" and "quit brandishing [something]" as unequipping. Check the player equipping: if the noun is dangerous: if the player wields the noun: say "You're already wielding [the noun]."; stop the action; otherwise if the player wields a dangerous thing: drop your weapon; otherwise: continue the action; otherwise: say "[one of]You doubt you could do any serious damage with [the noun].[or][if the noun is plural-named]Those are[otherwise]That's[end if] hardly a dangerous weapon.[or]You consider the possibility for a moment, then nix it. You need something more dangerous.[stopping]"; stop the action. Check someone who is not the player equipping: if the noun is dangerous: if the actor wields the noun: say "[The actor] tries to equip [the noun], but is already wielding [if the noun is plural-named]them[otherwise]it[end if]."; stop the action; otherwise if the actor wields a dangerous thing (called X): try the actor unequipping X; if the actor wields X: say "[The actor] attempts to switch weapons, but can't seem to get rid of [the X]."; stop the action; otherwise: continue the action; otherwise: continue the action; otherwise: say "[The actor] tries to weaponize [the noun], with little success."; stop the action. Check unequipping: if the actor wields the noun: continue the action; otherwise: say "[if the actor is the player]You're not[otherwise][The actor] attempts to unequip [the noun], but isn't[end if] wielding that."; stop the action. To drop your weapon: if the player wields a dangerous thing (called X): try the player unequipping X; if the player wields X: say "You can't seem to get rid of [the X]."; stop the action; otherwise: say "(first unequipping the [X])"; continue the action. Carry out the player equipping a dangerous thing (called the weapon): now the player wields the weapon; now the player-weapon is the printed name of the weapon; let N be the damage potential of the weapon; increase the atk of the player by N. Carry out someone who is not the player equipping: now the actor wields the noun; now the chosen-weapon-name of the actor is "[printed name of the noun]"; let N be the damage potential of the noun; increase the atk of the actor by N. Carry out unequipping: now the actor does not wield the noun; decrease the atk of the actor by the damage potential of the noun. Report the player equipping: say "[one of]You now wield [the noun].[or]You heft [the noun] in your hands, ready for combat.[or]You think [the noun] would make a fine weapon in battle, and equip it accordingly.[or]You equip [the noun]. [first time]No big deal, really.[only][purely at random]". Report someone who is not the player equipping: say "[The actor] equips [the noun]." Report unequipping: say "[if the actor is the player]You decide to put away [the noun] for now.[otherwise][The actor]stops brandishing [the noun] for a while.[end if]". Check dropping a dangerous thing: if the actor wields the noun: try the actor unequipping the noun; if the actor wields the noun: say "[if the actor is the player]You try[otherwise][The actor] tries[end if] to get rid of [the noun], but [the noun] is stubborn and will not leave [if the actor is the player]your[otherwise if the actor is female]her[otherwise if the actor is male]his[otherwise]their[end if] person."; stop the action; otherwise: continue the action; otherwise: continue the action. Section 3 - Vital Statistics A person has a number called hp. The hp of a person is usually 10. A person has a number called maxhp. The maxhp of a person is usually 10. A person has a number called atk. The atk of a person is usually 2. A person has a number called accuracy. The accuracy of a person is usually 2. A person has a number called defense. The defense of a person is usually 4. Before examining the player: say "HP: [hp of the player]/[maxhp of the player] | ATK: [atk of the player] | DEF: [defense of the player] | ACC: [accuracy of the player][line break]CARRY CAPACITY: [number of things carried by the player]/[carrying capacity of the player] ([carrying capacity of the player - number of things carried by the player] slots remaining)[paragraph break]". Section 4 - Attacking The block attacking rule is not listed in any rulebook. Check attacking a person (called the target): if the target is a person: if the target is the player: say "This seems like a poor decision."; stop the action; otherwise: continue the action; otherwise if the target is friendly: say "What? No. [The target] is your friend, for goodness sake!"; otherwise: say "And what exactly would that accomplish?"; stop the action. Check attacking something (called the target): if the target is worn by the player: say "This seems very ill-advised."; stop the action; otherwise if the noun is not a person: say "[one of]And what exactly would that accomplish?[or]That seems a tad pointless.[or]Violence really isn't the answer to this one.[or]Now, now, what did the [target] ever do to you?[purely at random]"; stop the action. Recentdamage is a number that varies. Carry out a person (called the attacker) attacking someone (called the target): now recentdamage is 0; let D be a random number between 1 and 10; increase D by the accuracy of the attacker;[ say “([D])[line break]â€;] if D is greater than the defense of the target: decrease the hp of the target by the atk of the attacker; increase recentdamage by the atk of the attacker; if a random chance of 1 in 8 succeeds: decrease the hp of the target by the atk of the attacker; increase recentdamage by the atk of the attacker; say "(critical hit!)"; otherwise: continue the action; otherwise if a random chance of 1 in 8 succeeds: say "(glancing blow)"; decrease the hp of the target by 1; increase recentdamage by 1; otherwise: say "[italic type]miss[roman type]". Carry out the player attacking a person (called the target): now recentdamage is 0; let D be a random number between 1 and 10; increase D by the accuracy of the player;[ say “([D])[line break]â€;] if D is greater than the defense of the target: decrease the hp of the target by the atk of the player; increase recentdamage by the atk of the player; if a random chance of 1 in 8 succeeds: decrease the hp of the target by the atk of the player; increase recentdamage by the atk of the player; say "(critical hit!)"; otherwise: continue the action; otherwise if a random chance of 1 in 8 succeeds: say "(glancing blow)"; decrease the hp of the target by 1; increase recentdamage by 1; otherwise: say "[italic type]miss[roman type]". Report the player attacking a person (called the target): if the target is indifferent: now the target is hostile; say "[if recentdamage is 0]You miss[otherwise]You attack [the target], dealing [recentdamage] damage[end if]."; if the hp of the target is less than 1: if the target is dead: say "[if recentdamage is 0]Not that it matters, since [the target] is already dead.[otherwise]You're just beating a dead [target] now.[end if]"; otherwise: try the player killing the target; say "You just killed [the target]."; otherwise: do nothing. Report someone who is not the player attacking a person (called the target): say "[The actor] attacks [if the target is the player]you[otherwise][the target][end if], [if recentdamage is 0]but misses.[otherwise]dealing [recentdamage] damage.[end if]"; if the hp of the target is less than 1: if the target is dead: say "[if recentdamage is 0]Apparently [the actor] can't even hit a dead [target].[otherwise][The actor] is really just beating a dead [target] now.[end if]"; otherwise: try the actor killing the target; if the target is not the player: say "[The actor] has now killed [the target]. Yikes."; otherwise: do nothing; otherwise if the hp of the target is 1: say "[if the target is the player]You're down to a single hit point. Better be careful.[otherwise][The target] is taking some serious damage here.[end if]"; otherwise: do nothing. Section 5 - Death? A person can be alive or dead. A person is usually alive. Killing is an action applying to one thing. Check the player killing something (called the victim): if the victim is dead: say "[The victim] is already dead."; stop the action; otherwise: continue the action. Carry out the player killing something (called the victim): now the victim is dead. Check someone who is not the player killing something (called the victim): if the victim is dead: say "[The actor] attempts to kill [the victim][one of], but [the victim] is already dead.[or]. Unfortunately, [the victim] is already dead.[or]. Bit late for that, really. [The victim] is already dead.[purely at random]"; stop the action; otherwise: continue the action. Carry out someone who is not the player killing something: now the noun is dead. Report someone killing something: say "...". Check a dead person trying going: if the actor is the player: say "You can't do much of anything, since you are now dead."; stop the action; otherwise: say "You think [the actor] would be trying to do something right about now, but they're dead."; stop the action. Check a dead person trying taking: if the actor is the player: say "You can't do much of anything, since you are now dead."; stop the action; otherwise: say "You think [the actor] would be trying to do something right about now, but they're dead."; stop the action. Check a dead person trying taking inventory: if the actor is the player: say "You can't do much of anything, since you are now dead."; stop the action; otherwise: say "You think [the actor] would be trying to do something right about now, but they're dead."; stop the action. [OPTIONAL] [After examining a dead person (called the corpse): say "[The corpse] is now dead."] Instead of asking a dead person (called the corpse) about something: say "[The corpse] is dead and cannot answer." Instead of telling a dead person (called the corpse) about something: say "[The corpse] is dead and cannot answer." Instead of showing something to a dead person (called the corpse): say "[The corpse] is dead and cannot respond." Carry out someone (called the murderer) killing the player: end the game in death. Check taking something carried by a dead person: ignore the can't take people's possessions rule. Check taking something worn by a dead person (called the corpse): say "(stripping it off of [the corpse]'s body...)"; ignore the can't take people's possessions rule. Check a dead person taking something: stop the action. Check a dead person going: stop the action. Check a dead person attacking something: stop the action. Section 6 - Disambiguation Attacking it with is an action applying to two things. Understand "attack [something] with [something]" and "hit [something] with [something]" and "murder [something] with [something]" and "kill [something] with [something]" and "stab [something] with [something]" and "slice [something] with [something]" and "harm [something] with [something]" and "shoot [something] with [something]" as attacking it with. Understand "shoot [something]" and "destroy [something]" as attacking. Carry out the player attacking a person with something: if the player wields the second noun: try the player attacking the noun; otherwise if the second noun is dangerous: try the player equipping the second noun; try the player attacking the noun; stop the action; otherwise: say "[The second noun] is hardly a functional weapon."; stop the action. Carry out someone who is not the player attacking a person with something: if the actor wields the second noun: try the actor attacking the noun; otherwise if the second noun is dangerous: try the actor equipping the second noun; try the actor attacking the noun; if the actor is hostile: try the actor attacking the noun; otherwise: stop the action; otherwise: say "[The actor] seems to consider attacking [if the noun is the player]you[otherwise][the noun], but [the second noun] is hardly a functional weapon."; stop the action. Section 7 - Clothing and Armor Clothing has a number called a defense potential. The defense potential of clothing is usually 0. Instead of equipping clothing (called the armor): try the actor wearing the armor. After the player wearing clothing (called the armor): increase the defense of the player by the defense potential of the armor; say "You don [the armor]." After the player taking off clothing (called the armor): decrease the defense of the player by the defense potential of the armor; say "You take off [the armor]." After someone who is not the player wearing clothing (called the armor): increase the defense of the actor by the defense potential of the armor; if the actor is in the location: say "[The actor] dons [the armor]." After someone who is not the player taking off clothing (called the armor): decrease the defense of the actor by the defense potential of the armor; if the actor is in the location: say "[The actor] takes off [the armor]." Section 8 - Friends and Enemies A person can be friendly, hostile, or indifferent. A person is usually indifferent. Persuasion rule for asking a friendly person (called the ally) to try doing something: if the ally is dead: say "[The ally] is dead and cannot respond to your instructions."; otherwise: persuasion succeeds. Check giving something to a friendly person (called the ally): ignore the block giving rule. Check someone who is not the player giving something to the player: ignore the block giving rule. Persuasion rule for asking an indifferent person (called the stranger) to try attacking the player: if the stranger is dead: say "[The stranger] is dead and cannot respond to your instructions."; otherwise: say "[first time][The stranger] does not seem opposed to the idea.[only]"; persuasion succeeds. A person can be ready for combat or unready for combat. A person is usually unready for combat. Every turn when a hostile person (called the enemy) can see the player: if the enemy is ready for combat: try the enemy attacking the player; otherwise: say "[The enemy] notices you. [if the enemy is male]He doesn't[otherwise if the enemy is female]She doesn't[otherwise]They don't[end if] look friendly."; now the enemy is ready for combat. Section 9 - Demonstration The Arena is a room. "You stand in a dusty arena." The player carries a wooden sword. The wooden sword is dangerous. The wooden sword has damage potential 1. The description of the sword is "A wooden practice sword. [if the player wields the sword]Currently equipped and providing +1 to your ATTACK.[otherwise]Adds +1 to your ATTACK. You'll need to EQUIP it first, though." The description of the player is "Currently wielding the [player-weapon].[line break]You're as good-looking as ever." Understand "practice sword" and "wooden practice sword" and "toy sword" as the wooden sword. There is a wooden chest in the arena. There is a real knife in the chest. The real knife is dangerous. The real knife has damage potential 3. The description of the real knife is "A real knife. +3 to ATTACK.[if the player wields the knife] You feel very dangerous.[otherwise] You shouldn't need it for this.[end if]". There is a practice spear. The practice spear is dangerous. The practice spear has damage potential 1. Ben is a person in the arena. "[if Ben is alive and Ben is hostile]Ben bounces from foot to foot, waiting for your next attack.[otherwise if Ben is alive and Ben is not friendly]Your friend Ben stands nearby, ready to spar.[otherwise if Ben is alive and the HP of Ben is less than 5][first time]Now that the fight is over, [only]Ben stands around aimlessly.[otherwise]Ben is dead.[end if]". The description of Ben is "Your sparring partner. [if Ben is indifferent]Ready whenever you are.[otherwise if Ben is hostile]Still fighting you, so pay attention.[otherwise]Friendly.[end if]". The description of the practice spear is "[if Ben is alive]A spear. +1 to ATTACK. It belongs to Ben, though.[otherwise if the player carries the spear]Belonged to Ben, but it's yours now, and he can't argue about that when he's dead, can he?[otherwise]Ben's spear.[end if]". Ben wields the practice spear. [Ben's commentary on weapon choices.] After equipping something (called the weapon) when Ben is indifferent: say "You equip [the weapon]."; if the damage potential of the weapon is less than 3: say "[line break][one of]Ben nods and assumes a fighting stance, waiting for you to make the first move.[or]Ben tentatively resumes his fighting stance, ready to go.[or]Ben gives you a confused look, but gets ready to fight anyway.[or]'Just make up your mind,' Ben says, sounding a bit peeved.[or]Ben is barely paying attention to you, but he still wearily resumes a fighting stance as he sees you equipping [the weapon] yet again.[stopping]"; else: say "[line break][one of]Ben raises his eyebrows. [line break]'Isn't a [weapon] a bit... lethal, for a sparring match?' he asks.[or]Ben gives you a look like he wants to ask if you're joking.[or]Ben sighs. [paragraph break]'Would you mind picking a less [italic type]deadly[roman type] weapon?[purely at random]". [To ensure you can fight him immediately.] Ben is indifferent. [To avoid killing anyone...] Every turn when Ben is hostile: if the HP of Ben is less than 4: now Ben is friendly; say "Ben bends over, hands on his knees. [paragraph break]'Okay, okay, I'm beat.' He puts his hands in the air. 'I yield.'"; if the HP of Ben is less than 1: say "[line break]Then he topples, dead."; else if the HP of the player is less than 5: now Ben is friendly; say "'Okay, we're done,' Ben says. 'You're pretty beat-up looking. Let's stop for now.'". Instead of attacking Ben when the HP of Ben is less than 4: say "Whoa, whoa, whoa! He's still your friend; you don't want to kill him!" There is a training dummy in the arena. The training dummy is a person. The description of the dummy is "[if the HP of the dummy is greater than 5]It's pretty dumb.[else if the HP of the dummy is greater than 1]The dummy isn't in great shape after the beating you gave it. Bits of cotton spill from its seams.[else]The dummy is battered beyond recognition. Dead as a dummy can be.[end if]". Instead of asking the dummy about something : say "It doesn't seem much for conversation." Instead of telling the dummy about something: say "It doesn't seem much for conversation." Instead of giving something to the dummy: say "It's just a dummy." [More commentary from Ben.] Before attacking the training dummy for the first time: say "'Trying out your [player-weapon] on the dummy first, I see,' Ben says. [paragraph break]'Well, whenever you want to try fighting me, I'm ready.'[line break]". The dummy is friendly. [Since Ben is a named NPC with an implied personality, he gets some custom text for when you begin fighting him.] Ben is ready for combat. AttackedBen is a number that varies. AttackedBen is 0. After attacking Ben while AttackedBen is 0: if the HP of Ben is not 10: now AttackedBen is 1; now the HP of Ben is 10; say "You make the first attack. He dodges nimbly out of the way, then steps back, waiting. He's giving you another chance before he starts fighting back." [As an example of basic armor] There is a safety vest in the chest. The safety vest is clothing. The defense potential of the safety vest is 1. The description of the vest is "It's a safety vest. [if the player does not wear the vest]Wearing it will increase your DEFENSE by 1 point.[otherwise]Wearing it increases DEFENSE by 1 point.[end if]". Before wearing the safety vest for the first time: say "[line break]'I don't think you'll really need that,' says Ben. 'We're only sparring, after all.'" [This is here to demonstrate error-handling for trying to equip non-weapons. It got funnier than I intended.] There is a teddy bear in the chest. Before doing something with the teddy bear for the first time: say "Ben looks embarrassed, as if he hadn't realized the bear was in there." Instead of telling Ben about something when Ben is indifferent: say "Ben doesn't seem interested in idle chatter at the moment." Instead of asking Ben about something when Ben is indifferent, say "'Less questions, more sparring, okay?'" Instead of asking Ben about something when Ben is hostile, say "[one of]Really not the time right now! Maybe later?[or]You try to brainstorm a good bit of battle-banter, but draw a blank.[or]You could really find a better time for that.[purely at random]". Instead of telling Ben about something when Ben is hostile: say "[one of]You attempt a snappy one-liner and fail miserably.[or]Not really the time.[or]He's not giving you a word in edgewise between the sweeps of his practice spear.[purely at random]". Instead of telling Ben about something when Ben is friendly: say "He doesn't seem to have much to say on the matter." Instead of asking Ben about something when Ben is friendly: say "He doesn't seem to have much to say on the matter." Instead of giving the bear to Ben when Ben is not hostile: say "Ben turns a bit red, but accepts."; now Ben carries the teddy bear. Section 10 - Help [For confused players.] Helping the player is an action out of world. Understand "help" and "help me" and "help please" and "please help" and "what do i do" and "hints" as helping the player. Carry out helping the player: say "[italic type]A quick guide to combat-related actions:[roman type][line break]EQUIP: equip and wield a weapon. [line break]UNEQUIP: stop wielding a weapon. Dropping it or equipping a different weapon will do this automatically. [line break]ATTACK: attack someone or something. [paragraph break][italic type]A quick guide to vital statistics:[roman type] [line break]ATTACK (ATK): baseline damage from your attacks. [line break]DEFENSE (DEF): increases how high a roll your attacker needs to hit you. [line break]ACCURACY (ACC): increases the odds you can hit someone else. [line break]HIT POINTS (HP): your health and durability. If a character's HP is 0, they die. [paragraph break]Hope this helped!" [From recent debugging] There is a blue shirt. The shirt is clothing. The defense potential of the shirt is 10.