Jump to content

Attack notification


Recommended Posts

Hmm for some reason, no matter at which directory I right-click and try to apply the patch using the menu option of TortoiseSVN, the changes for the following files keep getting rejected :

messages.js

GuiInterface.js

player.xml

template_unit_infantry.xml

I guess there is some specific way to apply the patch or perhaps the source which was used to make the patch for the above 4 existing files is different from the current state of the source for these 4 files. Anyway I am nearly 50% done on the git clone.

Have you applied diffs from github to your SVN copy successfully before ?

Edited by madmax
Link to comment
Share on other sites

Others (leper, quantumstate) have succesfully applied my diffs from Github before. Are you sure you are applying the patch relative to the right directory? (Edit: Oh, I guess you've tried several.)

Edited by zoot
Link to comment
Share on other sites

Yeah I right click on the 'trunk' directory and try to apply the diff.

Hmm its trying to find trunk\b\binaries\data\mods....

instead of trunk\binaries\data\mods....

wonder why its adding this b !!

The diff does contain lines like :

--- a/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml

+++ b/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml

But TortoiseSVN should understand that 'a' & 'b' here does not refer to the path. Maybe I ll find/replace the a & the b with blanks and try again. :P

Edited by madmax
Link to comment
Share on other sites

messages.js

GuiInterface.js

player.xml

template_unit_infantry.xml

You haven't edited these files yourself before, by any chance, have you? If you are using a Windows editor, it could cause line-endings mismatches.

Edited by zoot
Link to comment
Share on other sites

ok, so I manually changed the paths like these :

--- a/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml

+++ b/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml

to

--- binaries/data/mods/public/simulation/templates/template_unit_infantry.xml

+++ binaries/data/mods/public/simulation/templates/template_unit_infantry.xml

and right clicked on the trunk directory and applied the patch and it worked :)

Not the most developer friendly way I guess, I ll try the patch command next time.

Edited by madmax
Link to comment
Share on other sites

So the game starts fine when I patch messages.js, components\AttackDetection.js, GuiInterface.js, components\interfaces\AttackDetection.js and template_unit_infantry.xml

They are all patched in their correct directories. But player.xml after patching crashes the game : (I eliminated the files one by one, patching each time :P )

playererror.png

The error dialog box shows :

Assertion failed: "it != m_SharedLosMasks.end()"

Location: CCmpRangeManager.cpp:1064 (CCmpRangeManager::GetSharedLosMask)

Call stack:

(error while dumping stack: No stack frames found)

errno = 0 (No error reported here)

OS error = 0 (no error code was set)

player.xml seems to be only declaring a new component called AttackDetection. Maybe there is a bug in this component somewhere. The playerState seems to be invalid in session.js due to this.

Edited by madmax
Link to comment
Share on other sites

Changing checkPlayerState() in session.js to catch the invalid playerState var stops the crash :


function checkPlayerState()
{
var simState = Engine.GuiInterfaceCall("GetSimulationState");
var playerState = simState.players[Engine.GetPlayerID()];
if (!playerState)
{
return;
}
...
.......

Wonder why it becomes invalid though. Maybe because the game is starting up ? But then why wasn't it happening before. Is there someway to print out debugging lines like cout in c++ ?

Edited by madmax
Link to comment
Share on other sites

interestinglog.htmlmainlog.htmlSo strangely in interestinglog.html it says there is an error in parsing player.xml :

<!DOCTYPE html>
<meta charset="utf-8">
<title>Pyrogenesis Log</title>
<style>body { background: #eee; color: black; font-family: sans-serif; } p { background: white; margin: 3px 0 3px 0; } .error { color: red; } .warning { color: blue; }</style>
<h2>0 A.D. Main log (warnings and errors only)</h2>
<p class="error">ERROR: CXeromyces: Parse error: special/player:1: Did not expect element AttackDetection there</p>
<p class="error">ERROR: RelaxNGValidator: Validation failed</p>
<p class="error">ERROR: Failed to validate entity template 'special/player'</p>
<p class="error">ERROR: JavaScript error: uncaught exception: Player.js: Error creating player entity 0</p>
<p class="warning">WARNING: GetPlayerByID: no player defined for id '0'
(0)@simulation/components/PlayerManager.js:28</p>
<p class="error">ERROR: Failed to load entity template 'actor|props/flora/grass_tropic_field_tall.xml'</p>
<p class="warning">WARNING: GetPlayerByID: no player defined for id '0'
(0)@simulation/components/PlayerManager.js:28</p>
<p class="error">ERROR: Failed to load entity template 'actor|props/flora/grass_tropic_field_tall.xml'</p>
<p class="warning">WARNING: GetPlayerByID: no player defined for id '0'
(0)@simulation/components/PlayerManager.js:28</p>

My player.xml is:


<?xml version="1.0" encoding="utf-8"?>
<Entity>
<EntityLimits>
<LimitMultiplier>1.0</LimitMultiplier>
<Limits>
<CivilCentre/>
<DefenseTower>25</DefenseTower>
<Fortress>10</Fortress>
<Hero>1</Hero>
</Limits>
</EntityLimits>
<Player/>
<StatisticsTracker/>
<TechnologyManager/>
<AttackDetection/>
<BattleDetection>
<TimerInterval>200</TimerInterval>
<RecordLength>12</RecordLength>
<DamageRateThreshold>0.04</DamageRateThreshold>
<AlertnessBattleThreshold>4</AlertnessBattleThreshold>
<AlertnessPeaceThreshold>0</AlertnessPeaceThreshold>
<AlertnessMax>8</AlertnessMax>
</BattleDetection>
</Entity>

Edited by madmax
Link to comment
Share on other sites

"ERROR: CXeromyces: Parse error: special/player:1: Did not expect element AttackDetection there"

That's the culprit. Are you sure all files were patched correctly? And perhaps more importantly, that all files were created correctly. The diff contains new files that has to exist for the game to recognize the AttackDetection element.

Link to comment
Share on other sites

Yeah the new files have not been added :(...should have checked that right away. I will try to just the download the files - the 2 AttackDetection.js files

Or hey wait...now I have the git repo...I ll try to switch the branch instead and see if they magically appear !

Edited by madmax
Link to comment
Share on other sites

Phew !! It finally worked ! Thanks so much for patiently replying to all my questions.

Now to work.

So I guess to test the alarm I do not need to use one of the custom maps where the enemies will be really far away and I will have search around with my unit in the fog of war.

I should be able to quickly make a custom scenario in Atlas with 2 players against each other and quite close by.

Edited by madmax
Link to comment
Share on other sites

ok, so there is indeed a loud horn blaring out in Combat Demo. There does not seem to be multiple alarms either. Just one for the entire attack. Wonder where the logic for that is.

So now, we need to add the sound to all the other relevant unit templates. These I can see in simulation/templates. Has any decision been made as to which templates/units should have which sound. I guess unit specific sounds are not yet present and there is just 1 attacked alarm sound. So I can start adding it to the required xml files under the <SoundGroups> tag.

A question regarding the co-ordinate system used to place objects in 0ad. So I guess any point on the terrain surface can be located with (x,z) and elevation is through 'y' ?

1. I guess for the minimap, what needs to be done then is that I get all the units which are being attacked for the current player.

2. Get their co-ordinates (x,z) , so a list of co-ordinates

3. Transform these co-ordinates to minimap-space say (x', z')

4. Show a blinking dot on the minimap at the list of (x', z') positions for a specific amount of time.

5. Stop the blinking and keep a white dot to show the player where he was last attacked

6. For a new attack, clear the old white dots and show new blinking ones at new positions

Totally wild guess from someone who hasn't seen the code yet !

Where is the minimap cpp files. Are there functions exposed to Javascript so this entire thing could be done in it ?

Edited by madmax
Link to comment
Share on other sites

The logic is in AttackDetection.js. It keeps a list of previous attacks, called suppressedList.

There is no decision yet on which templates should have 'attacked' sounds. I suggest just using your own intuition, and then settle it during patch review.

Link to comment
Share on other sites

More questions added :P to previous post.

There is no decision yet on which templates should have 'attacked' sounds. I suggest just using your own intuition, and then settle it during patch review.

Right, I ll get cracking on that.

Edited by madmax
Link to comment
Share on other sites

ok, one other question, how do I print debug messages in the 0ad window from c++. Whats the equivalent for Javascript ?

I don't remember it offhand for C++, I believe it is DEBUG_PRINT() or DEBUG_WARN() or some such. For JS, it is warn() and error().

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...