Finishing up this Script: What are the final touches I'm mis

Post » Sun Jun 17, 2012 5:18 pm

Hello everyone, I'm really tired. I've spent about 4 hours working on a script aiming to tie involuntary werewolf transformations to the lunar cycle, and, after working through sytax error after syntax error and getting a lot of help from the wiki, this forum and others, I've finally whittled things down to just four errors.

The script is as follows.

scriptname cohTransformTiming extends Quest{Controls the Timing for transformation.}float property cohGetMoonPhase autofloat property cohPhaseDay autobool property cohCanTransform autobool property cohbmvar autoSpell property WerewolfChangeEffect autoGlobalVariable Property TimeOfDayGlobalProperty autoGlobalVariable Property GameDaysPassed autoGlobalVariable Property PlayerIsWerewolf auto;declaring propertiesEvent OnUpdateGameTime()RegisterForUpdateGameTime(5.0)float timeOfDay = TimeOfDayGlobalProperty.GetValue()float DaysPassed = GameDaysPassed.GetValue()cohGetMoonPhase = (( DaysPassed + ( TimeOfDay / 24 ) - 0.5 ) % 24 )cohPhaseDay = cohGetMoonPhase / 3; Most of the above is placeholder, I can't quite remember how logic dragon got it working in Curse of Hircine, though apparently Skyrim's lunar cycle is identical to the one in Oblivion, so naturally that can be reused. The problem here seems to be in the % 24, which doesn't seem to signify what it did in Oblivion, namely the previous calculation as a random chance multipled by 24.;/List of moon phases returned by cohGetMoonPhase calculation0 = full moon1 = 3/4 waning2 = half waning3 = 1/4 waning4 = new moon5 = 1/4 waxing6 = half waxing7 = 3/4 waxing/;If TimeOfDay >= 20 || TimeOfDay <= 6 && cohPhaseDay == 1SetStage(5)cohCanTransform == trueelseif TimeOfDay <= 20 || TimeOfDay >= 6 && cohPhaseDay == 0SetStage(0)cohCanTransform == falseendifif PlayerIsWerewolf.GetValue() == 1if cohCanTransform == trueWerewolfChangeEffect.Cast(player, player); I'm not exactly sure how to make this reference on the player...elseif game.getplayer().HasMagicEffect(WerewolfChangeEffect) == true && cohCanTransform == false; This one is also the location of an error two actaully, I haven't the faintest idea why this is happening.game.getplayer().DispelSpell(WerewolfChangeEffect)endifendifEndEvent


The errors were as follows.

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(18,61): Cannot calculate the modulus of non-integersc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(41,26): variable player is undefinedc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(41,34): variable player is undefinedc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(42,24): type mismatch on parameter 1 (did you forget a cast?)c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(42,61): cannot compare a none to a bool (cast missing or types unrelated)



I'd greatly appreciate any help in resolving these issues, and the ones that are bound to follow when this finally gets compiled. Thanks in advance for any advice I may recieve.
User avatar
loste juliana
 
Posts: 3417
Joined: Sun Mar 18, 2007 7:37 pm

Post » Sun Jun 17, 2012 2:15 pm

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(41,26): variable player is undefinedc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(41,34): variable player is undefined


WerewolfChangeEffect.Cast(Game.GetPlayer(), Game.GetPlayer())
User avatar
Karine laverre
 
Posts: 3439
Joined: Tue Mar 20, 2007 7:50 am

Post » Mon Jun 18, 2012 3:00 am

If you want to use "player" in your script, I'm guessing you'll need to include "Actor player = game.getPlayer()" somewhere near the top. As for the first error, I'm not sure how to cast things in this engine. You might need to do the float arithmetic, assign the result to an int, then do the modulus arithmetic with the int.
User avatar
Phillip Brunyee
 
Posts: 3510
Joined: Tue Jul 31, 2007 7:43 pm

Post » Sun Jun 17, 2012 1:17 pm

^ Nope, just "game.get(player)" instead of "player", but that still leaves all the other errors, which I haven't the faintest idea what's causing them.
User avatar
Solène We
 
Posts: 3470
Joined: Tue Mar 27, 2007 7:04 am

Post » Sun Jun 17, 2012 10:34 pm

What are you trying to do with this line here:

cohGetMoonPhase = (( DaysPassed + ( TimeOfDay / 24 ) - 0.5 ) % 24 )

Are you trying to divide by 24, or are you intentionally performing a mod operation?
User avatar
Laura Simmonds
 
Posts: 3435
Joined: Wed Aug 16, 2006 10:27 pm

Post » Mon Jun 18, 2012 1:44 am

Your line 42 warning is because you're passing a spell (werewolfChangeEffect) property where you should be passing a magicEffect.

As a veteran scripter, it'll take a while to get used to using game.getPlayer() all the time! I used to always declare a player property until I got acclimated.

As pointed out by GraniteDevil, you need to revisit your math on line 18 - I don't think Papyrus can do what you're asking in this context.

Looks like you've made lot of quick progress with this so far!
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Sun Jun 17, 2012 11:03 pm

What are you trying to do with this line here:

cohGetMoonPhase = (( DaysPassed + ( TimeOfDay / 24 ) - 0.5 ) % 24 )

Are you trying to divide by 24, or are you intentionally performing a mod operation?

That line of code was originally from Curse of Hircine (converted to Papyrus Syntax besides the erroneous part), since the formula Logic Dragon used to calculate the moon phase in Oblivion apparently works in Skyrim (in theory). I believe, but I'm not sure that the % was necessary for the random chance element of Curse of Hircine's werewolf transformation timings. (something I'm trying to replicate in Skyrim, with the original author's opinion. Then again, that formula is probably wrong, since I'm writing it from memory. I'll have to go back into the Curse of Hircine scripts and check that formula.

^ Ah, thanks, I fixed the line 42 error by swapping WerewolfChangeEffect for Werewolf and adding "MagicEffect Property Werewolf Auto" at the top of the script.
User avatar
Sarah Evason
 
Posts: 3507
Joined: Mon Nov 13, 2006 10:47 pm

Post » Sun Jun 17, 2012 9:00 pm

The “%” operator is called “modulus” and returns the remainder of a integer division. For example, if you divide 9 by 2, (just using integers) you get 4 with a remainder of 1. So then the math expression “9 % 2” returns 1, because 1 is the remainder left behind after 9 is divided by 2. The error is because you’re trying to find the remainder of a floating point math expression, which has no meaningful result. Because if you divide 9 by 2 using floating-point math, the result is 4.5 with no remainder. So what you want here is some way to convert your float expression to an integer so you can perform the modulus.

One way is as follows:

 cohGetMoonPhase = ((( DaysPassed + ( TimeOfDay / 24 ) - 0.5 ) as int) % 24 )

What this does is it calculates the result of “(DaysPassed + (TimeOfDay / 24) – 0.5)”, casts the result to an integer (by rounding the floating point value), and then performs the modulus.
User avatar
Elina
 
Posts: 3411
Joined: Wed Jun 21, 2006 10:09 pm

Post » Mon Jun 18, 2012 5:01 am

^ Oh yeah, that's why cohGetMoonPhase was supposed to be a short. Ty. Now its compiled, though cohGetMoonPhase and cohPhaseDay definitely aren't working the way they're supposed to.
User avatar
emma sweeney
 
Posts: 3396
Joined: Fri Sep 22, 2006 7:02 pm

Post » Mon Jun 18, 2012 2:15 am

Hey, is there any way to force a variable to round down?

ie make 1.7 round to 1.0?
User avatar
sas
 
Posts: 3435
Joined: Thu Aug 03, 2006 8:40 am

Post » Mon Jun 18, 2012 3:08 am

To round down you have to use Floor:

Floor(1.7) should return 1.0

To round up you use Ceiling
User avatar
sunny lovett
 
Posts: 3388
Joined: Thu Dec 07, 2006 4:59 am

Post » Sun Jun 17, 2012 7:36 pm

Hmm, I tried

PhaseDay = floor( PhaseDay / 3 ) , but its not working. I used "PhaseDay = PhaseDay /3 as floor"

But now its giving me a different error.

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(25,37): cannot cast a float to a floor, types are incompatible
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(25,1): type mismatch while assigning to a float (cast missing or types unrelated)
User avatar
Ebou Suso
 
Posts: 3604
Joined: Thu May 03, 2007 5:28 am

Post » Sun Jun 17, 2012 3:48 pm

I think you have to use a capital F as shown on the wiki(search Floor on creationkit . com)

Edit: Oh and your PhaseDay is a float, so you're trying to parse an int to a float, meaning the result from the Floor is an int, but your PhaseDay is a float.

Edit2: What I would write is something like:

int PhaseDayFloor = Floor(PhaseDay / 3)
User avatar
Krystina Proietti
 
Posts: 3388
Joined: Sat Dec 23, 2006 9:02 pm

Post » Mon Jun 18, 2012 1:07 am

So I should make a third property right?
User avatar
Mimi BC
 
Posts: 3282
Joined: Sat Oct 07, 2006 10:30 pm

Post » Mon Jun 18, 2012 4:21 am

Yeah that would work much better.
User avatar
Del Arte
 
Posts: 3543
Joined: Tue Aug 01, 2006 8:40 pm

Post » Sun Jun 17, 2012 3:24 pm

Wait, derp, I just realized there's no reason for PhaseDay to be a float in the first place. I changed it to an int but I still got an error.

cohGetMoonPhase = ((( DaysPassed + ( TimeOfDay / 24 ) - 0.5 ) as int) % 24 )
cohPhaseDay = (cohGetMoonPhase / 3) as floor

returns the errors

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(25,37): cannot cast a float to a floor, types are incompatible
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(25,1): type mismatch while assigning to a int (cast missing or types unrelated)
User avatar
Assumptah George
 
Posts: 3373
Joined: Wed Sep 13, 2006 9:43 am

Post » Sun Jun 17, 2012 9:11 pm

You don't want to cast cohPhaseDay as a floor, just write:

cohPhaseDay = Floor(cohGetMoonPhase / 3)
User avatar
Richus Dude
 
Posts: 3381
Joined: Fri Jun 16, 2006 1:17 am

Post » Sun Jun 17, 2012 10:04 pm

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\cohTransformTiming.psc(25,16): Floor is not a function or does not exist


Then again, I think I may be approaching this from the wrong angle.

Perhaps instead of trying to adapt the formula used by Curse of Hircine, I should just write a formula that returns 0-8, starting with zero, and changing every fourth increment of a value (DaysPassed) after the in game clock surpasses noon on said day.
User avatar
Pawel Platek
 
Posts: 3489
Joined: Sat May 26, 2007 2:08 pm

Post » Mon Jun 18, 2012 2:22 am

cohPhaseDay = (cohGetMoonPhase / 3) as int
if it was 1.7 (float) changing it to int will give you 1
then if you need float save the int as float.
User avatar
Ricky Rayner
 
Posts: 3339
Joined: Fri Jul 13, 2007 2:13 am

Post » Mon Jun 18, 2012 5:07 am

Ah, could be that you would have to import the Math script. Try writing:

import Math

in the top of your script
User avatar
Rachie Stout
 
Posts: 3480
Joined: Sun Jun 25, 2006 2:19 pm

Post » Sun Jun 17, 2012 6:53 pm

beat to it :D
User avatar
Siobhan Wallis-McRobert
 
Posts: 3449
Joined: Fri Dec 08, 2006 4:09 pm

Post » Mon Jun 18, 2012 5:05 am

Importing math made everything work, it actually compiled this time.

The formula I'm using doesn't actually use math functions, though I'll need them in the future.

(((DaysPassed + ( TimeOfDay / 24 ) - 0.5) as int ) % 8 )

Should hopefully return the moon phases as numbers 0 thru 8
User avatar
Maria Leon
 
Posts: 3413
Joined: Tue Aug 14, 2007 12:39 am

Post » Sun Jun 17, 2012 7:18 pm

ah *facepalm* needs to be 1 thru 7.

On the plus side, the script is now compiling. On the minus, its not working, despite the fact that its attach to a stargame enabled quest.
User avatar
jason worrell
 
Posts: 3345
Joined: Sat May 19, 2007 12:26 am

Post » Sun Jun 17, 2012 11:59 pm

BTW I dont read the CK wiki but PlayerIsWerewolf would logicaly be a boolen (true/false) for me not a bit 0/1

int timeOfDay = TimeOfDayGlobalProperty.GetValueint()If (( TimeOfDay >= 20 || TimeOfDay <= 6 ) && cohPhaseDay == 0 )  cohCanTransform == trueelse  cohCanTransform == falseendifif ( PlayerIsWerewolf.GetValue() == 0 && cohCanTransform == true )  WerewolfChangeEffect.Cast(game.player(), game.player())  elseif ( game.getplayer().HasMagicEffect(WerewolfChangeEffect) == true && cohCanTransform == false )	game.getplayer().DispelSpell(WerewolfChangeEffect)  endifendif
User avatar
Nichola Haynes
 
Posts: 3457
Joined: Tue Aug 01, 2006 4:54 pm

Post » Mon Jun 18, 2012 2:40 am

Well, checking that global in console yields 1 or 0.
User avatar
Isaac Saetern
 
Posts: 3432
Joined: Mon Jun 25, 2007 6:46 pm

Next

Return to V - Skyrim