Packets?

Discussion in 'Plugin Development' started by PHILLIPS_71, May 6, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    PHILLIPS_71

    Im wanting to make a interact event so if a player were to right cloc it would make them go invisible i think it involves packet i have never felt with packets so i have no idea how to do that any help will be much appreciated.
     
  2. Offline

    kiwhen

    No need to go that far. You can use the good old hidePlayer()-method. This is method found in the Player object, and it takes a Player as an argument.

    The player passed as the argument is hidden from the player you run the hidePlayer()-method on. Something like this:
    Code:java
    1.  
    2. Player frank = someEvent.getPlayer();
    3. Player pete = someEvent.getOtherPlayer();
    4.  
    5. frank.hidePlayer(pete);
    6.  

    Pete can now see Frank, but Frank can't see Pete.
     
  3. Offline

    PHILLIPS_71

    Ahh ok, how would I make it so if they were to right click with let's say a iron ingot it would make them invisable for only 6 seconds? kiwhen
     
  4. Offline

    skore87

  5. Offline

    kiwhen

    You would need to look into the PlayerInteractEvent for fetching those right clicks, combined with the Bukkit scheduler, which will allow you to store a task for later use; for example un-hiding a player after 6 seconds.

    For example:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(final PlayerInteractEvent e) { // e.getPlayer() must be final for use with scheduler
    3. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    4. // Right click
    5. if(e.hasItem()) {
    6. // Player has item
    7. if(e.getItem().getType() == Material.IRON_INGOT) {
    8. // Iron ingot
    9.  
    10. // Hide this player from everyone on the server
    11. for(Player subject : Bukkit.getOnlinePlayers()) {
    12. subject.hidePlayer(e.getPlayer());
    13. }
    14.  
    15. // In 6 seconds, reveal the player again
    16. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    17. public void run() {
    18. for(Player subject : Bukkit.getOnlinePlayers()) {
    19. subject.showPlayer(e.getPlayer());
    20. }
    21. }
    22. }, 120L); // 20 ticks * 6 = 120 (L = long, datatype)
    23. }
    24. }
    25. }
    26. }


    Note that with hidePlayer(), players who join in after the player is supposed to be hidden will still see them. You should probably write a method to fix that. Also, if the server reloads, hidden players become visible again.
     
  6. Offline

    skore87

    You would think bukkit would at least house a list of hidden players or maintain hidden players on join. =\
     
  7. Offline

    PHILLIPS_71

    kiwhen
    This is what i have

    Code:
    package me.PHILLIPS_71;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class ASmokeBomb extends JavaPlugin implements Listener {
     
        public void onEnable()
        {
            getServer().getPluginManager().registerEvents(this, this);
        }
     
        @EventHandler
        public void onPlayerInteract(final PlayerInteractEvent e) {
            final Player player = e.getPlayer();
            if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if(e.hasItem()) {
                    if(e.getItem().getType() == Material.IRON_INGOT) {
                        for(Player subject : Bukkit.getOnlinePlayers()) {
                            subject.hidePlayer(e.getPlayer());
                            player.sendMessage(ChatColor.AQUA + "You vanished");
                        }
     
                        Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                            public void run() {
                                for(Player subject : Bukkit.getOnlinePlayers()) {
                                    subject.showPlayer(e.getPlayer());
                                    player.sendMessage(ChatColor.AQUA + "You appeared!");
                                 
                                }
                            }
                        }, 120L);
                    }
                }
            }
        }
     
    }
    But i get an error in console with the delayed task
    Code:
      Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    
     
  8. Offline

    kiwhen

    It usually helps to include the error message as we're not psychic. :)

    I've tested your code as-is, and it works like a charm, no errors. I compile with the latest beta of craftbukkit (1.5.2) using Java Runtime Environment 7. Not that it should matter for a simple code like this, I'd imagine any version past 1.3.2 and JRE 6 should be fine.

    Please post your stacktrace, and I'll have a look. :)
     
  9. Offline

    PHILLIPS_71

    kiwhen
    This is the error

    Code:
    C:\Users\Jordan\Desktop\Java\Custom plugin server 1.4.7>java -Xms1024M -Xmx1024M
    -jar craftbukkit.jar -o true
    229 recipes
    27 achievements
    13:10:22 [INFO] Starting minecraft server version 1.5.1
    13:10:22 [INFO] Loading properties
    13:10:22 [INFO] Default game type: SURVIVAL
    13:10:22 [INFO] Generating keypair
    13:10:23 [INFO] Starting Minecraft server on *:25565
    13:10:23 [INFO] This server is running CraftBukkit version git-Bukkit-1.5.1-R0.1
    -21-g49b0699-b2754jnks (MC: 1.5.1) (Implementing API version 1.5.1-R0.2)
    13:10:23 [INFO] [SCCore] Loading SCCore v1.0
    13:10:23 [INFO] [SCPVP] Loading SCPVP v1.0
    13:10:23 [INFO] Preparing level "world"
    13:10:23 [INFO] Preparing start region for level 0 (Seed: -4323459720753503444)
    13:10:24 [INFO] Preparing start region for level 1 (Seed: 6377317237128306866)
    13:10:24 [INFO] Preparing spawn area: 45%
    13:10:24 [INFO] [SCCore] Enabling SCCore v1.0
    13:10:24 [INFO] [SCPVP] Enabling SCPVP v1.0
    13:10:24 [INFO] Server permissions file permissions.yml is empty, ignoring it
    13:10:24 [INFO] Done (1.313s)! For help, type "help" or "?"
    13:10:24 [INFO] ----- Bukkit Auto Updater -----
    13:10:24 [INFO] It appears that you're running a Beta Build, when you've specifi
    ed in bukkit.yml that you prefer to run Recommended Builds.
    13:10:24 [INFO] If you would like to be kept informed about new Beta Build relea
    ses, it is recommended that you change 'preferred-channel' in your bukkit.yml to
    'beta'.
    13:10:24 [INFO] With that set, you will be told whenever a new version is availa
    ble for download, so that you can always keep up to date and secure with the lat
    est fixes.
    13:10:24 [INFO] If you would like to disable this warning, simply set 'suggest-c
    hannels' to false in bukkit.yml.
    13:10:24 [INFO] ----- ------------------- -----
    13:10:47 [INFO] PHILLIPS_71[/25.86.207.3:51878] logged in with entity id 339 at
    ([world] 28.862059469686365, 77.0, 148.45178913372393)
    13:10:56 [SEVERE] Could not pass event EntityDamageByEntityEvent to SCPVP v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callEvent(Craf
    tEventFactory.java:88)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callEntityDama
    geEvent(CraftEventFactory.java:376)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.handleEntityDa
    mageEvent(CraftEventFactory.java:401)
            at net.minecraft.server.v1_5_R2.EntityLiving.damageEntity(EntityLiving.j
    ava:677)
            at net.minecraft.server.v1_5_R2.EntityAnimal.damageEntity(SourceFile:119
    )
            at net.minecraft.server.v1_5_R2.EntityArrow.l_(EntityArrow.java:229)
            at net.minecraft.server.v1_5_R2.World.entityJoinedWorld(World.java:1355)
     
            at net.minecraft.server.v1_5_R2.WorldServer.entityJoinedWorld(WorldServe
    r.java:614)
            at net.minecraft.server.v1_5_R2.World.playerJoinedWorld(World.java:1336)
     
            at net.minecraft.server.v1_5_R2.World.tickEntities(World.java:1224)
            at net.minecraft.server.v1_5_R2.WorldServer.tickEntities(WorldServer.jav
    a:480)
            at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:5
    62)
            at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:2
    25)
            at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:4
    76)
            at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java
    :409)
            at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:5
    73)
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_5_R2.entity.C
    raftCow cannot be cast to org.bukkit.entity.Player
            at me.PHILLIPS_71.APoisionDagger.PoisionDagger(APoisionDagger.java:25)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 19 more
    13:11:00 [SEVERE] Could not pass event EntityDamageByEntityEvent to SCPVP v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callEvent(Craf
    tEventFactory.java:88)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callEntityDama
    geEvent(CraftEventFactory.java:376)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.handleEntityDa
    mageEvent(CraftEventFactory.java:401)
            at net.minecraft.server.v1_5_R2.EntityLiving.damageEntity(EntityLiving.j
    ava:677)
            at net.minecraft.server.v1_5_R2.EntityAnimal.damageEntity(SourceFile:119
    )
            at net.minecraft.server.v1_5_R2.EntityArrow.l_(EntityArrow.java:229)
            at net.minecraft.server.v1_5_R2.World.entityJoinedWorld(World.java:1355)
     
            at net.minecraft.server.v1_5_R2.WorldServer.entityJoinedWorld(WorldServe
    r.java:614)
            at net.minecraft.server.v1_5_R2.World.playerJoinedWorld(World.java:1336)
     
            at net.minecraft.server.v1_5_R2.World.tickEntities(World.java:1224)
            at net.minecraft.server.v1_5_R2.WorldServer.tickEntities(WorldServer.jav
    a:480)
            at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:5
    62)
            at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:2
    25)
            at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:4
    76)
            at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java
    :409)
            at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:5
    73)
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_5_R2.entity.C
    raftCow cannot be cast to org.bukkit.entity.Player
            at me.PHILLIPS_71.APoisionDagger.PoisionDagger(APoisionDagger.java:25)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 19 more
    >reload
    13:12:04 [INFO] [SCPVP] Disabling SCPVP v1.0
    13:12:04 [INFO] [SCCore] Disabling SCCore v1.0
    13:12:04 [INFO] 229 recipes
    13:12:04 [INFO] [SCCore] Loading SCCore v1.0
    13:12:04 [INFO] [SCPVP] Loading SCPVP v1.0
    13:12:04 [INFO] [SCCore] Enabling SCCore v1.0
    13:12:04 [INFO] [SCPVP] Enabling SCPVP v1.0
    13:12:04 [INFO] Server permissions file permissions.yml is empty, ignoring it
    13:12:04 [INFO] CONSOLE: Reload complete.
    13:12:20 [SEVERE] Could not pass event PlayerInteractEvent to SCPVP v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:185)
            at net.minecraft.server.v1_5_R2.PlayerInteractManager.interact(PlayerInt
    eractManager.java:370)
            at net.minecraft.server.v1_5_R2.PlayerConnection.a(PlayerConnection.java
    :632)
            at net.minecraft.server.v1_5_R2.Packet15Place.handle(SourceFile:58)
            at net.minecraft.server.v1_5_R2.NetworkManager.b(NetworkManager.java:292
    )
            at net.minecraft.server.v1_5_R2.PlayerConnection.d(PlayerConnection.java
    :110)
            at net.minecraft.server.v1_5_R2.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.v1_5_R2.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:5
    80)
            at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:2
    25)
            at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:4
    76)
            at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java
    :409)
            at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:5
    73)
    Caused by: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to r
    egister task while disabled
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.validate(Craf
    tScheduler.java:394)
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.runTaskTimer(
    CraftScheduler.java:120)
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.scheduleSyncR
    epeatingTask(CraftScheduler.java:116)
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.scheduleSyncD
    elayedTask(CraftScheduler.java:100)
            at me.PHILLIPS_71.ASmokeBomb.onPlayerInteract(ASmokeBomb.java:31)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 16 more
    >
     
  10. Offline

    MCForger

    PHILLIPS_71
    What is line 25 in your PoisionDagger class? Your apparently casting a cow to a player?
     
  11. Offline

    kiwhen

    Are you sure that you are running the PlayerInteractEvent in your plugin's main class? The error states that the plugin which is trying to register the event is not enabled. That can only mean that the keyword "this" does not refer to your main class. The keyword "this", in this particular context, refers to the class itself ("ASmokeBomb"), and Bukkit does not recognize this as a main class for any plugin.

    If this is the case, you will need to change the keyword "this" into an object containing the running instance of your main class. The best way to do this is to use a constructor. In your main class, you probably have a code for registering the event listener. It should look something like this:
    Code:java
    1. getServer().getPluginManager().registerEvents(new ASmokeBomb(), this);

    In order to access the running instance of your main class inside the ASmokeBomb class, you need to pass it as an argument. Like I said, the keyword "this" refers to the class itself, so you can simply change the line above to this:
    Code:java
    1. getServer().getPluginManager().registerEvents(new ASmokeBomb(this), this);

    Notice how the keyword "this" is passed to your listener class.

    This should produce an error saying that the constructor for ASmokeBomb is not defined. Open up that class, and type in this piece of code somwhere in that class (outside any methods like onEnable() and onPlayerInteract(), of course):
    Code:java
    1. private Main plugin;
    2. public ASmokeBomb(Main plugin) {
    3. this.plugin = plugin;
    4. }

    Replace the word "Main" in this code with the name of your main class. This code creates a private object (only accessible in the ASmokeBomb class). The object "is" actually your main class, but it is not initialized. This means the object is a main class type, but it equals null for now. The second line of code is the constructor. A constructor is an access-point for a class, which means that it contains the code that will run when the class is initialized. Listener classes are usually initialized by the registering of events, like you do with registerEvents() in your main class. A single argument is given, "plugin", which is also a main class type. The only code inside the constructor is a line stating that the argument "plugin" is to be stored in the private object "plugin". You have to use the keyword "this" here, because the private object has the same name as the argument (both are called "plugin").

    The result of this is that you have the object "plugin", which now represents the running instance of your main class. Replace the keyword "this" with "plugin" down in the scheduler-code, and you should be good to go.

    Also, if this does solve your problem, you should probably remove the onEnable()-method from the ASmokeBomb class, as this method only should be run from your main class, once. It's just dead code sitting there.
     
    PHILLIPS_71 likes this.
  12. Offline

    PHILLIPS_71

    kiwhen
    Thanks you soo much!! really appreciated all works now, the only issue i'm getting is when a player reapares it send them a message letting the player who vanished to let them know that they are not visible but it is sending it to all the layers on the server for some reason also i was thinking of adding a smoke effect so when they vanish they leave a trail of smoke but how do i get it to play the effect every 10 ticks?

    Code:
                            if (player.getItemInHand().getType().getId() == 265) {
                                for(Player subject : Bukkit.getOnlinePlayers()) {
                                    subject.hidePlayer(e.getPlayer());
                                    location.getWorld().playEffect(location, Effect.SMOKE, 10);
                                    location.getWorld().createExplosion(location, 0F);
     
                                }
     
    Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                                    public void run() {
                                        for(Player subject : Bukkit.getOnlinePlayers()) {
                                            player.sendMessage(ChatColor.BLUE + "You have reappeared.");
                                            subject.showPlayer(e.getPlayer());
                                        }
                                    }
                                }, 120L);
     
  13. Offline

    Superkabii

    This isn't how the API works, you're hiding a specific player from another specific player. The closest equivalent to what you're thinking of is Player's canSee(Player) method.
     
  14. Offline

    kiwhen

    It doesn't send the message to everyone on the server, but it sends it once for every player there is. The reason this happens, is because you have placed the sendMessage()-method inside the for-loop. The loop iterates getOnlinePlayers(), which means the code inside runs once for every player currently online. Just move the sendMessage() outside the brackets of the for-loop, and everything will return to normal.

    To play an effect every 10 ticks, you have to use the scheduler again. Same procedure as with the re-appearing, really, just change the last argument to 10 (down from 120, which equals 6 seconds). This argument counts in ticks. However, the smoke is going to prove difficult, because the effect is so small, it will take a lot of effects to cover up the player's disappearance. Does it have to be smoke? There are other effects which covers a lot more of the affected area, for example the MOBSPAWNER_FLAMES-effect. This is the simple flame effect that you see inside mob spawners.

    Here is a sample code adjusted to create such an effect, with a large TNT-explosion as well:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e) {
    3. if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK)
    4. return; // Not a right-click
    5. if(!e.hasItem())
    6. return; // No item
    7. if (e.getItem().getType() != Material.IRON_INGOT)
    8. return; // Not iron ingot
    9.  
    10. // Grab objects for convenience
    11. final Player p = e.getPlayer();
    12. Location pos = p.getLocation();
    13.  
    14. // Hide from all players on the server
    15. for(Player subject : Bukkit.getOnlinePlayers()) {
    16. subject.hidePlayer(e.getPlayer());
    17. }
    18. p.sendMessage(ChatColor.BLUE + "You have vanished!");
    19.  
    20. // Create a puff of smoke/flames and a cool explosion
    21. Location smokePos = pos.clone(); // Just a copy of pos that we can modify
    22. for(int i = 0; i < 10; i++) { // Repeat the following code for more smoke (or flames)!
    23. // Generate a random position near the player, and shift smokePos to that position
    24. smokePos.setX((smokePos.getX() - 0.5) + Math.random()); // Random offset within 0,5 blocks of the player's position
    25. smokePos.setY((smokePos.getY() + 0.5) + Math.random());
    26. smokePos.setZ((smokePos.getZ() - 0.5) + Math.random());
    27.  
    28. // Play effects
    29. smokePos.getWorld().playEffect(smokePos, Effect.MOBSPAWNER_FLAMES, 4);
    30. smokePos.getWorld().createExplosion(smokePos, 0F);
    31.  
    32. // Reset smokePos to the players center again
    33. smokePos = pos.clone();
    34. }
    35.  
    36. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    37. public void run() {
    38. for(Player subject : Bukkit.getOnlinePlayers()) {
    39. subject.showPlayer(p);
    40. }
    41. p.sendMessage(ChatColor.RED + "You have re-appeared!");
    42. }
    43. }, 120L);
    44. }

    There are a couple of other differences from the previous code too. I thought I might as well show you a "better" way of dealing with multiple conditional statements. In this particular case, you need to verify that the player has right-clicked either air or a block (any kind of right-clicking), that the event involved an item, and that this item is of a certain type. You cannot pass all of these simultaneously, becase that will throw a NullPointerException-error in some cases. My technique for cleaning up the code is called negating. This means that I simply turn the if-statements around. I'm not checking to see if the player has right-clicked, I'm checking if he/she didn't right-click. If it's not a right-click, I just end the method using "return". Notice that brackets are not required when an if-statement only applies to a single statement. The benefit of this is that we get rid of three indents and a ton of curly brackets. The code is a lot easier to read this way, and the result is exactly the same.

    Since we are adding a convenience reference to the player object (p), we don't need to set the whole event to final anymore - just the player object.

    Also, in the lower section, you will see my method for creating a fiery disappearance. I grab the players location and copy it to a temporary Location object (smokePos). I start a for-loop which will repeat 10 times. Inside, I change the coordinates of the temporary location. I first subtract a small amount (0,5 units) from each, and then add a random number between 0 and 1 (not inclusive, so technically between 0 and 0,99999...). This will give us a random position that is very close to the player. I add some effects to this location, reset the temporary position and calculate another random position.

    You can easily do the same for smoke, but it won't look very good. The smoke is just not "smoky" enough to make for a good smokescreen.

    PS: I've added the number "4" into the effect-method. If used with smoke, "4" will result in smoke going straight up, not blowing sideways. With the flame effect, this number is useless.
     
    PHILLIPS_71 likes this.
Thread Status:
Not open for further replies.

Share This Page