|
Post by Fafnir on Aug 23, 2005 18:58:54 GMT -6
Ok, as of this moment in my mod, I have succesfully managed to grant creatures spell casting abilities, as well as work around all the bugs that were giving me problems.
Currently, golems get 3 daily charges of create rock, and a once per battle use of a self stoneskin ability. Gargoyles possess the ability to turn themselves to stone once per day, preventing movement for 20 seconds but greatly enhancing armour and health regen.
|
|
|
Post by Boaster on Aug 23, 2005 19:48:58 GMT -6
So whats the story? Can you give point-by-point specifics of what you did to create this?
|
|
|
Post by Fafnir on Aug 23, 2005 23:32:23 GMT -6
Ok, I shall do my best. I'll use the golem as an example. This explanation won't be very comprehensive for any one not already very familiar LOMSE gs modding.
Step #1: find champion.gs Find the Code reffering to cr5. Modify it so that it looks something like this: {a u UNIT_TYPE getunitdata unittypedict begin eacr2 end eq{a u artifactdict begin eacr2art end createartifactnow pop}
This will create a custom artifact on the golem everytime he is hired from the wizard's tower.
Step #2: make an invisible custom artifact (in this case eacr2art) with a begin combat proc that looks something like this:
artifactarmy artifactunit unittypedict /eawmi get permanentpolymorph artifactarmy artifactunit 2 copy artifactdict begin rockart end createartifactnow wieldartifact
Step #3: Find eawmi (troll) in the units section. Take all the data from the file, copy it and set it aside somewhere. Copy all the eacr2 (golem) data and stick it in there. Change all references to eacr2 to eawmi except the impfile. Change wizard's tower required to 4. Keep unit code as CR2. Make it special_unit_type Warrior and give him CAN_USE_LEFT/RIGHT_ARTIFACT.
Step #4:Create a Wield_Either custom artifact (in this case rockart) that can cast Stoneskin with enough mana to cast it once.
1st RECAP: Up till now we have an invisible artifact that comes with the golem that polymorphs the golem into a champion unit at the start of combat and creates/wields an artifact on him that allows him to cast stoneskin once. We're one third of the way there... more to come.
EXPLANATION OF EVERYTHING UP TO THIS POINT: Basically, invisible artifacts can't cast spells daily and regular units can't use left/right artifacts. To get around this problem, I made an invisible artifact that polymorphs the golem into a champion unit, allowing him to use the artifact that casts spells.
Problems so far: There are a few, but i'll address how to fix them in the next few posts (coming in the next half hour).
|
|
|
Post by FAFNIR on Aug 23, 2005 23:51:42 GMT -6
STEP #5: Add an end combat proc to the invisible artifact (in this case eacr2art) that looks something like this:
artifactarmy artifactunit artifactdict begin rockart end destroyartifacttype artifactarmy artifactunit unittypedict /eacr2 get permanentpolymorph
This will destroy the spellcasting artifact and polymorph the champion golem back to the regular golem before he returns to the minimap (this prevents any wierd army things with the golem occupying the champion slot once you leave combat)
2nd RECAP: OK, in a nutshell that's how I did it, but we're nowhere near done yet. There are shit loads of problems with this which need to be fixed. I've managed to fix them all, but it's taken time. I'll try to list them all here along with how I fixed them.
1st problem: Multi level dungeons. Entering the second lvl of a multi level dungeon will reorganize your army in such a way that the champion golem unit will occupy the champion slot, which is not a desireable thing. In order to fix this you need to find combat.gs. Find the part refering to licr3 (in the cleanup spells at end section) and add some code that looks like this:
army_id 0 UNIT_TYPE getunitdata unittypedict /eawmi get eq{army_id 0 unittypedict /eacr2 get permanentpolymorph}if
If you've been following closely you'll know that this polymorphs the champion golem back to the regular golem during the clean up spells phase at the end of combat. This is important because the clean up spells phase occurs before you can venture to the second level of the dungeon, but the end combat proc doesn't. This clears up the problem with the golems occupying champion slots. Also, you'll probably want to add a line that looks like this to the begin combat proc of the invisible artifact, before it creates the second artifact.
artifactarmy artifactunit 2 copy artifactdict begin rockart end destroyartifact
this prevents the golem from ever having two of the same spell casting artifact at the same time.
More to come...
|
|
|
Post by Fafnir on Aug 23, 2005 23:53:26 GMT -6
quick correction about just that last bit of code. It should read:
artifactarmy artifactunit artifactdict begin rockart end destroyartifact
not
artifactarmy artifactunit 2 copy artifactdict begin rockart end destroyartifact
It makes a big difference
|
|
|
Post by Fafnir on Aug 24, 2005 0:02:02 GMT -6
2nd Problem: The original eawmi.
Yes i gutted the troll unit's code to do this. There are two ways to fix this. The long and hard way to fix this, (which I did) is as follows:
Create a new custom unit. Call it something like eawmc. Make sure to add it to unittype.gs. Paste the troll's code into it. Change all the eawmi to eawmc. Now the long part. Go through EVERY dungeon, and makearmy.gs, and change every reference to eawmi to eawmc.
The alternative to this? Skip the first step (back in my first post) about using eawmi as the file for the champion golem unit, and instead use a custom file for the golem. The downside to this is that sounds don't work properly on added unit files, but they work fine for the unit files that are already there, no matter how much you alter them. So I reasoned that I'd sooner have a troll (which you don't get to control) have broken sound then the golem, which the unit you actually get to use. For some reason the attack and die sounds work fine on the troll, just none of the other ones (no clue why)
more to come...
|
|
|
Post by Fafnir on Aug 24, 2005 0:24:16 GMT -6
Problem #3: Per day, not per battle.
This is the trickiest one to fix. If you've been following my explanation perfectly so far, you might have noticed that a new spell casting artifact, with new artifact mana and new charges, gets created at the start of EVERY battle. This means that instead of giving the golem a once daily use of stoneskin, he gets a once per battle use. For the spell stoneskin, I reasoned this would be ok. But for other spells, this could pose a problem. My fix for this is yet again long and cumbersome, but worth it if you want the creature spells to function properly. To illustrate, i'll use the golem's second ability, 3 daily charges of creterock, as an example (NOTE: the artifact used here is called eacr2art2, which is a different artifact from eacr2art. I know it's confusingly named, but you'll have to bear with me)
The Concept: The idea here is to make use of charges to limit the use to per day instead of per battle. Every time an artifact that has charges is used to cast a spell, it loses a charge. I devised a code that sets the number of charges on the invisible artifact to the number of charges on the spell casting artifact during the clean up phase of every battle (in combat.gs) that looks like this.
{army_id 0 UNIT_TYPE getunitdata unittypedict /eawmi get eq{
army_id 0 artifactdict begin eacr2art2 end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES getartifactdata 1 lt{ pop army_id 0 artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES 0 setartifactdata}if}if}if
pop army_id 0 artifactdict begin eacr2art2 end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES getartifactdata 1 eq{ pop army_id 0 artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES 1 setartifactdata}if}if}if
pop army_id 0 artifactdict begin eacr2art2 end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES getartifactdata 2 eq{ pop army_id 0 artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES 2 setartifactdata}if}if}if
pop army_id 0 artifactdict begin eacr2art2 end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES getartifactdata 3 eq{ pop army_id 0 artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {army_id 0 artifact_id ARTIFACT_CHARGES 3 setartifactdata}if}if}if)if
Yes it's long. But's it's not as complicated as it might first appear.
I then added some code that sets the number of charges on the spell casting artifact to the number of charges on the invisible artifact when it is created, by adding the following lines to the mod proc of eacr2art2
artifactarmy artifactunit UNIT_TYPE getunitdata unittypedict /eawmi get eq{artifactarmy artifactunit artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {artifactarmy artifactunit artifact_id ARTIFACT_CHARGES getartifactdata 1 lt{artifactarmy artifactunit artifactself ARTIFACT_CHARGES 0 setartifactdata}if}if}if
artifactarmy artifactunit UNIT_TYPE getunitdata unittypedict /eawmi get eq{artifactarmy artifactunit artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {artifactarmy artifactunit artifact_id ARTIFACT_CHARGES getartifactdata 1 eq{artifactarmy artifactunit artifactself ARTIFACT_CHARGES 1 setartifactdata}if}if}if
artifactarmy artifactunit UNIT_TYPE getunitdata unittypedict /eawmi get eq{artifactarmy artifactunit artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {artifactarmy artifactunit artifact_id ARTIFACT_CHARGES getartifactdata 2 eq{artifactarmy artifactunit artifactself ARTIFACT_CHARGES 2 setartifactdata}if}if}if
artifactarmy artifactunit UNIT_TYPE getunitdata unittypedict /eawmi get eq{artifactarmy artifactunit artifactdict begin eacr2art end artifacttypegetuniqueid /artifact_id exch def artifact_id -1 ne {artifactarmy artifactunit artifact_id ARTIFACT_CHARGES getartifactdata 3 eq{artifactarmy artifactunit artifactself ARTIFACT_CHARGES 3 setartifactdata}if}if}if
Finally, I added the following lines to the begin turn proc of eacr2art that reset the number of charges each turn.
artifactarmy artifactunit artifactself ARTIFACT_CHARGES 3 setartifactdata
And that's that.
|
|
|
Post by Fafnir on Aug 24, 2005 0:26:41 GMT -6
Ok, i think that's almost everything. As you can see this won't work for units created in the lord editor, which is ok for my mod, because i'm going to disable the lord editor. But otherwise, for all playing functionality, it should work perfectly. I might be leaving something out, but I think I more or less covered it all.
|
|
|
Post by Fafnir on Aug 24, 2005 0:31:03 GMT -6
Oh one more thing, saved games made before you change all this won't work properly after you've done this. They'll be playable, but there might be a few things off about (eg: monster placement). All new games and saved games made after you make the change will work 100%
|
|
|
Post by Boaster on Aug 24, 2005 9:14:09 GMT -6
Stickied for those interested.
|
|