Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#561639 21/01/15 05:30 AM
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
I played around character levels/character stats today and I noticed that every single fight in the game has "hard coded" levels.
Even if the stats are dynamic and change depending on the levels, the fights are fixed ( in the main campaign).

I whipped up this simple script to adjust enemy level to the player level.

Code

PROC
	ProcAugmentLevel((CHARACTER)_Character,(INTEGER)_Level)
AND
	CharacterGetLevel(_Character,_CurrentLevel)
AND
	_CurrentLevel < _Level
THEN
	CharacterLevelUp(_Character);
	ProcAugmentLevel(_Character,_Level);



This command can be called, for example, when a character enters a trigger and enemies are spawned.
Code full code ex :

Code
//In the Init section
TriggerRegisterForPlayers(TRIGGER_MyTrigger);
DB_WolvesAttackTrigger(TRIGGER_MyTrigger);
DB_WolvesTrigger(CHARACTER_Wolf,TRIGGER_WolfSpawn,1);

//KB
IF
	CharacterEnteredTrigger(_Player,_Trigger)
AND
	DB_WolvesAttackTrigger(_Trigger)
AND
	DB_WolvesTrigger(_Character,_SpawnTrigger,_PlayAnimation)
AND
	_Player.isPlayer()
AND
	CharacterGetLevel(_Player,_Level)
THEN
	ProcAugmentLevel(_Character,_Level);
	ProcWolfAppear(_Character,_SpawnTrigger,_PlayAnimation);

PROC
	ProcAugmentLevel((CHARACTER)_Character,(INTEGER)_Level)
AND
	CharacterGetLevel(_Character,_CurrentLevel)
AND
	_CurrentLevel < _Level
THEN
	CharacterLevelUp(_Character);
	ProcAugmentLevel(_Character,_Level);



Note : This could also be applied to scale down enemies. It's easier to simply create each character at level one
and let the stat engine do the hard work for us smile


This is useful in the mod I'm making with Bard because we do not know in which order the player will fight each group of enemies.
Letting them scale up automatically let's us focus on other parts of the mod like dialogs, treasure etc...

Edit
The gain field from the stats script is dependent on the "Act part" property, not the character level in game
( I really wish it was the other way around...)
My previous theory was busted, but I have a solution for my automatic level of enemy to follow the experience line.


Every time a character dies, Osiris will catch the event and add the experience according to the level.
Code

//INIT
//Database containing all the max EXP / LEVEL of the player
DB_LevelExp(0,0);
DB_LevelExp(1,2000);
DB_LevelExp(2,6000);
DB_LevelExp(3,12000);
DB_LevelExp(4,20000);
DB_LevelExp(5,30000);
DB_LevelExp(6,42000);
DB_LevelExp(7,56000);
DB_LevelExp(8,72000);
DB_LevelExp(9,90000);
DB_LevelExp(10,110000);
DB_LevelExp(11,132000);
DB_LevelExp(12,156000);
DB_LevelExp(13,182000);
DB_LevelExp(14,210000);
DB_LevelExp(15,240000);
DB_LevelExp(16,272000);
DB_LevelExp(17,306000);
DB_LevelExp(18,342000);
DB_LevelExp(19,380000);
DB_LevelExp(20,420000);
DB_LevelExp(21,462000);
DB_LevelExp(22,506000);
DB_LevelExp(23,552000);
DB_LevelExp(24,600000);
DB_LevelExp(25,650000);
DB_LevelExp(26,702000);
DB_LevelExp(27,756000);
DB_LevelExp(28,812000);
DB_LevelExp(29,870000);
DB_LevelExp(30,930000);

//Database containing enemies you want to apply the manual exp/level system too. 
//Second parameter is a percentage. In this case, 10% of the level of the enemy 
//( 11000 exp if enemy is level 10)
DB_CharacterGain(CHARACTER_Aeril_Animals_W_Black1,0.1);


//KB
IF
	CharacterDied(_Character)
AND
	DB_CharacterGain(_Character,_Gain)
AND
	CharacterGetLevel(_Character,_Level)
AND
	DB_LevelExp(_Level,_ExpForLevel)
AND
	_Gain > 0
AND
	Real(_ExpForLevel,_ExpForLevelAsReal)
AND
	RealProduct(_ExpForLevelAsReal,_Gain,_ExpProduct)
AND
	Integer(_ExpProduct,_ExpProductAsInt)
THEN
	PartyAddExperience(_ExpProductAsInt);
	NOT DB_CharacterGain(_Character,_Gain);




This is it, both methods are tested and works. Automatic scaling of enemies + percentage based on the level of the enemy acquired as experience!

Hope this helps!

Last edited by TheMasterRat; 23/01/15 02:41 AM.
Joined: Oct 2014
B
enthusiast
Offline
enthusiast
B
Joined: Oct 2014
Some pretty slick scripting there. If I wasn't 3/4 done with my game I'd use it, but now mine is designed to be gated by NPC levels like D:OS was.

Maybe I'll use it for the next mod, if I can find the energy to make it when this one's finally finished.

Burgee #561704 23/01/15 03:38 AM
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Originally Posted by Burgee

Maybe I'll use it for the next mod


Hey Burgee, thanks for taking a look at it smile

If I can suggest a usage for this ( In your current mod ) is making some kind of sidequest / cavern / Fountain of youth / secret pirate hideout ( You get the picture) where the quest is accessible either from many places ( the crossing zone of a map / a teleport area / insert more cool ideas here ) but you do not know when the player will notice this or have access. You can easily use the script above into your mod and have an All level accessible quest!

Just a suggestion, if you ever feel like trying it out smile

Joined: Aug 2009
journeyman
Offline
journeyman
Joined: Aug 2009
Can you make a mod for the normal D:OS which makes enemies you encounter your level? Would be great. smile I love the game but when I missed out on something and come back to it the combat is boring because I'm overleveled for them. I would love them to be my level instead. smile

Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
I feel like this might work as a general-purpose script, rather than setting each and every encounter each time:

Code
IF
CharacterEnteredCombat(_Char, _)
AND
NOT _Char.IsPlayer()
THEN
ProcLevelUpEnemies(_Char);


PROC
ProcLevelUpEnemies((CHARACTER)_Char)
AND
CharacterGetLevel(CHARACTER_Player1, _pLevel)
AND
CharacterGetLevel(_Char, _eLevel)
AND
_eLevel < _pLevel
THEN
CharacteLevelUp(_Char);
ProcLevelUpEnemies(_Char);



I think that would have the drawback of showing the enemies level up each fight though, and I'm not sure how stats scale or whether points need to be added to enemies individually.

Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Rhidian's suggestion would work for the level.

The stats seems to be calculated each time a character levels up, which means that this theory would work.

The drawback of your solution VS the one I implemented is the experience gained. The EXP gained is not linked to the enemy's level, but rather it's stat in the character sheet.


Joined: Aug 2014
old hand
Offline
old hand
Joined: Aug 2014
I think it'd be okay for the EXP gain to not increase for encounters in main. Monsters would get stronger, but players would still have the same level progression so players wouldn't get overly powerful because we messed up the EXP rewards.

Possibly certain fights would be still be easy or would become really hard with leveled up enemies, but I think it'd be more interesting in general than walloping enemies even a single level below you almost for certain. I'm not sure if this script would level enemies down, and I'm not sure whether it should or not. It'd be cool if it would do it to a degree (maybe down to -3 or -4 levels) so the player has a bit more freedom on how he progresses, but not so much that the player could fight the last boss at level 4 or something.

Also I'm not sure how this would affect loot, whether enemies would drop items appropriate to their new level or their default one. I don't think it would be too bad either way. Obviously throwing a blanket script on enemies is going to create some balance problems, but I don't know whether it would actually break anything.


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5