Trap Possiblity?

onimike
Hello all im make a Island Survival game where you can take resources and craft them into different things. Well I also want to add traps to lay to catch game. Now I already am using a AI turn script that moves to a different room at random every turn; So question is there a way to drop the trap in a room setting it making the trap active. Then when the deer enters that room theres a possibility chance of ending the AI turn script? I have made several attempts and can't figure it out, I even changed player into object drop trap trying to get some function there but nothing. I know the best way just can't word it, so a script that "When Object.deer is in room Object.drop trap GetRandomInt 1-25% Then Disable AI turn script" is there a way to word this for quest please help thank you.

Mike

Espera
Hmm... I guess how I'd try to do it is this. I'd start with 'If Object is in room', then, 'if room has flag 'rapset'', then 'if random percentage 25%' or 'if randompercent player.trapskill' then end the turn script, and maybe slap a flag on the trapped animal that will alter its look to indicate that it's trapped, and unset the 'trapset' flag put on teh room when the player set the trap there.

Espera
All that can be set up in the editor. I'm sorry I don't know what the exact syntax in the code would look like, if you just want to code it.

HegemonKhan
this isn't fully done, but to give you an idea of how it looks in code:

// you'll probably want the conditions as separate layered nested lines, so you can give different (else if~else) messages, I just combined them all into a single line instead, in laziness:

if (animal_name.parent = room_name and trap_name.parent = room_name and trap_name.setted = true and RandomChance (Value: 0 to 100; or use for your 0 to 100 Value: trap_name.skill_level_integer) = true) {
animal_name.ensnared = true // this is a condition for that so in the other script block, preventing or allowing the animal to change rooms or not, and it'll allow or disallow the player from taking the animal or not.
trap_name.setted = false
} else {
// blah
}


RandomChance (Value: 0 to 100) = true_or_false

Conceptually:

if (RandomChance (100) = true) // then it always does: (your nested scripts)
// if (100% of being true = true) // ...
// if (true = true -> yes) // ...

if (RandomChance (100) = false) // then it never does: (your nested scripts)
// if (100% of being true = false // ...
// if (true = false -> no) // ...

if (RandomChance (0) = true) // then it never does: (your nested scripts)
// if (0% of being true = true) // ...
// if (false = true -> no) // ...

if (RandomChance (0) = false) // then it always does: (your nested scripts)
// if (0% of being true = false) // ...
// if (false = false -> yes) // ...

if (RandomChance (75) = true) // then it 'often' (75% of the time) does: (your nested scripts)
// if (75% of being true = true) // ...
// if (true = true -> yes: 75% of the time) // ...
// or
// if (false = true -> no: 25% of the time) // (rarely: 25% of the time) does NOT: (your nested scripts)

// hopefully you get the idea now of how it works

if (RandomChance (75) = false) // then it 'rarely' (25% of the time) does: (your nested scripts)
// if (75% of being true = false) // ...

if (RandomChance (25) = true) // then it 'rarely' (25% of the time) does: (your nested scripts)
// if (25% of being true = true) // then it 'rarely' (25% of the time) does: (your nested scripts)

if (RandomChance (25) = false) // then it 'often' (75% of the time) does: (your nested scripts)
// if (25% of being true = false) // then it 'often' (75% of the time) does: (your nested scripts)

if (RandomChance (50) = true) // then it 'sometimes' (50% of the time) does: (your nested scripts)
// if (50% of being true = true) // then it 'sometimes' (50% of the time) does: (your nested scripts)

if (RandomChance (50) = false) // then it 'sometimes' (50% of the time) does: (your nested scripts)
// if (50% of being true = false) // then it 'sometimes' (50% of the time) does: (your nested scripts)

hopefully, this explains the 'RandomChance' code.

onimike
Espera wrote:Hmm... I guess how I'd try to do it is this. I'd start with 'If Object is in room', then, 'if room has flag 'rapset'', then 'if random percentage 25%' or 'if randompercent player.trapskill' then end the turn script, and maybe slap a flag on the trapped animal that will alter its look to indicate that it's trapped, and unset the 'trapset' flag put on teh room when the player set the trap there.


Thank you I kinda worked something out. There was I could not really figure out how to make it for when the object "deer" enters the room with object "trap" that was the part I really got stuck on. I used a timer that if "trap" is set then at random % move "deer" to trap and disable turn script. This was the only way I could figure out without coding (I think) but the editor it self is awesome and covers just about every thing. Thanks again


Mike

onimike
HegemonKhan, thank you for your response. I do understand mostly how the random % works and figure out more as I go along and learn how to add variable or attribute with running if scripts, its all really cool and love learning this easy to use system. I have tried game engines and not gotten far so this editor is perfect for the projects I want to do. Thanks a lot for the amount of detail in your post really like how you take your time and really break down information for people.

Mike

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums