Advertisement

Scriptable magic system.

Started by March 11, 2005 06:41 PM
14 comments, last by Nice Coder 19 years, 11 months ago
Bascically you make 'magic scripts' These are one of two things: Spells, or incantations. Spells are used by a person, to do something to the environment, or another creature. Incantations are placed on objects, to give them poweres. Both have mana, so if you place a 10 mana spell to seal a door, and someone hits it with a door breaking spell which has 11 mana, then the door would become unlocked. Individual things have a minimum mana, so for eg. In order to lock a door, you need to use at least 10 mana. You can use more, to make it harder/take longer to unlock, but you need at least 10 manas worth of magic to do it. Basically both are a sort of script system. So, in your spell system, you can place an incantation on the door, so that it shoots 20 mana lighting bolts at anybody that comes close enough, that is not you. So the script would go like

Event_character_close(char as character)
if char.person != caster.person then
   do until char.dead or char.distance > close
   Castspell(Lightning_bolt, char, 20)
   loop
end if
end event
You could do something similar to make a door lock when someone else tries to lock it. Now, you cast that incantation, with a mana of 2000, so it can, at maximum fire 100 lighting bolts, before it no longer has enough mana to cast another one. At that time the incantation is broken. you can also break incantations, using scerge spells. These can take a lot of mana in order to break the spell (it needs the amount of mana that the spell has, + another 200 or something in order to break it), but if your a lv 110 wizard with a few million mana, you should be able to seal yourself into a room where it would take many powerfull wizards to get you out. Spells can also change things, such as break down doors, change the weather, throw stuff (including people) dry up lakes, ect. The more powerfull spells, (for eg. the nuke spell), would require massive amounts of mana in order to cast. But they would be able to break through most most other spells (including protection spells that some creatures have, although if you have a lv 20 troll, you should be able to blow it into little pieces if your a lv25 wizard). Mana slowly replenishes if you have enough health, and you can recover mana more quickly, by practicing magic. You can also get more mana from potions,ect. Any commments? Ideas? Suggestions? From, nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
cool.

are the spells prepackaged or does the player need to code the spells themselves? dunno how it would go with non programming-type persons.
"gah! stupid bug fried half the town"

balance wll also be hard. why does a lvl 110 mage need defensive spells? he can kill practically anything with his millions of mana.

as suggestion, how about concentration (threads of execution)
low level mages can only cast 1 spell at a time. putting an incantation on the
door means the mage can't cast another spell until the incantation dies or is cancelled by the mage. high level mages have more concentration ability so they can cast a firewall to keep hordes of the enemy at bay, while casting protect on himself and trying to unlock the magic door. Even high level mages should be limited to only a few spells activated at one time to stop them from summoning 1000 goblins at will.

or add stamina, more spells activated drains the stamina bar faster, you can have a low power, high stamina mage cast 10 low level spells while another mage can cast a few spells. This provides balance to the millions of mana the high level mage has. It also prevents a high level mage from stocking up mana potions and blasting everything on demand.

then you can add mana batteries, sources of energy aside from the mage. a mage can get an item (ie. skull of guldan) and store a set amount of mana in it. the mage can put the skull near the door and cast the lightning booby trap. the skull takes care of providing mana so the mage can cast other spells without the stamina/concentration penalty. A mana battery can explain why the "temple of TeH DOOMed" has powerful spells and why it crumbles after getting the treasure inside (temple must hold a lot of mana and hardwired to release all its energy during its destructor call)


You could then introduce anti-mage warriors. They have skills to disarm spells using a mana battery. They can steal the battery or use another item to drain/destroy the battery. They can have spells/items that disrupt or drain stamina/concentration of mages so a high level mage-killer can kill a high level mage while an army can not.

hmm.. wizard staffs can be mana batteries, hence a powerful wizard with a good staff can still be beaten by a warrior that has "break staff" skill

I can see this system in a RPG/puzzle game. given objectives and constraints (get of of the room while being hounded by an army of undead) program a spell or set of spells to help you get out. (cast firewall to slow army down, cast haste on me to run to door, cast break-open-door to get out)

hope this helps.
---------------Magic is real, unless declared integer.- the collected sayings of Wiz Zumwalt
Advertisement
I've been thinking of this in an rpg or derivitive (like mmorpg, not that i'd be able to make either one, but who cares, this is only an idea).

Basically, you'd be able to buy pre-packaged spells, from spellbooks (you would start out with one).

Noweach function has a chance of failure (which is dependant on exp. Formula for calculating falure would probably be Rand - (exp/neededexp) If this is positive, then it fails.

You get exp from doing spells, and you loose exp when you do nothing.

I've also been thinking about removing the leveling system. So i'm a wizard with 2000 exp, and 10K mana.

Maybe make functions take time to execute, so by the time you've summoned 1000 goblins, you've already been piked.

Also, spells should go forever if they have enough mana. (so, you can have a sealed door from the beginning of the game, which is still unopenable)

Exp and mana become harder to get as you 'level up'. This would mean that you would have a few heigh wizards, then your good wizards, yoru garden variety wizards, and apprentices.

Wizards would probably be payed to make magic items, for eg. a shield which will stop all arrows and swords which never break.

Mana batteries are a good idea.

Now, maybe how about if wizards could only be killed by other wizards, or by magical items?

You can shoot a low-level wizard, with a magical arrow, and using a magic shield for protection, but for a heigh level wizard, that arraw wouldn't be enough, and you need something like a magic sword, with protection spells (all avalible from your local hieigh-wizard).

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
I think a more elegant way of limiting players by level is to limit how many lines of script a spell can be by their level. For example, a level 1 caster could only write 1 line of script for his spell, so obviously it won't be anything special or powerful. Whereas a level 50 caster could write 50 lines of script. You could also make it so that the maximum lines of script the player can write are dependant on his TOTAL number of spells and their scripts. So if the player is level 50, and has 3 spells, one with 24 lines, another with 15, and the final one with 10 lines, then the player would only be able to use 1 line of script to write any other spell.
Good idea, exept that on one line, there could be something like Castspell(NUKE, SMALL_VILLAGE, 120000) Which would anialate the village, and put a large crater on the ground (the nuke spell is good for removing mountain ranges, if your a powerfull wizard, or blowing up houses if your ownly an apprentice).

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Might it be possible to have your level affect the magnitude of components? For instance, a level three mage could assign more power to the "lightning" aspect of a lightning shield spell than a level two mage, so the spell would be elevated in magnitude even though it would have the same number of lines.
Advertisement
Rofl, nuke small village. XD

The magnitude a caster can use can also be effected by level as Iron Chef Carnage suggested (at least thats what i think he's suggesting?). Infact, you could directly apply power to the number of lines the player could code.

So for example there's the level 50 mage again, and he scripts a 24 line spell with a power of 15, then he'd have 11 more lines of code/power to work with.
A modifyer system?

Castspell(Lightning_Field, self.x + 5, self.y + 5, 200, "LIGHNING=51%,FORCEFIELD=49%")

?

It would be easier with mana, as you level up, you get more mana. (for eg. by killing a troll using a thunderstrike spell, you get 5 mana)

Using spels depleates mana (most spells have a mana negitive effect).

You can store mana in objects

You can also get mana by making and using potions (which requires skill, as well as the ingredients, which you have to find).

for egsample:
If you were a good wizard (maybe mana 5000 exp 20000), you give your door a spell which basically makes a magic-proof force field which deactivates when you come near.

You then enchant the rest of your house, so that it cannot be destroyed, nor damaged, by most wizards, or anything else.

This would probably use up most of your mana, so you go hunting to get ingredients which you store in your house, which later, you let brew, so you get a nice potion (potion books are also avalible).

Any nice wizard, will also place sentinals in a ring around his house, to protect it, and to firebomb anything that decides to come near it. You exluded of cource.

You would basically get a few mana batteries, connect them up using a spell, then use those as the powersource for the defencive spell. (which includes its own forcefield).

now this would work well if your the only good wizard there, but if a great wizard (mana and exp in the tens of millions) comes up, he'd just curse your place to the ground. (or just get a really good protection spell, walk up, use a scfurge spell to remove the forcefield from a sentinal, walk through, go up and scourge the defencive spell from the door, which you then walk into, take the stuff, before walking away.

Now, why do we need levels?

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
[off topic]I think it's good for wizards and all but how can the other classes hope to match up with the wizards. They can't cast spells on stuff. Most of the advantage of mages is their magic allows them to do things from a distance or over a wide area. swords vs nukes will make a pretty poor battle.[/off topic]

hax0rz! make a skill (Magic Learn) that lets you see the code of the spell and possibly chage it depending on your level,skill etc.

Imagine a skillful wizard breaking into your house, hacking your spell and replacing
if (person!= caster) nuke --> if(person==caster) nuke :P

then make another skill to detect changes in spells. hacker mages can change your spells and you wouldn't have a clue but changes by noob mages can be easily detected and disregarded. on the opposite side, having spell protectors will prevent most people from peeking into your spells.

or at the very least gives another player ideas on how powerful the spell is, before attempting to disarm, cast spell against it.


I think spells can be classified into active and passive spells

active: requires constant mana supply. any action/spell cast against it will drain its mana source (mage, or mana battery). This means your golem door guard will lose mana only when being attacked. If nobody interacts the golem, it could last forever. A 1 million mana door lock(casts 1 mana lightning) can be broken by several powerful mages or sending 1 million noobs to their deaths to drain its mana reserve.


passive: set amount of mana. can not be broken until a set condition. notably seals or powerful magics. a 1000 mana seal can not be destroyed by 9999 open-sesame spell no matter how many times you do it. either disarm the spell another way or cast 1500 battering ram against it. this is because the seal does not do anything against the attacker.

spells of poison,protection, healing, or other "Buffs" contradicts the balance present in all living things so they need to lose mana over time. This means you cant cast a seal on your self,friend and expect it to last indefinitely even if nobody is attacking you.

mind spells (psyche) are a spell of a diferent order. they are cast once and can not be removed easily. they work like passive spells. you need to bypass them or cast a stronger spell against them to break. examples might include control spells for dragon, powerful curses

hehe. sorry for the long post.
in summary

spells:
active : drains mana when activated, lasts until no more mana or stronger spell is cast against it.
passive: does not drain mana. needs stronger spell to break

buffs : cast on living things, like active spells and loses mana over time.
psyche : cast on living things, like passive spells, MAY lose mana over time

---------------Magic is real, unless declared integer.- the collected sayings of Wiz Zumwalt
you might get interesting gameplay with this.

ex.
you are a female mage and can't get into a certain clubhouse. use magic learn to see code of spell.

you find a 50k mana spell that prevents entry of non members by checking if they
are male and have "club robes" as equipment.

now, you are only a 25k mana mage. no way you can break the seal, but you can hack it. or get a spell that ehermm..changes you into a man and steal club robes from a noob.

presto, you can get it without using uber spells.

another example is the lightning door spell. checking the spell reveals a powerful spell that casts 50 mana lightning. protected by high level spells to prevent hacking. cast a 51 mana seal on a rock and push towards the door. the lightning can't break the seal since it's a 51 mana spell but it will try anyway. just wait until the door spell fizzles from lack of mana.


---------------Magic is real, unless declared integer.- the collected sayings of Wiz Zumwalt

This topic is closed to new replies.

Advertisement