How would I make a Risk like combat system?

Discussion in 'Programming' started by PlayingKid, Jul 11, 2018.

  1. PlayingKid

    PlayingKid Member

    Joined:
    Jul 9, 2018
    Posts:
    3
    I am a beginner and I want to make a game like risk, but I can't seem to figure out how to make a similar combat system. There aren't any tutorials on this either. What are some suggestions on what to do that would work in Drag and Drop?
     
  2. arirish

    arirish Member

    Joined:
    Mar 13, 2017
    Posts:
    138
    This is such a big question. Are you talking about how to choose nations to attack, how to set up skirmishes with some degree of randomness (ie number of losses per side), how to establish ownership of a territory, etc., etc...
     
  3. PlayingKid

    PlayingKid Member

    Joined:
    Jul 9, 2018
    Posts:
    3
    The combat part of it (I attack, they attack, casualties, etc)and selecting which nation to attack is what I'm having trouble with.
     
  4. arirish

    arirish Member

    Joined:
    Mar 13, 2017
    Posts:
    138
    I have no idea how you'd tackle this in DnD. In code, you'd probably start by assigning a whole lot of variables. I'd probably do some sort of 2D array or Data Structure to keep track of who owns what, for example:
    Code:
    territory[0,0]="Irkutsk"; //territory name
    territory[0,1]=0; //territory is not owned
    territory[0,2]=0; //and nobody is here
    
    territory[1,0]="Kamchatka"; //territory name
    territory[1,1]=1; //territory is owned, let's say '1' is France
    territory[1,2]=10; //France has 10 men here
    //etc...
    
    I'm not suggesting any of this as final code, I'm just trying to get you thinking about how you might go about it.

    Alternatively, you could (since the map/territories are the same every game) create a different object for each territory, and have each object store the variables in themselves. Then you'd check if a territory abuts yours with a simple collision check (which, it immediately occurs to me, wouldn't necessary work if you have routes that cross the ocean, which you will, so you'd probably need another type of data structure to handle viable routes). If it's a valid territory you'd check your force number against the number in the other territory. You'd likely set up some probability stuff, so that the larger force is more likely to win but still sustain losses. Then you'd need to let the player decide how many of the surviving troops to move over, if they won.

    You'd also have to have variables keeping track of things like total territories held by each nation, total troops owned by each nation, etc.

    It's complicated, basically.
     
  5. HayManMarc

    HayManMarc Member

    Joined:
    Jun 21, 2016
    Posts:
    654
    If you're just starting out, I'd say the scope of a Risk-like game is likely too large for you. Hell, I've been messing around with GM for 10+ years, and that amount of scope is a bit large for me.

    I would suggest trying to make something simpler, but if your heart is set on doing it, try bringing down the scope of the game as a whole. Instead of the whole world map, make a map of 3 or 4 territories and reduce the number of army types to 2 or 3 types. Sure, the game won't be as good as a full on Risk game, but sizing down the game like this will make it less daunting and enable you to learn the programming better.

    Just my 2 cents of a suggestion. Good luck! :)
     
    arirish likes this.
  6. PlayingKid

    PlayingKid Member

    Joined:
    Jul 9, 2018
    Posts:
    3
    Scaling it down is perfectly fine, I just don't know how to do the combat?
     
  7. Pfap

    Pfap Member

    Joined:
    Apr 30, 2017
    Posts:
    249
    There are a lot of different ways; although, I'm not very sure about the exact rules of risk. When making a game figuring out exactly what you want can really help... exactly being a keyword. I just checked out drag and drop for the first time in Gms2 and it looks like there is a lot of options available. I think you would want to select who you are attacking and then roll dice ( how many dice are in Risk?) maybe drag and drop a function call to i_random(5); this will return a number from this set [0,1,2,3,4,5] which is 6 numbers if you count 0. You would then figure out who had the best roll by adding all of the players rolls up and all of the opponents rolls up. Whoever had the highest total would be declared the winner.
     
  8. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    339
    In general, if your question is "How do I do everything for X scenario" then the most realistic answer is usually "Don't try to code that yet." I've been using GM for many years now and I can scope a project off the top of my head and VERY often the answer to my internal question of "How do I do X" is "Well, I know how I would generally go about it, but the amount of work is rather large for one person so perhaps I should scope down my idea." On top of that if you're working with just DnD it becomes a lot harder for people from the forum to help as 99% of us don't use DnD and therefore can't give you step by step instructions for it.

    As always I'm going to offer the advice of: Start with something -much- simpler. Having to code the stuff for alternating player turns, full combat systems, AI decision making, etc (all which will be at least a little required for a game like Risk) is an almost impossibly huge task for someone who is new. Much better to program a fully working version of Pong and develop an understanding of how coding the most basic systems in a game works before jumping into anything larger (I know that that's a frustrating answer, after all, you want to get on with coding all the incredibly cool game ideas you have, but if you do it this way you will ironically get to the point where you can program your own cool game ideas much faster than if you spent all of your time trying to code your own stuff from the start).
     
    Pfap and HayManMarc like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice