Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Community
General Tabletop Discussion
*Geek Talk & Media
[NWN] How To: Make a Potion of Heroism
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="LightPhoenix" data-source="post: 243761" data-attributes="member: 115"><p>Alrighty, this one is a bit more difficult, but nothing that anyone shouldn't be able to handle.</p><p></p><p>First, a few concepts that we need to go over. If you open up Edit -> Module Properties and choose the Events tab, you'll see a bunch of events that can have scripts attached to them. Notably, you should see three entries already filled in - OnPlayerDeath, OnPlayerDying, and OnPlayerRespawn. These obviously control how death and spawning work in your game. We're interested in a different one - OnActivateItem. The script here is called whenever an item is activated. As you might guess, we're going to change that.</p><p></p><p>Another fundamental part of stuff in NWN is the "effect" type. They are initialized just like ints, floats, strings, and objects. For instance: effect eDamage; Simple as that. There are a number of things we can do with these - deal damage, show visial effects... you're basically limited only by what the game lets you do. Of specific note is that we can increase AC, skills, and saves.</p><p></p><p>Before we can script anything, you need to make the item. Make a potion, call it Potion of Heroism. In the Properties tab, the only effect you want it to have is "Unique Effect - Self only". You might want to put in a price adjustment too, since there's no price attached to this property.</p><p></p><p>So let's look at some code. Create a new script, name it whatever you like. In the OnActivateItem box from before, put the name of your script. This way, we'll be able to have items with custom effects in the game.</p><p></p><p>Here's my Potion of Heroism:</p><p></p><p>[code]</p><p>void main()</p><p>{</p><p> object oActivatedItem = GetItemActivated();</p><p></p><p> //</p><p> // Activated Item: Potion of Heroism</p><p> // Effect: Target creature gains +2 to attacks, saves, and skill checks for 1 hour.</p><p> //</p><p> if (oActivatedItem == GetObjectByTag("PotionofHeroism"))</p><p> {</p><p> //Declare major variables</p><p> int nBonus = 2;</p><p> float nDur = 3600.0;</p><p> object oTarget = GetItemActivator();</p><p> // Setup the instant visual effect</p><p> effect eVis = EffectVisualEffect(VFX_IMP_SUPER_HEROISM);</p><p> // Setup the Heroism bonuses</p><p> effect eAttack = EffectAttackIncrease(nBonus);</p><p> effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, nBonus, SAVING_THROW_TYPE_ALL);</p><p> effect eSkill = EffectSkillIncrease(SKILL_ALL_SKILLS, nBonus);</p><p> effect eLink = EffectLinkEffects(eAttack, eSave);</p><p> eLink = EffectLinkEffects(eLink, eSkill);</p><p> //Apply the VFX impact and effects</p><p> ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);</p><p> ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, nDur);</p><p> }</p><p>}</p><p>[/code]</p><p></p><p>Oof, quite a handful, but not nearly as bad as it might seem. We'll start from the top.</p><p></p><p>[code]</p><p>object oActivatedItem = GetItemActivated();</p><p></p><p>if (oActivatedItem == GetObjectByTag("PotionofHeroism"))</p><p>{</p><p> // Stuff goes here</p><p>}</p><p>[/code]</p><p></p><p>THE most important line. This gets the tag of the item that has been activated. We use this in the if statement to check what has been activated, and perform code based on that.</p><p></p><p>[code]</p><p>//Declare major variables</p><p>int nBonus = 2;</p><p>float nDur = 3600.0;</p><p>object oTarget = GetItemActivator();</p><p>[/code]</p><p></p><p>This section just declares variable. They're put up top to make changing them easier. It's nothing you have to do, but it avoids having to go through lines of code searching for one number. Note that nDur is in seconds - this potion lasts one hour. Also, no the GetItemActivator() function - this sets the target as the imbiber. There's also GetItemActivatedTarget() to get other targets, but we don't need that here.</p><p></p><p>[code]</p><p>// Setup the instant visual effect</p><p>effect eVis = EffectVisualEffect(VFX_IMP_SUPER_HEROISM);</p><p></p><p>// Setup the Heroism bonuses</p><p>effect eAttack = EffectAttackIncrease(nBonus);</p><p>effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, nBonus, SAVING_THROW_TYPE_ALL);</p><p>effect eSkill = EffectSkillIncrease(SKILL_ALL_SKILLS, nBonus);</p><p>effect eLink = EffectLinkEffects(eAttack, eSave);</p><p>eLink = EffectLinkEffects(eLink, eSkill);</p><p>[/code]</p><p></p><p>The meaty section. As you can see, there's a lot of "Effect" functions. The first sets up a visual effect, important but nothing special. The next group sets up the bonuses. As a note, for EffectSavingThrowIncrease - the first constant (SAVING_THROW_ALL) tells it to apply the save to Fort, Ref, and Will. The second (SAVING_THROW_TYPE_ALL) tells it to apply to all types of saving throws - vs. Poison, vs. Fire, whatever.</p><p></p><p>Important is the function EffectLinkEffects(). We need this because the functions which apply effects only take one effect as a parameter. This function will take two effects and link them together. You can not link visual and statistical effects, as far as I know. In the code, we link the three bonuses together so they're all called as one.</p><p></p><p>[code]</p><p>//Apply the VFX impact and effects</p><p>ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);</p><p>ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, nDur);</p><p>[/code]</p><p></p><p>The home stretch - this just applies the effects. Note the same function, but different numbers of parameters. Instant effects obviously don't need a duration, but temporary ones do. This sets off the visual effect, and applies the bonus for one hour.</p><p></p><p>I'd be more than happy to answer any questions or to give another example is people want one.</p></blockquote><p></p>
[QUOTE="LightPhoenix, post: 243761, member: 115"] Alrighty, this one is a bit more difficult, but nothing that anyone shouldn't be able to handle. First, a few concepts that we need to go over. If you open up Edit -> Module Properties and choose the Events tab, you'll see a bunch of events that can have scripts attached to them. Notably, you should see three entries already filled in - OnPlayerDeath, OnPlayerDying, and OnPlayerRespawn. These obviously control how death and spawning work in your game. We're interested in a different one - OnActivateItem. The script here is called whenever an item is activated. As you might guess, we're going to change that. Another fundamental part of stuff in NWN is the "effect" type. They are initialized just like ints, floats, strings, and objects. For instance: effect eDamage; Simple as that. There are a number of things we can do with these - deal damage, show visial effects... you're basically limited only by what the game lets you do. Of specific note is that we can increase AC, skills, and saves. Before we can script anything, you need to make the item. Make a potion, call it Potion of Heroism. In the Properties tab, the only effect you want it to have is "Unique Effect - Self only". You might want to put in a price adjustment too, since there's no price attached to this property. So let's look at some code. Create a new script, name it whatever you like. In the OnActivateItem box from before, put the name of your script. This way, we'll be able to have items with custom effects in the game. Here's my Potion of Heroism: [code] void main() { object oActivatedItem = GetItemActivated(); // // Activated Item: Potion of Heroism // Effect: Target creature gains +2 to attacks, saves, and skill checks for 1 hour. // if (oActivatedItem == GetObjectByTag("PotionofHeroism")) { //Declare major variables int nBonus = 2; float nDur = 3600.0; object oTarget = GetItemActivator(); // Setup the instant visual effect effect eVis = EffectVisualEffect(VFX_IMP_SUPER_HEROISM); // Setup the Heroism bonuses effect eAttack = EffectAttackIncrease(nBonus); effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, nBonus, SAVING_THROW_TYPE_ALL); effect eSkill = EffectSkillIncrease(SKILL_ALL_SKILLS, nBonus); effect eLink = EffectLinkEffects(eAttack, eSave); eLink = EffectLinkEffects(eLink, eSkill); //Apply the VFX impact and effects ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, nDur); } } [/code] Oof, quite a handful, but not nearly as bad as it might seem. We'll start from the top. [code] object oActivatedItem = GetItemActivated(); if (oActivatedItem == GetObjectByTag("PotionofHeroism")) { // Stuff goes here } [/code] THE most important line. This gets the tag of the item that has been activated. We use this in the if statement to check what has been activated, and perform code based on that. [code] //Declare major variables int nBonus = 2; float nDur = 3600.0; object oTarget = GetItemActivator(); [/code] This section just declares variable. They're put up top to make changing them easier. It's nothing you have to do, but it avoids having to go through lines of code searching for one number. Note that nDur is in seconds - this potion lasts one hour. Also, no the GetItemActivator() function - this sets the target as the imbiber. There's also GetItemActivatedTarget() to get other targets, but we don't need that here. [code] // Setup the instant visual effect effect eVis = EffectVisualEffect(VFX_IMP_SUPER_HEROISM); // Setup the Heroism bonuses effect eAttack = EffectAttackIncrease(nBonus); effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, nBonus, SAVING_THROW_TYPE_ALL); effect eSkill = EffectSkillIncrease(SKILL_ALL_SKILLS, nBonus); effect eLink = EffectLinkEffects(eAttack, eSave); eLink = EffectLinkEffects(eLink, eSkill); [/code] The meaty section. As you can see, there's a lot of "Effect" functions. The first sets up a visual effect, important but nothing special. The next group sets up the bonuses. As a note, for EffectSavingThrowIncrease - the first constant (SAVING_THROW_ALL) tells it to apply the save to Fort, Ref, and Will. The second (SAVING_THROW_TYPE_ALL) tells it to apply to all types of saving throws - vs. Poison, vs. Fire, whatever. Important is the function EffectLinkEffects(). We need this because the functions which apply effects only take one effect as a parameter. This function will take two effects and link them together. You can not link visual and statistical effects, as far as I know. In the code, we link the three bonuses together so they're all called as one. [code] //Apply the VFX impact and effects ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, nDur); [/code] The home stretch - this just applies the effects. Note the same function, but different numbers of parameters. Instant effects obviously don't need a duration, but temporary ones do. This sets off the visual effect, and applies the bonus for one hour. I'd be more than happy to answer any questions or to give another example is people want one. [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
[NWN] How To: Make a Potion of Heroism
Top