Jump to content


Photo

Scripting Help Needed!

Worldmap Area Areas Links Arealinks Arealink

  • Please log in to reply
5 replies to this topic

#1 Zanso

Zanso
  • Member
  • 3 posts

Posted 20 January 2016 - 10:08 AM

Hey Spellhold Studios!

 

I thought I give it a try and ask help for scripting since I have one thing I just can't figure out.

 

I have run to a bit of a snafu in my BG:EE modding since I am not that familiar with weidu scripting. Basic scripting is rather easy, but these two go a little bit over my head. I need to move existing areas a bit (AR4400 and AR4300). However, in this I haven't gotten very far in. This one goes way over my head and I am not even sure what I should do with this one :D

 

GET_OFFSET_ARRAY AB_AR4300 WMP_AREAS
    PHP_EACH AB_AR4300 AS int => fx_off BEGIN
        READ_SHORT fx_off fx_type
            PATCH_IF fx_type = 35 BEGIN
                READ_LONG 0x28 amountx
                READ_LONG 0x2c amounty
                    WRITE_LONG 0x28 (%amountx% + 100)
                    WRITE_LONG 0x2c (%amounty% + 100)
            END
END

 

Any suggestions are welcome, even if they have nothing to do with the scripts above :D Hopefully someone here can tell me how to actually do that :)


Edited by Zanso, 21 January 2016 - 12:29 PM.


#2 Creepin

Creepin
  • Administrator
  • 1676 posts

Posted 23 January 2016 - 06:32 AM

Hey Zanso, you might have better luck at WeiDU home here :) Also, the topic name isn't doing great job as well because this is not scripting but WeiDU coding. Sorry this is the best help I could come up with :rolleyes:


The Old Gold - v0.2 WIP (mod for BGT/BWP/BWS)


#3 White Agnus

White Agnus
  • Modder
  • 76 posts

Donator

Posted 23 January 2016 - 10:11 AM

COPY_EXISTING ~worldmap.wmp~ ~override~
PATCH_DEFINE_ASSOCIATIVE_ARRAY move_coordinates BEGIN //define array move_coordinates
  //the dummy is needed, because the first argument must be unique in a associative array  
  //dummy , x  , y, n/p x value, n/p y value => areaname		
	dummy1, 100, 100, nx, py => AR4300
	dummy2, 100, 100, px, ny => AR4400
END
PHP_EACH move_coordinates AS cord => aname //go through the array move_coordinates
BEGIN
	GET_OFFSET_ARRAY are_array WMP_AREAS //get predefined array WMP_AREAS
	PHP_EACH are_array AS are_num => are_offset //go through the array WMP_AREAS
	BEGIN
	READ_ASCII are_offset are_name //write area reference in variable
		PATCH_IF ~%are_name%~ STRING_EQUAL_CASE ~%aname%~ //check if the area_name has the same value as aname from the move_coordinates array
		BEGIN
			READ_LONG are_offset+0x38 xcord //read X coordinate into xcord variable
			READ_LONG are_offset+0x3c ycord //read Y coordinate into xcord variable
			PATCH_IF ~%cord_3%~ STRING_EQUAL_CASE ~px~ //if the xcord should be added
			BEGIN
				WRITE_LONG are_offset+0x38 (xcord+%cord_1%) //write X coordinate + second parameter (cord_0 would bec dummy1/2 in this case) from the move_coordinates array
			END
			PATCH_IF ~%cord_4%~ STRING_EQUAL_CASE ~py~ //if the ycord should be added
			BEGIN
			WRITE_LONG are_offset+0x3c (ycord+%cord_2%) //write Y coordinate + third parameter from the move_coordinates array
			END
			PATCH_IF ~%cord_3%~ STRING_EQUAL_CASE ~nx~ //if the xcord should be subtracted
			BEGIN
				WRITE_LONG are_offset+0x38 (xcord - %cord_1%) //write X coordinate - second parameter (cord_0 would bec dummy1/2 in this case) from the move_coordinates array
			END
			PATCH_IF ~%cord_4%~ STRING_EQUAL_CASE ~ny~ //if the ycord should be subtracted
			BEGIN
			WRITE_LONG are_offset+0x3c (ycord - %cord_2%) //write Y coordinate - third parameter from the move_coordinates array
			END
		END
	END  
END

 

Try something like this:

 

If you want to add an area for moving, add a line to the move_coordinates array... ;)


Edited by White Agnus, 24 January 2016 - 12:36 AM.


#4 Zanso

Zanso
  • Member
  • 3 posts

Posted 24 January 2016 - 12:09 AM

Thank you White Angus! You are a life saver! :D Works perfectly! This one goes way beyond my Weidu coding skills (I always mix the terms Creepin :D), so couldn't have done it without ya :) However, I have one more question:

dummy2, -21, 84 => AR4400

part of the code doesn't actually accept negative values. Is the only way to achieve this making another code with the WRITE_LONG part changed?

 

WRITE_LONG are_offset+0x3c (ycord-%cord_2%) //write Y coordinate - third parameter from the move_coordinates array


Edited by Zanso, 24 January 2016 - 12:10 AM.


#5 White Agnus

White Agnus
  • Modder
  • 76 posts

Donator

Posted 24 January 2016 - 12:35 AM

I've updated the code above, there are new parameters (in the array) to define if the value should be added/substracted... ;)



#6 Zanso

Zanso
  • Member
  • 3 posts

Posted 24 January 2016 - 01:47 AM

Thanks once more White Angus! Works perfectly. Amazing work! :)







Also tagged with one or more of these keywords: Worldmap, Area, Areas, Links, Arealinks, Arealink