NPC casting spell from dialogue topic

Post » Wed Feb 16, 2011 3:21 am

Hello, I am looking for guidance from an experienced modder. I want an NPC to cast a spell on the player from a dialogue option. In the result script of the topic in question, I have put Cast "spell ID" Player. When playing, the NPC will bring up the topic, but will not cast the spell. Is this something that is possible?
Also, for another NPC, I am trying to make a topic in which the resulting script bestows an amount of gold onto the player based on his fame. My script for this is: if getPCFame > 10 player.additem gold001 50
Neither of these things are working. Please help.
User avatar
Shaylee Shaw
 
Posts: 3457
Joined: Wed Feb 21, 2007 8:55 pm

Post » Wed Feb 16, 2011 12:02 pm

Please post your scripts in full so we can see where they might be going wrong. Out of curiosity, does your NPC have the spell in his/her spell list?
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Wed Feb 16, 2011 12:39 pm

Try putting NPCRef.cast SpellID player. Maybe the script was referencing the topic and not the NPC?

As for the other script, try
if(getPCFame >= 10)   player.additem f 50endif

User avatar
Andrew
 
Posts: 3521
Joined: Tue May 08, 2007 1:44 am

Post » Wed Feb 16, 2011 5:07 pm

As for the other script, try
if(getPCFame >= 10)   player.additem f 50endif



Negative. Due to the nature of FormIDs, scripts use the EditorIDs of objects, so Player.additem gold001 50 is correct.
User avatar
cutiecute
 
Posts: 3432
Joined: Wed Sep 27, 2006 9:51 am

Post » Wed Feb 16, 2011 12:25 pm

Hi, thank you for the replies. Here are my scripts.
My gold-adding script is supposed to reward a character based on his fame or infamy, depending upon the NPC he's talking to. If his infamy, for instance, is at or below a certain point, he gets a certain amount of gold determined by a new levelled list called 0goldbonus and his infamy rises one point, but if he has a low infamy score, then the disposition of the NPC is also lowered.
This is how it looks in the resulting script of the topic box.

Begin Gamemode

If (GetPCInfamy <= 10)
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 20)
player.additem 0goldbonus 1
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 30)
player.additem 0goldbonus 1
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 40)
player.additem 0goldbonus 1
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 50)
player.additem 0goldbonus 2
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 60)
player.additem 0goldbonus 2
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 70)
player.additem 0goldbonus 2
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 80)
player.additem 0goldbonus 3
ModDisposition Player -50
ModPCInfamy 1

elseif (GetPCInfamy <= 90)
player.additem 0goldbonus 4
ModDisposition Player -50
ModPCInfamy 1
endif

endif

end

I am also trying to get an NPC to cast a spell on the player after he chooses a certain dialogue choice. The resulting script looks like this:


Cast 0Heal Player


0Heal being a custom Touch spell. According to the Construction Set Wiki, the NPC does not need to have this spell in their inventory in order to cast it from the Cast function.
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Wed Feb 16, 2011 10:34 am

Oh yes, the NPC's are saying the correct greetings and topics; they just aren't performing the scripts when the topics are chosen.
User avatar
Joe Bonney
 
Posts: 3466
Joined: Tue Jul 17, 2007 12:00 pm

Post » Wed Feb 16, 2011 3:10 pm

I have never gotten an NPC to cast a spell unless it was in their spell list. Also, that should be NPCRef.cast 0Heal Player. You should also rename 0Heal and 0goldbonus to something that doesn't start with a number. When an item or spell starts with a number in a script, the game thinks it's supposed to look for a FormID. Since 0Heal and 0goldbonus are definitely not FormIDs, the game tends not to do anything with them. Rename them to something like AHeal and Agoldbonus. Also, what exactly is 0goldbonus? Is it a Leveled List, Miscellaneous Object, custom item or something else?
User avatar
Sammygirl500
 
Posts: 3511
Joined: Wed Jun 14, 2006 4:46 pm

Post » Wed Feb 16, 2011 4:54 am

I have never gotten an NPC to cast a spell unless it was in their spell list. Also, that should be NPCRef.cast 0Heal Player. You should also rename 0Heal and 0goldbonus to something that doesn't start with a number. When an item or spell starts with a number in a script, the game thinks it's supposed to look for a FormID. Since 0Heal and 0goldbonus are definitely not FormIDs, the game tends not to do anything with them. Rename them to something like AHeal and Agoldbonus. Also, what exactly is 0goldbonus? Is it a Leveled List, Miscellaneous Object, custom item or something else?


Thank you! That makes sense, considering some of the trouble I've been having. I usually use the initials of the mod as a prefix to an ID, but in this case, I used 0 because I had so many things going on, I wanted them to be easily accessible. Guess that won't work so well.
Yes, 0goldbonus is a levelled list of different gold amounts to simulate a random quantity.
Oh, I got the scripts for the gold to work. I just cut out all the IF statementts and made it non-dependant on the PC's fame/infamy score. Not what I wanted, but I think the Resulting Script box of the Topic tab won't take long scripts. If I just shorten it to a couple lines like,

player.additem 0goldbonus 1
ModPCFame 1

Then it works suitably enough. Now I will change the spell names, add it to the spell lists, and use NPCRef.cast SpellID Player and see how that works.
Thank you both so much for your help. I'll let you know here how it turns out. Hopefully, it'll work well.
User avatar
Ana
 
Posts: 3445
Joined: Sat Jul 01, 2006 4:29 am

Post » Wed Feb 16, 2011 4:44 pm

I have never gotten an NPC to cast a spell unless it was in their spell list. Also, that should be NPCRef.cast 0Heal Player. You should also rename 0Heal and 0goldbonus to something that doesn't start with a number. When an item or spell starts with a number in a script, the game thinks it's supposed to look for a FormID. Since 0Heal and 0goldbonus are definitely not FormIDs, the game tends not to do anything with them. Rename them to something like AHeal and Agoldbonus. Also, what exactly is 0goldbonus? Is it a Leveled List, Miscellaneous Object, custom item or something else?


Well, shoot. I tried adding the NPCRef to the script, but it didn't cast. I changed the spell to one of the standard spells, and that still didn't cast, even when I put it in her inventory. Could the Cast function be ineffective when placed in the Resulting Script box of the Topic tab in dialogue? For a test, I changed the script to things like, "player.additem apple 1" and she gave me an apple, so I know the NPC isn't malfunctioning. What do you think?
User avatar
Rebecca Dosch
 
Posts: 3453
Joined: Thu Jan 18, 2007 6:39 pm

Post » Wed Feb 16, 2011 12:39 pm

Honestly, it seems like no commands work in the Resulting Script box of the Topics tab. It doesn't allow you to set dependencies with an If statement or anything. Only some functions seem to work, and certainly not the Cast function.
User avatar
Chloe Mayo
 
Posts: 3404
Joined: Wed Jun 21, 2006 11:59 pm

Post » Wed Feb 16, 2011 12:58 pm

Honestly, it seems like no commands work in the Resulting Script box of the Topics tab. It doesn't allow you to set dependencies with an If statement or anything. Only some functions seem to work, and certainly not the Cast function.
User avatar
Lillian Cawfield
 
Posts: 3387
Joined: Thu Nov 30, 2006 6:22 pm

Post » Wed Feb 16, 2011 12:59 pm

Then use the topic result script to set a global which in turn activates the cast function in another script IE a quest script or something.
User avatar
Alisia Lisha
 
Posts: 3480
Joined: Tue Dec 05, 2006 8:52 pm

Post » Wed Feb 16, 2011 4:21 pm

Then use the topic result script to set a global which in turn activates the cast function in another script IE a quest script or something.

:( I'm just a noobie who doesn't really know what a global is, much less how to set one to activate another script. I am working from a quest script already, however, as the tutorial I read said it's best to always create new dialogue through a quest.
User avatar
loste juliana
 
Posts: 3417
Joined: Sun Mar 18, 2007 7:37 pm

Post » Wed Feb 16, 2011 6:22 pm

:( I'm just a noobie who doesn't really know what a global is, much less how to set one to activate another script. I am working from a quest script already, however, as the tutorial I read said it's best to always create new dialogue through a quest.


Okay no problem. Under the main menu on the CS, you'll see gameplay -> globals.

Click on that, right click on the list and add one, something like "myglobal" or "spellglobal." These are variables you can use anywhere, any time.

Under your quest script, do something like:

(gamemode block)

if spellglobal == 1
ref.Cast 0Heal Player
set spellglobal to 0
endif

AND, under the dialogue result script, do this:

set spellglobal to 1.

Since you're having trouble having "cast" work from the dialogue result script. Now instead, you're setting your global under the topic result script which will return "true" in the if statement in your quest script, thus you NPC will cast 0Heal.
User avatar
Music Show
 
Posts: 3512
Joined: Sun Sep 09, 2007 10:53 am

Post » Wed Feb 16, 2011 6:03 am

do not start any editor id with numbers - change them now - chances are the script will not work
User avatar
Isaac Saetern
 
Posts: 3432
Joined: Mon Jun 25, 2007 6:46 pm

Post » Wed Feb 16, 2011 8:02 am

OK, I've gotten rid of all the numbers in the ID's, now I will work on the globals. I think I understand them now. Thank you both very much. I will post back when I find out if it works or not.
User avatar
lolly13
 
Posts: 3349
Joined: Tue Jul 25, 2006 11:36 am

Post » Wed Feb 16, 2011 11:18 am

Well, that didn't seem to work. The spell ID is GRCarry. My global is named GRCarryGlobal. The NPC to cast it has a ref named KavisRef. The resulting script in Kavis' dialogue box sets the global to 1. The script is as follows:

scn GRCarryScript

Begin Gamemode

If (GRCarryGlobal == 1)
KavisRef.Cast GRCarry Player
Set GRCarryGlobal to 0
Endif

End

Did I do something wrong?
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Wed Feb 16, 2011 11:09 am

Well, that didn't seem to work. The spell ID is GRCarry. My global is named GRCarryGlobal. The NPC to cast it has a ref named KavisRef. The resulting script in Kavis' dialogue box sets the global to 1. The script is as follows:

scn GRCarryScript

Begin Gamemode

If (GRCarryGlobal == 1)
KavisRef.Cast GRCarry Player
Set GRCarryGlobal to 0
Endif

End

Did I do something wrong?
Anty chance you run into one of http://cs.elderscrolls.com/constwiki/index.php/Cast ? Is GRCarry a target spell ? Read the talk page -too
User avatar
Your Mum
 
Posts: 3434
Joined: Sun Jun 25, 2006 6:23 pm

Post » Wed Feb 16, 2011 11:13 am

It might be easier just to cause the effect on the player than to try and make an NPC cast it. It sounds like one of the many things NPCs are rubbish at.
User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Wed Feb 16, 2011 6:51 am

GRCarry is a touch spell. I had read that on the CSWiki, so I didn't want to mess with target spells even though the NPC's cast only from dialogue so they'd have to be up close. I'll see if I can find how to cause an effect on a player. I wouldn't want to use Player.Cast because that wouldn't look right for the PC to cast the spell. Maybe I will just scrap the whole thing and have the NPC hand over a healing potion. Is it possible to make a potion that a person could drink only once a day?
User avatar
Channing
 
Posts: 3393
Joined: Thu Nov 30, 2006 4:05 pm

Post » Wed Feb 16, 2011 6:22 pm

What do you mean 'once a day'? Do you want a potion that can be drank more than once? If so it would probably be best to make it a misc item that has an 'OnActivate' script.

I think the 'Cast' command doesn't need an actor to do it. Just remove the actor ref in the script you've already made. You won't see the actor cast it but it should just effect the player.
User avatar
Brian LeHury
 
Posts: 3416
Joined: Tue May 22, 2007 6:54 am

Post » Wed Feb 16, 2011 7:40 am

In the beginning, I wasn't using an actor ref at all in the resulting script of the dialogue topic and that wasn't working. Maybe the script attached to the global won't require an NPC Ref though...hmmm.
As far as the potion goes--I was thinking of a potion that would not have an effect on a character if he drank more than one a day. Let's say you have three potions in your inventory, called Major Heal. You drink one and it heals you. Later on, you drink another one, but it doesn't work because the script would say you have to wait 24 hours before this type of potion would heal you again. I don't know...it was just an idea to get around this Cast problem.
User avatar
Adrian Morales
 
Posts: 3474
Joined: Fri Aug 10, 2007 3:19 am

Post » Wed Feb 16, 2011 11:46 am

Hi, I haven't read all to the end, but NPC doesn't have to have spell on its list to cast it if you script it.

Magicman, I can't remember the details without checking it first, but I made mod Healers where you talk with NPC about healing and that NPC casts some healing spell on PC. You can check it out, find it through my signature link..
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm


Return to IV - Oblivion

cron