Scripting help needed

Post » Fri May 27, 2011 11:55 pm

ok, well i'm trying to design a leveled weapon system for the game, i'm starting with the glass claymore just to figure it out. I dont want to use the lvl item set up because it has no model and wont work everywhere. the script works, unless its in a container, heres the script

Begin lvlglass_ls

;leveled glass longsword

if ( OnActivate == 1 )
If ( Player->GetLevel < 8 )
Player->AddItem "0glass claymore1" 1
endif
if ( Player->GetLevel >= 8 )
If ( Player->GetLevel < 16 )
Player->AddItem "0glass claymore2" 1
endif
endif
If ( Player->GetLevel >= 16 )
If ( Player->GetLevel < 24 )
Player->AddItem "0glass claymore3" 1
endif
endif
If ( Player->GetLevel >=24 )
If ( Player->GetLevel < 32 )
Player->AddItem "0glass claymore4" 1
endif
endif
If ( Player->GetLevel >= 32 )
Player->AddItem "0glass claymore5" 1
endif
Activate
endif
Player->RemoveItem "0glass claymoreAv" 1

End

Any ideas as to what i need to do to get the script to run out of containers and dead NPC's?
thanks ahead of time
User avatar
Dan Wright
 
Posts: 3308
Joined: Mon Jul 16, 2007 8:40 am

Post » Fri May 27, 2011 4:09 pm

Welcome to the forums.

I think it will be easier and more reliable to 'level' the weapon when it is in the player's inventory. Besides it really does not matter what the weapon is like if it is not in the player's possession. The switch must be performed by two scripts working in concert since removing an item by its own script will crash the game.

The first script is attached to the weapon. It appears that the item you will place in the world initially is 0glass claymoreAv. It starts a global script that will perform the weapon switch.

This script is attached to the weapon:

Begin glass_ls; Attached to 0glass claymoreAvshort doOnceif ( menumode == 1 )   return ; level weapon when inventory closedendifif ( ( player->GetItemCount "0glass claymoreAv" ) == 0 )   return ; do not level weapon until it is in player's inventoryendifif ( doOnce == 1 )   return ; do not start level script more than once per weaponendifset doOnce to 1StartScrip "lvlglass_ls"End glass_ls


Global script:
Begin lvlglass_ls; Self-terminating global script started by the script glass_lsif ( ( player->GetLevel ) >= 32 )    player->AddItem "0glass claymore5" 1elseif ( ( player->GetLevel ) >=24 )   player->AddItem "0glass claymore4" 1elseif ( ( player->GetLevel ) >= 16 )   player->AddItem "0glass claymore3" 1elseif ( ( player->GetLevel ) >= 8 )   player->AddItem "0glass claymore2" 1else   player->AddItem "0glass claymore1" 1endifplayer->RemoveItem "0glass claymoreAv" 1StopScript "lvlglass_ls"End lvlglass_ls

This code has not been tested.

Do you intend to do this for every weapon in game?
User avatar
cassy
 
Posts: 3368
Joined: Mon Mar 05, 2007 12:57 am

Post » Fri May 27, 2011 11:47 am

I believe this should be better done without any scripting, by making leveled lists.

Go to TESCS 'Leveled lists' tab and crate new, then add there all variations of Your leveled sword, indexing them with maximum PC level when he can get them, then drop this list in any container or NPCs inventory - it should work.

The only thing where script should be needed then would be: if You want to give a leveled weapon as a quest reward and in such case there's no need to exchange anything in PCs inventory.

P.S. I'd also recommend to name those instances of leveled weapons so they end with a number of min or max level they are meant to - if You are going to differ the level tresholds (e.g. lvl 2 glass sword for lvl 8 char, lvl 2 ebony axe for lvl 7 char), You may easily get lost without proper naming. (IMHO)
User avatar
I’m my own
 
Posts: 3344
Joined: Tue Oct 10, 2006 2:55 am

Post » Fri May 27, 2011 10:56 pm

first cyran0, thanks for the help, i'll give that a try when i get a chance
second, to b0k0n0n, i cant use the levveled item system because there is no model for the leveled item, so anything in the open will show up as an angry question mark, trust me, i tried
User avatar
Mandi Norton
 
Posts: 3451
Joined: Tue Jan 30, 2007 2:43 pm


Return to III - Morrowind