0 Favourites

Can i use conditional operator (?) like this?

  • Hello!

    I'm currently developing roguelike rpg game for android and i'm very satisfied with the results, but i have one question for you about conditional operator (?). In my battle engine, i'm calculating enemy hit chance based on players dexterity: game will generate random integer number between 0 and 51 and if it's less than players dexterity + 10 it will be count as hit. Ok, this works perfect, but now i have added perks to the game that is modifying some gameplay elements. Right now, perk called "Triforce" is adding +20% chance for dodge, so i'm wondering if i can implement it like this:

    player.dexterity + 10 + int(player.perk="triforce" ? int((player.dexterity + 10))/5 : 0)[/code:2sbotb0t]
    
    [img="https://s13.postimg.org/46y6242mf/event.jpg"]
  • You have a ) in the wrong place.

    Right now it reads

    If player.perk=triforce, then set the value to player.dexterity + 10 + int(int((player.dexterity + 10))/5), else player.dexterity + 10 + int(0)

    I think it should be player.dexterity + 10 + int(player.perk="triforce") ? int((player.dexterity + 10))/5 : 0

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Sure, you can use a conditional operator like

    player.perk="triforce" ? int((player.dexterity + 10))/5 : 0

    but it should be round( (player.dexterity + 10) /5 ) ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
76 9,273
Pandadoor's avatar
Pandadoor
Unread hot topic
0 Favourites
[plugin] 3D using Copperlicht
72 25,990
Reken's avatar
Reken
Unread hot topic
67 9,855
spartacuswell's avatar
spartacuswell