Jump to content


Photo

global variables


  • Please log in to reply
2 replies to this topic

#1 Shinryokin

Shinryokin

    GMC Member

  • New Member
  • 13 posts
  • Version:GM8

Posted 06 December 2011 - 04:17 AM

We want to create a basic set of instructions so we don't have to retype all the code for each monster character and clog up our code. We want to have a basic set of globals or something that we can just give/adjust certain characteristics on each monster object and have them follow a set of instructions/rules. Anyone know how to go about doing this? An example would be to set up a rule like if x+1,y+1 does not have a solid object the monster won't walk off the cliff, but we don't want to draw a collision point at every drop off. I guess I need suggestions on creating an advanced AI that we can apply certain traits to certain monsters. I hope someone can help, I know this might be advanced stuff for someone that has been only coding for about a week now but we have huge ambitions for this game.
  • 0

#2 Myhijim

Myhijim

    .-* The Flying Fox *-.

  • GMC Member
  • 334 posts
  • Version:Unknown

Posted 06 December 2011 - 09:07 AM

Well you could set the default of all monsters, you could even do a randomisation of the skills.

Create a new object called cont_monster

Create Event
global.agilitydefault = 10
global.skilldefault = 34
global.blahblah = 50

The purpose of this code is to make the basic defaults for all the monsters, however you then need to implement it

In the Create event of your monster, this code is to randomise the skill number of the specific type of monster
agility = global.agilitydefault + floor(random(7)) //7 can be changed depending on the range
skill = global.skilldefault + floor(random(12))
hp = global.hpdefault + floor(random(40))



Next time you create a request, i suggest you divide your requests up neatly, because i got pretty lost in your jumble of words....
And therefore this is most probably not what you were after....

For the falling off the cliff i shall test it and think about it

-Myhi
  • 0

#3 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 06 December 2011 - 09:38 AM

Use parents. If you have an object (called, say, monster_parent), then you make that the parent of other objects, all children will initially contain the same code and actions in each event as the parent, internally. You can then give children specific code to either (a) override a parent event entirely or (B) add code to the beginning or end of a parent event (by using the "Call Event" action or the event_inherited() function where you want the parent's code to run).

-IMP
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users