I've added this feature
to our TC BG2 add-on CZ. I think that it would provide some
ideas or methods which can be added to other mods. I've tested
it properly, but especially from the technical side, no in
the true gameplay. I'm posting here this text but it is not
real 'tutorial'. It is just the text for the compare with
your modding and scripting experience - maybe, we'll find
some better ways how to improve non-lethal attack system.
AD&D says:
Non-Lethal Weapon Attacks
It is possible to make an armed attack without causing serious
damage--striking with the flat of the blade, for example.
This is not as easy as it sounds, however.
First, the character must be using a weapon that enables him
to control the damage he inflicts. This is impossible with
an arrow or sling. It isn't even feasible with a war hammer
or mace. It can be done with swords and axes, as long as the
blade can be turned so it doesn't cut.
Second, the character has a -4 penalty to his attack roll,
since handling a weapon in this way is clumsier than usual.
The damage from such an attack is 50% normal; one-half of
this damage is temporary, lasting one turn after the fight
is over and causing unconsciousness (never death) if the character
drops below zero hit points.
But I've modified it a little - no -4 penalty to THAC0; all
damage caused by this non-lethal attack is temporary (creature
losts HPs still; by what type of attack it reaches 0 HP it
will determine whether is the creature dead or unconscious).
Just some creatures can be affected by this attack. For example,
undead, magic or another unnatural enemies can't be affected
by non-lethal attack. Humanoids (humans, demi-humans, orcs,
gnolls, kobolds,...) and animals are general groups of creatures
which can be affected by non-lethal attack.
Why... ?
I think that non-lethal attacks system highly improves the
game possibilities. The player has more than two alternatives
how to solve the problems - not only dialog or fight - but
this compromis as well. If the player cannot 'defeat' his
enemy in dialog, he has still other way instead of the killing
his enemy. It is great especially for the paladins and good
characters - they aren't forced to killing their enemies.
Some stealth quests can be based on non-lethal attacks system
as well (quest where the character must infiltrate some building
etc. without "true" fight that can launch the alarm
and attention of guards). And finally, mini-stories about
the defeated enemies who watch the party for the revenge ("You
should kill me then. Now, I'll kill you ;-)))
Experiences...?
I think that combat experiences don't mean the fact that you've
killed your enemy, but the fact that you've defeated your
enemy. So according to that conception, there is no problem
about the XP - party gains the same amount of the XP as in
normal combat and no matter whether the cre was killed or
just defeated.
What is necessary...?
Item, creature, spell, effect and ids editing + scripting.
I'll demonstrate all modding stuff in DLTCEP terms...
Creature editing #1...
Why the creature editing? Because of the modifying of the
XP system. Party gets XP not just by the killing of the creature
but through its defeating as well - that means killing as
well as the defeating by non-lethal attacks system. XP value
of the creature is fixed only to the killing of cre, however.
That's the first problem. This can be solved via script. But
the second problem is how to ensure that party will get the
XP only once (defeating of the cre (xp) and then killing of
the cre (xp as well for second time)). So we must script both
of possible xp awards - means that there is a necessity to
set XP value field of all cretures affected by non-lethal
attacks system to 0. Everything will be scripted.
(Long sword editing for example)
Effect editing...
We have to make external effect through it will be simulate
non-lethal attacks system damage of our weapon (see below).
The new effect has opcode: HP: Damage [12]. Its target is
'pre-target' and permanent timing. Damage type: 134217728
(stunning) and 1d8 in dice/level limit - this simulates the
normal 1d8 damage of long sword but in non-lethal form. Left
'Damage amount' field as 0. Save it as _PLDAM8, for our example.
We have the damage effect for our long sword.
Item editing... (+effect and ids editing
as well...)
Well, we have a long sword for example. One extension header
is for the normal attack. We want to add another for our non-lethal
attack. Add new extension header. The copy of the first extension
header can be pasted here for the easier editing of original
long sword statistics. Main changes here - damage type: 'None';
damage rolls: 0dX; Tooltip: 'Non-lethal attack'; Charges:
0 and removal: 'Expended'. We can add Tooltip: 'Normal Attack'
to the first extension header; + we can alter the normal "attack
icon" (sword in this case) a little for non-lethal attact
extension header to differ the icons of normal and non-lethal
attack.
With these changes we have now: the sword that have two mods
of usage (the second is still "blank" at this moment).
We can switch them via right click on the attack icon on the
'main screen' in weapon slots or in the inventory via right
click on the item as well. Now we will put the effect to the
second extension header. This effect makes the heart of our
system.
Before that we have to do the little editing of STATS.IDS
(or use the default SCRIPTINGSTATE1..10). Add the line after
SCRIPTINGSTATE10 (or after some additional custom scripting
states from others mods) - I've had to add line 181 NON_LETHAL_ATTACK
Why the scripting state? To check in script, we have to have
some indication whether the creature fall unconscious under
our non-lethal attack. We can do this via the temporary assigning
of our scripting state to the cre affected by non-lethal attack.
Back to the effects in 2nd extended header of the item. The
weapon in the second mod of attack doesn't do anything now,
so we will add the non-lethal damage.
We have to ensure that the non-lethal damage will be given
just for the proper creatures (humanoids, animals,...). That
can be done via IDS targetting with 'Use EFF file [177]' effect.
Well, add this effect. We can target it to the certain type
of creatures through the IDS files and their entries. In case
of humanoids we use IDS file: 3-general; Entry: 1-humanoid
(for animals, etc. we must add another 'Use EFF file' with
corresponding IDS targetting). All our 'Use EFF files' have
target: pre-target and permanent timing. The effects' resource
is our damage effect made before (_PLDAM8).
Except the damage effects (done via 'Use EFF file' effect)
we have to add our 'scripting state indication'. Add the effect
'Scripting State Modifier [282]'. Target: 'pre-target'; timing:
duration, 10 (it is just the temporary assigning after the
succesful hit for the scripting purposes). Value: 1; Scripting
State: 25 (in my case; the description of that effect tells
us to substract 156 form the number of the line in STATS.IDS...
I have line 181 so: 181-156=25).
It is not necessary to put this effect under IDS targetting.
If the character will attack the creature which is immune
to non-lethal attack, the 'damage' effect does no damage (due
to ids targetting) and 'scripting state modifier' effect just
temporarily assign scripting state to the creature that means
nothing.
And that's all with the item editing.
Scripting...
Now, we can solve the combat situation when the creature falls
unconscious under our non-lethal attack - XP, equipment, etc.
General principle: In this method the party gets XP just once
and it is possible to get the equipment of the unconscious
creature. Equipment handling is done via invisible creature
that is summoned at the moment when the creature falls unconscious
(I've made it in this way because I was afraid about the proper
script running in unsconscious creature... and it is imho
better at all...).
All party members will get the "innate ability"
'Search enemy' (described below). If the player use it, the
character (if is in range) will get equipment of the unsconscious
creature via script of invisible creature. This is done in
the following way: "casting" of this innate summons
another invisible creature that has shout. The first invisible
creature is sensible to this shout and under conditions it
transfer equipment to the player's character inventory.
Scripts with a small desription. Complete
explanation is below of all scripts.
Script assigned to all creatures affected by non-lethal attacks:
IF
Die()
Global("NaPlocho","LOCALS",0)
THEN
RESPONSE #100
AddexperienceParty(70) //everything is done - creature is
dead, we have XP
END
IF
StateCheck(Myself,STATE_SLEEPING) // creature is unconscious
Global("NaPlocho","LOCALS",0) // for the
first time
CheckStat(Myself,1,BOJ_NAPLOCHO) // under our non-lethal attack
THEN
RESPONSE #100
ApplySpellRES("INV5",Myself) // invisible creature
is summoned on the unsconscious creature
SetGlobal("NaPlocho","LOCALS",1)
AddexperienceParty(70)
END
IF
StateCheck(Myself,STATE_SLEEPING)
CheckStat(Myself,1,BOJ_NAPLOCHO)
Global("NaPlocho","LOCALS",2) // creature
is not unconscious for the first time but there is the special
situation (see below, #1)
THEN
RESPONSE #100
ApplySpellRES("INV5",Myself)
// !!! -> AddexperienceParty(10) <- just for the test
purposes!!!
SetGlobal("NaPlocho","LOCALS",3)
END
#1 - Special situation means the following situation:
Party defeated its enemy but didn't get its equipment (but
got XP). Then party defeated the enemy for second time - it
gets no XP but still the possibility to get enemy's equipment
(summoning of the invisible creature).
Script of the invisible creature (cze_itm2):
IF
!StateCheck(LastSummonerOf(Myself),STATE_SLEEPING) // my summoner
is no longer uncoscious
THEN
RESPONSE #100
ActionOverride(LastSummonerOf(Myself),SetGlobal("NaPlocho","LOCALS",2))
// exit without the transfer of the equipment
DestroySelf()
END
IF
Heard([ANYONE],1001) // shout sensibility, #2
Range([PC],4) // character is in range
!Global("DosahProhledavani","LOCALS",1)
THEN
RESPONSE #100
SetGlobal("DosahProhledavani","LOCALS",1)
END
IF
!Range([PC],4) // character is not in range
THEN
RESPONSE #100
SetGlobal("DosahProhledavani","LOCALS",0)
END
IF
Global("DosahProhledavani","LOCALS",1)
// character is in range as well as the shout was heard
THEN
RESPONSE #100
DisplayStringHead(LastSummonerOf(Myself),'Searching of the
enemy...')
ActionOverride(LastSummonerOf(Myself),GivePartyAllEquipment())
// equipment transfer
DestroySelf()
END
#2 - there was a problem. Is seems that shout
are stored in the creature's "memory" in some way.
If the shout was heard and pc wasn't in the range nothing
was happened. But if the pc reached the range (without any
other use of 'search enemy' ability - another shout) the equipment
was transfered. However I didn't want this 'delayed transfering'
of equiment. I want to transfer when the button (innate ablitity)
is pressed so I had to do that variable handling in teh script
that seems to work fine.
Short script of the second invisible creature
sumonned after the 'casting' of 'search of enemy' innate ability.
(cze_itm3)
IF
True()
THEN
RESPONSE #100
Shout(1001) // shout
DestroySelf()
END
Complete explanation:
- Variables/Globals:
NaPlocho 0 - nothing was happend
NaPlocho 1 - XP was added, equipment was transfered
NaPlocho 2 - XP was added, equipment wasn't transfered
NaPlocho 3 - no additional XP was added, invis cre was summoned
another time; variable is left with this value if the equipment
was transfered or it is changed to value 2 if the equipment
wasn't still transfered
I think that the explaining of the values
of mentioned variables is sufficient to understand how both
scripts work and communicate.
Creature editing #2...
We want to create our invisible creatures. Just two creatures
with effects 'Transparency Fade [66]' (self; permanent; param
1: 255; param 2: 0), 'Selection Circle Removal [287]' (self;
permanent; params: #1 (constant value): 1, #2: 0) and with
item MINHP1 equiped (ensures the immortality of these creatures).
Two creatures cze_itm2, cze_itm3 with the corresponding scripts
(cze_itm2, cze_itm3) assigned.
Spell editing...
We have to make two spells - one that summons the invisible
creature when the creature falls unconscious and second that
is the "innate ability" 'search enemy" (that
actually summons invis cre as well).
First spell: in the 'general properties'
- spell type: innate; schoolless graphics (or I have 03 unknown
here ;))
in the 'extended effects' - required level: 1; normal form;
location: 'Innate'; target num.&type: 0, self; range:
10; speed: 0; no projectile animation; effect: 'Use EFF file
[177]' (pre-target; permanent, param 1: 0; param 2: 2; resource:
cze_itm2 (effect) -->
effect cz_itm2: 'Creature Summoning [67]' - target: none;
timing: permanent; resource: cze_itm2 (creature) ).
I've saved this spell as INV5 (but the name has no role with
RES actions)...
Second spell: it differs from previous just
in these things -
extended effects:
- it has casting icon (depends on your choice what icon ;)
- target type: none
- and resource in 'Use EFF file' is obviously cze_itm3 (and
the effect cze_itm3 has just one change from cze_itm2 - its
creature resource is cze_itm3)
I've saved it as SEARCHNL...
And this is all - non-lethal attack system
should work with these changes and new stuff :))
just how to add 'search enemy' into "special
abilities":
Add following block to the area script of the first location
of the game/mod or into baldur.bcs... or just the line with
ActionOverride somewhere to initiate block of actions of the
new game...
IF
Global("NastaveniAbilit","GLOBAL",0)
THEN
RESPONSE #100
ActionOverride(Player1,AddSpecialAbility("SEARCHNL"))
SetGlobal("NastaveniAbilit","GLOBAL",1)
END
Possible problem and ideas of improvements
1) I'm thinking about the apply of THAC0
penalty in case of non-lethal attack. Is it possible to use
negative numbers for THAC0 bonus field on extension header,
rsp. do negative numbers work?
2) I don't know about the "regeneration"
of damage suffered by non-lethal attack (~fist damage). Via
the attack to party memeber (it is possible to watch the progress
of HPs of certain creature) I figured out that creature lost
its HPs to the minimun of 1 HP and then falls unconscious.
But I can't figure out the duration of unconscious state (maybe
dependance to CON value). When the creature recovers consciousness
it has still 1 HP. Which is bad. I'm thinking about 50% of
its HP at minimum. So via modified Heal spell the creature
can get certain amount of HP when recovers consciousness -
technically, the script of cre (or maybe the script of invis
cre summoned when the creature falls unconscious) includes
ApplySpellRES("ModifiedHeal",Myself()) /ApplySpellRES("ModifiedHeal",LastSummonerof(Myself()))/
under certain conditions.
3) Transfer of equipment. Seems good but
there are some unnatural problems. For example - transfer
of heavy armor. It can be the quite problematic to strip unconscious
enemy from heavy armor. So maybe there should be some restriction.
It seems as quite complex to exclude heavy armors from this
system. I have in mind some solutions but there are very complex...
so if anybody has any elegant solution, it will be great ;)
|