Scene Slots and Variables

Users who are viewing this thread

Hello, I'm trying to create a list of conditions relating to scenes.

For instance check if a town is under siege, has a tournament or a feast.
I know I have to use slots to achieve these condition checks and I wanted to make sure my understanding is correct.
The idea is to have certain conditions for my agent spawning scene prop OSP that I'm working on.

So for example I want extra people watching at the arena during a tournament so I'd use the following operations

(store_current_scene,<destination>),

(scene_slot_eq,<scene_id>,<slot_no>,<value>),

and checking module constants I found

slot_town_has_tournament  = 156

So the code should look like

(store_current_scene,":Scene"),

(scene_slot_eq,":Scene",156,1),

where am I going wrong here? to me it reads does current scene have a tournament 1= Yes 0= No, if Yes it passes and the rest of the code continues.

Any help with this would be great.

So far I have got time of day conditions working, example extra people in the tavern at night and more civillians in town during the day.
 
slot_town_has_tournament is in party slots section. So it only applies to parties.

Use:
Code:
(party_slot_eq, "$current_town", slot_town_has_tournament, 1),
 
Thank you so much Lav that script works perfectly and in my enthusiasm I created an example what this could be useful for.



FWDcDaw.jpg

Cbf8dz5.jpg


Extra crowds at the arena


9z69k4B.jpg


Some town Ladies admire the red teams Champion Fighter. (bodyguard on duty)

wQNnhpt.jpg


Some Blue team members checking out Sargoths wares.

4miZW7s.jpg


Green team fans meet up before the tournament

wXmpFC2.jpg


Waiting to get in the Arena, extra guards on duty for the event.

0RHkDkS.jpg


What it looks like in scene edit mode without the tournament on.



Just to clarify everything is done with a single scene prop, no extra scripting or modifying has been done, just placing the Spawn Agent scene prop and tweaking the modifiers (Scale X, Scale Y, Var 1, Var 2)

Also is there a list of commands like "$current_town" somewhere? I thought I'd have to do a few steps to find the town then assign it to a variable to plug into the script.
 
Ah thank you very much.

I hope checking other conditions are similar?

I haven't properly had a look yet but I also want conditions for
Feasts: only appears during a feast (extra castle guards, musicians during the feast, servants)
Siege: Only when castle/town is under siege (possible also village under raid, lots of extra soldiers in the streets and on the castle walls, more labourers preparing for the worst)
Battle Only: Only appear if a battle is on, (eg, Siege soldiers wouldn't meet this requirement and therefore not appear during the actual siege battle so it wouldn't unbalance fighting in the streets)

and possibly conditions for high and low wealth/prosperity so a poor village could have beggars and not many workers but a wealthy village would have lots of farmers in the field and merchants/richly clothed villagers.



 
Most of what you mentioned is governed by various party slots, yes.

For battles, check script "script_game_event_party_encounter" - it is executed every time player encounters a party on the map (including centers). If the town is in battle (i.e. an active assault is going on), the global variable "$g_encountered_party_2" will be set to a non-negative value which you can check for in your scripts.

Of course this will only be necessary for a player neutral to the battle in question - if player is not neutral and is participating in the siege, he will be using a completely different set of mission templates, making detection of siege status a moot point.
 
Yeah I thought the Battle might be hard to have as a condition, is it possible that I could check mission templates or something similar as to what template is currently being used?

Also I've had a poke around constants and can't find anything related to feasts or Siege for party slots, I'm probably missing something simple however.

Sorry to ask so many questions but I think this will be a pretty great tool once finished but I'm lacking in the scripting department at the moment.
 
ShaunRemo said:
Yeah I thought the Battle might be hard to have as a condition, is it possible that I could check mission templates or something similar as to what template is currently being used?
Erm... your code works by being embedded into mission templates. Why detect what mission template is active when you know precisely what mission template you're embedding your code into? :smile:

ShaunRemo said:
Also I've had a poke around constants and can't find anything related to feasts or Siege for party slots, I'm probably missing something simple however.
Party slot slot_center_is_besieged_by is set to besieging party id, or to -1 when there's no siege.
 
All my code so far is in the scene_props.txt file and runs when the Spawn_Agent Scene prop is used, I thought this would be best as it is the least conflicting way to add the OSP to other mods, AH thank you, I saw that code but didn't think it'd help considering it would just return the faction of the attacker but if I use it like this

(party_slot_ge,"$current_town",slot_center_is_besieged_by,0),

it will pass during a siege by anyone, thank you again.
Also if I use this code

(faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),

wouldn't  it pass in multiple in locations, so the Rhodoks are having a feast at Jalkala, the condition would show the Rhodoks are having a feast, but wouldn't the condition still be true if I was at another town which isn't having a feast?
 
The current faction feast object can be found through the following
Code:
	  (faction_slot_eq, ":faction_no", slot_faction_ai_state, sfai_feast),
	  (faction_get_slot, ":faction_object", ":faction_no", slot_faction_ai_object),
Otherwise tournaments can be found through checking slot_town_has_tournament. Note that this slot is actually in a countdown mode - feasts automatically refresh this countdown to 2 whenever it is still in effect.
 
Late reply, thank you Somebody

I used the code like this and it works perfectly.

          (store_faction_of_party, ":center_faction", "$current_town"),
          (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
          (faction_get_slot, ":feast", ":center_faction", slot_faction_ai_object),
          (eq,":feast","$current_town"),


 
Hello, just a question without starting a new thread,

Can I create a loop somehow for conditions?

something like

(try_begin),
            (eq,":End Loop",10),
            (Go_To_End)
(else_try),
          (val_add,":End Loop",1),
          (Go_To_Begin)
(try_end),


That way the loop is repeated until a certain condition is met,

Anyway to do this?
 
Code:
(assign, ":end", 10),
(try_for_range, ":value", 0, ":end"),
   ...
   (assign, ":end", 0),
(else_try),
   (lt, ":end", 100),#it's better to add a limit, else you may cause some serious issues if for some reason the above block always fail
   (val_add, ":end", 1),
(try_end),
 
So if I understand correctly,

(try_for_range,<destination>,<lower_bound>,<upper_bound>),

The <destination> starts at the <lower_bound> and every loop the <destination> increases by 1 until it reaches the <upper_bound> where the loop stops?

So if I wanted the loop to fire 10 times (for no reason) but stop if it reaches 8  I would have something like this.

(assign, "Upper_Bound", 10),
(try_for_range, ":destination", 0, "Upper_Bound"),
        (eq,":destination",:cool:,
        (assign, "Upper_Bound", 9),     
(try_end),

So "destination" keeps adding 1 until it reaches 8 at which point it changes "Upper_Bound" to 9, destination adds 1 and therefore = 9 completing the loop early?



 
Ok, it makes sense in my head but I can't seem to get it to work.
I have 2 variables that I want to check if they pass the same conditions, so far it's setup like this.

(assign,":conditions",0),
(try_for_range,":loops",0,2), # Loop fires twice
          (eq,":var_1",0),
          (val_add,":conditions",1),  # Always True
  (else_try),
          (eq,":var_1",1),
          (is_currently_night),
          (val_add,":conditions",1),
  (else_try),
          (eq,":var_1",2),
          (is_between,":time_of_day",12,24), # Is it between noon and midnight
          (val_add,":conditions",1),
  (else_try),
          (eq,":conditions",0),    # First condition not met.
          (assign,":loops",10),    # Stop loop.
  (else_try),
          (eq,":conditions",1),    # First condition met.
          (assign,":var_1",":var_2"), # Change conditions variable for second loop.
  (try_end),
          (eq,":conditions",2),    # Both Variables passed conditions, continue with script.

So if Var_1 = 0 and Var_2 = 1, it must be night to pass.

But if Var_1 = 1 and Var_2 = 2, it must be night and before midnight  to pass.

But so far it doesn't seem to work properly, not sure where I'm going wrong.
 
Think you need multiple loops, one loop for each condition you want to test. because the script will only run, until one of it's (else_try) conditions does not fail. So your later (else_try)'s are never getting called.

Example:
If the following (eq, ":var_1", 0), is always true, the try_for_range operation will stop the current iteration after (val_add, ...) and go to the next iteration. Doesn't matter, if you run it a million times. You will never get past this block:
          (eq,":var_1",0),
          (val_add,":conditions",1),  # Btw. this is not an condition, it cannot be true or wrong!


Also try to follow Ikagua's post. In order to break a loop, you need to use this:
(assign,":end",2),
(try_for_range,":loops",0,":end"), # Loop fires twice

...
(else_try),
(eq,":conditions",0),
(assign, ":end", 0), #end the loop

If you assign a value to ":loop", it does nothing, as ":loop" gets overwritten by each new iteration.
 
So if at any point it successfully completes  an (else_try), it stops and starts again? therefore never swapping var_2 and only checking the same condition twice?

So if I changed the order a little.

(assign,":conditions",0),
(try_for_range,":loops",0,3), # Loop fires three time.
          (eq,":conditions",1),    # will fail first loop, will pass on second loop, and go to third loop.
          (assign,":var_1",":var_2"), # Change conditions variable for third loop.
          (val_add,":conditions",1), # Adds 1 so it fails third loop and checks second condition.
  (else_try),
          (eq,":var_1",0),
          (val_add,":conditions",1),  # Always True
  (else_try),
          (eq,":var_1",1),
          (is_currently_night),
          (val_add,":conditions",1),
  (else_try),
          (eq,":var_1",2),
          (is_between,":time_of_day",12,24), # Is it between noon and midnight
          (val_add,":conditions",1),
  (else_try),
          (eq,":conditions",0),    # First condition not met.
          (assign,":loops",10),    # Stop loop.
  (try_end),
          (eq,":conditions",3),    # Both Variables passed conditions, continue with script.


So now it loops 3 times, First loop checks var_1 passes, Second loop checks var_1 passed and swaps var_1 with Var_2, Third loop checks Var_2 passes.
Anything I'm missing? I will check soon anyway and see what happens.
 
Back
Top Bottom