/** * Title: trap_webber.script * Description: webber */ //------------------------------------------------ // Includes //------------------------------------------------ include ai.ai_combat; include library.prose; include library.ai_lib; include library.movement; include library.utils; //------------------------------------------------ // Inherits //------------------------------------------------ inherits item.trap.trap_base; //------------------------------------------------ // Constants //------------------------------------------------ const int TRAP_DIFF = 25; const string_id SID_SYS_EFFECT = new string_id( "trap/trap", "trap_webber_effect" ); const string_id SID_NO_EFFECT = new string_id( "trap/trap", "trap_webber_effect_no" ); //------------------------------------------------ // Methods //------------------------------------------------ //------------------------------------------------ // OnAttach //------------------------------------------------ trigger OnAttach() { if (!hasObjVar(self, "droid_trap")) { setObjVar( self, "trapDiff", TRAP_DIFF ); setObjVar( self, "trapName", "webber" ); setCount( self, 2 ); } return SCRIPT_CONTINUE; } //------------------------------------------------ // trapHit //------------------------------------------------ messageHandler trapHit() { if ( params == null ) return super.trapHit(self, params); obj_id target = params.getObjId( "target" ); if ( (target == null) || (target == obj_id.NULL_ID) ) return super.trapHit(self, params); if ( !ai_lib.isMonster( target ) || isIncapacitated( target ) || isDead( target ) ) return super.trapHit(self, params); // Get player. obj_id player = params.getObjId( "player" ); // Is it already affected? // TODO: This needs to use the new movement manager if this functionality is still needed. //if ( movement.isRooted( target ) ) //{ // prose_package pp = prose.getPackage( SID_NO_EFFECT, target ); // sendSystemMessageProse( player, pp ); // return SCRIPT_CONTINUE; //} prose_package pp = prose.getPackage( SID_SYS_EFFECT, target ); sendSystemMessageProse( player, pp ); // Send rooted message to target. dictionary outparams = new dictionary(); outparams.put( "player", player ); outparams.put( "duration", rand(30, 60) ); messageTo( target, "rootEnable", outparams, 0, false ); // Reduce the target's mind pool. /*int action = getAction( target ); int taction = 130 + rand( 0, 70 ); int drainaction = 0; if ( action > taction ) drainaction = taction; else if ( action > 1 ) drainaction = action - 1; assignTrapEffect( player, target, 0, drainaction, 0 ); */ // If they don't have an enemy, make them attack us. if (!hasObjVar(self, "droid_trap")) { if ( !ai_lib.isInCombat( target ) ) startCombat( target, player ); } else { if ( !ai_lib.isInCombat( target ) ) startCombat( target, self ); } // Grant XP. float chance = params.getFloat( "chance" ); grantTrapXP( player, target, 1.4f ); return super.trapHit(self, params); }