A script for DnD style levelling

Post » Wed Jun 20, 2012 11:42 pm

I wrote a script that when attached to any actor that's going to be killed by the player (this is for people making new games, not really modding vanilla game) it gives you a set amount of exp, and if you go over a certain amount of exp it levels you up (artificially by setting a global, which you can then associate with the "gains" you want so that you don't level in the manner of Skyrim)
EDIT: Where it says PlayerTeammateCount replace with PlayerFollowerCount
Here's the script:

Scriptname ExperienceModifier extends ActorGlobalVariable Property TormPlayerExp autoGlobalVariable Property PlayerTeammateCount autoint Property ExpOnDeath autoGlobalVariable Property TormPlayerCurrentLevel autoevent OnDeath(Actor akKiller)   int initialExp = TormPlayerExp.GetValue() as int   int ModdedExp = (ExpOnDeath/PlayerTeammateCount.GetValue() as int) + initialExp   TormPlayerExp.SetValue(ModdedExp)   if initialExp<100 && ModdedExp >=100	  TormPlayerCurrentLevel.SetValue( 2)   endIf   if initialExp<250 && ModdedExp >=250	  TormPlayerCurrentLevel.SetValue( 3)   endIf     if initialExp<350 && ModdedExp >=350	  TormPlayerCurrentLevel.SetValue( 4)   endIf     if initialExp<600 && ModdedExp >=600	  TormPlayerCurrentLevel.SetValue( 5)   endIf     if initialExp<950 && ModdedExp >=950	  TormPlayerCurrentLevel.SetValue( 6)   endIf     if initialExp<1550 && ModdedExp >=1550	  TormPlayerCurrentLevel.SetValue( 7)   endIf     if initialExp<2500 && ModdedExp >=2500	  TormPlayerCurrentLevel.SetValue( 8)   endIf     if initialExp<4050 && ModdedExp >=4050	  TormPlayerCurrentLevel.SetValue( 9)   endIf     if initialExp<6550 && ModdedExp >=6550	  TormPlayerCurrentLevel.SetValue( 10)   endIf     if initialExp<10100 && ModdedExp >=10100	  TormPlayerCurrentLevel.SetValue( 11)   endIf     if initialExp<16650 && ModdedExp >=16650	  TormPlayerCurrentLevel.SetValue( 12)   endIf     if initialExp<26750 && ModdedExp >=26750	  TormPlayerCurrentLevel.SetValue( 13)   endIf     if initialExp<43400 && ModdedExp >=43400	  TormPlayerCurrentLevel.SetValue( 14)   endIf     if initialExp<70150 && ModdedExp >=70150	  TormPlayerCurrentLevel.SetValue( 15)   endIf     if initialExp<113550 && ModdedExp >=113550	  TormPlayerCurrentLevel.SetValue( 16)   endIf     if initialExp<183700 && ModdedExp >=183700	  TormPlayerCurrentLevel.SetValue( 17)   endIf     if initialExp<297250 && ModdedExp >=297250	  TormPlayerCurrentLevel.SetValue( 18)   endIf     if initialExp<480950 && ModdedExp >=480950	  TormPlayerCurrentLevel.SetValue( 19)   endIf     if initialExp<778200 && ModdedExp >=778200	  TormPlayerCurrentLevel.SetValue( 20)   endIf    endEvent  

Note: For this to work right you need to have PlayerTeammateCount (a vanilla global) set to 1 initially, and then modify the DialogueFollowerScript function SetFollower() to have the PlayerTeammateCount.SetValue(1) to say PlayerTeammateCount.SetValue((PlayerTeammateCount.GetValue() as int) + 1)

Then you just set each enemie's ExpOnDeath to whatever value you want divvied up among the PC and his teammates, and you're done. Oh, and make the globals where appropriate.
User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am

Post » Wed Jun 20, 2012 8:05 pm

Gonna have "Classes" too, and apportion the levelup bonuses based on class? (Like "wizard" gets 80% of a normal mana levelup and 10%/10% on Health/Stamina, while a "Warrior" would get more like 5%/80%/15% (Mana/Health/Stamina)?

Monks! Gotta have Monks...Hand to Hand skills and natural Armor bonus FTW!
User avatar
Saul C
 
Posts: 3405
Joined: Wed Oct 17, 2007 12:41 pm

Post » Wed Jun 20, 2012 10:37 am

Oh, its far more complicated than that. Basically the system I have in play so far makes it such that you just "set" manually all enemies combat abilities, and don't have to worry about things like their ability scores and such. Followers and the Player however, they gain things like stat points (WIS, CHA, STR, etc.) as globals when you gain specific levels (every multiple of four) spell slots, HP based on CON, etc.
Mana plays no part in my game, as basically the way it works is every time you rest for 8 hours a messagebox pops up asking if you would like to manage your spells. If you choose yes, you can assign spells (which are actually one use powers) to the spell slots you have, and it basically works like DnD. Unfortunately, I don't have a lot of this working yet/don't know if its even possible.
We'll see!

Anyway, this and all of my questions recently have been directed at my ongoing project to rebuild Planescape: Torment for Skyrim. It's a thing I'm doing for a contest for Atari. Wish me luck!
User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am

Post » Wed Jun 20, 2012 8:05 am

So the experience needed to level up is just adding the needed experience for the previous two levels? If so, you could get rid of the long list of if conditions and just add in two global variables, like this:

Scriptname ExperienceModifier extends ActorGlobalVariable property CurrLevelUpEXP auto	;initially 100 for new gameGlobalVariable property LastLevelUpEXP auto	;initially 150 for new gameGlobalVariable property TormPlayerEXP autoGlobalVariable property TormPlayerCurrentLevel autoGlobalVariable Property PlayerTeammateCount autoInt property ExpOnDeath autoEvent OnDeath(Actor akKiller)	TormPlayerEXP.Value += (ExpOnDeath / PlayerTeammateCount.Value) as Int	Float TempValue	while (TormPlayerEXP.Value >= CurrLevelUpEXP.Value)		TormPlayerCurrentLevel.Value += 1.0		TempValue = http://forums.bethsoft.com/topic/1362974-a-script-for-dnd-style-levelling/CurrLevelUpEXP.Value		CurrLevelUpEXP.Value += LastLevelUpEXP.Value		LastLevelUpEXP.Value = TempValue	endwhileEndEvent
User avatar
Cameron Wood
 
Posts: 3384
Joined: Wed Oct 31, 2007 3:01 pm


Return to V - Skyrim