Posts: 51
Threads: 2
Joined: Jul 2019
I did read somewhere that IF statements slow down programs on modern processors. The reason is that modern processors pre-load the code that is to be executed, and if there is an IF statement, it can't continue preloading until the IF statement is resolved.
But sometimes, assuming the language supports it, you can get around that IF statement. For example:
suppose you have an array: A(1) to A(100) filled with numbers, and you want to count how many of these numbers are bigger than 16
MyCounter = 0
loop x from 1 to 100
if A(x) > 16
then MyCounter = MyCounter + 1
end loop
You can rewrite it to:
MyCounter = 0
loop x from 1 to 100
MyCounter = MyCounter + (A(x) > 16)
end loop
The condition (A(x) > 16) resolves to True or False, which is 1 or 0.
If True, it adds 1 to MyCounter, if False it adds 0 to MyCounter.
The advantage is that the code doesn't contain an IF statement, so the whole loop can be pre-loaded into the processor for faster execution.
Maybe worth a try. Assuming the language supports such coding tricks, of course.
August 15th, 2024, 14:56
(This post was last modified: August 15th, 2024, 14:58 by Seravy.)
Posts: 10,463
Threads: 394
Joined: Aug 2015
Yes, as far as I remember, "True" is 1 and "False" is 0 and they count as numeric values.
The speed of the IF depends on two factors :
-How far the THEN {} and ELSE {} parts are from each other (it's effectively a read but skip processing code until either ELSE shows up or the THEN block ends)
-How long it takes to evaluate the THEN condition
In general I would advise using multiple IFs whenever the condition is time consuming to calculate and this can be skipped often by the first half being false, and using one IF whenever the conditions are relatively simple to calculate but the Then {} block is very long.
A better general purpose solution might be to replace everything in the THEN {} block by a CALL if it's a large amount of code.
Posts: 1,004
Threads: 13
Joined: Nov 2020
(August 15th, 2024, 14:56)ธ่Seravy Wrote: Yes, as far as I remember, "True" is 1 and "False" is 0 and they count as numeric values.
The speed of the IF depends on two factors :
-How far the THEN {} and ELSE {} parts are from each other (it's effectively a read but skip processing code until either ELSE shows up or the THEN block ends)
-How long it takes to evaluate the THEN condition
In general I would advise using multiple IFs whenever the condition is time consuming to calculate and this can be skipped often by the first half being false, and using one IF whenever the conditions are relatively simple to calculate but the Then {} block is very long.
A better general purpose solution might be to replace everything in the THEN {} block by a CALL if it's a large amount of code.
Thank you.
August 16th, 2024, 02:40
(This post was last modified: August 16th, 2024, 02:48 by mewcatus.)
Posts: 62
Threads: 3
Joined: May 2022
Hi Seravy,
I really liked that new spell you put in for Chaos, but I am unable to replicate it myself as Wall Crusher as an ability is not present in the MASTER.CAS for modding. I also do not want to give up on the Basic Disrupt Spell, yet I do not want to increase the number of Spells I have put in as there I just nicely balanced out the numbers for the 5 Non Arcane Realms. (Will have to sacrifice 1 of my old spells or shift it to neutral if possible).
Could you put in Wall Crusher as an ability I can access for Scripts in the next version?
Also the new Spell 'Breakthrough' has not been assigned as a variable in MASTER.CAS under the Combat global enchantment IDs. I tried to assign it myself, thinking it would autogenerate, but 'CGBreakthrough' is not recognized as a variable yet.
That being said, I did put in a slight modification for the Disrupt Spell, I wanted to keep its niche purpose, yet make it a worthy Spell to research. Below is what I come up with.
Basically, Disrupt is now useful to any city attacker, providing them a decent boost to their defense and resistances from the start of combat until the end of the attackers 1st active combat turn. This is useful vs Ranged Defenders to at least help any weaker Attacker units to survive the 1st volley of Spells/Missile Attacks. Yet this is only useful in a City Attack situation, which perfectly aligns with the theme of 'Disrupt', being useful in a city siege. This Spell working as a Passive makes it worthwhile as you do not need to cast it for it to provide this small yet significant boost.
Posts: 10,463
Threads: 394
Joined: Aug 2015
Uploaded 1.5.7.
I've also enabled range checking specifically only for script commands that write game data for compiling this one.
Posts: 1,004
Threads: 13
Joined: Nov 2020
October 20th, 2024, 12:35
Posts: 127
Threads: 16
Joined: Apr 2021
How do we update from the latest 1.5.2 (from Steam) to the current 1.5.7 directly?
October 20th, 2024, 19:26
Posts: 736
Threads: 50
Joined: Jul 2020
You download and extract the relevant patch to your game folder file. All of the patches are linked in the first post.
November 5th, 2024, 10:39
Posts: 127
Threads: 16
Joined: Apr 2021
When I download the patch, I am not sure whether the files need to be overwritten in the main folder, or in the sub-folder "data".
There seems to be some of the same files in both folders.
Can anyone clarify?
Thanks!
November 5th, 2024, 22:26
Posts: 1,004
Threads: 13
Joined: Nov 2020
(November 5th, 2024, 10:39)zuzzu Wrote: When I download the patch, I am not sure whether the files need to be overwritten in the main folder, or in the sub-folder "data".
There seems to be some of the same files in both folders.
Can anyone clarify?
Thanks!
Overwrite the same folder as one that has caster.exe. This will also overwrite content in subfolder and subfolder CasApi too.
|