/*********************************************************************** * Copyright (c) ©2000,2001 Sony Online Entertainment Inc. * All Rights Reserved *********************************************************************** * Title: combat_test.script * Description: Report combat events. Test out states. * @author $Author: Anthony Castoro$ * @version $Revision: $ ***********************************************************************/ /***** INCLUDES ********************************************************/ //include anyLibrary; // includes a .scriptlib file /***** INHERITS ********************************************************/ //inherits anyScript; // inherits a .script file /***** CONSTANTS *******************************************************/ const string VERSION = "v0.00.00"; /***************************** 11/5/2001 12:32PM ************************ * Trigger OnAttach - Reports status and initializes object * * @param type A description of the parameter. * * @return A description of the return value. * ***********************************************************************/ trigger OnInitialize() { detachScript(self, "systems.combat.combat_test"); return SCRIPT_CONTINUE; } trigger OnAttach() { debugServerConsoleMsg(self, "combat_test: entered trigger OnAttach"); return SCRIPT_CONTINUE; } trigger OnDetach() { debugServerConsoleMsg(self, "combat_test: entered trigger OnAttach"); debugServerConsoleMsg(self, "combat_test: Bye!"); return SCRIPT_CONTINUE; } trigger OnRecapacitated() { //debugSpeakMsg(self, "I'm no longer incapacitated!"); debugServerConsoleMsg(self, "I'm no longer incapacitated!"); return SCRIPT_CONTINUE; } trigger OnHearSpeech(obj_id speaker, string message) { /* if (speaker != self) { return SCRIPT_CONTINUE; } */ if ( message == "com recover" ) { if (speaker != self) { return SCRIPT_CONTINUE; } if(isIncapacitated(self)) { int attribute; attribute = getAttrib(self, HEALTH); if ( attribute < 0 ) { setAttrib(self, HEALTH, -1); } attribute = getAttrib(self, ACTION); if ( attribute < 0 ) { setAttrib(self, ACTION, -1); } attribute = getAttrib(self, MIND); if ( attribute < 0 ) { setAttrib(self, MIND, -1); } return SCRIPT_CONTINUE; } else { debugSpeakMsg(self, "I'm not incapacitated!"); } } else if ( message == "com report" ) { string report = reportAttribs(self); debugSpeakMsg(self, "My stats are currently: " +report+ ""); } return SCRIPT_CONTINUE; } trigger OnIncapacitated(obj_id killer) { string killerName; killerName = getName(killer); //debugSpeakMsg(self, "I've been incapacitated by " + killerName + "!"); debugServerConsoleMsg(self, "setting negative attribute(s) to -5"); int attribute; attribute = getAttrib(self, HEALTH); if ( attribute < 0 ) { setAttrib(self, HEALTH, -5); } attribute = getAttrib(self, ACTION); if ( attribute < 0 ) { setAttrib(self, ACTION, -5); } attribute = getAttrib(self, MIND); if ( attribute < 0 ) { setAttrib(self, MIND, -5); } string report = reportAttribs(self); debugServerConsoleMsg(self, "My stats are currently: " +report+ ""); return SCRIPT_CONTINUE; } /* trigger OnIsHitting() { return SCRIPT_CONTINUE; } */ /** * Called when a weapon is used in combat. * * @param self the weapon * @param attacker the attacker id * @param defender the defender id * @param hit true if the attacker hit the defender * @param where combat skeleton location where the defender was hit * @param fumble true if the attacker fumbled * @param damage damage done * * @return if SCRIPT_OVERRIDE, the action will not take place */ trigger OnWeaponCombatAction( obj_id attacker, obj_id defender ) { /* if ( hit ) { string weaponName; //store the name of the weapon weaponName = getName(self); string victimName; //store the name of the victim victimName = getName(defender); string hitLocationName = getHitLocationName(self, hitLocation); //store the description of the hit location //debugSpeakMsg(attacker, "(HIT): " + victimName + " in the " + hitLocationName + " using " + weaponName + "!"); } else { string dName = getName(defender); //get the defender's name string wName = getName(self); //get the weapon's name if ( fumble ) { //debugSpeakMsg(attacker, "(FUMBLE)"); } else { //debugSpeakMsg(attacker, "(MISS)"); } } */ return SCRIPT_CONTINUE; } /** * Called when one object is being attacked by another. * * @param self the defender * @param attacker the attacker id * @param weapon the attacker's weapon id * @param hit true if the attacker hit the defender * @param where combat skeleton location where the defender was hit * @param fumble true if the attacker fumbled * @param damage damage done * * @return if SCRIPT_OVERRIDE, the action will not take place */ trigger OnDefenderCombatAction( obj_id attacker, obj_id weapon, int where ) { /* if ( hit ) { string atkrName; atkrName = getName(attacker); //debugSpeakMsg(self, "ow! " + atkrName + " attacked me!"); //int state = doStateCheck(self, hitLocation, weapon, attackEffects); string report = victimReportDamage(self, attacker, attackEffects); if( report != null) { //debugSpeakMsg(self, report); } else { debugServerConsoleMsg(self, "*** OnDefenderCombatAction: victimReportDamage returned null! ***"); } } */ return SCRIPT_CONTINUE; } /* trigger OnFumble() { return SCRIPT_CONTINUE; } trigger OnIncapacitateTarget() { return SCRIPT_CONTINUE; } */ /***************************** 11/5/2001 12:32PM ************************ * A description of the function. * * @param type A description of the parameter. * * @return A description of the return value. * ***********************************************************************/ //put method for returning hitlocation here // put method for returning attribute here string returnDamType(int attribute) { string damType; //store the damage type switch(attribute) //from consts, move this to a scriptlib! { case HEALTH : damType = "Health"; break; case CONSTITUTION : damType = "Constitution"; break; case ACTION : damType = "Action"; break; case STAMINA : damType = "Stamina"; break; case MIND : damType = "Mind"; break; case WILLPOWER : damType = "Willpower"; break; default: damType = "None"; break; } return(damType); } string victimReportDamage(obj_id self, obj_id attacker, attrib_mod[] attackEffects) { int effectsLength = 0; //store the length of the array (actually always 12) if ( attackEffects != null ) //make sure it's real { effectsLength = attackEffects.length; } else { debugServerConsoleMsg(self, "attackEffects was NULL! Exiting..."); return null; } if ( effectsLength == 0 ) //this shouldn't happen { debugServerConsoleMsg(self, "No damage done. That's odd..."); return null; } debugServerConsoleMsg(self, "effectsLength is " + effectsLength); //report! int damPoints = 0;//store the number of damage points int damIntType = 0; string damType = "unknown"; //store the name of the Attribute affected by the points string damageReport = "Damage Report: "; for ( int i = 0; i < attackEffects.length; ++i ) //cycle through the array and report info { if( attackEffects[i] == null) //don't do anything with null entries in the array { break; } int attribute = attackEffects[i].getAttribute(); // which attribute is being damaged damPoints = attackEffects[i].getValue(); // how much damage is being done float duration = attackEffects[i].getDuration(); // how long the damage will last (for buffs, generally 0 in this case) float attack = attackEffects[i].getAttack(); // how long it takes to get up to the damage level from 0 (for buffs, 0 in this case) float decay = attackEffects[i].getDecay(); // how long it takes to go back to 0 after duration (for buffs, MOD_FAUCET in this case if ( damPoints != 0) //it normally isn't { int curAttributeLevel; int maxAttributeLevel; int newAttributeLevel; damType = returnDamType(attribute);//get the string name of the damage type curAttributeLevel = getAttrib(self, attribute); maxAttributeLevel = getMaxAttrib(self, attribute); newAttributeLevel = (curAttributeLevel - damPoints); if(damType != "none") { string damageElement = ""+ damPoints + " of " + damType + " (" + newAttributeLevel + "/" + maxAttributeLevel + "), "; damageReport = join(damageReport, damageElement); } } } return damageReport; } string getHitLocationName(obj_id self, int hitLocation) { string hitLocationName; switch ( hitLocation ) //this info comes from perforce win32/shared/combat.cfg, put this in a script lib! { case 0 : hitLocationName = "body"; break; case 1 : hitLocationName = "head"; break; case 2 : hitLocationName = "right arm"; break; case 3 : hitLocationName = "left arm"; break; case 4 : hitLocationName = "right leg"; break; case 5 : hitLocationName = "left leg"; break; default: hitLocationName = "none"; debugServerConsoleMsg(self, "combat_test couldn't determine the hit location!"); break; } return(hitLocationName); } int doStateCheck(obj_id self, int hitLocation, obj_id weapon, attrib_mod[] attackEffects) { string hitLocationName; int hit; //if hit = 1, state stunned, if hit = 2 state blind, if hit = 3 state shock switch ( hitLocation ) //this info comes from perforce win32/shared/combat.cfg, put this in a script lib! { case 0 : //body hitLocationName = "body"; break; case 1 : //head hitLocationName = "head"; break; case 2 : //right arm hitLocationName = "right arm"; break; case 3 : //left arm hitLocationName = "left arm"; break; case 4 : //right leg hitLocationName = "right leg"; break; case 5 : //left leg hitLocationName = "left leg"; break; default: //none? hitLocationName = "none"; debugServerConsoleMsg(self, "combat_test couldn't determine the hit location!"); break; } return SCRIPT_CONTINUE; } //reports the three pools string reportAttribs(obj_id target) { string reportsum = ""; string element = ""; string attribname = ""; int curAttributeLevel = getAttrib(target, HEALTH); attribname = returnDamType(HEALTH); element = (""+attribname+" = " +curAttributeLevel + ","); reportsum = join(reportsum, element); curAttributeLevel = getAttrib(target, ACTION); attribname = returnDamType(ACTION); element = (""+attribname+" = " +curAttributeLevel + ","); reportsum = join(reportsum, element); curAttributeLevel = getAttrib(target, MIND); attribname = returnDamType(MIND); element = (""+attribname+" = " +curAttributeLevel + ","); reportsum = join(reportsum, element); return reportsum; }