Hello all, this is my first attempt at modding and fist time i have been here. I am trying to make a Freeze ray similar to Lit Ridl's Flame thrower. Here is the Source script:
// By Hangout Hermit
// The Damage is 60. If the Npc makes a DC save of 15+ then the damage will be half.
#include "k_inc_debug"
void main()
{
int nDamage=60;
int nDC=15;
object oSelf=GetSpellTargetObject();
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 30.0, GetLocation(oSelf), FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
while (GetIsObjectValid(oTarget))
{
if (GetIsEnemy(oTarget))
{
break;
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 30.0, GetLocation(oSelf), FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
}
if (GetIsObjectValid(oTarget))
{
effect eBeam = EffectBeam(2051, OBJECT_SELF, BODY_NODE_HAND);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oTarget, 1.0);
if(GetHitDice(oTarget) < 7 || FortitudeSave(oTarget, 15) == FALSE)
{
nDamage = 30;
}
EffectDamage(nDamage, DAMAGE_TYPE_COLD);
}
}
The Script is working fine, or should be...
I have done a Spells.2da edit and have made an new row like this...
number=299
label=ITEM_ABILITY_FREEZE_RAY
name=136328
forcepoints=0
goodevil=-
usertype=4
guardian=0
consular=0
sentinel=0
weapmstr=0
jedimaster=0
watchman=0
marauder=0
sithlord=0
assassin=0
inate=1
maxcr=3
category=0x1808
range=T
impactscript=hh_freeze
conjtime=170
conjanim=hand
castanim=self
casttime=1330
catchtime=0
proj=0
itemimmunity=0
exclusion=0x00
requireitemmask=0x0000
forbiditemmask=0x0000
itemtargeting=1
hostilesetting=0
formmask=0x00
And this is the .Uti file
<Property>Activate Item</Property>
<Subtype>ERROR</Subtype>
<CostTable>SpellUse</CostTable>
<CostValue>Unlimited Use</CostValue>
<Param1>n/a</Param1>
<Param2>n/a</Param2>
<Param2Value>n/a</Param2Value>
<Upgrade>n/a</Upgrade>
<_x0025__x0020_Chance_x0020_of_x0020_Appearance>100</_x0025__x0020_Chance_x0020_of_x0020_Appearance>
<PropertyID>10</PropertyID>
<SubtypeID>283</SubtypeID>
<CostTableID>3</CostTableID>
<CostValueID>13</CostValueID>
<Param1ID>255</Param1ID>
<Param1ValueID>0</Param1ValueID>
<Param2ID>-1</Param2ID>
<Param2ValueID>-1</Param2ValueID>
<UpgradeID>-1</UpgradeID>
The problem is when i spawn and equip it id dosent appear in my inventory and i can't use it.
Thanks in advance!
Your code is incomplete...it's missing something after
if(GetHitDice(oTarget) < 7 || FortitudeSave(oTarget, 15) == FALSE)
You don't have any target.
You could have a look at tk102's original flamethrower armband here at pcgm as your code is exactly the same...it seems that Lit Ridl' likes the copy/paste function...
http://pcgamemods.com/mod/5280.html)
To further elaborate on what Darth333 said, your script is incomplete. It ends before it actually applies damage to anything, at the EffectDamage(nDamage, DAMAGE_TYPE_COLD); line. This just declares a damage effect, but doesn't use it for anything.
Further, the line if(GetHitDice(oTarget) < 7 || FortitudeSave(oTarget, 15) == FALSE) seems to be backwards. Currently it ensures the script does half damage if the saving throw failed, or if the target is level 6 or lower. I assume you'd want to to do half damage if the victim succeeds with their save, or is high level, instead.
void main() {
int nDamage = 60;
int nDC = 15;
object oSelf = GetSpellTargetObject();
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 30.0, GetLocation(oSelf), FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
while (GetIsObjectValid(oTarget)) {
if (GetIsEnemy(oTarget))
break;
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 30.0, GetLocation(oSelf), FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
}
if (GetIsObjectValid(oTarget)) {
effect eBeam = EffectBeam(2051, OBJECT_SELF, BODY_NODE_HAND);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oTarget, 1.0);
if ((GetHitDice(oTarget) > 7) || FortitudeSave(oTarget, nDC)) {
nDamage = 30;
}
effect eDmg = EffectDamage(nDamage, DAMAGE_TYPE_COLD);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDmg, oTarget);
}
}
Also, in your UTI template, make sure you set the subtype of the "Activate Item" property to the line number in spells.2da of your new spell that runs when the item is activated, and that the base item type of the item is one what can be activated by the player.
(If I understand what you're doing correctly you should probably set the range value in spells.2da to P as well, if the spell targets the caster.)
Thanks very much!
As i said i am only a bigginer so i will make mistakes.
And i will test in a day or 2 :D