Jump to content


R10t--

Member Since 15 May 2011
Offline Last Active Nov 29 2012 01:31 AM

Topics I've Started

Script for checking adjacent area

13 July 2012 - 02:20 AM

Hello!

So, I am trying to create a script that will check if an object is in a certain area and if it is, then create a variable which is assigned to every object in the area. My objects are 16X16 and they are centered origin. Here is my script

/*
Discription: Checks to see if an area is exists

Argument0: effect x
Argument1: effect y
*/
xcheck = argument0
ycheck = argument1 


repeat(50)
{
while (place_meeting(xcheck,ycheck,obj_grass)=true) //while the check is on grass
      {
      xcheck-=16 //moves the check to the path to the left of the effect
      }
      
xcheck-=16 //moves the check back to the grass
while (place_meeting(xcheck,ycheck,obj_grass)=true) // while the check is on grass
      {
      ycheck-=16 //moves the check up
      }
ycheck+=16 //puts the check back on grass
//makes sure that the check reaches the top left corner of the area
}

repeat(50)
{
while (place_meeting(xcheck,ycheck,obj_grass)=true)
      {
      area=instance_position(xcheck,ycheck,obj_grass)
      with (area) change=true
      xcheck+=16
      }
xcheck-=16
while (place_meeting(xcheck,ycheck,obj_grass)=true)
      {
      area=instance_position(xcheck,ycheck,obj_grass)
      with (area) change=true
      xcheck-=16
      }
xcheck+=16
ycheck+=16
}

with (obj_grass)
{
if change=true
{
grassarea=1
}
}

When I run the debugger, xcheck=-767 and ycheck=1616.

Does anyone know how to reword the script?

Split an object?

13 July 2012 - 12:12 AM

Alright, so before I start to restart the creation of a failed game, I was wondering:

Is it possible to split objects?

For example if I have one box and I place for example: leaves, on the box,

BBLBB
BBLBB
BBLBB
BBLBB

Like so^ Is it possible to have the B's on the left one object and the B's on the right another object that each get the same variables as the original?

Thanks,
R10t--

Ammo refill problem

20 June 2012 - 10:09 PM

Hey guys, When I have two problems the first is a minor problem that when setting the maximum ammo for my player I use a 'skill' which is a global so I have:

On game start:
global.skill[1,0]="Ammo Capacity"
global.skill[1,1]=0
global.skill[1,2]= 25 + (25 * global.skill[1,1])//Ammo Supplies max
global.skill[1,3]= 4  + (4  * global.skill[1,1])//Troops max clip
But when the game starts the error says:
Error in code at line 2:
   maxcap= global.skill[1,2] //maximum ammo
                  ^
at position 17: Unknown variable skill or array index out of bounds
But I have the global variables in the room and on game start in the first room, but after clicking ignore a few times, the error box doesn't appear anymore...

Secondly, I have a troop that once he runs out of ammo, he will automatically go to an ammo supply box to refill his ammo and if he is going to get ammo, a variable called 'ammorun' is set to true however in the ammorefill box where it checks what freindlys to refill it also says the variable is unknown:
Error in code at line 8:
      if (instance_exists(troop)) {if troop.ammorun=true {check=true}} //if a friendly exists and it is getting ammo, check complete
                                            ^
at position 43: Unknown variable ammorun
when I clearly set it under the creation code of the soldier
creation:
ammo=4 //ammo count
maxclip=global.skill[1,3] //max possible ammo
reload=false //if the player is reloading
hp=100 //health
distance=0 //the closest enemy
ammorun=false //if the player is getting ammo

Thanks,
R10t--

People follow editable paths?

18 June 2012 - 03:25 AM

Hey guys so I have a 'path' that the user is able to create, destroy, etc. and I want there to be people on the paths (sort of like roller coaster tycoon) But I want the people to go to certain places for example "when person is hungry, walk to a restaurant" I want the people to be able to walk ON THE PATH to the closest restaurant. How is it possible to do something like that?

Thanks,
R10t--

EDIT: I think I have a start, I have an object named 'obj_path' Is it possible to find the x,y coordinates (yes it is centered) of every single 'obj_path' and add it to a path and then make sure that the AI never leave the points indicated on the path?

Thanks for the help

Distance_to_point on diagonal?

30 May 2012 - 04:23 AM

Hey, So I'm using the distance_to_point formula like this:
with (obj_water)
        {
        if distance_to_point(link.targetx,link.targety) < 20
            {
            obj_sprinkler.water-=1
            instance_create(self.x,self.y,obj_splash)
            instance_destroy()
            }
       }

link.targetx and link.targety is a pre-specified point that the user determines using the code:
if keyboard_key= vk_enter and enterdeny=false and choice=false and instance_exists(obj_splash_select)
    {
    targeted=true
    targetx = obj_splash_select.x
    targety = obj_splash_select.y
    choice=true
    }
(This code works fine)

I have EVERYTHING in the game on a snapped grid of 75.
So, when I click, if I make targetx and y on a horizontal or vertical line to the reference point (self.x,self.y) so it would be (self.x,14) or (53,self.y) as coordinates then it works fine
but if the coordinates are NOT snapped to a horizontal or vertical line, yes the target is still selected and my object still moves towards the selected object but the objects are not destroying themselves within 20 pixels of the object like I want it to, instead it keeps moving until it is off the screen...

Sincerely,
R10t--