leveled items and player->additem

Post » Wed Nov 30, 2011 12:05 pm

is it possible to use player->additem "leveled item id" in the results of a dialog and get the player to receive the items contained in the leveled list designated rather than a blank item with the leveled item id?

i'd rather avoid having to script the chances for these items, so would placing a container and then adding the leveled item to that work?

and on a side note, does nolore happen to block forcegreeting?
User avatar
le GraiN
 
Posts: 3436
Joined: Thu Mar 22, 2007 6:48 pm

Post » Wed Nov 30, 2011 8:19 am

Nothing blocks ForceGreeting as such, but nolore can cause no results to be available.

Leveled lists seem to be resolved when the game loads, so adding them to NPCs or the player will result in an item or items being chosen and added instead.
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm

Post » Wed Nov 30, 2011 8:44 pm

so then, what i would need to do is to make containers that contain my leveled items, through scripts, place them by the NPC, and remove it with another script, after the PC is done claiming the reward.

or i guess i could bite the bullet and script individual item chances in a "reward giver" script.
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Wed Nov 30, 2011 9:37 am

Just give the NPC or PC a leveled list (via dialog results). It'll automagically resolve when it enters the game. It's done quite often, like with almost every NPC ever.
User avatar
elliot mudd
 
Posts: 3426
Joined: Wed May 09, 2007 8:56 am

Post » Wed Nov 30, 2011 8:42 am

Just give the NPC or PC a leveled list (via dialog results). It'll automagically resolve when it enters the game. It's done quite often, like with almost every NPC ever.

that's the problem. instead of the leveled items getting resolved, i get one no icon item with the same name as the leveled item id i was using.

for example, instead of giving any gold at all, when i player->additem "RAK_Ransom_Gold" (a leveled item only containing gold) i get the cross-barred smiley, mousing over reveals it to be "RAK_Ransom_Gold"
User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm

Post » Wed Nov 30, 2011 7:26 pm

Are there valid objects in the list? The original devs used a lot of leveled lists all around, and as you probably have seen (by not noticing), they do work like that. It sounds more like a bug with that list. Try using a stock list, if that works, troubleshoot just your list.
User avatar
Juan Suarez
 
Posts: 3395
Joined: Sun Nov 25, 2007 4:09 am

Post » Wed Nov 30, 2011 5:15 pm

hrm. a bethesda default leveled entry "random_book_dunmer" still returned a null item. i'll try having the dialog start a script that uses additem "leveled list"

also, it seems the dialog result is not wanting to set "glabal_script_name".variable_name to integer. in this case, "RAK_tg_jobscript".status to 40. as "status == 40" is the "reset status" resetting variables to default and self-terminating the script, i think i'll switch to getitemcount "RAK_tg_jobmarker" < 1 as the conditional for resetting. RAK_tg_jobmarker is a "blank" item the player should never see, but is conditional to the greeting that uses the additem.

oh, i also think i figured out the forcegreeting issue. i have another "player"->getdistance check, and it seems that morrowind does not like checking the same variable unless its in one big elseif block.

i'll try the changes i mentioned, and get back.

edit, checked with script, rather than dialog. still got a null item. i guess i'll have to script individual item chances.
User avatar
John Moore
 
Posts: 3294
Joined: Sun Jun 10, 2007 8:18 am

Post » Wed Nov 30, 2011 10:36 am

You shouldn't call GetDistance twice like that anyway, for speed. Use a float variable to cache the results, you may see an FPS boost. be careful with if/elseif sizes.

I don't know what's wrong with the leveled lists though, they're used a lot and I've never seen that happen.
User avatar
W E I R D
 
Posts: 3496
Joined: Tue Mar 20, 2007 10:08 am

Post » Wed Nov 30, 2011 7:08 pm

You shouldn't call GetDistance twice like that anyway, for speed. Use a float variable to cache the results, you may see an FPS boost. be careful with if/elseif sizes.

I don't know what's wrong with the leveled lists though, they're used a lot and I've never seen that happen.

i had thought that using two getdistance checks would not be that bad if they were cordoned off from each other like -
if ( status == 10 )    if ( ( GetDistance, "player" ) < 200 )        ;do stuff    endifendifif ( status == 20 )     if ( ( GetDistance, "player" ) < 150 )        ;do other stuff    endifendif


as to the leveled lists, i saw a thread about something similar happening with one specific added entry, but i could get neither normal or custom entries to give the appropriate items. only the "null" item.

it's probably for the best, anyway. scripting the rewards the way i did adds for a bit more flexibility in what you get.

now i've just got to figure out why
if ( random100 < ( variable1 + varable2 + variable3 == 98 )

returned false two times in a row.
User avatar
Lexy Corpsey
 
Posts: 3448
Joined: Tue Jun 27, 2006 12:39 am

Post » Wed Nov 30, 2011 7:15 pm

I've never been able to make leveled lists put in player inventory work, scripted ifs with random is the way to go.
begin exampleshort i1set i1 to Random 1001; testing descending valuesif ( i1 > 900 )	player->AddItem "gold_001" 900elseif ( i1 > 800 )	player->AddItem "gold_001" 800; ....else	player->AddItem "gold_001" 100endifset i1 to Random 10001; testing ascending valuesif ( i1 < 1000 )	player->AddItem "gold_001" 100elseif ( i1 < 2000 )	player->AddItem "gold_001" 200; ....else	player->AddItem "gold_001" 900endifend

I don't know if this can help, but Random100 is a global short updated in the Main script when not in MenuMode, so until you exit dialog it is not updated.
User avatar
Stephy Beck
 
Posts: 3492
Joined: Mon Apr 16, 2007 12:33 pm

Post » Wed Nov 30, 2011 6:29 pm

*snip*
I don't know if this can help, but Random100 is a global short updated in the Main script when not in MenuMode, so until you exit dialog it is not updated.

yea, i ended up scripting the additem commands separately, using random100 and three other variables set to random 100 when the script initializes.
User avatar
Rach B
 
Posts: 3419
Joined: Thu Mar 08, 2007 11:30 am

Post » Wed Nov 30, 2011 7:06 pm

i had thought that using two getdistance checks would not be that bad if they were cordoned off from each other like -

-code snip-

No, that's not bad at all then. If you know it will be called, you can still precache the results, just for code simplicity. But as long as you're not actually calling it twice, it won't be too slow.


now i've just got to figure out why
if ( random100 < ( variable1 + varable2 + variable3 == 98 )

returned false two times in a row.


Because that's epically invalid. And nobody has any idea how the MW VM will process it. It should, in theory, test if variable 3 == 98, then add that to 1 and 2, then check if that's greater than random100. But, there's no reason to believe it will. That should be split into at least 3 lines, using variables to store the data while you're working with it.

I've never been able to make leveled lists put in player inventory work, scripted ifs with random is the way to go.

But it works for NPCs and containers... I wonder if a work-around would be to force-activate a container that has had the list added to it. I may also bring this up in the code patch thread, see if Hrnchamd can make lists resolve for the player.
User avatar
Emma-Jane Merrin
 
Posts: 3477
Joined: Fri Aug 08, 2008 1:52 am

Post » Wed Nov 30, 2011 2:53 pm

i havent tried containers, but they do work when plugging them into NPC inventory in CS.

the 1 + 2 + 3 == 98 is for your convieniance, it's really a variable with 50, a variable with 48 and a variable with zero so that
( random100 < ( v1 + v2 + v3 ) )


think it would be less wonkey if did the equation before comparing it to random100 and stored it in a different variable, so that
set total to ( v1 + v2 + v3 )if ( random100 < total )    ;do stuffendif


also, if the leveled list thing can be solved with MCP in the future, i will be a happy RAK indeed.
User avatar
cassy
 
Posts: 3368
Joined: Mon Mar 05, 2007 12:57 am

Post » Wed Nov 30, 2011 8:35 am

You should, as a general rule, always do as little as possible in a conditional. The script engine has particular trouble handling that. Putting it in a variable ahead of time can avoid some crashes you might otherwise run into.

You might try force-activating a container with the list somehow. I know most vanilla loot containers use leveled lists, so that should work, as long as you can make sure the player activates it. Alternatively, add it to an invisible NPC or a creature (which might be easier) who has companion share, and use ForceGreeting then instruct the player to grab the item(s) they want. Either should be a work-around for the moment.
User avatar
Kate Schofield
 
Posts: 3556
Joined: Mon Sep 18, 2006 11:58 am

Post » Wed Nov 30, 2011 8:24 pm

You should, as a general rule, always do as little as possible in a conditional. The script engine has particular trouble handling that. Putting it in a variable ahead of time can avoid some crashes you might otherwise run into.

You might try force-activating a container with the list somehow. I know most vanilla loot containers use leveled lists, so that should work, as long as you can make sure the player activates it. Alternatively, add it to an invisible NPC or a creature (which might be easier) who has companion share, and use ForceGreeting then instruct the player to grab the item(s) they want. Either should be a work-around for the moment.

thanks for the tip about conditionals, i shall modify my scripts accordingly.

what i'm doing is a variation of my "send any fighters guild member out to find work". a dialog result starts a targeted script that disables the NPC untill a timer is greater than a time limit variable. the NPC is then re-enabled, and when the PC is within "speaking distance", the NPC forcegreets and adds items to the PC.

to me, it is important that the "item added" messages show up in the dialog, and that the dialog indicates you are talking to the correct NPC. what gets to me is that the script to do this is built from the original "fighters guild find work" script, yet there are important differences. for one, in the fighter script, i control the correct greeting by use of an item that transparently is added and removed from the PC's inventory. in this script, it is not removed transparently (itemx was removed from your inventory message in dialog)

regardless, i'm somewhat satisfied with the current version, where i scripted the random items, and changed the dialog marker item's name to something "discreet".
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm


Return to III - Morrowind