Scripting 9 & 12 weeks

Post » Fri May 04, 2012 2:39 am

I am curious. Are you using double (GetDistance is not fast) condition test as safety measure?

Yes - I first used a script that Kateri had for Julan which did not have the double check - I couldn't get it to work consistently - and as the dialogue was dependent on the Global I ended up using the double which so far has worked correctly all the time - unless I rush ahead and don't let her catch up.

I'm going to do a clean start of the mod and take her directly to Gnisis to see if there is something wrong with the Tradehouse door - she is still not warping to me after going through it.

EDIT: Looking at the door marker in the CS for the Gnisis tradehouse - I see it is positioned quite low - is it possible that a companion coming through that door might be placed below the ground mesh and thus fall down into the void below the world mesh? I know I've had problems with position cell that if I place them too close to the floor they can fall through it.
User avatar
Megan Stabler
 
Posts: 3420
Joined: Mon Sep 18, 2006 2:03 pm

Post » Fri May 04, 2012 9:19 am

I've done some more testing around Gnisis and have found it is just the Tradehouse where my companion doesn't warp correctly - when I toggle collision and check underground she immediately warps to my position. If I walk forward about 20 steps she will warp into place as per her scripts - I turned off grass as there is a big clump outside the door but that didn't seem to make a difference - I'll post my findings in the modders section as this is no longer a scripting issue but perhaps a collision issue.

For abot the script I had previously used from kateri's Julan which wasn't working for me is written:

if ( "KS_Julan"->GetDistance Player > 512 )
set j_close to 0
endif

I had exactly the same but with my variable id's and it would constantly get stuck on BM_Withme = 1 when it should have been 0
User avatar
chloe hampson
 
Posts: 3493
Joined: Sun Jun 25, 2006 12:15 pm

Post » Fri May 04, 2012 4:50 am

I've tried a couple of times to force equip clothes and armour onto my player without success

I spent some time looking at the scripts Kateri had done for Julan which forced him to remove whatever items of armour or clothing he had on at the time

But was unable to replicate the same effects on the player - if I want to forcibly remove clothing and/or armour from a player and replace it with something else how do I do that?
User avatar
jadie kell
 
Posts: 3497
Joined: Sat Jul 29, 2006 3:54 pm

Post » Fri May 04, 2012 3:49 am

This doesn't work?

Player->additem "" 1
Player->equipitem ""
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am

Post » Fri May 04, 2012 6:29 am

This doesn't work?

Player->additem "" 1
Player->equipitem ""

No - because while that equips the item I want them to wear I am still left with the problem of the items I don't want them to wear

Typically the strip scripts go

Additem "fake_item" 1
Equip "fake_item" 1
Removeitem "fake_item" 1

But I found myself still wearing what I had on in the first place?

I noticed Kateri had created fake items that were of very high value - I suppose that was because NPC's tend to wear the highest value item - but I didn't think that mattered for the player?

I just wondered if there was anything different I should be doing?
User avatar
JAY
 
Posts: 3433
Joined: Fri Sep 14, 2007 6:17 am

Post » Thu May 03, 2012 10:33 pm

In what manner are you executing the scripts? For force-equipping the player with items I'd take a look at the "cursed item" script in Morrowind Scripting for Dummies. The cursed item has a local script that checks to see if it is equipped on the player every frame, and if it is not, equips itself. So you simply add the item to inventory and it is bound to them. One important detail is to omit the typicaly MenuMode check because you don't want them to be able to go into a menu and then drag the item away.

Furthermore, you can interlock that force-equip condition with a journal entry or global to allow you to unbind them later if appropriate. If it is armor (and not clothing), however, I'm not sure what would happen if it was being forcibly equipped once the condition of the armor reached 0 -- does anyone know if the game would crash?

As for the "fake items of high value," yep, that ensures that an NPC will choose to wear them.


Edit: This was the example. I don't know why but I can't get the forum to display the spacing all correctly.
Begin cursed_itemshort stateshort OnPCEquipif (OnPCEquip == 0) ; item is not equipped  if ( state == 0 ); if club has never been equipped, do nothing	return  else	Player -> Equip "cursed_club" ; reequip the item!	MessageBox "The item is cursed, it doesn't leave your hand" ;taunt the player  endifelse  if ( state == 0 ) ;first time equipped. The trap snaps shut	set state to 1  endifendifEnd
User avatar
Pat RiMsey
 
Posts: 3306
Joined: Fri Oct 19, 2007 1:22 am

Post » Fri May 04, 2012 3:37 am

Hmmm.... I need to think about that one - that script is designed to be attached to the cursed_club - whereas I'm trying to add items to the player's inventory that haven't been picked up yet

I suspect having a state between adding and removing might be good and a check to see if the item has been equipped is a good idea

I've done the reverse where the player has an item of clothing and if they try and put it on it un-equips - am just struggling to get it work the other way - thanks for jumping in with the idea :)
User avatar
Liii BLATES
 
Posts: 3423
Joined: Tue Aug 22, 2006 10:41 am

Post » Thu May 03, 2012 9:26 pm

This script worked for me:
begin _ALM_UndressPlayershort doOnceif ( MenuMode == 1 )	returnendifset doOnce to doOnce + 1if ( doOnce == 1 )	Player->AddItem "ALM_empty_glove_left" 1	Player->Equip "ALM_empty_glove_left" 1	Player->RemoveItem "ALM_empty_glove_left" 1	returnelseif ( doOnce == 2 )	Player->AddItem "ALM_empty_glove_right" 1	Player->Equip "ALM_empty_glove_right" 1	Player->RemoveItem "ALM_empty_glove_right" 1	returnelseif ( doOnce == 4 )	Player->AddItem "ALM_empty_pants" 1	Player->Equip "ALM_empty_pants" 1	Player->RemoveItem "ALM_empty_pants" 1	returnelseif ( doOnce == 5 )	Player->AddItem "ALM_empty_robe" 1	Player->Equip "ALM_empty_robe" 1	Player->RemoveItem "ALM_empty_robe" 1	returnelseif ( doOnce == 6 )	Player->AddItem "ALM_empty_shirt" 1	Player->Equip "ALM_empty_shirt" 1	Player->RemoveItem "ALM_empty_shirt" 1	returnelseif ( doOnce == 7 )	Player->AddItem "ALM_empty_shoes" 1	Player->Equip "ALM_empty_shoes" 1	Player->RemoveItem "ALM_empty_shoes" 1	returnelseif ( doOnce == 8 )	Player->AddItem "ALM_empty_cuirass" 1	Player->Equip "ALM_empty_cuirass" 1	Player->RemoveItem "ALM_empty_cuirass" 1	returnelseif ( doOnce == 9 )	Player->AddItem "ALM_empty_greaves" 1	Player->Equip "ALM_empty_greaves" 1	Player->RemoveItem "ALM_empty_greaves" 1	returnelseif ( doOnce == 10 )	Player->AddItem "ALM_empty_helmet" 1	Player->Equip "ALM_empty_helmet" 1	Player->RemoveItem "ALM_empty_helmet" 1	returnelseif ( doOnce == 11 )	Player->AddItem "ALM_empty_shield" 1	Player->Equip "ALM_empty_shield" 1	Player->RemoveItem "ALM_empty_shield" 1	returnelseif ( doOnce == 12 )	Player->AddItem "ALM_empty_pauld_left" 1	Player->Equip "ALM_empty_pauld_left" 1	Player->RemoveItem "ALM_empty_pauld_left" 1	returnelseif ( doOnce == 13 )	Player->AddItem "ALM_empty_pauld_right" 1	Player->Equip "ALM_empty_pauld_right" 1	Player->RemoveItem "ALM_empty_pauld_right" 1	returnelseif ( doOnce == 14 )	Player->AddItem "ALM_empty_ring1" 1	Player->AddItem "ALM_empty_ring2" 1	Player->Equip "ALM_empty_ring1" 1	Player->Equip "ALM_empty_ring2" 1	Player->RemoveItem "ALM_empty_ring1" 1	Player->RemoveItem "ALM_empty_ring2" 1	returnelseif ( doOnce == 15 )	Player->AddItem "ALM_empty_belt" 1	Player->Equip "ALM_empty_belt" 1	Player->RemoveItem "ALM_empty_belt" 1	returnelseif ( doOnce == 16 )	Player->AddItem "ALM_empty_amulet" 1	Player->Equip "ALM_empty_amulet" 1	Player->RemoveItem "ALM_empty_amulet" 1	returnelseif ( doOnce == 17 )	set doOnce to 0	stopscript _ALM_UndressPlayerendifend _ALM_UndressPlayer

IIRC, the script without frame-splitting worked as well, but it was choking the framerate, so I loosened it. Are you sure you used Player->AddItem and not just AddItem?
User avatar
Daniel Holgate
 
Posts: 3538
Joined: Tue May 29, 2007 1:02 am

Post » Fri May 04, 2012 6:09 am

Thank you Kir - I know I had a similar script except for all the doOnce's - I had tried to use existing items instead of creating new ones - so for instance I tried adding a chiten gauntlet equiping it and then removing it - but using existing id's did not seem to work - I suppose because the references persist box had not been ticked?
User avatar
Lil Miss
 
Posts: 3373
Joined: Thu Nov 23, 2006 12:57 pm

Post » Fri May 04, 2012 10:49 am

They weren't ticked in my mod as well, but the script still worked. Oh, and using existing items may glitch if you already have the same item in your inventory.
User avatar
Thema
 
Posts: 3461
Joined: Thu Sep 21, 2006 2:36 am

Post » Thu May 03, 2012 10:21 pm

I did have the same items in my inventory - thank you for rescuing me again Kir

I want to have a script that reduces the player's health to 10% of their original - at first I tried having a curse added and removed but I'm not sure this is the best way to handle it

I know GetHealthGetRatio gives me the health % - but do I need to do something like set myvariable to ( GetHealth / 10 ) and then do a ModHealth to myvariable?

I haven't done any division in scripting before so am unsure

Edit: I think I've worked it out and will just head off to test

Set myvariable to [ player->GetHealth / 100 ]
player->ModCurrentHealth myvariable

Well at least the CS didn't spit a dummy at me when compiling

Edit 2: Well that didn't work

So I tried

set my_variable to ( player->GetHealth )
set my_variable to ( my_variable / 100 )

and then under a different state

Player->ModCurrentHealth my_variable

That didn't work either

My character started on 46 health and should have got down to 4 or 5 health but at the end of the script they were still on 46 health - the script compiled and ran fine - just didn't damage the health

So any ideas are welcome
User avatar
Lucy
 
Posts: 3362
Joined: Sun Sep 10, 2006 4:55 am

Post » Thu May 03, 2012 11:35 pm

Well, you can use the loop:
while ( Player->GetCurrentHealth > my_variable )	Player->ModCurrentHealth -1endwhile
This will stutter your script, though. Or, if the script is a continuous rather than one-frame-stop type, use "if" instead of "while" and you will *see* your health dropping in about second's time.
User avatar
hannaH
 
Posts: 3513
Joined: Tue Aug 15, 2006 4:50 am

Post » Fri May 04, 2012 2:08 am

I like the idea of using the greater than - I've never used while before so will test both that and the if and let you know how it goes - thanks again for your help
User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Fri May 04, 2012 11:38 am

So I tried

set my_variable to ( player->GetHealth )
set my_variable to ( my_variable / 100 )

and then under a different state

Player->ModCurrentHealth my_variable

That didn't work either
almost there... :cool:
set my_variable to ( player->GetHealth )set my_variable to ( my_variable * 0.9 )set my_variable to ( 0 - my_variable )Player->ModCurrentHealth my_variable
User avatar
Michael Korkia
 
Posts: 3498
Joined: Mon Jul 23, 2007 7:58 pm

Post » Fri May 04, 2012 8:53 am

Thanks abot - that works great - am glad I gave it my best shot before asking here :)

When i was writing this script I tried adding a curse and putting it on a timer of 5 seconds to see if my health would slowly go down - instead all it does is a one fire action and left it's blood haze cloud around me - what am I doing wrong in not seeing my stats deteriorate?

I wrote it

player->addspell "BM_Lovehurts"    if ( timer < 5.0 )        set timer to ( timer + GetSecondsPassed )        return   endifset timer to 0
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Fri May 04, 2012 6:52 am

Can you post the whole script, Illy? I think that timer should go towards the top and the curse should have a do once condition on it so it's not added repeatedly.
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Fri May 04, 2012 10:16 am

Can you post the whole script, Illy? I think that timer should go towards the top and the curse should have a do once condition on it so it's not added repeatedly.

It's ok Jac - although it didn't work as I expected I've been able to use that to my advantage - and I'm happy with the script now - thanks for offering to help :)
User avatar
Peter lopez
 
Posts: 3383
Joined: Mon Sep 10, 2007 5:55 pm

Post » Fri May 04, 2012 4:31 am

Just wanted to say thanks to Kir, abot, Jac and others who have helped me deal with issues on 9 & 1/2 weeks - I couldn't have completed the mod without your support - thank you.
User avatar
Killah Bee
 
Posts: 3484
Joined: Sat Oct 06, 2007 12:23 pm

Previous

Return to III - Morrowind