Additional Information | GET PLAY_SOUND(sound number, volume, who hears the sound, where to play the sound)
To set up sounds to use with GET PLAY_SOUND, put a function like this near the top of your bos:
Sounds()
{
play-sound ("movement", 10);
play-sound ("pew", 10);
play-sound ("reporting", 10);
}
The sound number is based on the order the sounds appear, staring from 0. To call the songs by name, add #defines like this:
Sounds()
{
play-sound ("movement", 10);
#define movement 0
play-sound ("pew", 10);
#define pew 1
play-sound ("reporting", 10);
#define reporting 2
}
To actually call the sound, you use a line such as this:
GET PLAY_SOUND (pew, 655360);
1) sound number - as above
2) volume - similar to the volume for play-sound, more affecting the distance where it is audible than actual volume
- given as a float multiplied by 65536
3) who hears the sound
0 = anyone with the unit in ALOS
1 = anyone with the unit in LOS
2 = anyone with the unit in ALOS or radar
3 = anyone with the unit in LOS or radar
4 = everyone
5 = the unit's allies
6 = the unit's team
7 = the unit's enemies
4) where to play the sound
- if 0, the sound is played from the unit's position
- if 1, the sound is played directly from the speakers, the same way unit replies are
|
---|
Attached Files |
-
play_sound.patch (3,110 bytes) 2007-11-20 16:19
Index: rts/Game/Game.cpp
===================================================================
--- rts/Game/Game.cpp (revision 4832)
+++ rts/Game/Game.cpp (working copy)
@@ -4317,6 +4317,7 @@
delete unit->localmodel;
unit->localmodel =
modelParser->CreateLocalModel(unit->model, &unit->cob->pieces);
+ unit->cob->Call("Create");
}
}
}
Index: rts/Sim/Units/COB/CobInstance.cpp
===================================================================
--- rts/Sim/Units/COB/CobInstance.cpp (revision 4832)
+++ rts/Sim/Units/COB/CobInstance.cpp (working copy)
@@ -12,6 +12,7 @@
#include "Map/Ground.h"
#include "Rendering/UnitModels/3DOParser.h"
#include "Rendering/UnitModels/s3oParser.h"
+#include "Sim/Misc/LosHandler.h"
#include "Sim/Misc/RadarHandler.h"
#include "Sim/MoveTypes/AirMoveType.h"
#include "Sim/MoveTypes/MoveType.h"
@@ -104,6 +105,7 @@
#define CHANGE_TARGET 98 // set, the value it's set to determines the affected weapon
#define CEG_DAMAGE 99 // set
#define COB_ID 100 // get
+#define PLAY_SOUND 101 // get, so multiple args can be passed
#define ALPHA_THRESHOLD 103 // set or get
#define SET_WEAPON_UNIT_TARGET 106 // get (fake set)
#define SET_WEAPON_GROUND_TARGET 107 // get (fake set)
@@ -968,8 +970,15 @@
case STANDINGFIREORDERS:
return unit->fireState;
break;
- case HEALTH:
- return (int) ((unit->health/unit->maxHealth)*100.0f);
+ case HEALTH:{
+ if (p1 <= 0)
+ return (int) ((unit->health/unit->maxHealth)*100.0f);
+ CUnit *u = (p1 < MAX_UNITS) ? uh->units[p1] : NULL;
+ if (u == NULL)
+ return 0;
+ else
+ return (int) ((u->health/u->maxHealth)*100.0f);
+ }
case INBUILDSTANCE:
if (unit->inBuildStance)
return 1;
@@ -1159,6 +1168,40 @@
return (u == NULL) ? -1 : u->unitDef->cobID;
}
}
+ case PLAY_SOUND:
+ switch(p3) { //who hears the sound
+ case 0: //ALOS
+ if (!loshandler->InAirLos(unit->pos,gu->myAllyTeam)) {return 0;}
+ break;
+ case 1: //LOS
+ if (!(unit->losStatus[gu->myAllyTeam] & LOS_INLOS)) {return 0;}
+ break;
+ case 2: //ALOS or radar
+ if (!(loshandler->InAirLos(unit->pos,gu->myAllyTeam) || unit->losStatus[gu->myAllyTeam] & (LOS_INRADAR))) {return 0;}
+ break;
+ case 3: //LOS or radar
+ if (!(unit->losStatus[gu->myAllyTeam] & (LOS_INLOS | LOS_INRADAR))) {return 0;}
+ break;
+ case 4: //everyone
+ break;
+ case 5: //allies
+ if (unit->allyteam != gu->myAllyTeam) {return 0;}
+ break;
+ case 6: //team
+ if (unit->team != gu->myTeam) {return 0;}
+ break;
+ case 7: //enemies
+ if (unit->allyteam == gu->myAllyTeam) {return 0;}
+ break;
+ }
+ logOutput.Print("Playing %i %i %i", p1, p2, script.sounds[p1]);
+ if ((p1 + 1 > script.sounds.size()) || p1 < 0) { return 1;}
+ if (p4 == 0) {
+ sound->PlaySample(script.sounds[p1], unit->pos, float(p2) / COBSCALE);
+ }else{
+ sound->PlaySample(script.sounds[p1], float(p2) / COBSCALE);
+ }
+ return 0;
case SET_WEAPON_UNIT_TARGET: {
const int weaponID = p1 - 1;
const int targetID = p2;
-
play_sound_fixed.patch (3,043 bytes) 2007-11-20 16:23
Index: rts/Game/Game.cpp
===================================================================
--- rts/Game/Game.cpp (revision 4832)
+++ rts/Game/Game.cpp (working copy)
@@ -4317,6 +4317,7 @@
delete unit->localmodel;
unit->localmodel =
modelParser->CreateLocalModel(unit->model, &unit->cob->pieces);
+ unit->cob->Call("Create");
}
}
}
Index: rts/Sim/Units/COB/CobInstance.cpp
===================================================================
--- rts/Sim/Units/COB/CobInstance.cpp (revision 4832)
+++ rts/Sim/Units/COB/CobInstance.cpp (working copy)
@@ -12,6 +12,7 @@
#include "Map/Ground.h"
#include "Rendering/UnitModels/3DOParser.h"
#include "Rendering/UnitModels/s3oParser.h"
+#include "Sim/Misc/LosHandler.h"
#include "Sim/Misc/RadarHandler.h"
#include "Sim/MoveTypes/AirMoveType.h"
#include "Sim/MoveTypes/MoveType.h"
@@ -104,6 +105,7 @@
#define CHANGE_TARGET 98 // set, the value it's set to determines the affected weapon
#define CEG_DAMAGE 99 // set
#define COB_ID 100 // get
+#define PLAY_SOUND 101 // get, so multiple args can be passed
#define ALPHA_THRESHOLD 103 // set or get
#define SET_WEAPON_UNIT_TARGET 106 // get (fake set)
#define SET_WEAPON_GROUND_TARGET 107 // get (fake set)
@@ -968,8 +970,15 @@
case STANDINGFIREORDERS:
return unit->fireState;
break;
- case HEALTH:
- return (int) ((unit->health/unit->maxHealth)*100.0f);
+ case HEALTH:{
+ if (p1 <= 0)
+ return (int) ((unit->health/unit->maxHealth)*100.0f);
+ CUnit *u = (p1 < MAX_UNITS) ? uh->units[p1] : NULL;
+ if (u == NULL)
+ return 0;
+ else
+ return (int) ((u->health/u->maxHealth)*100.0f);
+ }
case INBUILDSTANCE:
if (unit->inBuildStance)
return 1;
@@ -1159,6 +1168,39 @@
return (u == NULL) ? -1 : u->unitDef->cobID;
}
}
+ case PLAY_SOUND:
+ switch(p3) { //who hears the sound
+ case 0: //ALOS
+ if (!loshandler->InAirLos(unit->pos,gu->myAllyTeam)) {return 0;}
+ break;
+ case 1: //LOS
+ if (!(unit->losStatus[gu->myAllyTeam] & LOS_INLOS)) {return 0;}
+ break;
+ case 2: //ALOS or radar
+ if (!(loshandler->InAirLos(unit->pos,gu->myAllyTeam) || unit->losStatus[gu->myAllyTeam] & (LOS_INRADAR))) {return 0;}
+ break;
+ case 3: //LOS or radar
+ if (!(unit->losStatus[gu->myAllyTeam] & (LOS_INLOS | LOS_INRADAR))) {return 0;}
+ break;
+ case 4: //everyone
+ break;
+ case 5: //allies
+ if (unit->allyteam != gu->myAllyTeam) {return 0;}
+ break;
+ case 6: //team
+ if (unit->team != gu->myTeam) {return 0;}
+ break;
+ case 7: //enemies
+ if (unit->allyteam == gu->myAllyTeam) {return 0;}
+ break;
+ }
+ if ((p1 + 1 > script.sounds.size()) || p1 < 0) { return 1;}
+ if (p4 == 0) {
+ sound->PlaySample(script.sounds[p1], unit->pos, float(p2) / COBSCALE);
+ }else{
+ sound->PlaySample(script.sounds[p1], float(p2) / COBSCALE);
+ }
+ return 0;
case SET_WEAPON_UNIT_TARGET: {
const int weaponID = p1 - 1;
const int targetID = p2;
-
get_play_sound_demo.sd7 (794,842 bytes) 2007-11-20 16:35
|
---|