SUPPORT ACCOUNT CLANS
Welcome, Unregistered.
 

Thread: How would you make CTF?

Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25
  1. #21
    Offline
    Account Icon
    Join Date
    Jul 2009
    Location
    Minnesnowta
    Posts
    2,085
    So, got it working for the most part here (even with them spawning at the beginning of the match without player interaction), but there's still one glitch: the very first time each "flag" is grabbed, it spawns 2. Circumstances don't matter, both enemy and ally grabs spawn a second flag.

    I'll post the code I have later, to see if someone can figure out why it's going on.
    HONOR- If you need it defined, you don't have it.

  2. #22
    when it comes to CTF what i'd do is rather than having a player "pick up a flag", I'd make a flag a monkey like criter or simply limit the speed of the carrier, and if he uses any escape mechanism the flag would just drop.

  3. #23
    Offline
    Account Icon
    Chat Symbol
    Join Date
    Jun 2009
    Location
    Belgium
    Posts
    415
    Quote Originally Posted by dandylion View Post
    I'll post the code I have later, to see if someone can figure out why it's going on.
    I'm looking forward
    Good luck with it!
    My Custom Maps
    Rampage Runner (SP) - showthread.php?t=255701
    SokoHoN (SP) - showthread.php?t=246141
    Chess of Newerth (MP) - showthread.php?t=312907

  4. #24
    Offline
    Account Icon
    Join Date
    Jul 2009
    Location
    Minnesnowta
    Posts
    2,085
    So... still combating my "double spawn" issue. I tried making an affector that killed any other flags, but it was essentially killing ALL the flags, even with using ignore and conditional tests... frustrating to say the least... but for the most part, the rest of it works well.

    I use a neutral_goat prespawned into the map for initial spawning of the flag (he's perched on a cliff over the flag area for constant vision of your flag), and then use that as the "predefined location" to spawn additional flags after scoring and whatnot.

    goat spawn ability:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <ability
        name="Ability_SpawnFlags"
        
        actiontype="self_position"
        icon="/items/powerups/speed/icon.tga"    
    >
        <onspawn>
            <compare a="team" b="source_team" op="eq">
                <compare a="team" b="1" op="eq">
                    <setent0 name="legionBase"/>
                    <spawnunit name="Powerup_Damage" target="ent0" offset="0 250" pushentity="true" />
                </compare>
                <else>
                    <setent1 name="hellbourneBase"/>
                    <spawnunit name="Powerup_MoveSpeed" target="ent1" offset="0 250" pushentity="true" />
                </else>
            </compare>
        </onspawn>
    </ability>
    flag entity (as a powerup, there's a different unit for each team, but you can imagine that they correspond to each other, but opposite)
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <powerup
        name="Powerup_Damage"
        
        icon="icon.tga"
        portrait="icon.tga"
        model="/items/powerups/damage/model.mdf"
        skin=""
        
        passiveeffect="/items/powerups/damage/effects/passive.effect"
        spawneffect="/items/powerups/damage/effects/spawn.effect"
        respawneffect=""
        selectsound=""
        orderconfirmedsound=""
        
        preglobalscale="1.7"
        modelscale="1"
        effectscale="0.9"
        boundsheight="32"
        boundsradius="16"
        selectionradius="32"
        targetoffset="0 0 16"
    
        immunity="GadgetImmunity"
    
        attacktype="none"
        combattype="Ranged"
        corpsetime="300"
        corpsefadetime="0"
        deathtime="0"
        
        touchtargetscheme="all_heroes"
        touchsound=""
    >
    
        <ontouched>
            <compare a="team" b="target_team" op="eq">
                <!-- if you have the flag, you score -->
                <condition test="hasstate State_HasFlagHell" target="target_entity">
                    <expirestate name="State_HasFlagHell" target="target_entity"/>
                    <!-- now reset the enemy flag -->
                    <compare a="team" b="1" op="eq">
                        <setent0 name="hellbourneBase"/>
                        <spawnunit name="Powerup_MoveSpeed" target="ent0" offset="0 -250" team="2"/>
                    </compare>
                    <else>
                        <setent1 name="legionBase"/>
                        <spawnunit name="Powerup_Damage" target="ent1" offset="0 250" team="1"/>
                    </else>
                </condition>
                <!-- spawn the flag again -->
                <spawnunit name="Powerup_Damage" target="this_position" fixedposition="true"/>
            </compare>
            <else>
                <!-- pick up the enemy flag -->
                <applystate name="State_HasFlagLeg" duration="-1" />
            </else>
        </ontouched>
        
        <modifier key="dropped" >
            <ontouched>
                <compare a="team" b="target_team" op="eq">
                    <!-- teleport your ally flag back to your base -->
                    <compare a="team" b="1" op="eq">
                        <setent0 name="legionBase"/>
                        <spawnunit name="Powerup_Damage" target="ent0" offset="0 250" pushentity="true" />
                        <deactivatemodifierkey entity="stack_entity" name="dropped" />
                    </compare>
                </compare>
                <else>
                    <!-- pick up the enemy flag -->
                    <applystate name="State_HasFlagLeg" duration="-1" />
                </else>
            </ontouched>    
        </modifier>  
    </powerup>
    states applied to flag carriers
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <state
        name="State_HasFlagLeg"
        
        icon="/items/powerups/damage/icon.tga"
        passiveeffect="/items/powerups/damage/effects/state.effect"
        
        silenced="true"
        perplexed="true"
        revealed="true"
        
        effecttype=""
    >
        <oninflict>
            <printdebuginfo />
        </oninflict>
        
        <ondeath>
            <!-- to calculate the opposite team, do 3-1=2 or 3-2=1 -->
            <setvar0 a="3" b="team" op="sub"/>
            <spawnunit name="Powerup_Damage" target="source_position" team="var0" pushentity="true"/>
            <activatemodifierkey name="dropped" entity="stack_entity"/>           
        </ondeath>
    </state>
    Still not picking up why a second flag spawns on the first <ontouch> activation of each flag. Thinking of adding an initial charge to it, where after the first, it loses a charge and then spawns a new flag, hopefully to fix the double spawn on first contact issue, but if anyone has any other ideas or explanations as to why it happens, feel free to give me your input.
    HONOR- If you need it defined, you don't have it.

  5. #25
    Offline
    Account Icon
    Chat Symbol
    Join Date
    Jun 2009
    Location
    Belgium
    Posts
    415
    I think that the <onspawn> of your spawn goat (makes my day ) triggers multiple frames if you spawn it at the very start of the game. I suggest you put a <wait duration="1000"/> after spawning the heroes in game_info.entity and then spawn your goat (dormant="1"). This should fix the double flags.

    Also I suggest you give your own names to these entities, instead of editing existing ones. Flag_Legion and Flag_Hellbourne for instance instead of Powerup_Damage and Powerup_Speed.

    My implementation made no difference between legion and hellbourne (Powerup_Flag), but you use 2 different files (Powerup_Speed and Powerup_Damage).
    The logic part works different here (it's a little simpler, but you've got to write/load it twice ... ). I wrote it in pseudo code, but it should be very clear.

    Flag_Legion (your Powerup_Damage)
    Code:
    Ontouch
      compare the target_team with 1 (= same team).
        condition hasstate HasFlag on target
          score points or whatever
          expire HasFlag
          setent0 hellbournbase
          spawnunit Flag_Hellbourne next to ent0
        /condition
        spawnunit Flag_Legion on this_position (because it disappeared ontouch)
      /compare
      else (= enemy)
        applystate HasFlag to target
      /else
    /ontouch
    
    modifier dropped
    ontouch
      compare target_team eq 1 (you return your ally flag)
        setent0 LegionBase
        spawnunit Flag_Legion next to ent0 and push it
        deactivatemodifier dropped on stack_entity
      /compare
      else (you pick up the enemy flag that was dropped)
        applystate HasFlag to target
      /else
    /ontouch
    Flag_Hellbourne (your Powerup_Speed). Just compare with team 2 and adjust the bases.
    Code:
    Ontouch
      compare the target_team with 2 (= same team).
        condition hasstate HasFlag on target
          score points or whatever
          expire HasFlag
          setent0 hellbournbase
          spawnunit Flag_Legion next to ent0
        /condition
        spawnunit Flag_Hellbourne on this_position (because it disappeared ontouch)
      /compare
      else (= enemy)
        applystate HasFlag to target
      /else
    /ontouch
    
    modifier dropped
    ontouch
      compare target_team eq 2 (you return your ally flag)
        setent0 LegionBase
        spawnunit Flag_Hellbourne next to ent0 and push it
        deactivatemodifier dropped on stack_entity
      /compare
      else (you pick up the enemy flag that was dropped)
        applystate HasFlag to target
      /else
    /ontouch


    Edit :
    Also, you have to adjust the HasFlag state, start with a compare team eq 1, then spawn a Flag_Hellbourne at this_owner_position with team="2" and activate dropped modifier. In else put the opposite.

    When debugging the double flag spawning, I suggest you put some different <print text="something"/> after each <spawnunit/>... you can find the source of your problem easier that way.

    This will solve your double spawning. Let me know if you have any other questions !
    Last edited by Tafelpoot; 04-26-2011 at 09:36 AM.
    My Custom Maps
    Rampage Runner (SP) - showthread.php?t=255701
    SokoHoN (SP) - showthread.php?t=246141
    Chess of Newerth (MP) - showthread.php?t=312907

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •