Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eudplib/eudlib/locf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
THE SOFTWARE.
"""

from .bringcount import f_bringcount
from .locf import f_setloc, f_addloc, f_dilateloc, f_getlocTL, f_setloc_epd
76 changes: 76 additions & 0 deletions eudplib/eudlib/locf/bringcount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
Copyright (c) 2022 Armoha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from ... import core as c, ctrlstru as cs, utils as ut
from ...core.eudfunc.eudf import _EUDPredefineParam


bring = c.Bring(0, c.AtLeast, 0, 0, 0)


@_EUDPredefineParam((ut.EPD(bring) + 1, ut.EPD(bring) + 3, ut.EPD(bring)))
@c.EUDTypedFunc([c.TrgPlayer, c.TrgUnit, c.TrgLocation], [None])
def _bringcount(player, unit, location):
cs.DoActions(
c.SetMemory(bring + 8, c.SetTo, 1024),
c.SetMemoryX(bring + 12, c.SetTo, 3 << 24, 0xFFFF0000),
)
c.RawTrigger(
conditions=[
bring,
c.Memory(bring + 8, c.AtMost, 1700)
]
)


def f_bringcount(player, unit, location):
if c.IsEUDVariable(player):
cache = c.EUDVariable()
cache_bring = c.Bring(player, c.Exactly, 0, unit, location)
if cs.EUDIfNot()(cache_bring):
_bringcount(player, unit, location, _ret=[cache])
c.VProc(cache, cache.QueueAssignTo(ut.EPD(cache_bring) + 2))
cs.EUDEndIf()
return cache

if any(c.IsEUDVariable(v) for v in (player, unit, location)):
return _bringcount(player, unit, location)

count = c.EUDVariable()
cache_bring = c.Bring(player, c.Exactly, 0, unit, location)
check_cache, reload_check, update_cache, skip = [c.Forward() for _ in range(4)]

check_cache << c.RawTrigger(
nextptr=update_cache,
conditions=cache_bring,
actions=c.SetNextPtr(check_cache, reload_check)
)
reload_check << c.RawTrigger(
nextptr=skip,
actions=c.SetNextPtr(check_cache, update_cache)
)
update_cache << c.NextTrigger()
skip << c.NextTrigger()
return count
13 changes: 11 additions & 2 deletions eudplib/eudlib/stringf/fmtprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,20 @@ def _eudformat(
# handle arg indexing when empty field_names are given.
if field_name == "":
if auto_arg_index is False:
raise ValueError(_("cannot switch from manual field specification to automatic field numbering"))
raise ValueError(
_(
"cannot switch from manual field specification to automatic field numbering"
)
)
field_name = str(auto_arg_index)
auto_arg_index += 1
elif field_name.isdigit():
if auto_arg_index:
raise ValueError(_("cannot switch from manual field specification to automatic field numbering"))
raise ValueError(
_(
"cannot switch from manual field specification to automatic field numbering"
)
)
# disable auto arg incrementing, if it gets
# used later on, then an exception will be raised
auto_arg_index = False
Expand Down Expand Up @@ -152,6 +160,7 @@ def f_eprintf(format_string, *args):
fmtargs = _format_args(format_string, *args)
f_eprintln(*fmtargs)


def f_eprintAll(format_string, *args):
fmtargs = _format_args(format_string, *args)
_eprintAll(*fmtargs)
8 changes: 5 additions & 3 deletions eudplib/eudlib/stringf/pname.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def IsPName(player, name):
else:
ut.ep_assert(
p == c.EncodePlayer(c.CurrentPlayer),
_("IsPName player should be Player1 to Player8 or CurrentPlayer, not {}").format(player),
_(
"IsPName player should be Player1 to Player8 or CurrentPlayer, not {}"
).format(player),
)

init, end, params = GetIsPNameCondition(name)
Expand Down Expand Up @@ -216,8 +218,8 @@ def _optimize(self):
cs.DoActions(c.SetMemory(prevTxtPtr + 8, c.SetTo, 0))
for i in range(3, -1, -1):
c.RawTrigger(
conditions=c.MemoryX(0x640B58, c.AtLeast, 1, 2 ** i),
actions=c.SetMemory(prevTxtPtr + 8, c.Add, 2 ** i),
conditions=c.MemoryX(0x640B58, c.AtLeast, 1, 2**i),
actions=c.SetMemory(prevTxtPtr + 8, c.Add, 2**i),
)
_end << c.NextTrigger()
self.optimize_end << c.RawTrigger()
Expand Down