Changeset 5121


Ignore:
Timestamp:
Jan 5, 2012 8:41:29 PM (4 months ago)
Author:
Zoey76
Message:

BETA: L2SkillSpawn rework:

  • Added support for summoner reference, based on VlLight? work.
  • Now L2SkillSpawn won't have null spawns...
  • Partially reverted [4890] changes on L2SkillSpawn...
  • Minor rework on L2TotemInstance.
  • Unhardcoded all NPC instances.
Location:
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Npc.java

    r5098 r5121  
    137137        public boolean _spsrecharged = true; 
    138138        private int _displayEffect = 0; 
     139         
     140        /** 
     141         * The character that summons this NPC. 
     142         */ 
     143        private L2Character _summoner = null; 
    139144         
    140145        private final L2NpcAIData _staticAIData = getTemplate().getAIDataStatic(); 
     
    16821687                return 0; 
    16831688        } 
     1689         
     1690        /** 
     1691         * @return the character that summoned this NPC. 
     1692         */ 
     1693        public L2Character getSummoner() 
     1694        { 
     1695                return _summoner; 
     1696        } 
     1697         
     1698        /** 
     1699         * @param summoner the summoner of this NPC. 
     1700         */ 
     1701        public void setSummoner(L2Character summoner) 
     1702        { 
     1703                _summoner = summoner; 
     1704        } 
    16841705} 
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2TotemInstance.java

    r4930 r5121  
    1515package com.l2jserver.gameserver.model.actor.instance; 
    1616 
    17 import java.util.Collection; 
    1817import java.util.concurrent.ScheduledFuture; 
    1918 
     
    2928/** 
    3029 * @author UnAfraid 
    31  * 
    3230 */ 
    3331public class L2TotemInstance extends L2Npc 
    3432{ 
    3533        private ScheduledFuture<?> _aiTask; 
    36         private final L2Skill _skill; 
     34         
     35        private L2Skill _skill; 
    3736         
    3837        private class TotemAI implements Runnable 
     
    5049                        if (_skill == null) 
    5150                        { 
    52                                 _caster._aiTask.cancel(false); 
    53                                 _caster._aiTask = null; 
     51                                if (_caster._aiTask != null) 
     52                                { 
     53                                        _caster._aiTask.cancel(false); 
     54                                        _caster._aiTask = null; 
     55                                } 
    5456                                return; 
    5557                        } 
    5658                         
    57                         Collection<L2PcInstance> plrs = getKnownList().getKnownPlayersInRadius(_skill.getSkillRadius()); 
    58                         for (L2PcInstance player : plrs) 
     59                        for (L2PcInstance player : getKnownList().getKnownPlayersInRadius(_skill.getSkillRadius())) 
    5960                        { 
    6061                                if (player.getFirstEffect(_skill.getId()) == null) 
     
    6465                        } 
    6566                } 
     67        } 
     68         
     69        public L2TotemInstance(int objectId, L2NpcTemplate template) 
     70        { 
     71                super(objectId, template); 
     72                setInstanceType(InstanceType.L2TotemInstance); 
    6673        } 
    6774         
     
    7885        { 
    7986                if (_aiTask != null) 
     87                { 
    8088                        _aiTask.cancel(true); 
     89                } 
    8190                super.deleteMe(); 
    8291        } 
     
    99108                player.sendPacket(ActionFailed.STATIC_PACKET); 
    100109        } 
     110         
     111        public void setAITask() 
     112        { 
     113                if (_aiTask == null) 
     114                { 
     115                        _aiTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new TotemAI(this), 3000, 3000); 
     116                } 
     117        } 
     118         
     119        /** 
     120         * @param skillId the _skill to set 
     121         */ 
     122        public void setSkill(int skillId) 
     123        { 
     124                _skill = SkillTable.getInstance().getInfo(skillId, 1); 
     125        } 
    101126} 
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/skills/l2skills/L2SkillSpawn.java

    r5083 r5121  
    1515package com.l2jserver.gameserver.skills.l2skills; 
    1616 
     17import java.util.logging.Level; 
     18import java.util.logging.Logger; 
     19 
    1720import com.l2jserver.gameserver.datatables.NpcTable; 
    18 import com.l2jserver.gameserver.idfactory.IdFactory; 
    1921import com.l2jserver.gameserver.model.L2Object; 
    2022import com.l2jserver.gameserver.model.L2Skill; 
     23import com.l2jserver.gameserver.model.L2Spawn; 
    2124import com.l2jserver.gameserver.model.StatsSet; 
    2225import com.l2jserver.gameserver.model.actor.L2Character; 
    2326import com.l2jserver.gameserver.model.actor.L2Npc; 
    24 import com.l2jserver.gameserver.model.actor.instance.L2BirthdayCakeInstance; 
    25 import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance; 
    2627import com.l2jserver.gameserver.model.actor.instance.L2TotemInstance; 
    27 import com.l2jserver.gameserver.model.actor.instance.L2XmassTreeInstance; 
    2828import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; 
    2929import com.l2jserver.util.Rnd; 
    3030 
     31/** 
     32 * @author Zoey76 
     33 */ 
    3134public class L2SkillSpawn extends L2Skill 
    3235{ 
     36        private static final Logger _log = Logger.getLogger(L2SkillSpawn.class.getName()); 
     37         
    3338        private final int _npcId; 
    3439        private final int _despawnDelay; 
     
    5055        public void useSkill(L2Character caster, L2Object[] targets) 
    5156        { 
    52                 int x, y; 
    53                  
    5457                if (caster.isAlikeDead()) 
     58                { 
    5559                        return; 
     60                } 
    5661                 
    5762                if (_npcId == 0) 
     
    6873                } 
    6974                 
    70                 final int id = IdFactory.getInstance().getNextId(); 
    71                 final L2Npc npc; 
    72                 if (template.isType("L2XmassTree")) 
     75                L2Spawn spawn; 
     76                try 
    7377                { 
    74                         npc = new L2XmassTreeInstance(id, template); 
     78                        spawn = new L2Spawn(template); 
    7579                } 
    76                 else if (template.isType("L2BirthdayCake")) 
     80                catch (Exception e) 
    7781                { 
    78                         npc = new L2BirthdayCakeInstance(id, template, caster.getObjectId()); 
    79                 } 
    80                 else if (template.isType("L2Totem")) 
    81                 { 
    82                         npc = new L2TotemInstance(id, template, _skillToCast); 
    83                 } 
    84                 else if (template.isType("L2WeddingCake")) 
    85                 { 
    86                          // TODO: npc = new L2WeddingCakeInstance(id, template); 
    87                         npc = new L2NpcInstance(id, template); 
    88                 } 
    89                 else 
    90                 { 
    91                         npc = new L2NpcInstance(id, template); 
     82                        _log.log(Level.WARNING, "Exception in L2SkillSpawn: " + e.getMessage(), e); 
     83                        return; 
    9284                } 
    9385                 
     86                int x = caster.getX(); 
     87                int y = caster.getY(); 
     88                if (_randomOffset) 
     89                { 
     90                        x += (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20)); 
     91                        y += (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20)); 
     92                } 
     93                 
     94                spawn.setLocx(x); 
     95                spawn.setLocy(y); 
     96                spawn.setLocz(caster.getZ() + 20); 
     97                spawn.setHeading(caster.getHeading()); 
     98                spawn.stopRespawn(); 
     99                 
     100                final L2Npc npc = spawn.doSpawn(_summonSpawn); 
    94101                npc.setName(template.getName()); 
    95102                npc.setTitle(caster.getName()); 
    96                 npc.setHeading(-1); 
    97                 npc.setShowSummonAnimation(_summonSpawn); 
     103                npc.setSummoner(caster); 
     104                if (_despawnDelay > 0) 
     105                { 
     106                        npc.scheduleDespawn(_despawnDelay); 
     107                } 
     108                npc.setIsRunning(false); // Broadcast info 
    98109                 
    99                 if (_randomOffset) 
     110                if ((npc instanceof L2TotemInstance) && (_skillToCast > 0)) 
    100111                { 
    101                         x = caster.getX() + (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20)); 
    102                         y = caster.getY() + (Rnd.nextBoolean() ? Rnd.get(20, 50) : Rnd.get(-50, -20)); 
     112                        ((L2TotemInstance) npc).setSkill(_skillToCast); 
     113                        ((L2TotemInstance) npc).setAITask(); 
    103114                } 
    104                 else 
    105                 { 
    106                         x = caster.getX(); 
    107                         y = caster.getY(); 
    108                 } 
    109                  
    110                 npc.spawnMe(x, y, caster.getZ() + 20); 
    111                 if (_despawnDelay > 0) 
    112                         npc.scheduleDespawn(_despawnDelay); 
    113115        } 
    114116} 
Note: See TracChangeset for help on using the changeset viewer.