Re: Creating a World - Building and maintaining unique Buildings
Nice one.
needed to cater for the cancellation of the building (removal from queue cannot be tested for directly)
Which you have done via a cooldown period of three turns, yes? This bit...
Code:
if I_EventCounter corn_exchange_queued > 3 ; the building should have been finished (building turns plus one)
set_event_counter build_corn_exchange 1 ; enable EDB event counter
inc_event_counter corn_exchange_queued 0 ; reset queue counter
end_if
I think you meant "set_event_counter corn_exchange_queued 0" there.
If the settlement is under siege while the building is under construction then it would take longer for it to be built. The counter might 'time out' and allow construction elsewhere, meanwhile the original could still be eventually finished once the siege ends. Also, it might be added to an already-busy queue, so there's no telling how long it will take to finish construction and meanwhile another one might be allowed to start. Or would it drop from the queue when the event counter becomes 0?
Re: Creating a World - Building and maintaining unique Buildings
I think you meant "set_event_counter corn_exchange_queued 0" there.
That was a silly copy\paste error. Fixed it now.
A building will not drop from a queue unless done so physically by the player. It might never finish if the building counter is disabled, which would be the case in your scenarios as the existence of the building sets to the counter to false.
Meaning if you are able to add another building to a queue somewhere else you pretty much shot yourself in the foot as you will not be able to finish the second one unless you destroy the first. Which I think will scrambled the script somewhat and is rather pointless, removing the second building from the queue will refund building costs and allow the queue in that settlement to progress again.
So, in the end you will still only have one building, regardless how many you may be able to queue at one time.
; Re-enable the event counter, if this isn't done the building will never complete.
monitor_event ButtonPressed ButtonPressed end_turn
if not I_IsFactionAIControlled england
set_event_counter build_corn_exchange 1 ; enabling EDB event counter
end_if
end_monitor
; Disable the event counter again if building is queued to prevent more buildings being added
monitor_event FactionTurnEnd FactionType england
and not FactionBuildingExists = corn_exchange ; building does not exist in faction
if I_IsFactionAIControlled england ; terminate if faction is AI controlled
terminate_monitor
end_if
if I_EventCounter corn_exchange_queued > 0 ; the building has been queued
set_event_counter build_corn_exchange 0 ; disable EDB event counter
inc_event_counter corn_exchange_queued 1 ; increasing the queue counter
end_if
if I_EventCounter corn_exchange_queued > 3 ; the building should have been finished (building turns plus one)
set_event_counter build_corn_exchange 1 ; enable EDB event counter
set_event_counter corn_exchange_queued 0 ; reset queue counter
end_if
end_monitor
Last edited by Gigantus; November 20, 2015 at 05:49 AM.
Re: Creating a World - Building and maintaining unique Buildings
The code for adding a message would be like this, entries in the box brackets are variables. The faction section for the message will restrict the message to the faction(s) listed - you can omit it if the message is for all factions.