Spawning scene props

Users who are viewing this thread

La Grandmaster

Sergeant Knight at Arms
Im trying to figure out how to spawn a scene prop in a scene and I've been partially successful. Iv managed to get the scene prop to spawn right in front of the player perfectly - but the problem is i only want it to spawn once and at the moment it seems to spawn constantly

Iv got the following code in module_mission_templates
(iv commented in what i believe each line roughly does but im probably wrong so feel free to correct me if i am)

spawnscript = (
  0, 0, 0, [],
    [ (get_player_agent_no, ":player_agent"),      # gets position of player and stores it in player_agent?
            (agent_get_position, pos2, ":player_agent"),    # sets pos2 as player_agent position
            (position_move_y, pos2, 50),      # moves pos2 forward (i think) by a small amount
            (set_spawn_position, pos2),      #sets the place where the scene prop will spawn to pos2
            (spawn_scene_prop, "spr_feeding_trough_a"),      #spawns the scene prop
    ])
Note iv just used a feeding trough to test it - i dont actually plan on spawning this

Does anyone know how i could fix this, i realise its pretty basic but i cant figure out what to do  :???:
 
La Grandmaster said:
Spawnscript = (
  0, 0, ti_once, [],
    [ (get_player_agent_no, ":player_agent"),      # gets position of player and stores it in player_agent?
            (agent_get_position, pos2, ":player_agent"),    # sets pos2 as player_agent position
            (position_move_y, pos2, 50),      # moves pos2 forward (i think) by a small amount
            (set_spawn_position, pos2),      #sets the place where the scene prop will spawn to pos2
            (spawn_scene_prop, "spr_feeding_trough_a"),      #spawns the scene prop
    ])

[quote author=Caba`drin]
(These are the types of questions that are best in the stickied Q&A thread)
[/quote]
 
Then let's make the thread worth a discussion.

There are 2 kinds of triggers on MB modding :
1. Simple Triggers
2. Standard Triggers


1. Simple Triggers
( x,
[<execution block>]),

Simple triggers are widely  used on world map via module_simple_triggers. If x=0 then it will be triggered every frame. If x>0 then it will be triggered every x hours of gameplay time.
So if we want a trigger that fired once every day (gameplay time), then we should set x = 24. If we want to disable it in some condition, just make the execution block failed.
If x<0 then it's a defined game event trigger, like ti_simulate_battle (depreciated).
Triggers that fired by items and written into part of items on module_items.py use the same format as simple triggers, as scene props and icon maps have too, but they always have x<0 and there're only very limited options for x.


2. Standard Triggers
(x, y, z,
[<Conditions block>], [<Consequences block>]),

Standard Triggers are commonly used as mission triggers, just like what you wrote on OP. World map also support this kind of trigger via module_triggers.py.
x = check interval
y = delay interval
z = rearm interval

If x>=0, then it's timed triggers and the game will respect values of y and z, but if x<0 then it's defined game event trigger that neglect y and z. You can get the list of defined game event triggers at header_triggers.py.
So, after x time units , the game will run condition blocks. If it's not failed, then after y time units of delay, the game will execute Consequences block. Then the game will wait for z time unit before starting check interval for x time units to recycle the process. If  condition blocks 's failed then the game immediately starting x check interval.

Notes :
1. Time unit is seconds [real time] if it's a mission trigger, and hours [gameplay time] if it's a world map trigger.
2. There' re special condition  if z=ti_once. You can see on header_triggers :
ti_once        = 100000000.0
    With the rearm interval as long as it, simply we can say that the trigger will be only triggered once. 
    We will never play a WB's mission  for 100000000.0s = 3 years (real time), don't we?
3. Local variables of condition blocks aren't passed to Consequences block.
    If you need to pass  something between, use global variables.
 
You're right. But if we're talking about really real time timed trigger, even timers are roughly.
(0, 0, 0,
[(store_mission_timer_a_msec, ":now"),
  (ge, ":now", 1000),
  (reset_mission_timer_a),
<timed event code every 1s> ], []),

It's still FPS depended.
 
For me, I remember putting 0.2 or something and having the results ridiculously off :smile:. So ya, I suggest using your second method for things less than 1 second and has to be time-dependent.

Sorry for the extremely tangential posts  :oops:.
 
No need to sorry. I wrote my post for newbies, hoping it will be useful for them, and your post enrich it with some practical issues.

I never mods for Multiplayer, may be that's why I never see the need of high accuracy time trigger. In fact, I demand for  little more variance about how long a trigger rearmed. I use a 0.1 s trigger to do looping for all agents, to make them check if they have valid targets so they will perform one of 3 special attack moves : shield bashing, pike bracing and flying daggers, depend on the weapon/shield they equip. I should use an agent slot so all agents have their own rearming trigger and some randomizing check so we don't always see 200 AI agents perform shieldbashing at the very same time :smile:.
 
Back
Top Bottom