Jump to content


Photo

is anything wrong with this code?


5 replies to this topic

#1 Nirran

Nirran
  • Member
  • 17 posts

Posted 06 December 2016 - 06:10 AM

trying to add random spells scrolls dependant on cre level,seems this code is faulty

 

READ_BYTE 0x234 "class1"
         READ_BYTE 0x235 "class2"
         READ_BYTE 0x236 "class3"
         READ_BYTE 0x273 "class_id"
         PATCH_IF (("%class_id%" = 4) OR ("%class_id%" = 5) OR ("%class_id%" = 1) OR ("%class_id%" = 19) OR ("%class_id%" = 3) OR ("%class_id%" = 11) OR ("%class_id%" = 20) OR ("%class_id%" = 2) OR ("%class_id%" = 6) OR ("%class_id%" = 12)) BEGIN    
            SET "level" = "%class1%"     
         END ELSE PATCH_IF (("%class_id%" = 18) OR ("%class_id%" = 16) OR ("%class_id%" = 14) OR ("%class_id%" = 15) OR ("%class_id%" = 13) OR ("%class_id%" = 8) OR ("%class_id%" = 7) OR ("%class_id%" = 9)) BEGIN      
            SET "level" = "%class1%" + "%class2%"          
         END ELSE PATCH_IF (("%class_id%" = 17) OR ("%class_id%" = 10)) BEGIN      
            SET "level" = "%class1%" + "%class2%" + "%class3%"    
         END ELSE BEGIN     
            SET "level" = "%class1%"   
         END

 

help appreciated

 

 



#2 Argent77

Argent77
  • Member
  • 809 posts

Posted 06 December 2016 - 06:41 AM

When checking so many values it is easier to use the MATCH construct in place of chained IF statements.

READ_BYTE 0x234 class1
READ_BYTE 0x235 class2
READ_BYTE 0x236 class3
READ_BYTE 0x273 class_id
PATCH_MATCH class_id
WITH
  4 5 1 19 3 11 20 2 6 12
  BEGIN
    SET level = class1
  END
  18 16 14 15 13 8 7 9
  BEGIN
    SET level = class1 + class2
  END
  17 10
  BEGIN
    SET level = class1 + class2 + class3
  END
  DEFAULT
    SET level = class1
END

 

Btw, numeric values don't have to be enclosed into quotes or percentage signs. This is only required for string values.



#3 Nirran

Nirran
  • Member
  • 17 posts

Posted 06 December 2016 - 06:48 AM

Thanks,big help


Edited by Nirran, 06 December 2016 - 07:45 AM.


#4 Nirran

Nirran
  • Member
  • 17 posts

Posted 06 December 2016 - 07:46 AM

Not that there you code is better?or just tidy it?



#5 agb1

agb1
  • Member
  • 1623 posts

Posted 06 December 2016 - 07:58 AM

According to IESDP, the class level offsets are:

 

0x0234 1 (byte) Highest attained level in class (0-100). For dual/multi class characters, the levels for each class are split between 0x0234, 0x0235 and 0x0236 according to the internal class name, i.e. for a FIGHTER_THIEF 0x0234 will hold the fighter level, 0x0235 will hold the thief level and 0x0236 will be 0.
0x0235 1 (byte) Highest attained level in class (0-100)
0x0236 1 (byte) Highest attained level in class (0-100)
 
The class id offset is:
 
0x0273 1 (byte) Class (CLASS.IDS)
 
Personally, I would not worry about dual/multi and just use 0x0234 (highest attained level in the first class or true class if not dual/multi) for the level decision.

Edited by agb1, 06 December 2016 - 07:59 AM.

BiG World Fixpack (community collection of mod fixes and compatibility patches, with user-friendly cross-platform script)

 

BiG World Setup (tool to automate best-practice installation of Infinity Engine mods on Windows, with conflict analysis)

Latest version:    https://bitbucket.or.../get/master.zip


#6 Nirran

Nirran
  • Member
  • 17 posts

Posted 06 December 2016 - 08:15 AM

Alright ty need to fight with the rest of the script





Reply to this topic