Jump to content

Script: Float * Integer = Kaboom


Recommended Posts

I have tried every permutation of this without success.

 

The formula:

  • Max Encumbrance = Strength * fActorStrengthEncumbranceMult

The problem: Strength is an int, and fActorStrengthEncumbranceMult is a float

int iStrength
float fMax

set iStrength to player.GatAV Strength  ; this is the ONLY instruction that works.
set fMax to player.GatAV Strength   ; This won't work.  and I have found no other way to convert that int to a float for the next instruction.
set fMax to iStrength * fActorStrengthEncumbranceMult    ; This won't work
set fMax to fActorStrengthEncumbranceMult * iStrength    ; This won't work

The above compiles in the CK, but it fails in-game. In fact the script won't run at all (not even the GameLoad stuff I have there). It looks like the game is failing to compile the script at runtime. The code above is only executed when a hotkey is pressed. This is different from other situations where the script crashes on or just fails to execute an instruction that violates some rule. I even tried converting the float to an int first, and nope.

 

It does the same thing regardless of how I try and code it. Nothing works.

 

I am stumped. This is the ONLY language I ever learned that has no rules (that I know of) of how to use mismatched types.

 

I also tried using the OBSE let command instead of set. Nope.

Edited by GamerRick
Link to comment
Share on other sites

In fact I never had a problem with this. Is this straight copy from your script? Because I see some errors in it:

1. GatAV > it should be GetAV

2. Where fActorStrengthEncumbranceMult comes from (it's not defined in example) and what value it has?

 

When I'm in doubt, I always insert print commands to see how calculation goes.

int iStrength
float fMax
float fActorStrengthEncumbranceMult
.......................................
set fActorStrengthEncumbranceMult to 5.1
set iStrength to player.GetAV Strength
set fMax to player.GetAV Strength
print "Player's strength is: "+$iStrength
print "fMax value before modification is: "+$fMax
print "Multiplicator is: "+$fActorStrengthEncumbranceMult
set fMax to iStrength * fActorStrengthEncumbranceMult
print "fMax modified: "+$fMax
.......................................

Link to comment
Share on other sites

You didn't answer my questions, but that link gave me a hint. Through experiments i found that problem is in accesing this setting (and others too). Oblivion knows them, they will compile (in my case) without errors, but as they aren't normal global or local variables, in running Oblivion the result is non-functional script. The type doesn't matter, be it float or integer. And it's not limited to set command, I can't even print them. I can't tell if it's a bug or it's made for purpose to not access them by scripting. And as I never needed to tinker with any settings I can't offer more help, except to define variable with same value.

 

I don't know about your working enviroment, but if you get error messages, I think there is additional problem within your script.

Link to comment
Share on other sites

OK, I figured it out. I was attempting to just use a Game Setting like a global (mental fart). Odd it compiles in the CS.

 

This works:

set iResult1 to player.GetAv Strength
set fTemp1 to GetGameSetting fActorStrengthEncumbranceMult
set fTemp1 to iResult1 * fTemp1

Now I have to deal with the fact that that doesn't even come close to a number that matches what my real current carry capacity is. FNV has a command that works perfectly for this. I was hoping Oblivion had one.

 

Thanks for trying tho!

 

Here is the code in FNV that works:

set iCarryLimit to player.getAV CarryWeight           ; Max carry weight
set iWeightAll to player.getAV InventoryWeight      ; Current carry weight
Edited by GamerRick
Link to comment
Share on other sites

I used float on a 386 without an FPU around 1990, by mistake, with Borland C++. Well that computer crashed hard within 0.00001 s when I ran that exe file in MS-DOS. :D I had to compile it on a Motorola Computer instead as Motorola had FPU inbuilt into all their CPU's and Intel did not. CPU with FPU -> 486dx and without, -> 486sx. So silly old memory... A 486sx was a failed 486dx as they did have issues making them in the factory but wanted to get them sold. The Float is calculated in the FPU. - This was just a silly old memory popping up. :D

 

Ints, well rather shorts and long as they are called in CS, is nothing else than a truncated float in both Oblivion and Skyrim. I bet it is so in Morrowind as well.

 

Where did the script fail? Did you get an offset from OBSE? It mostly write offset in console, well at least when we use LET but most likely not SET.

 

This line should work perfect:

float fMax

set fMax to player.GatAV Strength 

Well, I do see the problem really. :D You wrote Gatav with A instead of GetAV with E, so was that a typo in the forum or a typo inside CS? Did you mark, copy and paste from CS? Everything is floats.

 

CK is Construction Kit, CS is Construction Set... But I bet you know that :D Just a silly remark, nothing else really... They renamed it to CK as CK differ so much from CS.

Edited by Pellape
Link to comment
Share on other sites

Too late Pellape, he already found a problem :smile:. But Motorola with build-in FPU? If I recall correctly this was about at least 68040 non LC version. And in 1990? You worked with Macintosh Quadra or something similar?

Edited by RomanR
Link to comment
Share on other sites

I know he did find the answer, but I could not understand why it did fail in the first place, not until I found the typo and I base that answer on that int's are truncated floats in TES 3-5. I saw the typo first after I written half that no sense babble.... :D - I am Chaos, Mr Chaos. :D

 

Nope. It was a Atari ST based on 68000 but I did had a Atari XL before that and it is still on my desk here, and I think it has the 6504 but I am not sure really. I could look it up but I only have a Line Basic on it, not C. So the question is then, if the 68000 did not have am inbuilt FPU, how come it succeeded with floats? Did it have a separate FPU? I do not know but if we want to go deeper in that sump subject, I can look it up, just for nostalgic fun really, but it is not that important. We did try a Mac II in our studio 1992 as our bass player thought it was a better comp than the Atari. I almost threw both that comp and him out from the studio. That Apple comp only had half MIDI speed than the Atari had in its inbuilt MIDI interfase and it was 64Kbit if I recall right and the Mac II had 32Kbit transfer rate and I heard the difference as my synths did not keep up properly to the synctrack on our 13 channel tape recorder. Mac Quadra came around that period I think with a new type of CPU right that seemed nice and they did call it PowerPC if I am not wrong? I am not familiar with the Apple comps, only PC and Mac and some Sun computers with Sun Solaris and also some Linux back and forth. Well the thing is: I did hate that Mac II, a lot as it did cause more issues than my Atari did. He saw Atari as a kids cheap junk. Maybe he still does? Me ad him did not come along much really about anything what I can recall. Fastest bassplayer I played with though... :wink: Funk and slap player... That did not help much as he was a bloody pig :D

 

He did send 48V from our mixer to my sampler and it did cost me €450 to have it repaired as he burned the whole motherboard and he refused to admit he was the one that pushed that button. Just one of our many conflicts we had as I wanted him to pay for the damage he did cause. :D

 

Well this thread was about floats... Sorry... Not about someone pushing buttons he did not knew anything about... :wink:

Edited by Pellape
Link to comment
Share on other sites

Well, Atari ST and Amiga did their float computation purely by software. There was memory upgrades which contained socket for FPU too, but in beginning of nineties they cost a small fortune. Also with IC integration they fitted rather to Atari's or Commodore's more pro-lines, like Amiga 2000/3000 or MegaST/TT. So every programming language for these "home" versions had also built-in software libraries for float numbers. The affordable "turbocards" for Amiga were selling in second half of nineties (in my country), mostly containing 030, but in the end of nineties you could buy one with 040 or even 060 (for premium price of course). They were mostly for A1200 (as 500/600s were viewed as obsolete back then) and sometimes they were problems with heat, as they fitted into small trapdoor below and A1200 didn't have any cooling (not even a heatsink) and CPU on the turbocard often didn't had one either.

 

Damn nostalgia...we've got offtopic...

 

Edit: Atari ST line was good, but not for games. Tramiel didn't like games so for him the absence of blitter or using Yamaha PSG as sound-chip was "good solution". As STE came too late, this line ended in the sound studios (thanks to MIDI) or as cheap DTP (thanks to SM124 monitor - monochromatic, but with sharp picture and 70Hz as standard and programs like Calamus).

Edited by RomanR
Link to comment
Share on other sites

Are long's actually 8-bytes? I already know short and int are synonyms (they are both 4-bytes, or what I used to call a word (in my IBM 370 assembler days).

 

I just can't get CS versus CK straight in my head. However, CK = Creation Kit, I would guess to match their Creation Club on Steam.

 

I haven't learned scripting for Skyrim, beyond just modifying some variables in the scripts of mods I am using and getting then to compile in the CK. I spent the time it takes to learn the scripting language for Oblivion, FO3, and FNV. Looking at any Skyrim script just makes me feel like I gotta start from scratch and learn a new scripting language. One day in the not too distant future, I plan to start with taking tutorials on it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...