Post new topic    
King Slime
Send private message
Of Slice and Men 
 PostWed Aug 10, 2011 12:20 am
Send private message Reply with quote
I like to pun my titles Smile

Anyways, how would I be able to put a medium enemy sprite on the map? It is a Caravan, and I really did not feel like using maptiles, so I whipped up a spiffy caravan in enemy editor, and would like to know how I can put it on a map.
Liquid Metal King Slime
Send private message
Re: Of Slice and Men 
 PostWed Aug 10, 2011 5:27 pm
Send private message Reply with quote
Master K wrote:
I like to pun my titles :)


We noticed :)

Master K wrote:
Anyways, how would I be able to put a medium enemy sprite on the map? It is a Caravan, and I really did not feel like using maptiles, so I whipped up a spiffy caravan in enemy editor, and would like to know how I can put it on a map.


This should be enough to get you started.

Code:

# replace 5 with the actual sprite number of your caravan
define constant(5, caravan sprite)
global variable(1, caravan slice)

plotscript, load caravan, begin
  caravan slice := load medium enemy sprite(caravan sprite)
  variable(map layer)
  map layer := lookup slice(sl:map layer 0) # this should be the same map layer that the heroes stand on, not always zero
  set parent(caravan slice, map layer)
  set slice x(caravan slice, ? * 20) # replace ? with the caravan's tile x
  set slice y(caravan slice, ? * 20) # replace ? with the caravan's pixel y
end

plotscript, remove caravan, begin
  # If you turn on the "Recreate map slices when changing maps" bitset, you
  # won't really need this script anymore
  free slice(caravan slice)
  caravan slice := 0
end
King Slime
Send private message
 
 PostWed Aug 10, 2011 9:49 pm
Send private message Reply with quote
The Caravan won't show up. I put the Define Constant and Global Variable at the top of the script.

Quote:
plotscript, load caravan, begin
caravan slice := load medium enemy sprite(caravan sprite)
variable(map layer)
map layer := lookup slice(sl:map layer 4) # this should be the same map layer that the heroes stand on, not always zero
set parent(caravan slice, map layer)
set slice x(caravan slice, 23 * 20) # replace ? with the caravan's tile x
set slice y(caravan slice, 3 * 20) # replace ? with the caravan's pixel y
end


EDIT: Also, I do not know what to do with the Remove Caravan script. I do not know where the alledged bitset you spoke of is.
Super Slime
Send private message
 
 PostWed Aug 10, 2011 11:56 pm
Send private message Reply with quote
What is "caravan sprite"?
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
King Slime
Send private message
 
 PostThu Aug 11, 2011 3:18 am
Send private message Reply with quote
@Mogri: I don't quite understand what your asking...but, the thing is supposed to load Medium Enemy Sprite 0.
Red Slime
Send private message
 
 PostThu Aug 11, 2011 4:53 am
Send private message Reply with quote
I might not be able to help much more beyond this, but just to confirm, did you change the number in the "define constant" command to zero instead of five when you copied it? If you just copied and pasted it from James's script, it is trying to load medium enemy sprite 5, not zero.
King Slime
Send private message
 
 PostThu Aug 11, 2011 4:59 am
Send private message Reply with quote
Nope, I changed it to 0.
Liquid Metal King Slime
Send private message
 
 PostThu Aug 11, 2011 4:21 pm
Send private message Reply with quote
How is the script being triggered? Are you using it as a map autorun script, or calling it from a map autorun script?


The bitset for "Recreate map layers when changing maps" didn't exist in the Zenziznenzic release, it is only available in nightly wip builds.

The "remove caravan" script is to prevent the caravan from appearing in the same spot on the next map you visit. I think the easiest way to run it would be in the map autorun for each map that you can get to directly from the map that has the caravan on it.

I really need to add a "default map autorun" script that can run on every map. that will make things like this easier to script without needing to set an autorun for each connected map.

Here is an example of a map autorun that could be used for all maps

Code:

plotscript, universal map autorun, begin
  if(current map == 3) then( # replace 3 with the actual map number that has the caravan
    load caravan
  )else(
    remove caravan
  )
end


Of course if you already have some map autorun scripts on some of your maps, then this gets a little more complicated
King Slime
Send private message
 
 PostThu Aug 11, 2011 4:50 pm
Send private message Reply with quote
Thank you James. I got it to work.
I don't have any Autoruns, so thank you for the universal autorun suggestion.
King Slime
Send private message
 
 PostThu Aug 11, 2011 8:17 pm
Send private message Reply with quote
Actually, slash the above. It isn't working. I got an ingame warning:

Warning!
Freeslice: invalid slice handle 0.

Call chain (current script last):
Universalmapautorun -> removecaravan
Liquid Metal King Slime
Send private message
 
 PostThu Aug 11, 2011 8:33 pm
Send private message Reply with quote
Oops! I forgot that you get an error message if you free an empty slice. Here is a fixed "remove caravan" script

Code:

plotscript, remove caravan, begin
  # If you turn on the "Recreate map slices when changing maps" bitset, you
  # won't really need this script anymore
  if(slice is valid(caravan slice)) then(
      free slice(caravan slice)
  )
  caravan slice := 0
end
Display posts from previous: