Some Dialogue Questions # 2

Post » Sat Feb 06, 2010 9:30 pm

well, after testing a few possibilities, it seems i have no choice but to transfer those local to global script variables into global variables. was really trying to avoid doing that.

but for future reference, setting a global variable to itself plus a local variable in a global script causes the CS to CTD,

i also must remember that the item conditional for dialog refers to the PC, not the NPC.
User avatar
Amber Hubbard
 
Posts: 3537
Joined: Tue Dec 05, 2006 6:59 pm

Post » Sat Feb 06, 2010 11:46 pm

Some usuful http://mwmodders.com/scriptingnotes.html by Josh, especially the part about global variables usage may be interesting.
User avatar
Matthew Barrows
 
Posts: 3388
Joined: Thu Jun 28, 2007 11:24 pm

Post » Sat Feb 06, 2010 10:46 pm

very enlightening. bookmarked the page for future reference, thank you.

i'm avoiding globals for another reason, not suspected lag. the console only outputs so many lines, and keeping variables as local in a global script keeps them down at the bottom of sv output, so i can check them. as true global variables, they get pushed out of the console.

again, thank you abot, you've been more than patient with me, and quite helpful.
User avatar
Bereket Fekadu
 
Posts: 3421
Joined: Thu Jul 12, 2007 10:41 pm

Post » Sun Feb 07, 2010 12:12 am

I keep getting a left eval error in a script I've placed on an NPC - the idea I had was to add gold to the NPC during dialogue - different responses in dialogue would add varying rates of gold - the script is intended to check and see how much gold the NPC has then set a local variable that can be used as a dialogue filter

Here's the script - if someone could let me know what I'm doing wrong i'd be very grateful :)

Begin CT_Romance; Set via Dialogue to reduce Journal entries; Items added or removed via dialogue Short Romantic_notionsIf [ CT_Sobani->GetItemCount "Gold_001" < 10 ]	returnendifIf [ CT_Sobani->GetItemCount "Gold_001" < 15 ]	if [ CT_Sobani->GetItemCount "Gold_001" > 9 ]		Set Romantic_notions to 1	endifendifIf [ CT_Sobani->GetItemCount "Gold_001" < 20 ]	if [ CT_Sobani->GetItemCount "Gold_001" > 15 ]		Set Romantic_notions to 2	endifendifIf [ CT_Sobani->GetItemCount "Gold_001" >= 20 ]	Set Romantic_notions to 3endifEnd CT_Romance

User avatar
Sweet Blighty
 
Posts: 3423
Joined: Wed Jun 21, 2006 6:39 am

Post » Sat Feb 06, 2010 8:47 am

it may be superfluous, but wrapping extra brackets around functions (and having quotation marks around fix targets) in if statements has helped me in the past.

if ( (  "CT_sobani"->GetItemCount "gold_001" ) > 10 )


also, when comparing the same value, it seems to work better if you use elseif rather than multiple if blocks.

try this:

Begin CT_Romance; Set via Dialogue to reduce Journal entries; Items added or removed via dialogue Short Romantic_notionsIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) < 10 )	returnelseIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) < 15 )	if ( ( "CT_Sobani"->GetItemCount "Gold_001" ) > 9 )		Set Romantic_notions to 1	endifelseIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) < 20 )	if ( ( "CT_Sobani"->GetItemCount "Gold_001" ) > 15 )		Set Romantic_notions to 2	endifelseIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) >= 20 )	Set Romantic_notions to 3endifEnd CT_Romance


oh, and as noted above, it wont work unless this is the script attached to the NPC in the CS, using startscript will not work because of the whole local variable thing. pretty sure you know that, but just throwing it out there.
User avatar
James Rhead
 
Posts: 3474
Joined: Sat Jul 14, 2007 7:32 am

Post » Sat Feb 06, 2010 3:37 pm

it may be superfluous, but wrapping extra brackets around functions (and having quotation marks around fix targets) in if statements has helped me in the past.

if ( (  "CT_sobani"->GetItemCount "gold_001" ) > 10 )


also, when comparing the same value, it seems to work better if you use elseif rather than multiple if blocks.

try this:

Begin CT_Romance; Set via Dialogue to reduce Journal entries; Items added or removed via dialogue Short Romantic_notionsIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) < 10 )	returnelseIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) < 15 )	if ( ( "CT_Sobani"->GetItemCount "Gold_001" ) > 9 )		Set Romantic_notions to 1	endifelseIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) < 20 )	if ( ( "CT_Sobani"->GetItemCount "Gold_001" ) > 15 )		Set Romantic_notions to 2	endifelseIf ( ( "CT_Sobani"->GetItemCount "Gold_001" ) >= 20 )	Set Romantic_notions to 3endifEnd CT_Romance


oh, and as noted above, it wont work unless this is the script attached to the NPC in the CS, using startscript will not work because of the whole local variable thing. pretty sure you know that, but just throwing it out there.


Thanks - I will try that - but I'm doubtful - I had tried various if elseif combinations similar to what you are suggesting before posting but still got the left eval error

I just tried removing the NPC id from the script as i see on the slave script it is not required and various beth scripts sometimes don't bother with quotation marks around targetted items - thanks for the reply I will try it out tomorrow and see if it makes any difference
User avatar
evelina c
 
Posts: 3377
Joined: Tue Dec 19, 2006 4:28 pm

Post » Sat Feb 06, 2010 8:44 am

Not to have anything with the eval problem, but the script is more complex than it deserves to be.
Begin CT_Romance; Set via Dialogue to reduce Journal entries; Items added or removed via dialogue Short goldShort Romantic_notionsSet gold to CT_Sobani->GetItemCount "Gold_001"If ( gold < 10 )	returnelseif ( gold < 15 )	Set Romantic_notions to 1elseif ( gold < 20 )	Set Romantic_notions to 2else	Set Romantic_notions to 3endifEnd CT_Romance

User avatar
Stacyia
 
Posts: 3361
Joined: Mon Jul 24, 2006 12:48 am

Post » Sat Feb 06, 2010 10:33 am

Howdy,

I apologise if this question has a very simple answer, but i've been trying to find out for the past couple of hours and i just cant find anything telling me what i want to know.


I'll give you the premise first...

I'm making a companion mod, or rather i'm using Grumpy's Companion Project to make my own mod.

one of the orders you can give the companion is to "guard this spot"

all i want to do.. is add a function/variable to the companion's response so that if she has a weapon she will say one thing, and she will say something else if she doesn't have a weapon.

-*(EDIT: and by this i mean if she has ANY weapon, not a particular one)*-

now i know this should be really simple, and if i could find what i'm looking for i know how to set it up to check whether something is true or not. BUT...

my problem is that i can't find any kind of "weapon check" script, either in the game already, or on google so i can make my own.

Can someone please tell me what to do?

thanks

KoR
User avatar
Lucie H
 
Posts: 3276
Joined: Tue Mar 13, 2007 11:46 pm

Post » Sat Feb 06, 2010 6:28 pm

i'm not sure that this will work, but how about
if ( ( GetWeaponType ) > -1 )     set weaponvariable to 1
in the npc's script, then do the conditionals of your dialog to this local variable? i've never tried this function, so i'm not too sure how it'll work. edit: it's a tribunal function, so you'll need that (not sure if it also comes in bloodmoon)

oh and good catch kir, i should have also meantioned nesting if checks of the same thing is error prone, i was just a wee bit too wrapped up in functions.

Illuminiel, beth's scripts are not really written "the best," though i'm a pot calling the kettle black. it's one of those things the engine gets finicky over and sometimes works one way, and sometimes another.
User avatar
Dezzeh
 
Posts: 3414
Joined: Sat Jun 16, 2007 2:49 am

Post » Sat Feb 06, 2010 9:31 pm

just wondering, does anyone happen to know the formula for Intimidate?
User avatar
Scarlet Devil
 
Posts: 3410
Joined: Wed Aug 16, 2006 6:31 pm

Post » Sat Feb 06, 2010 5:07 pm

just wondering, does anyone happen to know the formula for Intimidate?


If you search the MCP threads you should be able to find Hrnchamd's deconstruction of the formula as he fixed it in the MCP - though it may take some time - might be faster to PM him

Edit: I went and found it for you - the formula are in this http://www.gamesas.com/index.php?/topic/1097214-gameplay-mechanics-anolysis

target2 = max(iPerMinChance, target2)roll 100, win if roll <= target2if roll != target2:    r = int(target2 - roll)else:    r = 1    if roll <= target2:    s = int(r * fPerDieRollMult * fPerTempMult)    flee = max(iPerMinChange, s)    fight = min(-iPerMinChange, -s)c = -abs(int(r * fPerDieRollMult))if success:    if abs(c) < iPerMinChange:        x = 0, y = -iPerMinChange    else:        x = -int(c * fPerTempMult), y = celse fail:    x = int(c * fPerTempMult), y = c

User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Sat Feb 06, 2010 10:59 am

just wondering, does anyone happen to know the formula for Intimidate?

They can be found http://www.gamesas.com/index.php?/topic/1097214-gameplay-mechanics-anolysis/
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Sat Feb 06, 2010 5:11 pm

thanks, but i can barely comprehend all that. a few things are undefined. i think i'll just make my own success formula rather than try to emulate that.
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Sun Feb 07, 2010 12:48 am

i've searched a bit, and the answers i have found are not that encouraging.

my newest issue is that i need to find a way to cause NPCs to "call the guards". i have a couple of new actions for the player. they are implemented with a mix of targeted scripts and dialog. i have no problem changing the PC's bounty for committing these new illegal actions, but what i cannot do is cause the NPC acted against to react, nor the guards to respond. what i want to do is duplicate the effect of stealing from the NPC, or striking it. i'm iffy on using startcombat, as i'm thining this would cause guards to jump into the fight on the side of the PC, and also because i'm fairly sure striking the NPC (and killing it) will not incur additional bounty.

from what i've read about setalarm, this controls if the NPC will report your crimes, as in increase your bounty. i dont need that, i've allready set the bounty myself.
User avatar
Pumpkin
 
Posts: 3440
Joined: Sun Jun 25, 2006 10:23 am

Post » Sat Feb 06, 2010 2:32 pm

I just lately did something like this. Are these specific NPCs that you want to trigger a response from the guards or any NPC when certain conditions are satisfied? Is this a result of dialog or just the player drawing near the NPC? Do you want the NPC to respond violently for just express alarm?

If it is from dialog, it can be managed without knowing the NPC's ID with a targeted global script. In the results section of the dialog entry that will trigger the response add the line: StartScript "RAK_GuardResponse" .

Begin RAK_GuardResponseif ( menumode == 1 )    returnendifif ( doOnce == 2 )    set doOnce to 0 ; in case this script would be started again    StopScript "RAK_GuardResponse"    returnendifif ( doOnce == 0 )    set doOnce to 1    SetFight 100    SetFlee 0    StartCombat player    ModPCCrimeLevel 10000 ; this will make guards attack playerendifif ( doOnce == 1 )    set timer to ( timer + GetSecondsPassed )    if ( timer < 1 ) ; give guards moment to respond        return    endif    set timer to 0 ; reset for next time    set doOnce to 2    ModPCCrimeLevel -10000 ; restores original bountyendifEnd RAK_GuardResponse

This code has not been tested.

If this is too strong a response for your needs it can be toned down. Rather than initiate combat the NPC could make a cry for help by calling the appropriate voice file however that would require knowing the NPC's race and gender to get the right fit. A bounty of 1000 will certainly call the guards over to the player with the intent of arresting rather than killing, but if the bounty is removed they will stop. You will have to decide if you want the player to have a bounty as a result of the encounter with the NPC in question.

Postscript: I read that you have already set a bounty so perhaps that can be incorporated into the script.
User avatar
Max Van Morrison
 
Posts: 3503
Joined: Sat Jul 07, 2007 4:48 pm

Post » Sun Feb 07, 2010 1:28 am

about the setfight and startcombat, will the guards attack the NPC? will the PC gain more bounty for defending him/herself?

i'll test a bit later today, thanks for the script and help.
User avatar
C.L.U.T.C.H
 
Posts: 3385
Joined: Tue Aug 14, 2007 6:23 pm

Post » Sat Feb 06, 2010 9:39 pm

allright, tried the script, changed it a little (to include preserving original fight and flee settings) then changed it more as this script and my main script for this action were fighting over which one got to set fight and flee, and i' fiddled with it some more trying to get it to work.

the problem with it is that guards will only run to the PC for the duration of the "extended" bounty. when it resets, so do the guards. i do NOT want to pronounce a death sentence, i want the PC to be able to pay the fine or go to jail, if desired, and the extended bounty screws that up.

this may be because i reduced the extended bounty to 1000 (just enough to bring the guards running to confront you) at 10000, i'm pretty sure they will start combat. i do not want them to immediately start combat, the PC will have no way to pay the fine or go to jail if so desired.
User avatar
RUby DIaz
 
Posts: 3383
Joined: Wed Nov 29, 2006 8:18 am

Post » Sun Feb 07, 2010 1:29 am

I was not certain what you wanted to have happen. I know from my own tests that a bounty of 1000 will draw the guards but the removal of it would suspend the arrest (unless perhaps if the player already had a bounty). I used a bounty of 10000 because I needed the guards to initiate combat with the player so that worked for me.

You might consider applying the bounty of 1000 and then removing most of it. I thought you wrote that you had already applied a bounty to the player for whatever crime (real or imagined) that the player is supposed to have committed. If the bounty remains at least one I should think the guards will fine/arrest the player. If this is slightly more than what you already assigned I cannot see that it would be an issue... but perhaps I am still misunderstanding you.
User avatar
Holli Dillon
 
Posts: 3397
Joined: Wed Jun 21, 2006 4:54 am

Post » Sat Feb 06, 2010 5:42 pm

i'm adding "kidnapping and holding nobles for ransom" functionality. i have decided that a failed kidnapping attempt nets a bounty equal to assault (40gp). this is not enough for the guards to arrest the player.

the GuardReaction script adds 1000 to the players current bounty (if the player has done nothing other than the failed kidnap attempt, the total will be 1040)

the guards go on alert and run to the player. if a guard reaches the player in the one second it takes for the bounty to be reduced by 1000 (going back to 40 total bounty), he will demand 1040 gold.

if no guards reach the player before the bounty is modified by -1000 (bringing the total back to the "correct" amount of 40gp) then the guards stop attempting to arrest the player and return to normal.

what i need is for the guards to continue to pursue the player, and forcegreet the player when in melee range (as they do when the player has a bounty > 1000) even after the bounty is reduced back to it's "real" value.
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Sat Feb 06, 2010 8:41 pm

I suggest that you create a new greetings for guards above their official arrest responses in Greeting0 filtered by a global variable toggled then the player attempts to abduct the NPC. Apply the bounty of 1000 to draw the guards. When they force greet the player they will use your response irrespective of the player's actual bounty so you can decide what is appropriate. In dialog results you can restore the player's bounty to its previous level using ModPCCrimeLevel -1000 (or SetPCCrimeLevel 0 if you think the player's record should be clean after the encounter with the guards).
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am

Post » Sat Feb 06, 2010 3:10 pm

didnt work, guards still demand 1000 more than the actual bounty.
User avatar
*Chloe*
 
Posts: 3538
Joined: Fri Jul 07, 2006 4:34 am

Post » Sat Feb 06, 2010 11:34 pm

I find that hard to believe if you did as I suggested. Create a new entry above the guard 'Alarm' greetings (and below the choices if you intend to use them), filtered for a global variable that you toggle at the same time you bump the player's bounty. Have the guard say something like:

You violated the law, %PCName. Since you turned yourself in voluntarily, I'll take that into consideration. Pay 40 gold to the court or serve your sentence of hard labor. Deliver the gold immediately, or come with me.

...and have appropriate player choices in dialog results. Dialog results will toggle the global variable off and lower the player's bounty. I cannot see how the guard could ask for more than 40 gold unless the filtering conditions for your new greeting are not being satisfied.
User avatar
lexy
 
Posts: 3439
Joined: Tue Jul 11, 2006 6:37 pm

Post » Sat Feb 06, 2010 9:56 am

I find that hard to believe if you did as I suggested. Create a new entry above the guard 'Alarm' greetings (and below the choices if you intend to use them), filtered for a global variable that you toggle at the same time you bump the player's bounty. Have the guard say something like:

You violated the law, %PCName. Since you turned yourself in voluntarily, I'll take that into consideration. Pay 40 gold to the court or serve your sentence of hard labor. Deliver the gold immediately, or come with me.

...and have appropriate player choices in dialog results. Dialog results will toggle the global variable off and lower the player's bounty. I cannot see how the guard could ask for more than 40 gold unless the filtering conditions for your new greeting are not being satisfied.

i did a straight copy of both the pchascrimegold and not versions of the dialog. i created a global variable - RAK_guardalarm - and replaced the line in RAK_guardreaction that previously read
modpccrimelevel -1000
to
set RAK_guardalarm to 1


the new dialog entries were above the regular arrest dialog entries.

and it didnt work, the guard demanded 1040 gold.

please dont doubt my word. i want this functionality, i have no reason to lie to you.
User avatar
WYatt REed
 
Posts: 3409
Joined: Mon Jun 18, 2007 3:06 pm

Post » Sat Feb 06, 2010 1:18 pm

I do not doubt you. The reason that you and I received different results is because we are doing different things. I am not certain exactly how PCHasCrimeGold works, but I suspect it references the player's current bounty. There is no need to reference that since you know that you want the bounty to be and you know how much you want the player to pay.

The two new entries might be:

Filter [Class: Guard; Global: RAK_GuardAlarm == 1; Item: Gold_001 >= 40You violated the law, %PCName. Since you turned yourself in voluntarily, I'll take that into consideration. Pay 40 gold to the court or surrender to me and serve your sentence of hard labor. Deliver the gold immediately, or come with me.
Result: Choice "Pay Gold." 1 "Go to Jail." 2 "Resist Arrest." 3

Filter [Class: Guard; Global: RAK_GuardAlarm == 1]: You violated the law, %PCName. Since you don't have the 40 gold to pay the court, you must surrender to me and serve your sentence of punitive labor. Come with me.
Result: Choice "Go to Jail." 2 "Resist Arrest." 3

The three new choices might be:

Filter [Class: Guard; Global: RAK_GuardAlarm == 1; Function: Choice = 1]: I accept this gold in payment of the fines and compensation ordered by the court. And now you are free to go.
Result: Player->RemoveItem Gold_001 40
ModPCCrimeLevel -1000
set RAK_GuardAlarm to 0

Filter [Class: Guard; Global: RAK_GuardAlarm == 1; Function: Choice = 2]: Then you must serve a sentence of hard labor. Serve your time peaceably, and pay your debt to society.
Result: GotoJail
ModPCCrimeLevel -1000
set RAK_GuardAlarm to 0
Goodbye

Filter [Class: Guard; Global: RAK_GuardAlarm == 1; Function: Choice = 3]: Then pay with your blood, outlaw!
Result: StartCombat Player
ModPCCrimeLevel -1000
set RAK_GuardAlarm to 0
Goodbye

All of these go above the existing guard response entries (including the existing choices).
User avatar
Emerald Dreams
 
Posts: 3376
Joined: Sun Jan 07, 2007 2:52 pm

Post » Sat Feb 06, 2010 2:26 pm

while this will work for this one specific situation, i'm going to use RAK_guardreaction for ALL "new" crimes.

PCHasCrimeGold is a global variable that returns 1 when

player->getitemcount "gold_001" >= PCCrimelevel


if the modpccrimegold command in the results box were functioning as expected, than it should be able to tell when the player has the gold or not, and give the appropriate choices (pay fine, go to jail, resist arrest)

you'll note the "function alarmed" conditional for default arrest dialogs? right now i'm looking into getting this to fire by script and not just player action.
User avatar
Erika Ellsworth
 
Posts: 3333
Joined: Sat Jan 06, 2007 5:52 am

PreviousNext

Return to III - Morrowind