Jump to content


Photo

Advanced script editor/generator


  • Please log in to reply
5 replies to this topic

#1 aigleborgne

aigleborgne
  • Member
  • 95 posts

Posted 16 November 2013 - 12:18 PM

For all of you that have played with complex scripts editing, you know that it's quickly become a pain when you want to change something or just to find a block in a 2500+ lines' file.

I've written many scripts, and while I was on them, I was good. But one year after, it was a pain to read them and be sure they were correct and well-written.

 

I have written a small script generator, something like SCS, and while it's good, I want more. So, I have started a bigger project: an advanced script editor.

It is usable by modders and by players.

 

When a mod uses script templates, it must generate scripts from a configuration file. This file will contain many things like tracking options, prebuff, spell checks, tobEx enabled ....

Modders will have a web-interface to configure their templates and shortcuts.

 

How it will works:

- it can be used a normal script editor, it will include completion and helper as any good editor.

- it will have new keywords that are shortcuts to triggers or actions. A keyword can be a shortcut for one or several actions/triggers.

- it will have an action configuration. It will be possible to configure how an action (with params) can be used. Then, when you want to use this action, all blocks will get generated. This is one of the most powerful feature.

- it will have a templating system: a template is a portion of code to be included somewhere, it can have some parameters too.

- it will used the best available triggers to perform an action, based on config (EE, tobEx, spell checks...) 

 

My goal is to reduce a 5000 lines script to about 100 lines.

I could detail a lot more if some are interested...

 

ETA: 6 months

It is on GitHub, using java EE 7, hsql database, liquibase, spring, hibernate, and angular client-side.

 

My first release will not include any web interface, it will only be a command-line program. All configuration can be done with CSV editing or query in database.

 



#2 DavidWallace

DavidWallace
  • Validating
  • 337 posts

Posted 16 November 2013 - 01:06 PM

You can do pretty much all of this in SSL, the scripting metalanguage used in SCS and aTweaks.

That's not a criticism - I'm sure SSL can be improved on. I mention it because
(a) if you're not aware of SSL, it might be that you can use that instead, and save lots of time;
(b) if you are aware of SSL, it would be interesting to know more about how this tool will improve on it.

#3 aigleborgne

aigleborgne
  • Member
  • 95 posts

Posted 16 November 2013 - 02:30 PM

You can do pretty much all of this in SSL, the scripting metalanguage used in SCS and aTweaks.

That's not a criticism - I'm sure SSL can be improved on. I mention it because
(a) if you're not aware of SSL, it might be that you can use that instead, and save lots of time;
(b) if you are aware of SSL, it would be interesting to know more about how this tool will improve on it.

 

I have looked at it brievly, not that much and it didn't seem to be that powerful. So, I'll get a look again this week ! :)



#4 aigleborgne

aigleborgne
  • Member
  • 95 posts

Posted 17 November 2013 - 12:02 AM

Below an example of my old generator for a level 20 mage. Config was set in an excel workbook, with all spells, triggers, and spell detection checkstat.

While it was quite ok, config were a mess to maintain and rather limitated, compared to a true database. Even the java code was quite a mess because of no database...

 

My new generator would be made from scratch, but based on my previous work. I want more declarative syntax, simplier if possible, and of course more powerful.

I have looked at some of your scripts in SCS and it is still strongely based on IE scripting engine. My system can be a total wrapper where you don't have to write a single line of IE scripting engine.

It means that my code could be shorter and thus, easier to read on huge script.

 

But well, I might be wrong about your system !

 

// Dradeel (Enchanter)
[CLASS=WIZARD;CASTER_LEVEL=20;MAX_SPELL_LEVEL=10]
[include=autocast_spell_arcane]


[action=CHAINCONTINGENCY(Improved Mantle,Ghostform,Protection from Energy,response<100>);require=seeEnemy]
[action=CONTINGENCY(Shadow Door,response<100>);requireSelf=hp%lt(51)]


[include=init_npc]
[include=tracking]
[include=disable_spellcasting]


[spell=Shadow Door;requireSelf=!improvedInvisible]
[spell=Shadow Door;requireSelf=hit]


[spell=Absolute Immunity]
[spell=Protection from Magical Weapons]
[spell=Stoneskin]


[spell=Spell Shield]
[spell=True Seeing]
[spell=Remove Magic]
[spell=Greater Malison]


[action=TRIGGER(Remove Magic,Hold Monster,Disintegrate,response<80>),
        TRIGGER(Remove Magic,Chaos,Disintegrate,response<100>)
 ;target=player;require=!disable,random(75)]


[spell=Selune's Blessing]
[spell=Selune's Curse;requireSelf=random(50)]


[spell=Comet]
[spell=Power Word Kill]
[spell=Symbol of Stunning]
[spell=Power Word Stun]
[spell=Power Word Blind]
[spell=Symbol of Weakness]
[spell=Prismatic Spray]


[action=SEQUENCER(Stoneskin,Protection from Missiles,Haste,response<100>);require=random(50)]
[action=SEQUENCER(Remove Magic,Greater Malison,Emotion Despair,response<100>);target=player;require=!disable,random(75)]


[spell=Domination]
[spell=Dire Charm]
[spell=Charm Person]
[spell=Disintegrate]
[spell=Power Word Silence]
[spell=Hold Monster]
[spell=Otiluke's Resilient Sphere]
[spell=Hold Person]
[spell=Confusion]
[spell=Emotion Despair]
[spell=Slow]


[spell=Selune's Blade]


[action=MINORSEQUENCER(Sleep,Power Word Sleep,response<80>),
        MINORSEQUENCER(Sleep,Ray of Enfeeblement,response<100>)
 ;target=player,fighter;require=!disable,random(75)]


[spell=Sleep]
[spell=Power Word Sleep]
[spell=Color Spray]
[spell=Knock]
[spell=Ray of Enfeeblement]
[spell=Melf's Acid Arrow]
[spell=Chromatic Orb]


[offensive_spells=Selune's Blade,Selune's Blessing,Selune's Curse]


[include=combat_caster]
[include=combat_smart]

 

template disable_spellcasting:

// Enable/Disable Spellcasting
[action=GLOBAL(ja#disable_spellcasting,0);requireSelf=global(ja#disable_spellcasting,1),canCast]
[action=GLOBAL(ja#disable_spellcasting,1);requireSelf=global(ja#disable_spellcasting,0),!canCast]

combat_caster:

 

// is there is any nearest enemy able to hurt me ?
[target=nearest(num:10,random:false);require=!disable,!stat(1,POLYMORPH_OTHER),see]


[name=Avoid melee if able to cast spells and no magical melee weapon
  ;action=RUN(60);requireSelf=global(ja#disable_spellcasting,0),global(ja#melee,0),movementgt(6)
                            ,!item(chillt),!item(ghoult),!item(phanblad),!item(blakblad),!item(sblade)
                            ,!item(shille),!item(shille2),!item(shille3),!item(shille3),!item(serious),!item(critical),!item(slaylive),!item(harm)
                            ,!item(fblade1),!item(fblade2),!item(fblade3),!item(fblade4),!item(fblade5),!item(fblade6),!item(fblade7),!item(fblade8),!item(fblade9),!item(fblade)
                            ,!item(shammr),!item(shammr2),!item(shammr3),!item(shammr4),!item(shammr5)
  ;require=!disable,!stat(1,POLYMORPH_OTHER),range(5),see]


[name=Avoid combat if able to cast spells and no magical weapon or invisible
  ;action=WALK;requireSelf=global(ja#disable_spellcasting,0),global(ja#melee,0),movementgt(6),!magicalWeaponItem;require=!disable,!stat(1,POLYMORPH_OTHER),see]


[action=WALK;requireSelf=global(ja#disable_spellcasting,0),global(ja#melee,0),!movementgt(6),!magicalWeaponItem;require=!disable,!stat(1,POLYMORPH_OTHER),see]

 

Code after generation is about 5000 lines, too long to post it here.

 


#5 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 16 December 2013 - 11:45 PM

This is very interesting. I too would like to know how it differs from SSL (also not a criticism - I am not really familiar with it either).


Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#6 -Aigleborgne-

-Aigleborgne-
  • Guest

Posted 14 January 2014 - 04:50 AM

This is very interesting. I too would like to know how it differs from SSL (also not a criticism - I am not really familiar with it either).

 

I can't talk a lot about SSL because I didn't dig a lot into it.

My current script editor is now fully integrated with my other tool (creature editor), which allow me more possibilities.

You can configure it with a user-interface. Spells can be imported from the game directory and link to a mod. A mod must be seen as a main spell mod, which should be Vanilla, Spell Revisions, or Spell Pack for example. At this point, all spells are loaded and pre-configured. 

 

For example, reading fireball will configure: fire damage, area of effect, harms self & allies, range 30, school invocation, level 3 ....

Then, you will script :

 

spell=fireball

 

It will automatically parse configuration to add appropriate triggers. You can also modify configuration with user-interface or bypass some parts using scripts options like:

 

spell=fireball(!hurtAllies)

 

...which means it won't hurt allies.

 

Spells importation will read all opcodes and projectiles, so it will take quite some time. Spells can have several different effects & projectiles based on level. At this point, it becomes difficult to properly code. So I will assume that they are all the same.

 

When you generate your scripts, you must say what mod to use. You can safely script spells without knowing what triggers to put, it will always be appropriate.

Additionnally, there is a lot of options that may activate or not: resting, tracking, look into resistances, saving throws.... All of this can be enable or disable before generation.

And I also want to decrypt spell detection from opcodes, so you will be sure there is no mistakes.

 

All configuration is stored in a HSQL database, so no install is required !

User-interface runs a tomcat 7 server which might be integrated into jar using spring boot (I wait for a more stable version).

Script generator will be run on a command line and also integrated on user-interface, to allow visualisation before and after generation. I might also add an editor for it with syntax coloring and helpers for triggers/action/template....

 

As you can see, it's quite a big project.... still very early on development stage but I work on it around 2-3 hours per day.

Code is available on github if anyone is interested.