[Project] Third Person Shooter

Discussion in 'Starcraft 2 (SC2) Editor Help' started by wingdnosring, May 10, 2010.

  1. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    Yeah, that's the way I had it before I made the whole thing one move order. When I changed the order I also made it detect where the bullet was. When I was checking collision ahead of the bullet, the impact effects tended to float in midair, which looked terrible. I really need something that can detect a unit the instant it hits the ground and stop it from moving any more.

    Welcome back Onisagi. Can you tell me what you meant by using the Grammar Text field to make a custom interface?

    I just added an awesome new parameter for weapon creation. Explosive Ammunition. It's exactly what it sounds like. Every bullet explodes upon contact with the ground or a unit. It gets a little messy :p.

    The "Create Weapon" Action seems to be getting a little too long...should I leave it all one line, or should I split it into Create Weapon (with the basic parameters), and Set Advanced Weapon parameters for Impale Effects, Explosive Ammo, etc;?
     
  2. onisagi

    onisagi New Member

    Ratings:
    +6 / 0 / -0
    last post on page 9, shows examples of grammar text.

    Well maybe there are some parameters you can leave out? or combine if they work closely with another one?

    I wouldn't be too worried, just set default values for your parameters so people only need to change parameters that they feel like changing. Grammar text will definitely help, you can make each parameter on separate lines to make it easier to look at.

    Simple Example:

    Create Weapon
    Bullet Model: <sphere>
    Damage: 10
    Explosive: False
    Impales: False
     
  3. onisagi

    onisagi New Member

    Ratings:
    +6 / 0 / -0
    weirdly enough... tricky's camera work looks almost exactly like mine. Yet my camera lags behind my unit's movements. Could it be that our camera is too close to our unit that it can't keep up? I'm using issue order to move my unit, and hes using instant move. Perhaps his unit move speed is tailored to the point where the camera can move fast enough to keep him centered. I just used the unit's default walking speed.

    I like how my camera is working now... but i'd like to try implementing over the shoulder, if i can get my camera to stick to my unit as close as his does.

    My idea for offset was to get an invisible unit to move in a circle around the player unit. The position would be a function of camera yaw, and the camera would follow the invisible unit. Wingd was using invisible units a few versions ago, not sure if hes still doing that. But this will definitely work, i just can't imagine how much stuttering will occur when moving a unit in a circle while following it with the camera. Hopefully none?
     
  4. SerraAvenger

    SerraAvenger Cuz I can

    Ratings:
    +236 / 0 / -0
    @demon: Please don't doublepost.
    @wing:
    A create weapon and a "Weapon Set Attribute (weapon, attribute, value)" action should do the trick. Doing a lot of stuff in one line only increases learning curve, adds unnecessary overhead and makes your stuff harder to use&read.
     
  5. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    Yeah. I don't want it to be TOO simple though. The last thing I want is for people to need to make an entirely different action for every weapon attribute for each weapon. Maybe just grouping certain ones together will do the trick.

    I can guarantee that's what mine is doing too. Both of us follow much more cloesly than he does. I tried messing with values to make it as fast as the unit's max speed, to no avail. Also, my system uses Instant movement, so that shouldn't be an issue.
     
  6. xxxtrickyxxx

    xxxtrickyxxx (o Y o)

    Ratings:
    +63 / 0 / -0
    hmm, i can follow as close as 0.01 and still have no real issue with stuttering. there could be a possible problem you are having with the move speed, but it does not seem logical that you would. the units should move relatively close to the actual movement speed they are given by default. however, simply using the units movement speed divided by 100 in some sense was not accurate so I multiplied it by the closest looking factor I could to represent an accurate speed it should be moving. Its not perfect, but movespeed * 0.03 was about as close as you should try but I found that a bit too slow for some units such as the marine.

    you can send me your map if you want to if you are still having stuttering issues and problems with the camera keeping up. and ill email you back what the problem was.

    ive spent a lot of time working with cameras and systems that are used by them like WASD and hit detection etc in Warcraft III so i can generally figure out any problems if you want to let me check the map out.
     
    Last edited: Apr 3, 2015
  7. SerraAvenger

    SerraAvenger Cuz I can

    Ratings:
    +236 / 0 / -0
    Checked cam distance and stuff?
     
  8. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    I'm pretty sure it's a problem with the camera rather than my movement. My marine seems to be moving quite smoothly when I revert back to my old camera system.

    You could probably use version six and get the same result I have. Just remove the Pan action from the Moving & Turning trigger.

    Then make a new trigger that runs at map init that makes the camera follow Controlled_Shooter[1].

    [Edit]: Is there any way to fade in or out an image for only one player? It just hit me that my aiming cursors would show up for every player simultaneously.

    I would also really like to be able to add in support for sniper rifles. As it is, no weapon can zoom beyond roughly 2.0 distance. To go beyond 2 I would need a negative camera value, which I don't think is possible. Can anybody else think of a way around this little issue?

    [Edit 2]: I have added a large section to the first post that explains each of the custom functions and actions in version 7 (which you don't have access to quite yet, but will soon). As you can see, with the amount of actions I've added in, there is no reason for people to mess about with my library's variables anymore (unless they're editing the actual Library). Is it possible to hide the variables in my library if you're working outside of it? I don't want people to have to wade through my ridiculously long list of variables to find their own.

    I tried actually changing the camera target to the zoom distance, but the problem is that the camera's rotation point becomes that zoom point rather than the marine. I then tried refreshing the camera to a specified rotation based on the facing angle of the shooter, but that also presents difficulties. Perhaps most important is that the scope literally skips over everything between the marine and the zoom distance, so you have no way of seeing if there is something in between you and your target.
     
  9. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    I'm getting that stupid error message all the time now.

    "Script Failed to Compile: Code jumps out of bounds (try reducing the size of very large functions or triggers)"

    I can't save all of my latest changes because of it. The only thing that's really changed is that I have alot of large arrays going now [14][4][4]. I've been breaking my larger triggers into smaller chunks that each make custom actions and then running them with a 'master' trigger, but I'm still getting this error.

    What's the deal? This editor seems way too limited if this is taxing it...
     
  10. Sensang

    Sensang TH.net Regular

    Ratings:
    +7 / 0 / -0
    mmh wasnt the size limit at about 5mb overall?
    Or maybe there was another one for code only and that was for models and stuff. If the size of your map hasnt increased too much from your current downloadable version there really shouldnt be any problem...

    Maybe it's a bug or the problem lies somewhere else?
     
  11. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    5 mb is the limit? That's awful, you can barely do anything with that. My map is quickly approaching 1 mb, and it barely has any data editor work done and no custom models.

    It's an issue within triggers themselves. I'm finding if I add one or two loops to an already long trigger, the whole thing crashes. Triggers can only be so long apparently...
     
  12. onisagi

    onisagi New Member

    Ratings:
    +6 / 0 / -0
    the limit is for sure over 8MB, thats the current limit for WC3, i believe. I forgot the actual numbers but i think SC2 has a limit of about 10MB to upload on bnet for the beta. size limits are subject to change on release. I've seen maps larger than 30-40MB already from sc2mapster, but not published on beta bnet.

    There's gotta be some sort of length limitation on single triggers. You need to consolidate your code a bit more.

    Btw, i'm still alive. I just came back from a week vacation.
     
  13. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    Ha! I was wondering. Yeah giving us access to make proper campaigns suggested the file size would be fairly high. WC3 came out nearly a decade ago (I think) and its limit was 4MB.

    I have been cleaning up my triggers a bit here and there. If you look on the first post, you'll see that I'm making a point of using custom functions/actions wherever I can to limit size and organize it a little better. Unfortunately, I discovered the hard way that custom functions have...issues when using them to determine an array size. It could just be that once again, I'm pushing the editor to its limits while also using custom functions, but I don't think so.

    Welcome back onisagi. Look back a couple of posts, I had some questions.

    And I'll add a new one here. Is it possible to check if a unit has a chance of hitting an enemy before firing? The only thing I can think of would be to run an instant bullet and see what it hits, which would tax people's systems too much. Allied units seem to just spray their bullets at walls right now and since they have limited ammo, that really sucks.
     
  14. Renendaru

    Renendaru (Evol)ution is nothing without love.

    Ratings:
    +309 / 0 / -0
    Well, that's a theoretical bullet, as tricky suggested. You basically have to calculate a proper trajectory, adding in any factors for a fall/drag effect if you wish, where it will arc, instead of simply drawing a line to that location. It runs periodically through points, instead of checking the end points, filtering for possible player, or environmental collisions.
     
  15. onisagi

    onisagi New Member

    Ratings:
    +6 / 0 / -0
    - Easiest way is to Show/Hide Dialog for different players depending on situation, and for dialog choice use the function "screen image dialog" and enter the screenImageID for your image (pay close attention to assigning screen image ID's to your different crosshairs).
    - I think the most efficient way if everyone pretty much uses the same set of screen images, is to initialize all screen images at the beginning using the screen image actions, and then hide all the ones that aren't being used at the beginning, and show/hide "screen image" dialogs to specific players as you need to (ie. zooming/scoping/running).
    - You can also copy/duplicate built-in library actions/functions and modify for you own purposes (like add parameters). But in this case its probably more efficient to use the original ones.

    I use the camera's "field of view" property to change zoom level, and i haven't hit any boundaries using that yet. Probably supports negative values? It's a relative value after all, because it doesn't move the actual camera's position. I haven't tested the boundaries of this property yet tho, so maybe i'm wrong.

    I recommending using local variables as much as possible, and only make global variables when you absolutely need to (like for constants that you can adjust). Local variables meaning the vars that are made inside actions/functions and are only visible internally. Pass in variables from the outside of these functions/actions using parameters. If its an function only used in specific actions or other functions, you don't need to be afraid of making use of too many parameters, because users of your library shouldn't be touching those core functions anyways. It's kinda the reason why some programming languages separate access to public and private functions and variables to prevent unintended access.

    it kinda depends on how you're making your units fire. You could check for collision first, basically what renendaru suggested. Don't NPC units have unlimited ammo usually? How about you just force units to stop firing and reload after ther ammo runs out for a set amount of time, and give them unlimited ammo. Or if you wanna make it more realistic, force them to go to a certain place to pick up more ammo wen they run out along with the reloading. Make ther reload location/object destructible... muahaha..
     
  16. wingdnosring

    wingdnosring New Member

    Ratings:
    +16 / 0 / -0
    I'm kicking myself for that one, that should have been obvious.

    Awesomeness, testing it momentarily.

    I do that :(. I think I only have two or three variables from way back at the start of this that could be local, but are global instead. All others are absolute musts. It's still a MASSIVE list. It seems like there should be some way to prevent them from being used outside of the library.

    Lmao. Seems like Instant bullet is the way to go. That really sucks. The system will be running twice as many bullets this way...

    My enemies reload realistically, and they have unlimited ammo. It's your allies that can run out. And as I said, right now they just spray it at the cover they're behind instead of using it wisely.

    [Edit]: Field of View seems to have the same limitations. It can only go from 10 to 120 and only in the wrong direction, since negative values aren't allowed.

    Having trouble with the AI state trigger now:

    Code:
            Unit Group - Remove all units from CloseEnemyGroup
            Unit Group - Pick each unit in (TPS Unit units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
                Actions
                    Unit Group - Add all units in (Units in (Region((Position of (Picked unit)), 15.0)) having alliance Enemy with player (Owner of (Picked unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount) to CloseEnemyGroup
            Unit Group - Pick each unit in CloseEnemyGroup and do (Actions)
                Actions
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            ((Picked unit) is in SearchingForCoverGroup) != true
                        Then
                            ------- Not In Cover
                            General - If (Conditions) then do (Actions) else do (Actions)
                            ------- In Cover Hiding
                            General - If (Conditions) then do (Actions) else do (Actions)
                                If
                                    ((Picked unit) has NullCoverHidingBuff) == true
                                Then
                                    ------- Aim in Cover
                                    Variable - Set FoundTarget = false
                                    Variable - Set PotentialTargetsGroup = (Units in (Region((Position of (Picked unit)), 15.0)) having alliance Enemy with player (Owner of (Picked unit)) matching Excluded: Missile, Dead, Hidden, Invulnerable, with at most Any Amount)
                                    General - For each integer GroupLoop from 1 to (Number of Living units in PotentialTargetsGroup) with increment 1, do (Actions)
                                        Actions
                                            General - If (Conditions) then do (Actions) else do (Actions)
                                                If
                                                    (Determine Open Target((Unit GroupLoop from PotentialTargetsGroup), (Picked unit))) == true
                                                Then
                                                    Unit - Remove 1 NullCoverHidingBuff from (Picked unit)
                                                    Unit - Add 1 NullCoverAimingBuff to (Picked unit) from (Owner of (Picked unit))
                                                    Unit - Enable the Attack ability for (Picked unit)
                                                    Unit - Order (Picked unit) to ( Attack (Unit GroupLoop from PotentialTargetsGroup)) (Replace Existing Orders)
                                                    UI - Display "Open Target" and play Marine_DeathFXSilentKill for (All players)
                                                    Variable - Set FoundTarget = true
                                                    General - Break
                                                Else
                                    General - If (Conditions) then do (Actions) else do (Actions)
                                        If
                                            FoundTarget == false
                                        Then
                                            General - If (Conditions) then do (Actions) else do (Actions)
                                                If
                                                    (Random integer between 0 and 100) <= 30
                                                Then
                                                    ------- Aim at Random
                                                    Unit - Remove 1 NullCoverHidingBuff from (Picked unit)
                                                    Unit - Add 1 NullCoverAimingBuff to (Picked unit) from (Owner of (Picked unit))
                                                    Unit - Enable the Attack ability for (Picked unit)
                                                    UI - Display "aim at random" and play Marine_DeathFXSilentKill for (All players)
                                                Else
                                                    General - If (Conditions) then do (Actions) else do (Actions)
                                                        If
                                                            (Random integer between 0 and 100) <= 30
                                                        Then
                                                            ------- Off Cover
                                                            Unit - Remove 1 NullCoverHidingBuff from (Picked unit)
                                                            Unit - Enable the Attack ability for (Picked unit)
                                                            UI - Display "off cover" and play Marine_DeathFXSilentKill for (All players)
                                                        Else
                                                            ------- Keep Hiding
                                                            Unit - Make (Picked unit) face ((Angle from (Position of (Picked unit)) to (Position of (Closest unit to (Position of (Picked unit)) in (Short Cover units in (Region((Position of (Picked unit)), 4.0)) owned by player Any Player matching Required: Destructible, with at most Any Amount)) over 0.0 seconds
                                                            UI - Display "hide" and play Marine_DeathFXSilentKill for (All players)
                                        Else
                                Else
                                    ------- In Cover Aiming
                                    General - If (Conditions) then do (Actions) else do (Actions)
                                        If
                                            ((Picked unit) has NullCoverAimingBuff) == true
                                        Then
                                            ------- Continue Aiming
                                            Variable - Set FoundTarget = false
                                            Variable - Set PotentialTargetsGroup = (Units in (Region((Position of (Picked unit)), 15.0)) having alliance Enemy with player (Owner of (Picked unit)) matching Excluded: Missile, Dead, Hidden, Invulnerable, with at most Any Amount)
                                            General - For each integer GroupLoop from 1 to (Number of Living units in PotentialTargetsGroup) with increment 1, do (Actions)
                                                Actions
                                                    General - If (Conditions) then do (Actions) else do (Actions)
                                                        If
                                                            (Determine Open Target((Unit GroupLoop from PotentialTargetsGroup), (Picked unit))) == true
                                                        Then
                                                            Unit - Order (Picked unit) to ( Attack (Unit GroupLoop from PotentialTargetsGroup)) (Replace Existing Orders)
                                                            UI - Display "open target" and play Marine_DeathFXSilentKill for (All players)
                                                            Variable - Set FoundTarget = true
                                                            General - Break
                                                        Else
                                            General - If (Conditions) then do (Actions) else do (Actions)
                                                If
                                                    FoundTarget == false
                                                Then
                                                    General - If (Conditions) then do (Actions) else do (Actions)
                                                        If
                                                            (Random integer between 0 and 100) <= 80
                                                        Then
                                                            ------- Hide in Cover
                                                            Unit - Remove 1 NullCoverAimingBuff from (Picked unit)
                                                            Unit - Add 1 NullCoverHidingBuff to (Picked unit) from (Owner of (Picked unit))
                                                            Unit - Disable the Attack ability for (Picked unit)
                                                            UI - Display "hide in cover" and play Marine_DeathFXSilentKill for (All players)
                                                        Else
                                                            General - If (Conditions) then do (Actions) else do (Actions)
                                                                If
                                                                    (Random integer between 0 and 100) <= 10
                                                                Then
                                                                    ------- Off Cover
                                                                    Unit - Remove 1 NullCoverAimingBuff from (Picked unit)
                                                                    UI - Display "off Cover" and play Marine_DeathFXSilentKill for (All players)
                                                                Else
                                                Else
                                        Else
                        Else
            Timer - Start AI State Timer as a One Shot timer that will expire in (Random real between 2.0 and 10.0) Game Time seconds
    
    Yeah..it's long. Anyways, I keep getting the following errors, which I think take place within the "open target" sections. I know there's a lot of error messages, that's simply because I'm trying to narrow down the problem area. The error I'm getting is "Nested Iteration Detected", but I don't see the issue. I'm not even entirely sure what the Nested Iteration implies, though I have a guess. Sorry ahead of time for it being so damn hard to read.

    Here's the function "Determine open target"

    Code:
    Determine Open Target
        Options: Function
        Return Type: Boolean
        Parameters
            Target = No Unit <Unit>
            Attacker = No Unit <Unit>
        Grammar Text: Determine Open Target(Target, Attacker)
        Hint Text: Determines whether one unit can hit an enemy while aiming at another.  NOTE: this can slow the game down if performed too often.  Use only when necessary.
        Custom Script Code
        Local Variables
            Loop = 0 <Integer>
            InstantCheckPoint = (Position of Attacker) <Point>
            AngleOfAttack = (Angle from InstantCheckPoint to (Position of Target)) <Real>
            Height = (0.5 + ((Ground height at InstantCheckPoint) + (Height of Attacker))) <Real>
            Distance = (Distance between (Position of Target) and InstantCheckPoint) <Real>
            Number of Runs = (Distance / 1.5) <Real>
            PotentialColGroup = (Empty unit group) <Unit Group>
            PotentialColRemovalGroup = (Empty unit group) <Unit Group>
            TargetHeight = 0.0 <Real>
        Actions
            General - For each integer Loop from 1 to (Max((Integer((Distance / 1.5))), 1)) with increment 1, do (Actions)
                Actions
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            Height > (Ground height at InstantCheckPoint)
                        Then
                            Variable - Modify Height: + ((((Ground height at (Position of Attacker)) + (Height of Attacker)) - ((Ground height at (Position of Target)) + (Height of Target))) / Number of Runs)
                            Variable - Set InstantCheckPoint = (InstantCheckPoint offset by 1.5 towards AngleOfAttack degrees)
                            Variable - Set PotentialColGroup = (Units in (Region(InstantCheckPoint, 3.0)) having alliance Enemy with player (Owner of Attacker) matching Excluded: Missile, Dead, Hidden, Invulnerable, with at most Any Amount)
                            ------- Add potential cover to target group
                            Unit Group - Add all units in (Any units in (Region(InstantCheckPoint, 3.0)) owned by player Any Player matching Required: Destructible, with at most Any Amount) to PotentialColGroup
                            Unit Group - Pick each unit in PotentialColGroup and do (Actions)
                                Actions
                                    ------- Sets the unit's height to its supply cost/10.  If the unit is behind cover, that value is halved
                                    General - If (Conditions) then do (Actions) else do (Actions)
                                        If
                                            ((Unit Loop from PotentialColGroup) has NullCoverHidingBuff) == true
                                        Then
                                            Variable - Set TargetHeight = (((Unit type of (Unit Loop from PotentialColGroup)) Supplies Used) / 20.0)
                                        Else
                                            Variable - Set TargetHeight = (((Unit type of (Unit Loop from PotentialColGroup)) Supplies Used) / 10.0)
                                    General - If (Conditions) then do (Actions) else do (Actions)
                                        If
                                            ------- If any of the below conditions are true, the unit is removed from the potential target group
                                            Or
                                                Conditions
                                                    (Unit Loop from PotentialColGroup) == No Unit
                                                    (Distance between InstantCheckPoint and (Position of (Unit Loop from PotentialColGroup))) > (((Unit type of (Unit Loop from PotentialColGroup)) Radius) * 2.0)
                                                    (Abs((((Height of (Unit Loop from PotentialColGroup)) + (Ground height at (Position of (Unit Loop from PotentialColGroup)))) - Height))) > TargetHeight
                                                    Height < ((Height of (Unit Loop from PotentialColGroup)) + (Ground height at (Position of (Unit Loop from PotentialColGroup))))
                                                    ((Unit Loop from PotentialColGroup) is Dead) == true
                                        Then
                                        Else
                                            General - If (Conditions) then do (Actions) else do (Actions)
                                                If
                                                    ((Unit type of (Unit Loop from PotentialColGroup)) is Destructible) == true
                                                Then
                                                    General - Return false
                                                    General - Skip remaining actions
                                                Else
                                                    General - Return true
                                                    General - Skip remaining actions
                            General - Wait 0.0 Game Time seconds
                        Else
                            General - Return false
            General - Return false
    
    [Edit 2]: The Nested Iteration is only part of the problem. I changed the Determine Open Target function to create flames as it checked points, so I could make sure it's trajectory was right. It was bang on, but it was about 4 height or so above it's target's head from beginning to end. Why would the Determine Open Target function be checking things so high above the terrain?
     
  17. onisagi

    onisagi New Member

    Ratings:
    +6 / 0 / -0
    you should comment each variable you're setting, and why you're adding say:
    Height = (0.5 + ((Ground height at InstantCheckPoint) + (Height of Attacker))) <Real>

    im guessing 0.5 is where you want it to start, ground height at instantcheckpoint is to offset for ground height if your on a hill for effects that are ignoring terrain, and height of attacker is?

    a weird height could just be you're adding something unnecessary. Make sure everything you're adding to height makes sense, and has a definite purpose.

    Constants like 0.5 can be made into a constant var. It'll then have a label that people can more relate to. Unless of course this is the only place you'll ever use it, and any other value would not work. Which is rarely true.

    Aside from primary function of a section of code, commenting all variables and why u set them a certain way is pretty important to help other people understand your code better. It's nice to see you're getting proficient with custom actions/functions. I think the next step is incorporating your own galaxy custom scripts into your library. Everything just runs more smoothly with native code, rather than all this stuff Blizz created to make it more user friendly.
     
  18. SerraAvenger

    SerraAvenger Cuz I can

    Ratings:
    +236 / 0 / -0
    nonsense.
     
  19. Renendaru

    Renendaru (Evol)ution is nothing without love.

    Ratings:
    +309 / 0 / -0
    Serra speaks the truth, as GUI is actually pretty efficient except for the period limitation which is fixed by 0.00 periods. If you look at the script when using GUI, it's just about the same as pure Galaxy code, minus the formatting of the code.
     
  20. SerraAvenger

    SerraAvenger Cuz I can

    Ratings:
    +236 / 0 / -0
    I do very often, but in this thread noone ever listens to me. Since I'm quite lazy I stopped posting more than one word per reply. This thread definetly ain't worth it. This is an exception to tell the OP that he should really change the way he interacts with his helpers, or he'll never manage to finish this cute project of his.
     

Share This Page