Post new topic    
Liquid Metal Slime
Send private message
Is there a more efficient way to run this script? 
 PostWed Dec 06, 2017 4:10 am
Send private message Reply with quote
This is my current class change code:

Code:
plotscript, update spell list, begin

    # Lead Character, Jack of All Trades
    if (check equipment (0, slot:class) == item:JackAll) then (
      write spell (0, 0, 0, atk:First Aid)
      write spell (0, 0, 1, atk:Haste)
      write spell (0, 0, 2, atk:Jump)
    )
   

    # Lead Character, Warrior
    if (check equipment (0, slot:class) == item:Warrior) then (
      write spell (0, 0, 0, atk:Chuck)
      write spell (0, 0, 1, atk:Berserk)
      write spell (0, 0, 2, atk:Defend)
    )
   

    # Lead Character, Pirate
    if (check equipment (0, slot:class) == item:Pirate) then (
      write spell (0, 0, 0, atk:Lookout)
      write spell (0, 0, 1, atk:Seasick)
      write spell (0, 0, 2, atk:Rum)
    )
   

    # Lead Character, Rogue
    if (check equipment (0, slot:class) == item:Rogue) then (
      write spell (0, 0, 0, atk:Pilfer)
      write spell (0, 0, 1, atk:Throw)
      write spell (0, 0, 2, atk:Backstab)
    )
   

    # Lead Character, Ranger
    if (check equipment (0, slot:class) == item:Ranger) then (
      write spell (0, 0, 0, atk:Snipe)
      write spell (0, 0, 1, atk:Cure)
      write spell (0, 0, 2, atk:Camoflage)
    )
   

    # Lead Character, Ninja
    if (check equipment (0, slot:class) == item:Ninja) then (
      write spell (0, 0, 0, atk:Throw)
      write spell (0, 0, 1, atk:Doku)
      write spell (0, 0, 2, atk:Vanish)
    )
   

    # Lead Character, Crusader
    if (check equipment (0, slot:class) == item:Crusade) then (
      write spell (0, 0, 0, atk:Life)
      write spell (0, 0, 1, atk:Disrupt)
      write spell (0, 0, 2, atk:HaveFaith)
    )
   

    # Lead Character, Wizard
    if (check equipment (0, slot:class) == item:Wizard) then (
      write spell (0, 0, 0, atk:Fireball)
      write spell (0, 0, 1, atk:Lightning)
      write spell (0, 0, 2, atk:Sleep)
    )
   

    # Lead Character, Martial Artist
    if (check equipment (0, slot:class) == item:Martial) then (
      write spell (0, 0, 0, atk:Surge Fist) #HADOUKEN
      write spell (0, 0, 1, atk:Hurricane) #TATSUMAKISENPUKYAKU
      write spell (0, 0, 2, atk:Drgn Punch) #SHORYUKEN
    )
   

    # Lead Character, Placeholder Class
    if (check equipment (0, slot:class) == 39) then (
      write spell (0, 0, 0, atk:First)
      write spell (0, 0, 1, atk:Second)
      write spell (0, 0, 2, atk:Third)
    )
   

   #Now it starts with the second character in the party
    # Second Character, Jack of All Trades
    if (check equipment (1, slot:class) == item:JackAll) then (
      write spell (1, 0, 0, atk:First Aid)
      write spell (1, 0, 1, atk:Haste)
      write spell (1, 0, 2, atk:Jump)
    )
   

    # Second Character, Warrior
    if (check equipment (1, slot:class) == item:Warrior) then (
      write spell (1, 0, 0, atk:Chuck)
      write spell (1, 0, 1, atk:Berserk)
      write spell (1, 0, 2, atk:Defend)
    )
   

    # Second Character, Pirate
    if (check equipment (1, slot:class) == item:Pirate) then (
      write spell (1, 0, 0, atk:Lookout)
      write spell (1, 0, 1, atk:Seasick)
      write spell (1, 0, 2, atk:Rum)
    )
   

    # Second Character, Rogue
    if (check equipment (1, slot:class) == item:Rogue) then (
      write spell (1, 0, 0, atk:Pilfer)
      write spell (1, 0, 1, atk:Throw)
      write spell (1, 0, 2, atk:Backstab)
    )
   

    # Second Character, Ranger
    if (check equipment (1, slot:class) == item:Ranger) then (
      write spell (1, 0, 0, atk:Snipe)
      write spell (1, 0, 1, atk:Cure)
      write spell (1, 0, 2, atk:Camoflage)
    )
   

    # Second Character, Ninja
    if (check equipment (1, slot:class) == item:Ninja) then (
      write spell (1, 0, 0, atk:Throw)
      write spell (1, 0, 1, atk:Doku)
      write spell (1, 0, 2, atk:Vanish)
    )
   

    # Second Character, Crusader
    if (check equipment (1, slot:class) == item:Crusade) then (
      write spell (1, 0, 0, atk:Life)
      write spell (1, 0, 1, atk:Disrupt)
      write spell (1, 0, 2, atk:HaveFaith)
    )
   

    # Second Character, Wizard
    if (check equipment (1, slot:class) == item:Wizard) then (
      write spell (1, 0, 0, atk:Fireball)
      write spell (1, 0, 1, atk:Lightning)
      write spell (1, 0, 2, atk:Sleep)
    )
   

    # Second Character, Martial Artist
    if (check equipment (1, slot:class) == item:Martial) then (
      write spell (1, 0, 0, atk:Surge Fist) #HADOUKEN
      write spell (1, 0, 1, atk:Hurricane) #TATSUMAKISENPUKYAKU
      write spell (1, 0, 2, atk:Drgn Punch) #SHORYUKEN
    )
   

    # Second Character, Placeholder Class
    if (check equipment (1, slot:class) == 39) then (
      write spell (1, 0, 0, atk:First)
      write spell (1, 0, 1, atk:Second)
      write spell (1, 0, 2, atk:Third)
    )
 


   #Now it does it for the third character
    # Third Character, Jack of All Trades
    if (check equipment (2, slot:class) == item:JackAll) then (
      write spell (2, 0, 0, atk:First Aid)
      write spell (2, 0, 1, atk:Haste)
      write spell (2, 0, 2, atk:Jump)
    )
   

    # Third Character, Warrior
    if (check equipment (2, slot:class) == item:Warrior) then (
      write spell (2, 0, 0, atk:Chuck)
      write spell (2, 0, 1, atk:Berserk)
      write spell (2, 0, 2, atk:Defend)
    )
   

    # Third Character, Pirate
    if (check equipment (2, slot:class) == item:Pirate) then (
      write spell (2, 0, 0, atk:Lookout)
      write spell (2, 0, 1, atk:Seasick)
      write spell (2, 0, 2, atk:Rum)
    )
   

    # Third Character, Rogue
    if (check equipment (2, slot:class) == item:Rogue) then (
      write spell (2, 0, 0, atk:Pilfer)
      write spell (2, 0, 1, atk:Throw)
      write spell (2, 0, 2, atk:Backstab)
    )
   

    # Third Character, Ranger
    if (check equipment (2, slot:class) == item:Ranger) then (
      write spell (2, 0, 0, atk:Snipe)
      write spell (2, 0, 1, atk:Cure)
      write spell (2, 0, 2, atk:Camoflage)
    )
   

    # Third Character, Ninja
    if (check equipment (2, slot:class) == item:Ninja) then (
      write spell (2, 0, 0, atk:Throw)
      write spell (2, 0, 1, atk:Doku)
      write spell (2, 0, 2, atk:Vanish)
    )
   

    # Third Character, Crusader
    if (check equipment (2, slot:class) == item:Crusade) then (
      write spell (2, 0, 0, atk:Life)
      write spell (2, 0, 1, atk:Disrupt)
      write spell (2, 0, 2, atk:HaveFaith)
    )
   

    # Third Character, Wizard
    if (check equipment (2, slot:class) == item:Wizard) then (
      write spell (2, 0, 0, atk:Fireball)
      write spell (2, 0, 1, atk:Lightning)
      write spell (2, 0, 2, atk:Sleep)
    )
   

    # Third Character, Martial Artist
    if (check equipment (2, slot:class) == item:Martial) then (
      write spell (2, 0, 0, atk:Surge Fist) #HADOUKEN
      write spell (2, 0, 1, atk:Hurricane) #TATSUMAKISENPUKYAKU
      write spell (2, 0, 2, atk:Drgn Punch) #SHORYUKEN
    )
   

    # Third Character, Placeholder Class
    if (check equipment (2, slot:class) == 39) then (
      write spell (2, 0, 0, atk:First)
      write spell (2, 0, 1, atk:Second)
      write spell (2, 0, 2, atk:Third)
    )
 


   #And here's where it begins for the fourth character slot.
    # Caboose, Jack of All Trades
    if (check equipment (3, slot:class) == item:JackAll) then (
      write spell (3, 0, 0, atk:First Aid)
      write spell (3, 0, 1, atk:Haste)
      write spell (3, 0, 2, atk:Jump)
    )
   

    # Caboose, Warrior
    if (check equipment (3, slot:class) == item:Warrior) then (
      write spell (3, 0, 0, atk:Chuck)
      write spell (3, 0, 1, atk:Berserk)
      write spell (3, 0, 2, atk:Defend)
    )
   

    # Caboose, Pirate
    if (check equipment (3, slot:class) == item:Pirate) then (
      write spell (3, 0, 0, atk:Lookout)
      write spell (3, 0, 1, atk:Seasick)
      write spell (3, 0, 2, atk:Rum)
    )
   

    # Caboose, Rogue
    if (check equipment (3, slot:class) == item:Rogue) then (
      write spell (3, 0, 0, atk:Pilfer)
      write spell (3, 0, 1, atk:Throw)
      write spell (3, 0, 2, atk:Backstab)
    )
   

    # Caboose, Ranger
    if (check equipment (3, slot:class) == item:Ranger) then (
      write spell (3, 0, 0, atk:Snipe)
      write spell (3, 0, 1, atk:Cure)
      write spell (3, 0, 2, atk:Camoflage)
    )
   

    # Caboose, Ninja
    if (check equipment (3, slot:class) == item:Ninja) then (
      write spell (3, 0, 0, atk:Throw)
      write spell (3, 0, 1, atk:Doku)
      write spell (3, 0, 2, atk:Vanish)
    )
   

    # Caboose, Crusader
    if (check equipment (3, slot:class) == item:Crusade) then (
      write spell (3, 0, 0, atk:Life)
      write spell (3, 0, 1, atk:Disrupt)
      write spell (3, 0, 2, atk:HaveFaith)
    )
 

    # Caboose, Wizard
    if (check equipment (3, slot:class) == item:Wizard) then (
      write spell (3, 0, 0, atk:Fireball)
      write spell (3, 0, 1, atk:Lightning)
      write spell (3, 0, 2, atk:Sleep)
    )
   

    # Caboose, Martial Artist
    if (check equipment (3, slot:class) == item:Martial) then (
      write spell (3, 0, 0, atk:Surge Fist) #HADOUKEN
      write spell (3, 0, 1, atk:Hurricane) #TATSUMAKISENPUKYAKU
      write spell (3, 0, 2, atk:Drgn Punch) #SHORYUKEN
    )
   

    # Caboose, Placeholder Class
    if (check equipment (3, slot:class) == 39) then (
      write spell (3, 0, 0, atk:First)
      write spell (3, 0, 1, atk:Second)
      write spell (3, 0, 2, atk:Third)
    )
 

end


So far, it works really smoothly as the autorun script on all maps; I just can't escape the feeling that I'm doing things in the most brute-force manner possible, and if I decide to add a few more classes beyond the basic ten then it might start getting annoying to add their functions to the script.
Remeber: God made you special and he loves you very much. Bye!
Metal Slime
Send private message
 
 PostWed Dec 06, 2017 4:49 am
Send private message Reply with quote
OK, I'm not going to do the entire thing, but I'll do the first two iterations for the sake of example:

Code:
switch (check equipment (hero, slot:class)) do (
   # Lead Character, Jack of All Trades
   case (item:JackAll) do (
      write spell (0, 0, 0, atk:First Aid)
      write spell (0, 0, 1, atk:Haste)
      write spell (0, 0, 2, atk:Jump)
   )
   # Lead Character, Warrior
   case (item:Warrior) do (
      write spell (0, 0, 0, atk:Chuck)
      write spell (0, 0, 1, atk:Berserk)
      write spell (0, 0, 2, atk:Defend)
   )
   #etc.
   #etc.
)


EDIT: Working on a more elegant solution, I didn't read the entire thing very closely at first.
Metal Slime
Send private message
 
 PostWed Dec 06, 2017 4:55 am
Send private message Reply with quote
Code:
plotscript, update spell list, begin
   variable (h)
   
   for (h, 0, 3) do (
      switch (check equipment (h, slot:class)) do (
         # Lead Character, Jack of All Trades
         case (item:JackAll) do (
            write spell (h, 0, 0, atk:First Aid)
            write spell (h, 0, 1, atk:Haste)
            write spell (h, 0, 2, atk:Jump)
         )
         # Lead Character, Warrior
         case (item:Warrior) do (
            write spell (h, 0, 0, atk:Chuck)
            write spell (h, 0, 1, atk:Berserk)
            write spell (h, 0, 2, atk:Defend)
         )
         #etc.
         #etc.
      )
   )
end
Metal King Slime
Send private message
 
 PostWed Dec 06, 2017 7:04 am
Send private message Reply with quote
Autorun script? Do you mean each-step? You may also want to set this as the on-close script for the main menu (although that won't run if you use the Equip option in a shop)
(And in Etheldreme there are now global map script triggers, no need to set the same script on every map)
Display posts from previous: