mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
157 lines
3.7 KiB
Plaintext
157 lines
3.7 KiB
Plaintext
include library.ai_lib;
|
|
include library.beast_lib;
|
|
include library.factions;
|
|
include library.trial;
|
|
include library.utils;
|
|
|
|
trigger OnAttach()
|
|
{
|
|
|
|
|
|
// Set vulnerable HP
|
|
int hp = hasObjVar(self, "hp") ? getIntObjVar(self, "hp") : 5000;
|
|
setMaxHitpoints(self, hp);
|
|
setHitpoints(self, hp);
|
|
|
|
|
|
// Set NPC interaction
|
|
string attract = hasObjVar(self, "attraction") ? getStringObjVar(self, "attraction") : "none";
|
|
int attractRange = hasObjVar(self, "attraction_range") ? getIntObjVar(self, "attraction_range") : 20;
|
|
if (!attract.equals("none"))
|
|
{
|
|
trial.setInterest(self);
|
|
setTriggerVolume(self, attract, attractRange);
|
|
}
|
|
|
|
// Does this structure ignore player attackers?
|
|
int ignore_player = hasObjVar(self, "ignore_player") ? getIntObjVar(self, "ignore_player") : 0;
|
|
if (ignore_player == 1)
|
|
factions.setIgnorePlayer(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectDisabled (obj_id killer)
|
|
{
|
|
location death = getLocation( self );
|
|
|
|
string effect = "clienteffect/combat_explosion_lair_large.cef";
|
|
|
|
if(hasObjVar(self, "deathEffect"))
|
|
{
|
|
effect = getStringObjVar(self, "deathEffect");
|
|
}
|
|
|
|
playClientEffectObj(killer, effect, self, "");
|
|
playClientEffectLoc(killer, effect, death, 0);
|
|
|
|
|
|
setInvulnerable( self, true );
|
|
messageTo( self, "destroyDisabledLair", null, .5f, false );
|
|
obj_id[] enemies = getWhoIsTargetingMe( self );
|
|
if ( enemies != null && enemies.length > 1 )
|
|
{
|
|
for ( int i = 0; i < enemies.length; i++ )
|
|
{
|
|
if ( isPlayer( enemies[i] ) )
|
|
{
|
|
//setTarget( enemies[i], null );
|
|
//setCombatTarget( enemies[i], null );
|
|
}
|
|
}
|
|
}
|
|
|
|
// We attach the ai_controller now which does this.
|
|
// reportDeath(self, killer);
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
|
|
trigger OnTriggerVolumeEntered(string volumeName, obj_id breacher)
|
|
{
|
|
if (!ai_lib.isMob(breacher) || beast_lib.isBeast(breacher))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
|
|
string attraction_name = getStringObjVar(self, "attraction");
|
|
string social = ai_lib.getSocialGroup(breacher);
|
|
|
|
if (volumeName.equals(attraction_name))
|
|
{
|
|
if (social != null && social != "" && social.equals(attraction_name))
|
|
startCombat(breacher, self);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void setTriggerVolume(obj_id self, string vol_name, int vol_range)
|
|
{
|
|
createTriggerVolume(vol_name, vol_range, true);
|
|
}
|
|
|
|
messageHandler destroyDisabledLair()
|
|
{
|
|
destroyObject( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectDamaged(obj_id attacker, obj_id weapon, int damage)
|
|
{
|
|
|
|
int curHP = getHitpoints (self);
|
|
int maxHP = getMaxHitpoints( self );
|
|
int smolder = (maxHP - (maxHP/3));
|
|
int fire = (maxHP/ 3);
|
|
|
|
if (!hasObjVar (self, "playingEffect"))
|
|
{
|
|
if (curHP < smolder)
|
|
{
|
|
if (curHP < fire)
|
|
{
|
|
location death = getLocation (self);
|
|
setObjVar (self, "playingEffect", 1);
|
|
messageTo (self, "effectManager", null, 15, true);
|
|
}
|
|
else
|
|
{
|
|
location death = getLocation (self);
|
|
//playClientEffectObj(attacker, "clienteffect/lair_med_damage_smoke.cef" , self, "");
|
|
//playClientEffectLoc(attacker, "clienteffect/combat_explosion_lair_large.cef", death, 0);
|
|
setObjVar (self, "playingEffect", 1);
|
|
messageTo (self, "effectManager", null, 15, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler effectManager ()
|
|
{
|
|
removeObjVar (self, "playingEffect");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void reportDeath(obj_id self, obj_id killer)
|
|
{
|
|
int row = getIntObjVar(self, "row");
|
|
|
|
string spawn_id = "none";
|
|
if (hasObjVar(self, "spawn_id"))
|
|
spawn_id = getStringObjVar(self, "spawn_id");
|
|
|
|
int respawn = getIntObjVar(self, "respawn");
|
|
|
|
dictionary dict = trial.getSessionDict(trial.getParent(self));
|
|
dict.put("object", self);
|
|
dict.put("row", row);
|
|
dict.put("spawn_id", spawn_id);
|
|
dict.put("respawn", respawn);
|
|
dict.put("killer", killer);
|
|
|
|
messageTo(trial.getParent(self), "terminationCallback", dict, 0.0f, false);
|
|
|
|
} |