Help - Search - Members - Calendar
Full Version: Non-Lethal Combat
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Tutorials, hints & tips
Vlasák
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 :

CODE
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):

CODE
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)

CODE
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 wink.gif)
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 wink.gif
- 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 smile.gif)

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...

CODE
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",Myslelf()) /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 wink.gif

Vlasak
jastey
Hi,
I didn't read everything in detail now, but the idea is to make an enemy unconscious instead of killing him? I always wished a possibility like that, if only for the wild bears that only attacked me because I got too close (that was BG1, but well!) Having to kill every person I am not in agreement with is one of the things that are disturbing me at the BG series...
Great idea!

Edit: I have the impression this is a spam post. Sorry! sad.gif
Vlasák
yep, you can make your enemy unconscious instead of killing him. You get the XPs as well as the equipment (if you want) of your enemy.
jastey
Please don't hit me if I could have read this somewhere else...

What exactly happens to the enemy then? Does he/it wakes up after some time, fighting me again? Or does he "dissappear", pretending he ran away after waking up because I've beaten him?

Is the BGII add on also for BG1Tutu, or do you plan to make such a mod for BG1, too? (Talking about wild bears again...) smile.gif
Vlasák
What exactly happens to the enemy then? All enemies will wake up after some time - what will follow depends on the certain situation.
Your enemy can run away - because he can be afraid of you as he has been already defeated by you or due to he has no equipment as you have got it from him... He can run away, recover and track you with reinforcement as the revenge...
Many mini-quest can be based on this too - you must make your enemy unconscious to dismay him to get some secret information from him... or you can get just the reputation in the pub if you defeat a local thug... etc. etc.

There are many possibilities how the enemies as well as netural NPCs can react to the fact that you've have defeated them by this type of attack... dialog options, their actions, your reputation, reaction of your companions etc.

It can be developed for the story purposes as well - if you defeat one of your major enemies by this attack and do not kill him he can help you in the late stage of the story as a revard that you have left him alive...

Our BG2 add-on for what i've developed this method is BG2 TC - the name is just temporary and can get people in the impression that it is rather small mod due to the "add-on" in the name. We must conceive better and serious name to avoid this mystification rolleyes.gif

I'm not going to apply this possibilities into BG1 or BG2 - it will be very complex and especially very time consuming to turn all the BG1/2 original content for Non-Lethal attack option. In case of whole new mods, their creators count with this possibility from the beginning and everything is simplier.

Everyone can improve, modify or just use this method in his mods so such "Non-Lethal attack" expansion of the original BG2 is not only up to me wink.gif
jastey
Yes, of course... I guess from my post you saw that I got it wrong, I thought it could be implemented into BGII, giving the opportunity of non-lethal combat for the fights, but YES, considering the need of the invisible creature for item transfer I *could* have noticed myself that it was a stupid question... dry.gif

By the way: I am very curious to use this idea in my mod, I think it would fit perfectly, as I am writing Ajantis (paladin...) for BGII, and *sigh* I guess the amount of work just tripled... laugh.gif
jastey
Vlasák,
I have some questions to the non-leathal attack tutorial which most probably show that I didn't quite understand the principle yet.
If the weapons have to be modified for the non-leathal attack to function, this means the party has to use special weapons for a fight to be able to make it a non-leathal one, i.e. the ability of the non-leathal attack is coupled with the weapon and can't be restricted to a special fight, yes?
In your mod, how do you prevent the player using these weapons for non-lethal attack in a fight where it's not planned to function? Is it in any way possible to restrict the non-lethal ability to a special fight?
Is it possible to equip the weapons (swords, axes) the party members already use with the non-lethal ability?
Thanks,
jastey
Vlasák
Well, the non-lethal attack (NLA) is not the character ability but the weapon ability. If you have the proper weapon for NLA you can use this method of attack at will - against the orc, against the vampire, against the human figher, against the dragon, etc.... Some creatures are vulnerable by this attack, other creatures aren't.

There are no special weapons or fights - there are just weapons with the possibility to NLA and creatures who are "sensible" for NLA. If I want to make the plot based on NLA - I'll edit NLA scripts of important cres (variables etc.) and I can work with it later in story; If I want to make the quest based on NLA it is similar as previous... and if I want to make some commoner, I'll use some basic script, i.e. the cre will escape the are after it gets consicous...

The key of the system is in the modified items (additional extension header), assigning/detecting of scripting states, invisible cre and its scripting...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.