1
0
forked from 0ad/0ad

Added aura scripts and 3 auras: a Courage aura of 15 on Themistocles and 5 on Alexander, a Fear aura of 5 on Leonidas, and an Infidelity aura on female citizens.

This was SVN commit r3237.
This commit is contained in:
Matei 2005-12-13 08:03:49 +00:00
parent 6e82e33ccf
commit 0eb7108272
6 changed files with 150 additions and 1 deletions

View File

@ -3,6 +3,7 @@
<Entity parent="template_entity">
<Script File="entities/template_entity_script.js" />
<Event On="Initialize" Function="entity_event_initialize" />
<Event On="Attack" Function="entity_event_attack" />
<Event On="Gather" Function="entity_event_gather" />
<Event On="Heal" Function="entity_event_heal" />

View File

@ -1,3 +1,35 @@
function entity_event_initialize( evt )
{
if( this.traits.auras )
{
for( name in this.traits.auras )
{
console.write( "Creating " + name + " aura for " + this );
switch( name )
{
case "courage":
a = this.traits.auras.courage;
this.addAura( name, a.radius, new CourageAura( this, true, a.bonus ) );
break;
case "fear":
a = this.traits.auras.fear;
this.addAura( name, a.radius, new CourageAura( this, false, -a.bonus ) );
break;
case "infidelity":
a = this.traits.auras.infidelity;
this.addAura( name, a.radius, new InfidelityAura( this ) );
break;
default:
console.write( "Unknown aura: " + name + " on " + this + ", ignoring it");
break;
}
}
}
}
// ====================================================================
function entity_event_attack( evt )
{
curr_hit = getGUIGlobal().newRandomSound("voice", "hit", this.traits.audio.path);
@ -247,7 +279,6 @@ function entity_event_takesdamage( evt )
}
// We've taken what we need. Kill the swine.
console.write("Kill!!");
this.kill();
}
else if( evt.inflictor && this.actions.attack )
@ -507,3 +538,97 @@ function entity_CheckQueueReq (entry)
}
// ====================================================================
function CourageAura( source, ally, bonus )
{
this.source = source;
this.bonus = bonus;
this.ally = ally;
this.affects = function( e )
{
if( this.ally )
{
return ( e.player.id == this.source.player.id && e.actions.attack );
}
else
{
return ( e.player.id != this.source.player.id && e.actions.attack );
}
}
this.onEnter = function( e )
{
if( this.affects( e ) )
{
console.write( "Courage aura: giving " + this.bonus + " damage to " + e );
e.actions.attack.damage += this.bonus;
}
};
this.onExit = function( e )
{
if( this.affects( e ) )
{
console.write( "Courage aura: taking away " + this.bonus + " damage from " + e );
e.actions.attack.damage -= this.bonus;
}
};
}
// ====================================================================
function InfidelityAura( source )
{
this.source = source;
this.count = new Array( 9 );
for( i = 1; i <= 8; i++ )
{
this.count[i] = 0;
}
this.affects = function( e )
{
return ( e.player.id != 0 );
}
this.onEnter = function( e )
{
if( this.affects( e ) )
{
console.write( "Infidelity aura: adding +1 count to " + e.player.id );
this.count[e.player.id]++;
this.changePlayerIfNeeded();
}
};
this.onExit = function( e )
{
if( this.affects( e ) )
{
console.write( "Infidelity aura: adding -1 count to " + e.player.id );
this.count[e.player.id]--;
this.changePlayerIfNeeded();
}
};
this.changePlayerIfNeeded = function()
{
numNearby = 0;
someoneNearby = 0;
for( i = 1; i <= 8; i++ )
{
if( this.count[i] > 0 )
{
numNearby++;
someoneNearby = i;
}
}
if( numNearby == 1 )
{
console.write( "Infidelity aura: changing ownership to " + someoneNearby );
this.source.player = players[someoneNearby];
}
}
}

View File

@ -11,6 +11,12 @@
history="The most powerful hero of them all - son of Philip II, king of Macedonia (336 BC - 323 BC). After conquering the rest of the Thracians and quelling the unrest of the Greeks, Alexander embarked on a world-conquest march. Defeating the Persian forces at Granicus (334 BC), Issus (333 BC) and Gaugamela (331 BC), he became master of the Persian Empire. Entering India, he defeated king Porus at Hydaspes (326 BC), but his weary troops made him halt. Died in Babylon at the age of 33 while planning a campaign against Arabia."
/>
<Auras>
<Courage>
<Radius>20</Radius>
<Bonus>5</Bonus>
</Courage>
</Auras>
</Traits>
<Actor>units/hellenes/alexander.xml</Actor>
</Entity>

View File

@ -11,6 +11,12 @@
history="The king of Sparta, whom fought and died at the battle of Thermopylae in 480 BC. He successfully blocked the way of the huge Persian army through the narrow passage with his 7000 men, until Xerxes was made aware of a secret unobstructed path. Finding the enemy at his rear, Leonidas sent home most of his troops, choosing to stay behind with 300 hand-picked hoplites and win time for the others to withdraw."
/>
<Auras>
<Fear>
<Radius>20</Radius>
<Bonus>5</Bonus>
</Fear>
</Auras>
</Traits>
<Actor>units/hellenes/leonidas.xml</Actor>
</Entity>

View File

@ -11,6 +11,12 @@
history="The general whom persuaded the Athenians to invest their income from silver mines in a war navy of 200 Triremes. A key figure during the Persian Wars, he commanded the victorious Athenian navy at the decisive battle of Salamis in 479 BC. Later, he pursued an active policy against the Persians in the Aegean, thereby laying the foundations of future Athenian power. Ostracised by the Athenians, he was forced to flee to the protection of the Persians."
/>
<Auras>
<Courage>
<Radius>20</Radius>
<Bonus>10</Bonus>
</Courage>
</Auras>
</Traits>
<Actor>units/hellenes/thermistocles.xml</Actor>
</Entity>

View File

@ -9,6 +9,11 @@
rollover="Women in the ancient world took on a variety of roles - from leadership (Celts) to servant (Greeks). Women are hard workers, the economic backbone of any civilisation. In history, it was typical when all the males (capable of fighting) were killed for the females, children, and elderly to be sold as slaves."
/>
<Auras>
<Infidelity>
<Radius>30</Radius>
</Infidelity>
</Auras>
</Traits>
<Actions>
<Create